LLVM: include/llvm/CodeGenTypes/MachineValueType.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16#ifndef LLVM_CODEGEN_MACHINEVALUETYPE_H

17#define LLVM_CODEGEN_MACHINEVALUETYPE_H

18

24#include

25#include

26

27namespace llvm {

28

32

33

34

35

37 public:

39

40

42

43#define GET_VT_ATTR(Ty, sz, Any, Int, FP, Vec, Sc, Tup, NF, NElem, EltTy) Ty,

44#define GET_VT_RANGES

45#include "llvm/CodeGen/GenVT.inc"

46#undef GET_VT_ATTR

47#undef GET_VT_RANGES

48

50 };

51

52 static_assert(FIRST_VALUETYPE > 0);

53 static_assert(LAST_VALUETYPE < token);

54

56

57 constexpr MVT() = default;

59

66

67

69

70

72

73

75 return (SimpleTy >= MVT::FIRST_VALUETYPE &&

76 SimpleTy <= MVT::LAST_VALUETYPE);

77 }

78

79

81 return ((SimpleTy >= MVT::FIRST_FP_VALUETYPE &&

82 SimpleTy <= MVT::LAST_FP_VALUETYPE) ||

83 (SimpleTy >= MVT::FIRST_FP_FIXEDLEN_VECTOR_VALUETYPE &&

84 SimpleTy <= MVT::LAST_FP_FIXEDLEN_VECTOR_VALUETYPE) ||

85 (SimpleTy >= MVT::FIRST_FP_SCALABLE_VECTOR_VALUETYPE &&

86 SimpleTy <= MVT::LAST_FP_SCALABLE_VECTOR_VALUETYPE));

87 }

88

89

91 return ((SimpleTy >= MVT::FIRST_INTEGER_VALUETYPE &&

92 SimpleTy <= MVT::LAST_INTEGER_VALUETYPE) ||

93 (SimpleTy >= MVT::FIRST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE &&

94 SimpleTy <= MVT::LAST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE) ||

95 (SimpleTy >= MVT::FIRST_INTEGER_SCALABLE_VECTOR_VALUETYPE &&

96 SimpleTy <= MVT::LAST_INTEGER_SCALABLE_VECTOR_VALUETYPE));

97 }

98

99

101 return (SimpleTy >= MVT::FIRST_INTEGER_VALUETYPE &&

102 SimpleTy <= MVT::LAST_INTEGER_VALUETYPE);

103 }

104

105

107 return (SimpleTy >= MVT::FIRST_VECTOR_VALUETYPE &&

108 SimpleTy <= MVT::LAST_VECTOR_VALUETYPE);

109 }

110

111

112

114 return (SimpleTy >= MVT::FIRST_SCALABLE_VECTOR_VALUETYPE &&

115 SimpleTy <= MVT::LAST_SCALABLE_VECTOR_VALUETYPE);

116 }

117

118

119

121 return (SimpleTy >= MVT::FIRST_RISCV_VECTOR_TUPLE_VALUETYPE &&

122 SimpleTy <= MVT::LAST_RISCV_VECTOR_TUPLE_VALUETYPE);

123 }

124

125

129

130

134

136 return (SimpleTy >= MVT::FIRST_FIXEDLEN_VECTOR_VALUETYPE &&

137 SimpleTy <= MVT::LAST_FIXEDLEN_VECTOR_VALUETYPE);

138 }

139

140

144

145

149

150

154

155

159

160

164

165

169

170

174

175

179

180

182 return (SimpleTy >= MVT::FIRST_CHERI_CAPABILITY_VALUETYPE) &&

183 (SimpleTy <= MVT::LAST_CHERI_CAPABILITY_VALUETYPE);

184 }

185

186

189#define GET_VT_ATTR(Ty, sz, Any, Int, FP, Vec, Sc, Tup, NF, NElem, EltTy) \

190 case Ty: \

191 return Any;

192#include "llvm/CodeGen/GenVT.inc"

193#undef GET_VT_ATTR

194 default:

195 return false;

196 }

197 }

198

199

200

201

207 "Simple vector VT not representable by simple integer vector VT!");

208 return VecTy;

209 }

210

211

212

216 "Simple vector VT not representable by simple integer vector VT!");

217 return VecTy;

218 }

219

220

221

222

228

229

230

234 assert(EltCnt.isKnownEven() && "Splitting vector, but not in half!");

235 return getVectorVT(EltVT, EltCnt.divideCoefficientBy(2));

236 }

237

238

239

245

246

249 return !(NElts & (NElts - 1));

250 }

251

252

253

256 return *this;

257

262 }

263

264

268

272#define GET_VT_ATTR(Ty, Sz, Any, Int, FP, Vec, Sc, Tup, NF, NElem, EltTy) \

273 EltTy,

274#include "llvm/CodeGen/GenVT.inc"

275#undef GET_VT_ATTR

276 };

279 return VT;

280 }

281

282

285 static constexpr uint16_t NElemTable[] = {

286#define GET_VT_ATTR(Ty, Sz, Any, Int, FP, Vec, Sc, Tup, NF, NElem, EltTy) \

287 NElem,

288#include "llvm/CodeGen/GenVT.inc"

289#undef GET_VT_ATTR

290 };

291 unsigned NElem = NElemTable[SimpleTy - FIRST_VALUETYPE];

292 assert(NElem != 0 && "Not a vector MVT!");

293 return NElem;

294 }

295

299

303 "Possible incorrect use of MVT::getVectorNumElements() for "

304 "scalable vector. Scalable flag may be dropped, use "

305 "MVT::getVectorElementCount() instead");

307 }

308

309

310

311

312

313

315 static constexpr TypeSize SizeTable[] = {

316#define GET_VT_ATTR(Ty, Sz, Any, Int, FP, Vec, Sc, Tup, NF, NElem, EltTy) \

317 TypeSize(Sz, Sc || Tup || Ty == aarch64svcount

318),

319#include "llvm/CodeGen/GenVT.inc"

320#undef GET_VT_ATTR

321 };

322

327 llvm_unreachable("Value type is non-standard value, Other.");

328 case iPTR:

329 llvm_unreachable("Value type size is target-dependent. Ask TLI.");

330 case pAny:

331 case iAny:

332 case fAny:

333 case vAny:

334 case Any:

336 case token:

337 llvm_unreachable("Token type is a sentinel that cannot be used "

338 "in codegen and has no size");

341 default:

343 return SizeTable[SimpleTy - FIRST_VALUETYPE];

344 }

345 }

346

347

351 }

355 }

356

357

358

359

360

361

366 }

367

368

372 }

373

374

375

376

377

378

382 }

383

384

385

387

391 }

392

393

397 }

398

402 }

403

404

408 }

409

410

413 "Comparison between scalable and fixed types");

415 }

416

417

420 "Comparison between scalable and fixed types");

422 }

423

424

427 "Comparison between scalable and fixed types");

429 }

430

431

434 "Comparison between scalable and fixed types");

436 }

439#define GET_VT_ATTR(Ty, sz, Any, Int, FP, Vec, Sc, Tup, NF, NElem, EltTy) \

440 if (FP == 3 && sz == BitWidth) \

441 return Ty;

442#include "llvm/CodeGen/GenVT.inc"

443#undef GET_VT_ATTR

444

446 }

449#define GET_VT_ATTR(Ty, sz, Any, Int, FP, Vec, Sc, Tup, NF, NElem, EltTy) \

450 if (Int == 3 && sz == BitWidth) \

451 return Ty;

452#include "llvm/CodeGen/GenVT.inc"

453#undef GET_VT_ATTR

454

456 }

459#define GET_VT_VECATTR(Ty, Sc, Tup, nElem, ElTy) \

460 if (!Sc && !Tup && VT.SimpleTy == ElTy && NumElements == nElem) \

461 return Ty;

462#include "llvm/CodeGen/GenVT.inc"

463#undef GET_VT_VECATTR

464

466 }

469#define GET_VT_VECATTR(Ty, Sc, Tup, nElem, ElTy) \

470 if (Sc && VT.SimpleTy == ElTy && NumElements == nElem) \

471 return Ty;

472#include "llvm/CodeGen/GenVT.inc"

473#undef GET_VT_VECATTR

474

476 }

479#define GET_VT_ATTR(Ty, sz, Any, Int, FP, Vec, Sc, Tup, NF, nElem, EltTy) \

480 if (Tup && sz == Sz && NF == NFields) \

481 return Ty;

482#include "llvm/CodeGen/GenVT.inc"

483#undef GET_VT_ATTR

484

486 }

487

488

492 static constexpr uint8_t NFTable[] = {

493#define GET_VT_ATTR(Ty, Sz, Any, Int, FP, Vec, Sc, Tup, NF, NElem, EltTy) NF,

494#include "llvm/CodeGen/GenVT.inc"

495#undef GET_VT_ATTR

496 };

497 return NFTable[SimpleTy - FIRST_VALUETYPE];

498 }

500 static MVT getVectorVT(MVT VT, unsigned NumElements, bool IsScalable) {

501 if (IsScalable)

504 }

507 if (EC.isScalable())

509 return getVectorVT(VT, EC.getKnownMinValue());

510 }

511

512

513

514

515

516

518

519

520

522

523 public:

524

529 }

533 MVT::LAST_INTEGER_VALUETYPE,

535 }

540 }

544 MVT::LAST_VECTOR_VALUETYPE,

546 }

550 MVT::LAST_FIXEDLEN_VECTOR_VALUETYPE,

552 }

556 MVT::LAST_SCALABLE_VECTOR_VALUETYPE,

558 }

561 return enum_seq_inclusive(MVT::FIRST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE,

562 MVT::LAST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE,

564 }

568 MVT::LAST_FP_FIXEDLEN_VECTOR_VALUETYPE,

570 }

573 return enum_seq_inclusive(MVT::FIRST_INTEGER_SCALABLE_VECTOR_VALUETYPE,

574 MVT::LAST_INTEGER_SCALABLE_VECTOR_VALUETYPE,

576 }

580 MVT::LAST_FP_SCALABLE_VECTOR_VALUETYPE,

582 }

586 MVT::LAST_CHERI_CAPABILITY_VALUETYPE,

588 }

589

590 };

595 }

596

597}

598

599#endif

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

Provides some synthesis utilities to produce sequences of values.

static constexpr ElementCount get(ScalarTy MinVal, bool Scalable)

Machine Value Type.

Definition MachineValueType.h:36

LLVM_ABI void dump() const

Support for debugging, callable in GDB: VT.dump()

static MVT getFloatingPointVT(unsigned BitWidth)

Definition MachineValueType.h:437

bool isByteSized() const

Returns true if the number of bits for the type is a multiple of an 8-bit byte.

Definition MachineValueType.h:385

bool is128BitVector() const

Return true if this is a 128-bit vector type.

Definition MachineValueType.h:156

bool knownBitsGT(MVT VT) const

Return true if we know at compile time this has more bits than VT.

Definition MachineValueType.h:388

SimpleValueType

Definition MachineValueType.h:38

@ VALUETYPE_SIZE

Definition MachineValueType.h:49

@ INVALID_SIMPLE_VALUE_TYPE

Definition MachineValueType.h:41

static auto integer_fixedlen_vector_valuetypes()

Definition MachineValueType.h:559

unsigned getVectorMinNumElements() const

Given a vector type, return the minimum number of elements it contains.

Definition MachineValueType.h:283

bool isRISCVVectorTuple() const

Return true if this is a RISCV vector tuple type where the runtime length is machine dependent.

Definition MachineValueType.h:120

bool operator>(const MVT &S) const

Definition MachineValueType.h:60

SimpleValueType SimpleTy

Definition MachineValueType.h:55

bool isOverloaded() const

Return true if this is an overloaded type for TableGen.

Definition MachineValueType.h:187

bool isScalableTargetExtVT() const

Return true if this is a custom target type that has a scalable size.

Definition MachineValueType.h:126

uint64_t getScalarSizeInBits() const

Definition MachineValueType.h:352

MVT changeVectorElementType(MVT EltVT) const

Return a VT for a vector type whose attributes match ourselves with the exception of the element type...

Definition MachineValueType.h:213

bool operator<=(const MVT &S) const

Definition MachineValueType.h:65

bool bitsLE(MVT VT) const

Return true if this has no more bits than VT.

Definition MachineValueType.h:431

unsigned getVectorNumElements() const

Definition MachineValueType.h:300

bool knownBitsLT(MVT VT) const

Return true if we know at compile time this has fewer bits than VT.

Definition MachineValueType.h:399

static MVT getRISCVVectorTupleVT(unsigned Sz, unsigned NFields)

Definition MachineValueType.h:477

bool isVector() const

Return true if this is a vector value type.

Definition MachineValueType.h:106

bool isInteger() const

Return true if this is an integer or a vector integer type.

Definition MachineValueType.h:90

bool isScalableVector() const

Return true if this is a vector value type where the runtime length is machine dependent.

Definition MachineValueType.h:113

static MVT getScalableVectorVT(MVT VT, unsigned NumElements)

Definition MachineValueType.h:467

bool is16BitVector() const

Return true if this is a 16-bit vector type.

Definition MachineValueType.h:141

bool is32BitVector() const

Return true if this is a 32-bit vector type.

Definition MachineValueType.h:146

unsigned getRISCVVectorTupleNumFields() const

Given a RISC-V vector tuple type, return the num_fields.

Definition MachineValueType.h:488

MVT changeTypeToInteger()

Return the type converted to an equivalently sized integer or vector with integer element type.

Definition MachineValueType.h:223

static LLVM_ABI MVT getVT(Type *Ty, bool HandleUnknown=false)

Return the value type corresponding to the specified type.

bool isScalableVT() const

Return true if the type is a scalable type.

Definition MachineValueType.h:131

bool bitsLT(MVT VT) const

Return true if this has less bits than VT.

Definition MachineValueType.h:424

static auto all_valuetypes()

SimpleValueType Iteration.

Definition MachineValueType.h:525

bool operator<(const MVT &S) const

Definition MachineValueType.h:61

bool is512BitVector() const

Return true if this is a 512-bit vector type.

Definition MachineValueType.h:166

bool operator==(const MVT &S) const

Definition MachineValueType.h:62

static auto integer_valuetypes()

Definition MachineValueType.h:530

bool is1024BitVector() const

Return true if this is a 1024-bit vector type.

Definition MachineValueType.h:171

TypeSize getSizeInBits() const

Returns the size of the specified MVT in bits.

Definition MachineValueType.h:314

bool isPow2VectorType() const

Returns true if the given vector is a power of 2.

Definition MachineValueType.h:247

uint64_t getScalarStoreSize() const

Definition MachineValueType.h:369

static auto scalable_vector_valuetypes()

Definition MachineValueType.h:553

static auto fixedlen_vector_valuetypes()

Definition MachineValueType.h:547

uint64_t getFixedSizeInBits() const

Return the size of the specified fixed width value type in bits.

Definition MachineValueType.h:348

LLVM_ABI const fltSemantics & getFltSemantics() const

Returns an APFloat semantics tag appropriate for the value type.

bool bitsGT(MVT VT) const

Return true if this has more bits than VT.

Definition MachineValueType.h:410

bool isFixedLengthVector() const

Definition MachineValueType.h:135

static auto vector_valuetypes()

Definition MachineValueType.h:541

bool is256BitVector() const

Return true if this is a 256-bit vector type.

Definition MachineValueType.h:161

ElementCount getVectorElementCount() const

Definition MachineValueType.h:296

bool isCheriCapability() const

Return true if this is a CHERI capability type.

Definition MachineValueType.h:181

TypeSize getStoreSize() const

Return the number of bytes overwritten by a store of the specified value type.

Definition MachineValueType.h:362

bool bitsGE(MVT VT) const

Return true if this has no less bits than VT.

Definition MachineValueType.h:417

bool isScalarInteger() const

Return true if this is an integer, not including vectors.

Definition MachineValueType.h:100

TypeSize getStoreSizeInBits() const

Return the number of bits overwritten by a store of the specified value type.

Definition MachineValueType.h:379

static MVT getVectorVT(MVT VT, unsigned NumElements)

Definition MachineValueType.h:457

bool knownBitsGE(MVT VT) const

Return true if we know at compile time this has more than or the same bits as VT.

Definition MachineValueType.h:394

static auto fp_scalable_vector_valuetypes()

Definition MachineValueType.h:577

MVT getVectorElementType() const

Definition MachineValueType.h:269

bool isFloatingPoint() const

Return true if this is a FP or a vector FP type.

Definition MachineValueType.h:80

bool operator>=(const MVT &S) const

Definition MachineValueType.h:64

bool isValid() const

Return true if this is a valid simple valuetype.

Definition MachineValueType.h:74

static MVT getIntegerVT(unsigned BitWidth)

Definition MachineValueType.h:447

MVT getDoubleNumVectorElementsVT() const

Definition MachineValueType.h:240

static auto fp_valuetypes()

Definition MachineValueType.h:536

MVT getHalfNumVectorElementsVT() const

Return a VT for a vector type with the same element type but half the number of elements.

Definition MachineValueType.h:231

bool knownBitsLE(MVT VT) const

Return true if we know at compile time this has fewer than or the same bits as VT.

Definition MachineValueType.h:405

bool operator!=(const MVT &S) const

Definition MachineValueType.h:63

MVT getScalarType() const

If this is a vector, return the element type, otherwise return this.

Definition MachineValueType.h:265

static auto integer_scalable_vector_valuetypes()

Definition MachineValueType.h:571

LLVM_ABI void print(raw_ostream &OS) const

Implement operator<<.

static auto cheri_capability_valuetypes()

Definition MachineValueType.h:583

bool is64BitVector() const

Return true if this is a 64-bit vector type.

Definition MachineValueType.h:151

MVT changeVectorElementTypeToInteger() const

Return a vector with the same number of elements as this vector, but with the element type converted ...

Definition MachineValueType.h:202

MVT getPow2VectorType() const

Widens the length of the given vector MVT up to the nearest power of 2 and returns that type.

Definition MachineValueType.h:254

static auto fp_fixedlen_vector_valuetypes()

Definition MachineValueType.h:565

constexpr MVT(SimpleValueType SVT)

Definition MachineValueType.h:58

bool is2048BitVector() const

Return true if this is a 2048-bit vector type.

Definition MachineValueType.h:176

The instances of the Type class are immutable: once they are created, they are never changed.

constexpr bool isKnownMultipleOf(ScalarTy RHS) const

This function tells the caller whether the element count is known at compile time to be a multiple of...

constexpr ScalarTy getFixedValue() const

static constexpr bool isKnownLE(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)

static constexpr bool isKnownLT(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)

constexpr bool isScalable() const

Returns whether the quantity is scaled by a runtime quantity (vscale).

constexpr ScalarTy getKnownMinValue() const

Returns the minimum value this quantity can represent.

static constexpr bool isKnownGT(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)

static constexpr bool isKnownGE(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)

This class implements an extremely fast bulk output stream that can only output to a stream.

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

This is an optimization pass for GlobalISel generic memory operations.

unsigned Log2_32_Ceil(uint32_t Value)

Return the ceil log base 2 of the specified value, 32 if the value is zero.

auto enum_seq_inclusive(EnumT Begin, EnumT End)

Iterate over an enum type from Begin to End inclusive.

constexpr force_iteration_on_noniterable_enum_t force_iteration_on_noniterable_enum

LLVM_ABI void reportFatalInternalError(Error Err)

Report a fatal error that indicates a bug in LLVM.

raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)

constexpr unsigned BitWidth