LLVM: lib/CodeGen/ValueTypes.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

18using namespace llvm;

19

20EVT EVT::changeExtendedTypeToInteger() const {

24}

25

26EVT EVT::changeExtendedVectorElementTypeToInteger() const {

31}

32

33EVT EVT::changeExtendedVectorElementType(EVT EltVT) const {

37}

38

43 return VT;

44}

45

46EVT EVT::getExtendedVectorVT(LLVMContext &Context, EVT VT, unsigned NumElements,

47 bool IsScalable) {

48 EVT ResultVT;

49 ResultVT.LLVMTy =

52 return ResultVT;

53}

54

56 EVT ResultVT;

59 return ResultVT;

60}

61

62bool EVT::isExtendedFloatingPoint() const {

65}

66

67bool EVT::isExtendedInteger() const {

70}

71

72bool EVT::isExtendedScalarInteger() const {

75}

76

77bool EVT::isExtendedVector() const {

80}

81

82bool EVT::isExtended16BitVector() const {

83 return isExtendedVector() &&

85}

86

87bool EVT::isExtended32BitVector() const {

88 return isExtendedVector() &&

90}

91

92bool EVT::isExtended64BitVector() const {

93 return isExtendedVector() &&

95}

96

97bool EVT::isExtended128BitVector() const {

98 return isExtendedVector() &&

100}

101

102bool EVT::isExtended256BitVector() const {

103 return isExtendedVector() &&

105}

106

107bool EVT::isExtended512BitVector() const {

108 return isExtendedVector() &&

110}

111

112bool EVT::isExtended1024BitVector() const {

113 return isExtendedVector() &&

115}

116

117bool EVT::isExtended2048BitVector() const {

118 return isExtendedVector() &&

120}

121

122bool EVT::isExtendedFixedLengthVector() const {

123 return isExtendedVector() && isa(LLVMTy);

124}

125

126bool EVT::isExtendedScalableVector() const {

127 return isExtendedVector() && isa(LLVMTy);

128}

129

130EVT EVT::getExtendedVectorElementType() const {

132 return EVT::getEVT(cast(LLVMTy)->getElementType());

133}

134

135unsigned EVT::getExtendedVectorNumElements() const {

137 ElementCount EC = cast(LLVMTy)->getElementCount();

138 if (EC.isScalable()) {

140 << "The code that requested the fixed number of elements has made the "

141 "assumption that this vector is not scalable. This assumption was "

142 "not correct, and this may lead to broken code\n";

143 }

144 return EC.getKnownMinValue();

145}

146

147ElementCount EVT::getExtendedVectorElementCount() const {

149 return cast(LLVMTy)->getElementCount();

150}

151

152TypeSize EVT::getExtendedSizeInBits() const {

154 if (IntegerType *ITy = dyn_cast(LLVMTy))

156 if (VectorType *VTy = dyn_cast(LLVMTy))

157 return VTy->getPrimitiveSizeInBits();

159}

160

161

164 default:

168 unsigned MinNumElts = Sz / (NF * 8);

169 return "riscv_nxv" + utostr(MinNumElts) + "i8x" + utostr(NF);

170 }

180 case MVT::bf16: return "bf16";

181 case MVT::ppcf128: return "ppcf128";

182 case MVT::isVoid: return "isVoid";

183 case MVT::Other: return "ch";

184 case MVT::Glue: return "glue";

185 case MVT::x86mmx: return "x86mmx";

186 case MVT::x86amx: return "x86amx";

187 case MVT::i64x8: return "i64x8";

188 case MVT::Metadata: return "Metadata";

189 case MVT::Untyped: return "Untyped";

190 case MVT::funcref: return "funcref";

191 case MVT::exnref: return "exnref";

192 case MVT::externref: return "externref";

193 case MVT::aarch64svcount:

194 return "aarch64svcount";

195 case MVT::spirvbuiltin:

196 return "spirvbuiltin";

197 }

198}

199

200#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)

203 dbgs() << "\n";

204}

205#endif

206

207

208

209

211

213 default:

215 return LLVMTy;

218 case MVT::aarch64svcount:

225#define GET_VT_EVT(Ty, EVT) case MVT::Ty: return EVT;

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

227#undef GET_VT_EVT

228 }

229

230}

231

232

233

234

235

236

238 assert(Ty != nullptr && "Invalid type");

240 default:

241 if (HandleUnknown) return MVT(MVT::Other);

244 return MVT::isVoid;

252 return MVT(MVT::f80);

254 TargetExtType *TargetExtTy = cast(Ty);

255 if (TargetExtTy->getName() == "aarch64.svcount")

256 return MVT(MVT::aarch64svcount);

258 return MVT(MVT::spirvbuiltin);

259 if (TargetExtTy->getName() == "riscv.vector.tuple") {

260 unsigned Sz = cast(TargetExtTy->getTypeParameter(0))

261 ->getMinNumElements() *

262 8;

264

266 }

267 if (HandleUnknown)

268 return MVT(MVT::Other);

270 }

276 VectorType *VTy = cast(Ty);

280 }

281 }

282}

283

284

285

286

287

288

291 default:

292 return MVT::getVT(Ty, HandleUnknown);

294 return MVT::Untyped;

299 VectorType *VTy = cast(Ty);

303 }

304 }

305}

306

317 }

318}

319

322}

323

324#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)

327 dbgs() << "\n";

328}

329#endif

330

333 OS << "invalid";

334 else

336}

This file declares a class to represent arbitrary precision floating point values and provide a varie...

assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())

static unsigned getBitWidth(Type *Ty, const DataLayout &DL)

Returns the bitwidth of the given scalar or pointer type.

static FixedVectorType * get(Type *ElementType, unsigned NumElts)

Class to represent integer types.

static IntegerType * get(LLVMContext &C, unsigned NumBits)

This static method is the primary way of constructing an IntegerType.

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

void dump() const

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

@ INVALID_SIMPLE_VALUE_TYPE

static MVT getRISCVVectorTupleVT(unsigned Sz, unsigned NFields)

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

Return the value type corresponding to the specified type.

const fltSemantics & getFltSemantics() const

Returns an APFloat semantics tag appropriate for the value type.

static MVT getVectorVT(MVT VT, unsigned NumElements)

static MVT getIntegerVT(unsigned BitWidth)

MVT getScalarType() const

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

void print(raw_ostream &OS) const

Implement operator<<.

bool starts_with(StringRef Prefix) const

Check if this string starts with the given Prefix.

Class to represent target extensions types, which are generally unintrospectable from target-independ...

static TargetExtType * get(LLVMContext &Context, StringRef Name, ArrayRef< Type * > Types={}, ArrayRef< unsigned > Ints={})

Return a target extension type having the specified name and optional type and integer parameters.

Type * getTypeParameter(unsigned i) const

unsigned getIntParameter(unsigned i) const

StringRef getName() const

Return the name for this target extension type.

static constexpr TypeSize getFixed(ScalarTy ExactSize)

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

bool isVectorTy() const

True if this is an instance of VectorType.

bool isIntOrIntVectorTy() const

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

static Type * getX86_AMXTy(LLVMContext &C)

static Type * getMetadataTy(LLVMContext &C)

@ X86_AMXTyID

AMX vectors (8192 bits, X86 specific)

@ HalfTyID

16-bit floating point type

@ TargetExtTyID

Target extension type.

@ VoidTyID

type with no size

@ ScalableVectorTyID

Scalable SIMD vector type.

@ FloatTyID

32-bit floating point type

@ IntegerTyID

Arbitrary bit width integers.

@ FixedVectorTyID

Fixed width SIMD vector type.

@ BFloatTyID

16-bit floating point type (7-bit significand)

@ DoubleTyID

64-bit floating point type

@ X86_FP80TyID

80-bit floating point type (X87)

@ PPC_FP128TyID

128-bit floating point type (two 64-bits, PowerPC)

@ FP128TyID

128-bit floating point type (112-bit significand)

static Type * getVoidTy(LLVMContext &C)

LLVMContext & getContext() const

Return the LLVMContext in which this type was uniqued.

bool isIntegerTy() const

True if this is an instance of IntegerType.

TypeID getTypeID() const

Return the type id for the type.

static Type * getWasm_FuncrefTy(LLVMContext &C)

bool isFPOrFPVectorTy() const

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

static Type * getWasm_ExternrefTy(LLVMContext &C)

Base class of all SIMD vector types.

ElementCount getElementCount() const

Return an ElementCount instance to represent the (possibly scalable) number of elements in the vector...

static VectorType * get(Type *ElementType, ElementCount EC)

This static method is the primary way to construct an VectorType.

Type * getElementType() const

static raw_ostream & warning()

Convenience method for printing "warning: " to stderr.

constexpr ScalarTy getKnownMinValue() const

Returns the minimum value this quantity can represent.

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.

raw_ostream & dbgs()

dbgs() - This returns a reference to a raw_ostream for debugging messages.

constexpr unsigned BitWidth

static const fltSemantics & IEEEsingle() LLVM_READNONE

static const fltSemantics & PPCDoubleDouble() LLVM_READNONE

static const fltSemantics & x87DoubleExtended() LLVM_READNONE

static const fltSemantics & IEEEquad() LLVM_READNONE

static const fltSemantics & IEEEdouble() LLVM_READNONE

static const fltSemantics & IEEEhalf() LLVM_READNONE

static const fltSemantics & BFloat() LLVM_READNONE

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.

bool isFloatingPoint() const

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

ElementCount getVectorElementCount() const

TypeSize getSizeInBits() const

Return the size of the specified value type in bits.

unsigned getRISCVVectorTupleNumFields() const

Given a RISCV vector tuple type, return the num_fields.

uint64_t getScalarSizeInBits() const

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

Return the value type corresponding to the specified type.

MVT getSimpleVT() const

Return the SimpleValueType held in the specified simple EVT.

void dump() const

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

static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)

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

bool isRISCVVectorTuple() const

Return true if this is a vector value type.

std::string getEVTString() const

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

bool isVector() const

Return true if this is a vector value type.

EVT getScalarType() const

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

Type * getTypeForEVT(LLVMContext &Context) const

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

bool isScalableVector() const

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

EVT getVectorElementType() const

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

bool isExtended() const

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

void print(raw_ostream &OS) const

Implement operator<<.

const fltSemantics & getFltSemantics() const

Returns an APFloat semantics tag appropriate for the value type.

bool isInteger() const

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