LLVM: include/llvm/CodeGen/ValueTypes.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15#ifndef LLVM_CODEGEN_VALUETYPES_H

16#define LLVM_CODEGEN_VALUETYPES_H

17

22#include

23#include

24#include

25

26namespace llvm {

27

31

32

33

34

36 private:

38 Type *LLVMTy = nullptr;

39

40 public:

41 constexpr EVT() = default;

43 constexpr EVT(MVT S) : V(S) {}

44

46 return !(*this != VT);

47 }

49 if (V.SimpleTy != VT.V.SimpleTy)

50 return true;

52 return LLVMTy != VT.LLVMTy;

53 return false;

54 }

55

56

57

58

62

63

64

68 return M;

69 return getExtendedIntegerVT(Context, BitWidth);

70 }

71

72

73

75 bool IsScalable = false) {

78 return M;

79 return getExtendedVectorVT(Context, VT, NumElements, IsScalable);

80 }

81

82

83

87 return M;

88 return getExtendedVectorVT(Context, VT, EC);

89 }

90

91

92

93

97 return changeExtendedVectorElementTypeToInteger();

98 }

99

100

101

105 "Can't change simple vector VT to have extended element VT");

107 }

108 return changeExtendedVectorElementType(EltVT);

109 }

110

111

112

117

118

119

120

124

127 return changeExtendedTypeToInteger();

128 }

129

130

131

135

136

140

141

145

146

148 return isSimple() ? V.isFloatingPoint() : isExtendedFloatingPoint();

149 }

150

151

153 return isSimple() ? V.isInteger() : isExtendedInteger();

154 }

155

156

158 return isSimple() ? V.isScalarInteger() : isExtendedScalarInteger();

159 }

160

161

162

164 return isSimple() && V.isScalableTargetExtVT();

165 }

166

167

169 return isSimple() ? V.isVector() : isExtendedVector();

170 }

171

172

173

175 return isSimple() ? V.isScalableVector() : isExtendedScalableVector();

176 }

177

178

180

182 return isSimple() ? V.isFixedLengthVector()

183 : isExtendedFixedLengthVector();

184 }

185

186

190

191

193 return isSimple() ? V.is16BitVector() : isExtended16BitVector();

194 }

195

196

198 return isSimple() ? V.is32BitVector() : isExtended32BitVector();

199 }

200

201

203 return isSimple() ? V.is64BitVector() : isExtended64BitVector();

204 }

205

206

208 return isSimple() ? V.is128BitVector() : isExtended128BitVector();

209 }

210

211

213 return isSimple() ? V.is256BitVector() : isExtended256BitVector();

214 }

215

216

218 return isSimple() ? V.is512BitVector() : isExtended512BitVector();

219 }

220

221

223 return isSimple() ? V.is1024BitVector() : isExtended1024BitVector();

224 }

225

226

228 return isSimple() ? V.is2048BitVector() : isExtended2048BitVector();

229 }

230

231

233 return isSimple() ? V.isCheriCapability() : false;

234 }

235

236

238 return (V == MVT::iAny || V == MVT::fAny || V == MVT::vAny ||

239 V == MVT::pAny);

240 }

241

242

246

247

250 return false;

252 return BitSize >= 8 && !(BitSize & (BitSize - 1));

253 }

254

255

257 if (EVT::operator==(VT)) return true;

259 }

260

261

265

266

267

271

272

276

277

278

282

283

285 if (EVT::operator==(VT)) return false;

287 "Comparison between scalable and fixed types");

289 }

290

291

293 if (EVT::operator==(VT)) return true;

295 "Comparison between scalable and fixed types");

297 }

298

299

301 if (EVT::operator==(VT)) return false;

303 "Comparison between scalable and fixed types");

305 }

306

307

309 if (EVT::operator==(VT)) return true;

311 "Comparison between scalable and fixed types");

313 }

314

315

320

321

322

326

327

331 return V.getVectorElementType();

332 return getExtendedVectorElementType();

333 }

334

335

338

341 "Possible incorrect use of EVT::getVectorNumElements() for "

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

343 "EVT::getVectorElementCount() instead");

344

345 return isSimple() ? V.getVectorNumElements()

346 : getExtendedVectorNumElements();

347 }

348

349

353 return V.getVectorElementCount();

354

355 return getExtendedVectorElementCount();

356 }

357

358

362

363

365 return V.getRISCVVectorTupleNumFields();

366 }

367

368

369

370

371

372

375 return V.getSizeInBits();

376 return getExtendedSizeInBits();

377 }

378

379

380

384

388

389

390

391

392

393

394

399

400

401

405

406

407

408

409

410

411

415

416

417

418

423 return EVT(MVT::i8);

425 }

426

427

428

429

433 for (unsigned IntVT = MVT::FIRST_INTEGER_VALUETYPE;

434 IntVT <= MVT::LAST_INTEGER_VALUETYPE; ++IntVT) {

437 return HalfVT;

438 }

439 return getIntegerVT(Context, (EVTSize + 1) / 2);

440 }

441

442

443

449

450

451

452

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

457 return EVT::getVectorVT(Context, EltVT, EltCnt.divideCoefficientBy(2));

458 }

459

460

461

462

468

469

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

473 }

474

475

476

483 }

484 else {

485 return *this;

486 }

487 }

488

489

491

492

494

495

499

500

501

502

504

505

506

507

508

509

511

514 return V.SimpleTy;

515 else

516 return (intptr_t)(LLVMTy);

517 }

518

519

520

523 if (L.V.SimpleTy == R.V.SimpleTy)

524 return L.LLVMTy < R.LLVMTy;

525 else

526 return L.V.SimpleTy < R.V.SimpleTy;

527 }

528 };

529

530

531

533

534 private:

535

536

537

538 LLVM_ABI EVT changeExtendedTypeToInteger() const;

539 LLVM_ABI EVT changeExtendedVectorElementType(EVT EltVT) const;

540 LLVM_ABI EVT changeExtendedVectorElementTypeToInteger() const;

543 unsigned NumElements,

544 bool IsScalable);

565 };

566

568 V.print(OS);

569 return OS;

570 }

571}

572

573#endif

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

static constexpr ElementCount get(ScalarTy MinVal, bool Scalable)

This is an important class for using LLVM in a threaded context.

static MVT getFloatingPointVT(unsigned BitWidth)

@ INVALID_SIMPLE_VALUE_TYPE

MVT changeVectorElementType(MVT EltVT) const

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

MVT changeTypeToInteger()

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

static MVT getVectorVT(MVT VT, unsigned NumElements)

static MVT getIntegerVT(unsigned BitWidth)

MVT changeVectorElementTypeToInteger() const

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

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.

constexpr bool isZero() const

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.

@ C

The default llvm calling convention, compatible with C.

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.

T bit_ceil(T Value)

Returns the smallest integral power of two no smaller than Value if Value is nonzero.

LLVM_ABI void reportFatalInternalError(Error Err)

Report a fatal error that indicates a bug in LLVM.

constexpr unsigned BitWidth

A meaningless but well-behaved order, useful for constructing containers.

Definition ValueTypes.h:521

bool operator()(EVT L, EVT R) const

Definition ValueTypes.h:522

Extended Value Type.

Definition ValueTypes.h:35

EVT changeVectorElementTypeToInteger() const

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

Definition ValueTypes.h:94

TypeSize getStoreSize() const

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

Definition ValueTypes.h:395

EVT getPow2VectorType(LLVMContext &Context) const

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

Definition ValueTypes.h:477

bool isSimple() const

Test if the given EVT is simple (as opposed to being extended).

Definition ValueTypes.h:137

constexpr EVT(MVT::SimpleValueType SVT)

Definition ValueTypes.h:42

intptr_t getRawBits() const

Definition ValueTypes.h:512

bool knownBitsLE(EVT VT) const

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

Definition ValueTypes.h:279

static EVT getVectorVT(LLVMContext &Context, EVT VT, unsigned NumElements, bool IsScalable=false)

Returns the EVT that represents a vector NumElements in length, where each element is of type VT.

Definition ValueTypes.h:74

EVT changeTypeToInteger() const

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

Definition ValueTypes.h:121

uint64_t getScalarStoreSize() const

Definition ValueTypes.h:402

bool isOverloaded() const

Return true if this is an overloaded type for TableGen.

Definition ValueTypes.h:237

bool bitsGT(EVT VT) const

Return true if this has more bits than VT.

Definition ValueTypes.h:284

bool bitsLT(EVT VT) const

Return true if this has less bits than VT.

Definition ValueTypes.h:300

bool isFloatingPoint() const

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

Definition ValueTypes.h:147

ElementCount getVectorElementCount() const

Definition ValueTypes.h:350

EVT getDoubleNumVectorElementsVT(LLVMContext &Context) const

Definition ValueTypes.h:463

bool is32BitVector() const

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

Definition ValueTypes.h:197

TypeSize getSizeInBits() const

Return the size of the specified value type in bits.

Definition ValueTypes.h:373

bool isByteSized() const

Return true if the bit size is a multiple of 8.

Definition ValueTypes.h:243

bool isCheriCapability() const

Return true if this is a capability type.

Definition ValueTypes.h:232

EVT changeElementType(EVT EltVT) const

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

Definition ValueTypes.h:113

bool is1024BitVector() const

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

Definition ValueTypes.h:222

bool knownBitsGT(EVT VT) const

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

Definition ValueTypes.h:262

unsigned getVectorMinNumElements() const

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

Definition ValueTypes.h:359

unsigned getRISCVVectorTupleNumFields() const

Given a RISCV vector tuple type, return the num_fields.

Definition ValueTypes.h:364

uint64_t getScalarSizeInBits() const

Definition ValueTypes.h:385

EVT getHalfSizedIntegerVT(LLVMContext &Context) const

Finds the smallest simple value type that is greater than or equal to half the width of this EVT.

Definition ValueTypes.h:430

bool isPow2VectorType() const

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

Definition ValueTypes.h:470

static LLVM_ABI EVT getEVT(Type *Ty, bool HandleUnknown=false)

Return the value type corresponding to the specified type.

TypeSize getStoreSizeInBits() const

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

Definition ValueTypes.h:412

MVT getSimpleVT() const

Return the SimpleValueType held in the specified simple EVT.

Definition ValueTypes.h:316

LLVM_ABI void dump() const

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

constexpr EVT(MVT S)

Definition ValueTypes.h:43

bool is128BitVector() const

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

Definition ValueTypes.h:207

static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)

Returns the EVT that represents an integer with the given number of bits.

Definition ValueTypes.h:65

bool is2048BitVector() const

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

Definition ValueTypes.h:227

bool isRISCVVectorTuple() const

Return true if this is a vector value type.

Definition ValueTypes.h:179

uint64_t getFixedSizeInBits() const

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

Definition ValueTypes.h:381

EVT widenIntegerVectorElementType(LLVMContext &Context) const

Return a VT for an integer vector type with the size of the elements doubled.

Definition ValueTypes.h:444

bool knownBitsLT(EVT VT) const

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

Definition ValueTypes.h:273

bool isScalableVT() const

Return true if the type is a scalable type.

Definition ValueTypes.h:187

bool is512BitVector() const

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

Definition ValueTypes.h:217

bool isFixedLengthVector() const

Definition ValueTypes.h:181

LLVM_ABI std::string getEVTString() const

This function returns value type as a string, e.g. "i32".

static EVT getFloatingPointVT(unsigned BitWidth)

Returns the EVT that represents a floating-point type with the given number of bits.

Definition ValueTypes.h:59

bool operator!=(EVT VT) const

Definition ValueTypes.h:48

EVT getRoundIntegerType(LLVMContext &Context) const

Rounds the bit-width of the given integer EVT up to the nearest power of two (and at least to eight),...

Definition ValueTypes.h:419

bool isVector() const

Return true if this is a vector value type.

Definition ValueTypes.h:168

EVT getScalarType() const

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

Definition ValueTypes.h:323

bool is16BitVector() const

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

Definition ValueTypes.h:192

bool bitsGE(EVT VT) const

Return true if this has no less bits than VT.

Definition ValueTypes.h:292

bool is256BitVector() const

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

Definition ValueTypes.h:212

bool bitsEq(EVT VT) const

Return true if this has the same number of bits as VT.

Definition ValueTypes.h:256

LLVM_ABI Type * getTypeForEVT(LLVMContext &Context) const

This method returns an LLVM type corresponding to the specified EVT.

bool isRound() const

Return true if the size is a power-of-two number of bytes.

Definition ValueTypes.h:248

static EVT getVectorVT(LLVMContext &Context, EVT VT, ElementCount EC)

Returns the EVT that represents a vector EC.Min elements in length, where each element is of type VT.

Definition ValueTypes.h:84

bool isScalableVector() const

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

Definition ValueTypes.h:174

bool knownBitsGE(EVT VT) const

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

Definition ValueTypes.h:268

EVT getVectorElementType() const

Given a vector type, return the type of each element.

Definition ValueTypes.h:328

bool isExtended() const

Test if the given EVT is extended (as opposed to being simple).

Definition ValueTypes.h:142

void print(raw_ostream &OS) const

Implement operator<<.

Definition ValueTypes.h:496

bool isScalableTargetExtVT() const

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

Definition ValueTypes.h:163

bool isScalarInteger() const

Return true if this is an integer, but not a vector.

Definition ValueTypes.h:157

EVT changeVectorElementType(EVT EltVT) const

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

Definition ValueTypes.h:102

LLVM_ABI const fltSemantics & getFltSemantics() const

Returns an APFloat semantics tag appropriate for the value type.

unsigned getVectorNumElements() const

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

Definition ValueTypes.h:336

bool operator==(EVT VT) const

Definition ValueTypes.h:45

bool isZeroSized() const

Test if the given EVT has zero size, this will fail if called on a scalable type.

Definition ValueTypes.h:132

bool bitsLE(EVT VT) const

Return true if this has no more bits than VT.

Definition ValueTypes.h:308

EVT getHalfNumVectorElementsVT(LLVMContext &Context) const

Definition ValueTypes.h:453

bool isInteger() const

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

Definition ValueTypes.h:152

bool is64BitVector() const

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

Definition ValueTypes.h:202