1 //===----------- ValueTypes.cpp - Implementation of EVT methods -----------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "llvm/CodeGen/ValueTypes.h"
10 #include "llvm/ADT/StringExtras.h"
11 #include "llvm/IR/DerivedTypes.h"
12 #include "llvm/IR/Type.h"
13 #include "llvm/Support/Debug.h"
14 #include "llvm/Support/ErrorHandling.h"
15 #include "llvm/Support/TypeSize.h"
16 #include "llvm/Support/WithColor.h"
19 EVT
EVT::changeExtendedTypeToInteger() const {
20 assert(isExtended() && "Type is not extended!");
21 LLVMContext
&Context
= LLVMTy
->getContext();
22 return getIntegerVT(Context
, getSizeInBits());
25 EVT
EVT::changeExtendedVectorElementTypeToInteger() const {
26 assert(isExtended() && "Type is not extended!");
27 LLVMContext
&Context
= LLVMTy
->getContext();
28 EVT IntTy
= getIntegerVT(Context
, getScalarSizeInBits());
29 return getVectorVT(Context
, IntTy
, getVectorElementCount());
32 EVT
EVT::changeExtendedVectorElementType(EVT EltVT
) const {
33 assert(isExtended() && "Type is not extended!");
34 LLVMContext
&Context
= LLVMTy
->getContext();
35 return getVectorVT(Context
, EltVT
, getVectorElementCount());
38 EVT
EVT::getExtendedIntegerVT(LLVMContext
&Context
, unsigned BitWidth
) {
40 VT
.LLVMTy
= IntegerType::get(Context
, BitWidth
);
41 assert(VT
.isExtended() && "Type is not extended!");
45 EVT
EVT::getExtendedVectorVT(LLVMContext
&Context
, EVT VT
, unsigned NumElements
,
49 VectorType::get(VT
.getTypeForEVT(Context
), NumElements
, IsScalable
);
50 assert(ResultVT
.isExtended() && "Type is not extended!");
54 EVT
EVT::getExtendedVectorVT(LLVMContext
&Context
, EVT VT
, ElementCount EC
) {
56 ResultVT
.LLVMTy
= VectorType::get(VT
.getTypeForEVT(Context
), EC
);
57 assert(ResultVT
.isExtended() && "Type is not extended!");
61 bool EVT::isExtendedFloatingPoint() const {
62 assert(isExtended() && "Type is not extended!");
63 return LLVMTy
->isFPOrFPVectorTy();
66 bool EVT::isExtendedInteger() const {
67 assert(isExtended() && "Type is not extended!");
68 return LLVMTy
->isIntOrIntVectorTy();
71 bool EVT::isExtendedScalarInteger() const {
72 assert(isExtended() && "Type is not extended!");
73 return LLVMTy
->isIntegerTy();
76 bool EVT::isExtendedVector() const {
77 assert(isExtended() && "Type is not extended!");
78 return LLVMTy
->isVectorTy();
81 bool EVT::isExtended16BitVector() const {
82 return isExtendedVector() &&
83 getExtendedSizeInBits() == TypeSize::getFixed(16);
86 bool EVT::isExtended32BitVector() const {
87 return isExtendedVector() &&
88 getExtendedSizeInBits() == TypeSize::getFixed(32);
91 bool EVT::isExtended64BitVector() const {
92 return isExtendedVector() &&
93 getExtendedSizeInBits() == TypeSize::getFixed(64);
96 bool EVT::isExtended128BitVector() const {
97 return isExtendedVector() &&
98 getExtendedSizeInBits() == TypeSize::getFixed(128);
101 bool EVT::isExtended256BitVector() const {
102 return isExtendedVector() &&
103 getExtendedSizeInBits() == TypeSize::getFixed(256);
106 bool EVT::isExtended512BitVector() const {
107 return isExtendedVector() &&
108 getExtendedSizeInBits() == TypeSize::getFixed(512);
111 bool EVT::isExtended1024BitVector() const {
112 return isExtendedVector() &&
113 getExtendedSizeInBits() == TypeSize::getFixed(1024);
116 bool EVT::isExtended2048BitVector() const {
117 return isExtendedVector() &&
118 getExtendedSizeInBits() == TypeSize::getFixed(2048);
121 bool EVT::isExtendedFixedLengthVector() const {
122 return isExtendedVector() && isa
<FixedVectorType
>(LLVMTy
);
125 bool EVT::isExtendedScalableVector() const {
126 return isExtendedVector() && isa
<ScalableVectorType
>(LLVMTy
);
129 EVT
EVT::getExtendedVectorElementType() const {
130 assert(isExtended() && "Type is not extended!");
131 return EVT::getEVT(cast
<VectorType
>(LLVMTy
)->getElementType());
134 unsigned EVT::getExtendedVectorNumElements() const {
135 assert(isExtended() && "Type is not extended!");
136 ElementCount EC
= cast
<VectorType
>(LLVMTy
)->getElementCount();
137 if (EC
.isScalable()) {
139 << "The code that requested the fixed number of elements has made the "
140 "assumption that this vector is not scalable. This assumption was "
141 "not correct, and this may lead to broken code\n";
143 return EC
.getKnownMinValue();
146 ElementCount
EVT::getExtendedVectorElementCount() const {
147 assert(isExtended() && "Type is not extended!");
148 return cast
<VectorType
>(LLVMTy
)->getElementCount();
151 TypeSize
EVT::getExtendedSizeInBits() const {
152 assert(isExtended() && "Type is not extended!");
153 if (IntegerType
*ITy
= dyn_cast
<IntegerType
>(LLVMTy
))
154 return TypeSize::getFixed(ITy
->getBitWidth());
155 if (VectorType
*VTy
= dyn_cast
<VectorType
>(LLVMTy
))
156 return VTy
->getPrimitiveSizeInBits();
157 llvm_unreachable("Unrecognized extended type!");
160 /// getEVTString - This function returns value type as a string, e.g. "i32".
161 std::string
EVT::getEVTString() const {
162 switch (V
.SimpleTy
) {
165 return (isScalableVector() ? "nxv" : "v") +
166 utostr(getVectorElementCount().getKnownMinValue()) +
167 getVectorElementType().getEVTString();
169 return "i" + utostr(getSizeInBits());
170 if (isFloatingPoint())
171 return "f" + utostr(getSizeInBits());
172 llvm_unreachable("Invalid EVT!");
173 case MVT::bf16
: return "bf16";
174 case MVT::ppcf128
: return "ppcf128";
175 case MVT::isVoid
: return "isVoid";
176 case MVT::Other
: return "ch";
177 case MVT::Glue
: return "glue";
178 case MVT::x86mmx
: return "x86mmx";
179 case MVT::x86amx
: return "x86amx";
180 case MVT::i64x8
: return "i64x8";
181 case MVT::Metadata
: return "Metadata";
182 case MVT::Untyped
: return "Untyped";
183 case MVT::funcref
: return "funcref";
184 case MVT::externref
: return "externref";
185 case MVT::aarch64svcount
:
186 return "aarch64svcount";
187 case MVT::spirvbuiltin
:
188 return "spirvbuiltin";
192 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
193 void EVT::dump() const {
199 /// getTypeForEVT - This method returns an LLVM type corresponding to the
200 /// specified EVT. For integer types, this returns an unsigned type. Note
201 /// that this will abort for types that cannot be represented.
202 Type
*EVT::getTypeForEVT(LLVMContext
&Context
) const {
204 switch (V
.SimpleTy
) {
206 assert(isExtended() && "Type is not extended!");
208 case MVT::isVoid
: return Type::getVoidTy(Context
);
209 case MVT::i1
: return Type::getInt1Ty(Context
);
210 case MVT::i2
: return Type::getIntNTy(Context
, 2);
211 case MVT::i4
: return Type::getIntNTy(Context
, 4);
212 case MVT::i8
: return Type::getInt8Ty(Context
);
213 case MVT::i16
: return Type::getInt16Ty(Context
);
214 case MVT::i32
: return Type::getInt32Ty(Context
);
215 case MVT::i64
: return Type::getInt64Ty(Context
);
216 case MVT::i128
: return IntegerType::get(Context
, 128);
217 case MVT::f16
: return Type::getHalfTy(Context
);
218 case MVT::bf16
: return Type::getBFloatTy(Context
);
219 case MVT::f32
: return Type::getFloatTy(Context
);
220 case MVT::f64
: return Type::getDoubleTy(Context
);
221 case MVT::f80
: return Type::getX86_FP80Ty(Context
);
222 case MVT::f128
: return Type::getFP128Ty(Context
);
223 case MVT::ppcf128
: return Type::getPPC_FP128Ty(Context
);
224 case MVT::x86mmx
: return Type::getX86_MMXTy(Context
);
225 case MVT::aarch64svcount
:
226 return TargetExtType::get(Context
, "aarch64.svcount");
227 case MVT::x86amx
: return Type::getX86_AMXTy(Context
);
228 case MVT::i64x8
: return IntegerType::get(Context
, 512);
229 case MVT::externref
: return Type::getWasm_ExternrefTy(Context
);
230 case MVT::funcref
: return Type::getWasm_FuncrefTy(Context
);
232 return FixedVectorType::get(Type::getInt1Ty(Context
), 1);
234 return FixedVectorType::get(Type::getInt1Ty(Context
), 2);
236 return FixedVectorType::get(Type::getInt1Ty(Context
), 4);
238 return FixedVectorType::get(Type::getInt1Ty(Context
), 8);
240 return FixedVectorType::get(Type::getInt1Ty(Context
), 16);
242 return FixedVectorType::get(Type::getInt1Ty(Context
), 32);
244 return FixedVectorType::get(Type::getInt1Ty(Context
), 64);
246 return FixedVectorType::get(Type::getInt1Ty(Context
), 128);
248 return FixedVectorType::get(Type::getInt1Ty(Context
), 256);
250 return FixedVectorType::get(Type::getInt1Ty(Context
), 512);
252 return FixedVectorType::get(Type::getInt1Ty(Context
), 1024);
254 return FixedVectorType::get(Type::getInt1Ty(Context
), 2048);
256 return FixedVectorType::get(Type::getIntNTy(Context
, 2), 128);
258 return FixedVectorType::get(Type::getIntNTy(Context
, 2), 256);
260 return FixedVectorType::get(Type::getIntNTy(Context
, 4), 64);
262 return FixedVectorType::get(Type::getIntNTy(Context
, 4), 128);
264 return FixedVectorType::get(Type::getInt8Ty(Context
), 1);
266 return FixedVectorType::get(Type::getInt8Ty(Context
), 2);
268 return FixedVectorType::get(Type::getInt8Ty(Context
), 4);
270 return FixedVectorType::get(Type::getInt8Ty(Context
), 8);
272 return FixedVectorType::get(Type::getInt8Ty(Context
), 16);
274 return FixedVectorType::get(Type::getInt8Ty(Context
), 32);
276 return FixedVectorType::get(Type::getInt8Ty(Context
), 64);
278 return FixedVectorType::get(Type::getInt8Ty(Context
), 128);
280 return FixedVectorType::get(Type::getInt8Ty(Context
), 256);
282 return FixedVectorType::get(Type::getInt8Ty(Context
), 512);
284 return FixedVectorType::get(Type::getInt8Ty(Context
), 1024);
286 return FixedVectorType::get(Type::getInt16Ty(Context
), 1);
288 return FixedVectorType::get(Type::getInt16Ty(Context
), 2);
290 return FixedVectorType::get(Type::getInt16Ty(Context
), 3);
292 return FixedVectorType::get(Type::getInt16Ty(Context
), 4);
294 return FixedVectorType::get(Type::getInt16Ty(Context
), 8);
296 return FixedVectorType::get(Type::getInt16Ty(Context
), 16);
298 return FixedVectorType::get(Type::getInt16Ty(Context
), 32);
300 return FixedVectorType::get(Type::getInt16Ty(Context
), 64);
302 return FixedVectorType::get(Type::getInt16Ty(Context
), 128);
304 return FixedVectorType::get(Type::getInt16Ty(Context
), 256);
306 return FixedVectorType::get(Type::getInt16Ty(Context
), 512);
308 return FixedVectorType::get(Type::getInt32Ty(Context
), 1);
310 return FixedVectorType::get(Type::getInt32Ty(Context
), 2);
312 return FixedVectorType::get(Type::getInt32Ty(Context
), 3);
314 return FixedVectorType::get(Type::getInt32Ty(Context
), 4);
316 return FixedVectorType::get(Type::getInt32Ty(Context
), 5);
318 return FixedVectorType::get(Type::getInt32Ty(Context
), 6);
320 return FixedVectorType::get(Type::getInt32Ty(Context
), 7);
322 return FixedVectorType::get(Type::getInt32Ty(Context
), 8);
324 return FixedVectorType::get(Type::getInt32Ty(Context
), 9);
326 return FixedVectorType::get(Type::getInt32Ty(Context
), 10);
328 return FixedVectorType::get(Type::getInt32Ty(Context
), 11);
330 return FixedVectorType::get(Type::getInt32Ty(Context
), 12);
332 return FixedVectorType::get(Type::getInt32Ty(Context
), 16);
334 return FixedVectorType::get(Type::getInt32Ty(Context
), 32);
336 return FixedVectorType::get(Type::getInt32Ty(Context
), 64);
338 return FixedVectorType::get(Type::getInt32Ty(Context
), 128);
340 return FixedVectorType::get(Type::getInt32Ty(Context
), 256);
342 return FixedVectorType::get(Type::getInt32Ty(Context
), 512);
344 return FixedVectorType::get(Type::getInt32Ty(Context
), 1024);
346 return FixedVectorType::get(Type::getInt32Ty(Context
), 2048);
348 return FixedVectorType::get(Type::getInt64Ty(Context
), 1);
350 return FixedVectorType::get(Type::getInt64Ty(Context
), 2);
352 return FixedVectorType::get(Type::getInt64Ty(Context
), 3);
354 return FixedVectorType::get(Type::getInt64Ty(Context
), 4);
356 return FixedVectorType::get(Type::getInt64Ty(Context
), 8);
358 return FixedVectorType::get(Type::getInt64Ty(Context
), 16);
360 return FixedVectorType::get(Type::getInt64Ty(Context
), 32);
362 return FixedVectorType::get(Type::getInt64Ty(Context
), 64);
364 return FixedVectorType::get(Type::getInt64Ty(Context
), 128);
366 return FixedVectorType::get(Type::getInt64Ty(Context
), 256);
368 return FixedVectorType::get(Type::getInt128Ty(Context
), 1);
370 return FixedVectorType::get(Type::getHalfTy(Context
), 1);
372 return FixedVectorType::get(Type::getHalfTy(Context
), 2);
374 return FixedVectorType::get(Type::getHalfTy(Context
), 3);
376 return FixedVectorType::get(Type::getHalfTy(Context
), 4);
378 return FixedVectorType::get(Type::getHalfTy(Context
), 8);
380 return FixedVectorType::get(Type::getHalfTy(Context
), 16);
382 return FixedVectorType::get(Type::getHalfTy(Context
), 32);
384 return FixedVectorType::get(Type::getHalfTy(Context
), 64);
386 return FixedVectorType::get(Type::getHalfTy(Context
), 128);
388 return FixedVectorType::get(Type::getHalfTy(Context
), 256);
390 return FixedVectorType::get(Type::getHalfTy(Context
), 512);
392 return FixedVectorType::get(Type::getBFloatTy(Context
), 2);
394 return FixedVectorType::get(Type::getBFloatTy(Context
), 3);
396 return FixedVectorType::get(Type::getBFloatTy(Context
), 4);
398 return FixedVectorType::get(Type::getBFloatTy(Context
), 8);
400 return FixedVectorType::get(Type::getBFloatTy(Context
), 16);
402 return FixedVectorType::get(Type::getBFloatTy(Context
), 32);
404 return FixedVectorType::get(Type::getBFloatTy(Context
), 64);
406 return FixedVectorType::get(Type::getBFloatTy(Context
), 128);
408 return FixedVectorType::get(Type::getFloatTy(Context
), 1);
410 return FixedVectorType::get(Type::getFloatTy(Context
), 2);
412 return FixedVectorType::get(Type::getFloatTy(Context
), 3);
414 return FixedVectorType::get(Type::getFloatTy(Context
), 4);
416 return FixedVectorType::get(Type::getFloatTy(Context
), 5);
418 return FixedVectorType::get(Type::getFloatTy(Context
), 6);
420 return FixedVectorType::get(Type::getFloatTy(Context
), 7);
422 return FixedVectorType::get(Type::getFloatTy(Context
), 8);
424 return FixedVectorType::get(Type::getFloatTy(Context
), 9);
426 return FixedVectorType::get(Type::getFloatTy(Context
), 10);
428 return FixedVectorType::get(Type::getFloatTy(Context
), 11);
430 return FixedVectorType::get(Type::getFloatTy(Context
), 12);
432 return FixedVectorType::get(Type::getFloatTy(Context
), 16);
434 return FixedVectorType::get(Type::getFloatTy(Context
), 32);
436 return FixedVectorType::get(Type::getFloatTy(Context
), 64);
438 return FixedVectorType::get(Type::getFloatTy(Context
), 128);
440 return FixedVectorType::get(Type::getFloatTy(Context
), 256);
442 return FixedVectorType::get(Type::getFloatTy(Context
), 512);
444 return FixedVectorType::get(Type::getFloatTy(Context
), 1024);
446 return FixedVectorType::get(Type::getFloatTy(Context
), 2048);
448 return FixedVectorType::get(Type::getDoubleTy(Context
), 1);
450 return FixedVectorType::get(Type::getDoubleTy(Context
), 2);
452 return FixedVectorType::get(Type::getDoubleTy(Context
), 3);
454 return FixedVectorType::get(Type::getDoubleTy(Context
), 4);
456 return FixedVectorType::get(Type::getDoubleTy(Context
), 8);
458 return FixedVectorType::get(Type::getDoubleTy(Context
), 16);
460 return FixedVectorType::get(Type::getDoubleTy(Context
), 32);
462 return FixedVectorType::get(Type::getDoubleTy(Context
), 64);
464 return FixedVectorType::get(Type::getDoubleTy(Context
), 128);
466 return FixedVectorType::get(Type::getDoubleTy(Context
), 256);
468 return ScalableVectorType::get(Type::getInt1Ty(Context
), 1);
470 return ScalableVectorType::get(Type::getInt1Ty(Context
), 2);
472 return ScalableVectorType::get(Type::getInt1Ty(Context
), 4);
474 return ScalableVectorType::get(Type::getInt1Ty(Context
), 8);
476 return ScalableVectorType::get(Type::getInt1Ty(Context
), 16);
478 return ScalableVectorType::get(Type::getInt1Ty(Context
), 32);
480 return ScalableVectorType::get(Type::getInt1Ty(Context
), 64);
482 return ScalableVectorType::get(Type::getInt8Ty(Context
), 1);
484 return ScalableVectorType::get(Type::getInt8Ty(Context
), 2);
486 return ScalableVectorType::get(Type::getInt8Ty(Context
), 4);
488 return ScalableVectorType::get(Type::getInt8Ty(Context
), 8);
490 return ScalableVectorType::get(Type::getInt8Ty(Context
), 16);
492 return ScalableVectorType::get(Type::getInt8Ty(Context
), 32);
494 return ScalableVectorType::get(Type::getInt8Ty(Context
), 64);
496 return ScalableVectorType::get(Type::getInt16Ty(Context
), 1);
498 return ScalableVectorType::get(Type::getInt16Ty(Context
), 2);
500 return ScalableVectorType::get(Type::getInt16Ty(Context
), 4);
502 return ScalableVectorType::get(Type::getInt16Ty(Context
), 8);
504 return ScalableVectorType::get(Type::getInt16Ty(Context
), 16);
506 return ScalableVectorType::get(Type::getInt16Ty(Context
), 32);
508 return ScalableVectorType::get(Type::getInt32Ty(Context
), 1);
510 return ScalableVectorType::get(Type::getInt32Ty(Context
), 2);
512 return ScalableVectorType::get(Type::getInt32Ty(Context
), 4);
514 return ScalableVectorType::get(Type::getInt32Ty(Context
), 8);
516 return ScalableVectorType::get(Type::getInt32Ty(Context
), 16);
518 return ScalableVectorType::get(Type::getInt32Ty(Context
), 32);
520 return ScalableVectorType::get(Type::getInt64Ty(Context
), 1);
522 return ScalableVectorType::get(Type::getInt64Ty(Context
), 2);
524 return ScalableVectorType::get(Type::getInt64Ty(Context
), 4);
526 return ScalableVectorType::get(Type::getInt64Ty(Context
), 8);
528 return ScalableVectorType::get(Type::getInt64Ty(Context
), 16);
530 return ScalableVectorType::get(Type::getInt64Ty(Context
), 32);
532 return ScalableVectorType::get(Type::getHalfTy(Context
), 1);
534 return ScalableVectorType::get(Type::getHalfTy(Context
), 2);
536 return ScalableVectorType::get(Type::getHalfTy(Context
), 4);
538 return ScalableVectorType::get(Type::getHalfTy(Context
), 8);
540 return ScalableVectorType::get(Type::getHalfTy(Context
), 16);
542 return ScalableVectorType::get(Type::getHalfTy(Context
), 32);
544 return ScalableVectorType::get(Type::getBFloatTy(Context
), 1);
546 return ScalableVectorType::get(Type::getBFloatTy(Context
), 2);
548 return ScalableVectorType::get(Type::getBFloatTy(Context
), 4);
550 return ScalableVectorType::get(Type::getBFloatTy(Context
), 8);
552 return ScalableVectorType::get(Type::getBFloatTy(Context
), 16);
554 return ScalableVectorType::get(Type::getBFloatTy(Context
), 32);
556 return ScalableVectorType::get(Type::getFloatTy(Context
), 1);
558 return ScalableVectorType::get(Type::getFloatTy(Context
), 2);
560 return ScalableVectorType::get(Type::getFloatTy(Context
), 4);
562 return ScalableVectorType::get(Type::getFloatTy(Context
), 8);
564 return ScalableVectorType::get(Type::getFloatTy(Context
), 16);
566 return ScalableVectorType::get(Type::getDoubleTy(Context
), 1);
568 return ScalableVectorType::get(Type::getDoubleTy(Context
), 2);
570 return ScalableVectorType::get(Type::getDoubleTy(Context
), 4);
572 return ScalableVectorType::get(Type::getDoubleTy(Context
), 8);
573 case MVT::Metadata
: return Type::getMetadataTy(Context
);
578 /// Return the value type corresponding to the specified type. This returns all
579 /// pointers as MVT::iPTR. If HandleUnknown is true, unknown types are returned
580 /// as Other, otherwise they are invalid.
581 MVT
MVT::getVT(Type
*Ty
, bool HandleUnknown
){
582 assert(Ty
!= nullptr && "Invalid type");
583 switch (Ty
->getTypeID()) {
585 if (HandleUnknown
) return MVT(MVT::Other
);
586 llvm_unreachable("Unknown type!");
589 case Type::IntegerTyID
:
590 return getIntegerVT(cast
<IntegerType
>(Ty
)->getBitWidth());
591 case Type::HalfTyID
: return MVT(MVT::f16
);
592 case Type::BFloatTyID
: return MVT(MVT::bf16
);
593 case Type::FloatTyID
: return MVT(MVT::f32
);
594 case Type::DoubleTyID
: return MVT(MVT::f64
);
595 case Type::X86_FP80TyID
: return MVT(MVT::f80
);
596 case Type::X86_MMXTyID
: return MVT(MVT::x86mmx
);
597 case Type::TargetExtTyID
: {
598 TargetExtType
*TargetExtTy
= cast
<TargetExtType
>(Ty
);
599 if (TargetExtTy
->getName() == "aarch64.svcount")
600 return MVT(MVT::aarch64svcount
);
601 else if (TargetExtTy
->getName().starts_with("spirv."))
602 return MVT(MVT::spirvbuiltin
);
604 return MVT(MVT::Other
);
605 llvm_unreachable("Unknown target ext type!");
607 case Type::X86_AMXTyID
: return MVT(MVT::x86amx
);
608 case Type::FP128TyID
: return MVT(MVT::f128
);
609 case Type::PPC_FP128TyID
: return MVT(MVT::ppcf128
);
610 case Type::PointerTyID
: return MVT(MVT::iPTR
);
611 case Type::FixedVectorTyID
:
612 case Type::ScalableVectorTyID
: {
613 VectorType
*VTy
= cast
<VectorType
>(Ty
);
615 getVT(VTy
->getElementType(), /*HandleUnknown=*/ false),
616 VTy
->getElementCount());
621 /// getEVT - Return the value type corresponding to the specified type. This
622 /// returns all pointers as MVT::iPTR. If HandleUnknown is true, unknown types
623 /// are returned as Other, otherwise they are invalid.
624 EVT
EVT::getEVT(Type
*Ty
, bool HandleUnknown
){
625 switch (Ty
->getTypeID()) {
627 return MVT::getVT(Ty
, HandleUnknown
);
628 case Type::IntegerTyID
:
629 return getIntegerVT(Ty
->getContext(), cast
<IntegerType
>(Ty
)->getBitWidth());
630 case Type::FixedVectorTyID
:
631 case Type::ScalableVectorTyID
: {
632 VectorType
*VTy
= cast
<VectorType
>(Ty
);
633 return getVectorVT(Ty
->getContext(),
634 getEVT(VTy
->getElementType(), /*HandleUnknown=*/ false),
635 VTy
->getElementCount());
640 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
641 void MVT::dump() const {
647 void MVT::print(raw_ostream
&OS
) const {
648 if (SimpleTy
== INVALID_SIMPLE_VALUE_TYPE
)
651 OS
<< EVT(*this).getEVTString();