clang: include/clang/Support/RISCVVIntrinsicUtils.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9#ifndef CLANG_SUPPORT_RISCVVINTRINSICUTILS_H

10#define CLANG_SUPPORT_RISCVVINTRINSICUTILS_H

11

12#include "llvm/ADT/ArrayRef.h"

13#include "llvm/ADT/BitmaskEnum.h"

14#include "llvm/ADT/SmallVector.h"

15#include "llvm/ADT/StringRef.h"

16#include

17#include

18#include

19#include

20#include <unordered_map>

21#include

22

23namespace llvm {

24class raw_ostream;

25}

26

28namespace RISCV {

29

31

32

75};

76

77

78

89};

90

91

101

102

103

104

105

109};

110

112public:

116 };

117

118private:

119

120

123

124public:

128 : TailPolicy(TailPolicy), MaskPolicy(MaskPolicy) {}

129

132 }

133

136 }

137

140 }

141

144 }

145

147

149

151

153

155 return TailPolicy == Other.TailPolicy && MaskPolicy == Other.MaskPolicy;

156 }

157

159

161

162 if (MaskPolicy != Other.MaskPolicy)

163 return Other.MaskPolicy < MaskPolicy;

164 return TailPolicy < Other.TailPolicy;

165 }

166};

167

168

169

176 : PT(static_cast<uint8_t>(PT)), VTM(static_cast<uint8_t>(VTM)),

177 TM(static_cast<uint8_t>(TM)) {}

180

184

186 return !(*this == PD);

187 }

190 }

192 return std::tie(PT, VTM, TM) < std::tie(PD.PT, PD.VTM, PD.TM);

193 }

197 static std::optional

199};

200

203

204

207 Int8 = 1 << 0,

217};

218

219

233};

234

235

239

240 std::string str() const;

241 std::optional getScale(unsigned ElementBitwidth) const;

243};

244

249

250

253

257 bool IsPointer = false;

258

259 bool IsImmediate = false;

260

261 bool IsConstant = false;

262 unsigned ElementBitwidth = 0;

264 bool Valid;

265 bool IsTuple = false;

266 unsigned NF = 0;

267

268 std::string BuiltinStr;

269 std::string ClangBuiltinStr;

270 std::string Str;

271 std::string ShortStr;

272

273 enum class FixedLMULType { LargerThan, SmallerThan, SmallerOrEqual };

274

276

277public:

278

279

280 const std::string &getBuiltinStr() const { return BuiltinStr; }

281

282

283

285

286

287

288 const std::string &getTypeStr() const { return Str; }

289

290

292

293

294 if (ShortStr.empty())

295 initShortStr();

296 return ShortStr;

297 }

298

299 bool isValid() const { return Valid; }

300 bool isScalar() const { return Scale && *Scale == 0; }

301 bool isVector() const { return Scale && *Scale != 0; }

303 return isVector() && ElementBitwidth == Width;

304 }

309 }

311 return isVector() && isFloat() && ElementBitwidth == Width;

312 }

314 return isFloat() && ElementBitwidth == Width;

315 }

318 bool isTuple() const { return IsTuple; }

320

324 assert(NF > 1 && NF <= 8 && "Only legal NF should be fetched");

325 return NF;

326 }

327

328private:

329

330 bool verifyType() const;

331

332

333 void applyBasicType();

334

335

336

338

339 void applyLog2EEW(unsigned Log2EEW);

340 void applyFixedSEW(unsigned NewSEW);

341 void applyFixedLog2LMUL(int Log2LMUL, enum FixedLMULType Type);

342

343

344 void initBuiltinStr();

345

346 void initClangBuiltinStr();

347

348 void initTypeStr();

349

350 void initShortStr();

351};

352

353

354

356private:

357 std::unordered_map<uint64_t, RVVType> LegalTypes;

358 std::set<uint64_t> IllegalTypes;

359

360public:

361

362

363

364

365 std::optional

370};

371

374

377};

378

379

380

381

383

384private:

385 std::string BuiltinName;

386 std::string Name;

387 std::string OverloadedName;

388 std::string IRName;

389 bool IsMasked;

390 bool HasMaskedOffOperand;

391 bool HasVL;

393 bool SupportOverloading;

394 bool HasBuiltinAlias;

395 std::string ManualCodegen;

396 RVVTypePtr OutputType;

397 RVVTypes InputTypes;

398

399

400 std::vector<int64_t> IntrinsicTypes;

401 unsigned NF = 1;

403

404public:

405 RVVIntrinsic(llvm::StringRef Name, llvm::StringRef Suffix,

406 llvm::StringRef OverloadedName, llvm::StringRef OverloadedSuffix,

407 llvm::StringRef IRName, bool IsMasked, bool HasMaskedOffOperand,

408 bool HasVL, PolicyScheme Scheme, bool SupportOverloading,

409 bool HasBuiltinAlias, llvm::StringRef ManualCodegen,

411 const std::vector<int64_t> &IntrinsicTypes,

412 unsigned NF, Policy PolicyAttrs, bool HasFRMRoundModeOp);

414

419 bool hasVL() const { return HasVL; }

423 }

426 }

430 bool isMasked() const { return IsMasked; }

432 llvm::StringRef getIRName() const { return IRName; }

435 unsigned getNF() const { return NF; }

437 return IntrinsicTypes;

438 }

440 return PolicyAttrs;

441 }

443

444

445

446

447

449 return 2;

451 return 3;

453 return 0;

455 return 1;

456

457 llvm_unreachable("unsupport policy");

458 return 0;

459 }

460

461

463

464 static std::string

467

470 bool IsMasked, bool HasMaskedOffOperand, bool HasVL,

472 Policy PolicyAttrs, bool IsTuple);

473

477

479 std::string &Name, std::string &BuiltinName,

480 std::string &OverloadedName,

481 Policy &PolicyAttrs, bool HasFRMRoundModeOp);

482};

483

484

485

508

510};

511

512

513

515

517

518

519

521

522

524

525

527

528

530

531

533

534

536

537

539

540

542

543

545

546

548

549

551

563};

564

565llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,

567

569}

570

571}

572

573#endif

bool isTUMUPolicy() const

Policy(PolicyType TailPolicy)

bool isTUMAPolicy() const

bool operator==(const Policy &Other) const

bool isTAMUPolicy() const

bool operator!=(const Policy &Other) const

bool operator<(const Policy &Other) const

Policy(PolicyType TailPolicy, PolicyType MaskPolicy)

bool isTAMAPolicy() const

bool hasPassthruOperand() const

static llvm::SmallVector< Policy > getSupportedMaskedPolicies(bool HasTailPolicy, bool HasMaskPolicy)

llvm::StringRef getBuiltinName() const

llvm::StringRef getIRName() const

const std::vector< int64_t > & getIntrinsicTypes() const

bool hasMaskedOffOperand() const

Policy getPolicyAttrs() const

static llvm::SmallVector< PrototypeDescriptor > computeBuiltinTypes(llvm::ArrayRef< PrototypeDescriptor > Prototype, bool IsMasked, bool HasMaskedOffOperand, bool HasVL, unsigned NF, PolicyScheme DefaultScheme, Policy PolicyAttrs, bool IsTuple)

static void updateNamesAndPolicy(bool IsMasked, bool HasPolicy, std::string &Name, std::string &BuiltinName, std::string &OverloadedName, Policy &PolicyAttrs, bool HasFRMRoundModeOp)

llvm::StringRef getOverloadedName() const

static std::string getSuffixStr(RVVTypeCache &TypeCache, BasicType Type, int Log2LMUL, llvm::ArrayRef< PrototypeDescriptor > PrototypeDescriptors)

bool hasPolicyOperand() const

bool hasManualCodegen() const

bool hasBuiltinAlias() const

static llvm::SmallVector< Policy > getSupportedUnMaskedPolicies()

RVVTypePtr getOutputType() const

unsigned getPolicyAttrsBits() const

bool supportOverloading() const

llvm::StringRef getManualCodegen() const

std::string getBuiltinTypeStr() const

const RVVTypes & getInputTypes() const

PolicyScheme getPolicyScheme() const

std::optional< RVVTypePtr > computeType(BasicType BT, int Log2LMUL, PrototypeDescriptor Proto)

std::optional< RVVTypes > computeTypes(BasicType BT, int Log2LMUL, unsigned NF, llvm::ArrayRef< PrototypeDescriptor > Prototype)

Compute output and input types by applying different config (basic type and LMUL with type transforme...

const std::string & getTypeStr() const

ScalarTypeKind getScalarType() const

bool isFloatVector(unsigned Width) const

bool isSignedInteger() const

const std::string & getShortStr()

const std::string & getClangBuiltinStr() const

VScaleVal getScale() const

bool isFloat(unsigned Width) const

bool isVector(unsigned Width) const

unsigned getElementBitwidth() const

const std::string & getBuiltinStr() const

The base class of the type hierarchy.

llvm::SmallVector< PrototypeDescriptor > parsePrototypes(llvm::StringRef Prototypes)

LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE()

std::optional< unsigned > VScaleVal

@ LLVM_MARK_AS_BITMASK_ENUM

@ RVV_REQ_Xsfvfnrclipxfqf

std::vector< RVVTypePtr > RVVTypes

The JSON file list parser is used to communicate input to InstallAPI.

@ Other

Other implicit parameter.

Diagnostic wrappers for TextAPI types for error reporting.

std::optional< unsigned > getScale(unsigned ElementBitwidth) const

void MulLog2LMUL(int Log2LMUL)

bool operator!=(const PrototypeDescriptor &PD) const

static std::optional< PrototypeDescriptor > parsePrototypeDescriptor(llvm::StringRef PrototypeStr)

static const PrototypeDescriptor VL

constexpr PrototypeDescriptor()=default

static const PrototypeDescriptor Mask

constexpr PrototypeDescriptor(uint8_t PT, uint8_t VTM, uint8_t TM)

static const PrototypeDescriptor Vector

constexpr PrototypeDescriptor(BaseTypeModifier PT, VectorTypeModifier VTM=VectorTypeModifier::NoModifier, TypeModifier TM=TypeModifier::NoModifier)

bool operator==(const PrototypeDescriptor &PD) const

bool operator<(const PrototypeDescriptor &PD) const

uint8_t OverloadedSuffixSize

uint16_t OverloadedSuffixIndex

uint8_t MaskedPolicyScheme

const char * OverloadedName

uint8_t UnMaskedPolicyScheme

uint32_t RequiredExtensions