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() && getExtendedSizeInBits() == 16;
85 bool EVT::isExtended32BitVector() const {
86 return isExtendedVector() && getExtendedSizeInBits() == 32;
89 bool EVT::isExtended64BitVector() const {
90 return isExtendedVector() && getExtendedSizeInBits() == 64;
93 bool EVT::isExtended128BitVector() const {
94 return isExtendedVector() && getExtendedSizeInBits() == 128;
97 bool EVT::isExtended256BitVector() const {
98 return isExtendedVector() && getExtendedSizeInBits() == 256;
101 bool EVT::isExtended512BitVector() const {
102 return isExtendedVector() && getExtendedSizeInBits() == 512;
105 bool EVT::isExtended1024BitVector() const {
106 return isExtendedVector() && getExtendedSizeInBits() == 1024;
109 bool EVT::isExtended2048BitVector() const {
110 return isExtendedVector() && getExtendedSizeInBits() == 2048;
113 bool EVT::isExtendedFixedLengthVector() const {
114 return isExtendedVector() && isa
<FixedVectorType
>(LLVMTy
);
117 bool EVT::isExtendedScalableVector() const {
118 return isExtendedVector() && isa
<ScalableVectorType
>(LLVMTy
);
121 EVT
EVT::getExtendedVectorElementType() const {
122 assert(isExtended() && "Type is not extended!");
123 return EVT::getEVT(cast
<VectorType
>(LLVMTy
)->getElementType());
126 unsigned EVT::getExtendedVectorNumElements() const {
127 assert(isExtended() && "Type is not extended!");
128 ElementCount EC
= cast
<VectorType
>(LLVMTy
)->getElementCount();
129 if (EC
.isScalable()) {
131 << "The code that requested the fixed number of elements has made the "
132 "assumption that this vector is not scalable. This assumption was "
133 "not correct, and this may lead to broken code\n";
135 return EC
.getKnownMinValue();
138 ElementCount
EVT::getExtendedVectorElementCount() const {
139 assert(isExtended() && "Type is not extended!");
140 return cast
<VectorType
>(LLVMTy
)->getElementCount();
143 TypeSize
EVT::getExtendedSizeInBits() const {
144 assert(isExtended() && "Type is not extended!");
145 if (IntegerType
*ITy
= dyn_cast
<IntegerType
>(LLVMTy
))
146 return TypeSize::Fixed(ITy
->getBitWidth());
147 if (VectorType
*VTy
= dyn_cast
<VectorType
>(LLVMTy
))
148 return VTy
->getPrimitiveSizeInBits();
149 llvm_unreachable("Unrecognized extended type!");
152 /// getEVTString - This function returns value type as a string, e.g. "i32".
153 std::string
EVT::getEVTString() const {
154 switch (V
.SimpleTy
) {
157 return (isScalableVector() ? "nxv" : "v") +
158 utostr(getVectorElementCount().getKnownMinValue()) +
159 getVectorElementType().getEVTString();
161 return "i" + utostr(getSizeInBits());
162 if (isFloatingPoint())
163 return "f" + utostr(getSizeInBits());
164 llvm_unreachable("Invalid EVT!");
165 case MVT::bf16
: return "bf16";
166 case MVT::ppcf128
: return "ppcf128";
167 case MVT::isVoid
: return "isVoid";
168 case MVT::Other
: return "ch";
169 case MVT::Glue
: return "glue";
170 case MVT::x86mmx
: return "x86mmx";
171 case MVT::x86amx
: return "x86amx";
172 case MVT::i64x8
: return "i64x8";
173 case MVT::Metadata
: return "Metadata";
174 case MVT::Untyped
: return "Untyped";
175 case MVT::funcref
: return "funcref";
176 case MVT::externref
: return "externref";
177 case MVT::aarch64svcount
:
178 return "aarch64svcount";
179 case MVT::spirvbuiltin
:
180 return "spirvbuiltin";
184 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
185 void EVT::dump() const {
191 /// getTypeForEVT - This method returns an LLVM type corresponding to the
192 /// specified EVT. For integer types, this returns an unsigned type. Note
193 /// that this will abort for types that cannot be represented.
194 Type
*EVT::getTypeForEVT(LLVMContext
&Context
) const {
196 switch (V
.SimpleTy
) {
198 assert(isExtended() && "Type is not extended!");
200 case MVT::isVoid
: return Type::getVoidTy(Context
);
201 case MVT::i1
: return Type::getInt1Ty(Context
);
202 case MVT::i2
: return Type::getIntNTy(Context
, 2);
203 case MVT::i4
: return Type::getIntNTy(Context
, 4);
204 case MVT::i8
: return Type::getInt8Ty(Context
);
205 case MVT::i16
: return Type::getInt16Ty(Context
);
206 case MVT::i32
: return Type::getInt32Ty(Context
);
207 case MVT::i64
: return Type::getInt64Ty(Context
);
208 case MVT::i128
: return IntegerType::get(Context
, 128);
209 case MVT::f16
: return Type::getHalfTy(Context
);
210 case MVT::bf16
: return Type::getBFloatTy(Context
);
211 case MVT::f32
: return Type::getFloatTy(Context
);
212 case MVT::f64
: return Type::getDoubleTy(Context
);
213 case MVT::f80
: return Type::getX86_FP80Ty(Context
);
214 case MVT::f128
: return Type::getFP128Ty(Context
);
215 case MVT::ppcf128
: return Type::getPPC_FP128Ty(Context
);
216 case MVT::x86mmx
: return Type::getX86_MMXTy(Context
);
217 case MVT::aarch64svcount
:
218 return TargetExtType::get(Context
, "aarch64.svcount");
219 case MVT::x86amx
: return Type::getX86_AMXTy(Context
);
220 case MVT::i64x8
: return IntegerType::get(Context
, 512);
221 case MVT::externref
: return Type::getWasm_ExternrefTy(Context
);
222 case MVT::funcref
: return Type::getWasm_FuncrefTy(Context
);
224 return FixedVectorType::get(Type::getInt1Ty(Context
), 1);
226 return FixedVectorType::get(Type::getInt1Ty(Context
), 2);
228 return FixedVectorType::get(Type::getInt1Ty(Context
), 4);
230 return FixedVectorType::get(Type::getInt1Ty(Context
), 8);
232 return FixedVectorType::get(Type::getInt1Ty(Context
), 16);
234 return FixedVectorType::get(Type::getInt1Ty(Context
), 32);
236 return FixedVectorType::get(Type::getInt1Ty(Context
), 64);
238 return FixedVectorType::get(Type::getInt1Ty(Context
), 128);
240 return FixedVectorType::get(Type::getInt1Ty(Context
), 256);
242 return FixedVectorType::get(Type::getInt1Ty(Context
), 512);
244 return FixedVectorType::get(Type::getInt1Ty(Context
), 1024);
246 return FixedVectorType::get(Type::getInt1Ty(Context
), 2048);
248 return FixedVectorType::get(Type::getIntNTy(Context
, 2), 128);
250 return FixedVectorType::get(Type::getIntNTy(Context
, 2), 256);
252 return FixedVectorType::get(Type::getIntNTy(Context
, 4), 64);
254 return FixedVectorType::get(Type::getIntNTy(Context
, 4), 128);
256 return FixedVectorType::get(Type::getInt8Ty(Context
), 1);
258 return FixedVectorType::get(Type::getInt8Ty(Context
), 2);
260 return FixedVectorType::get(Type::getInt8Ty(Context
), 4);
262 return FixedVectorType::get(Type::getInt8Ty(Context
), 8);
264 return FixedVectorType::get(Type::getInt8Ty(Context
), 16);
266 return FixedVectorType::get(Type::getInt8Ty(Context
), 32);
268 return FixedVectorType::get(Type::getInt8Ty(Context
), 64);
270 return FixedVectorType::get(Type::getInt8Ty(Context
), 128);
272 return FixedVectorType::get(Type::getInt8Ty(Context
), 256);
274 return FixedVectorType::get(Type::getInt8Ty(Context
), 512);
276 return FixedVectorType::get(Type::getInt8Ty(Context
), 1024);
278 return FixedVectorType::get(Type::getInt16Ty(Context
), 1);
280 return FixedVectorType::get(Type::getInt16Ty(Context
), 2);
282 return FixedVectorType::get(Type::getInt16Ty(Context
), 3);
284 return FixedVectorType::get(Type::getInt16Ty(Context
), 4);
286 return FixedVectorType::get(Type::getInt16Ty(Context
), 8);
288 return FixedVectorType::get(Type::getInt16Ty(Context
), 16);
290 return FixedVectorType::get(Type::getInt16Ty(Context
), 32);
292 return FixedVectorType::get(Type::getInt16Ty(Context
), 64);
294 return FixedVectorType::get(Type::getInt16Ty(Context
), 128);
296 return FixedVectorType::get(Type::getInt16Ty(Context
), 256);
298 return FixedVectorType::get(Type::getInt16Ty(Context
), 512);
300 return FixedVectorType::get(Type::getInt32Ty(Context
), 1);
302 return FixedVectorType::get(Type::getInt32Ty(Context
), 2);
304 return FixedVectorType::get(Type::getInt32Ty(Context
), 3);
306 return FixedVectorType::get(Type::getInt32Ty(Context
), 4);
308 return FixedVectorType::get(Type::getInt32Ty(Context
), 5);
310 return FixedVectorType::get(Type::getInt32Ty(Context
), 6);
312 return FixedVectorType::get(Type::getInt32Ty(Context
), 7);
314 return FixedVectorType::get(Type::getInt32Ty(Context
), 8);
316 return FixedVectorType::get(Type::getInt32Ty(Context
), 9);
318 return FixedVectorType::get(Type::getInt32Ty(Context
), 10);
320 return FixedVectorType::get(Type::getInt32Ty(Context
), 11);
322 return FixedVectorType::get(Type::getInt32Ty(Context
), 12);
324 return FixedVectorType::get(Type::getInt32Ty(Context
), 16);
326 return FixedVectorType::get(Type::getInt32Ty(Context
), 32);
328 return FixedVectorType::get(Type::getInt32Ty(Context
), 64);
330 return FixedVectorType::get(Type::getInt32Ty(Context
), 128);
332 return FixedVectorType::get(Type::getInt32Ty(Context
), 256);
334 return FixedVectorType::get(Type::getInt32Ty(Context
), 512);
336 return FixedVectorType::get(Type::getInt32Ty(Context
), 1024);
338 return FixedVectorType::get(Type::getInt32Ty(Context
), 2048);
340 return FixedVectorType::get(Type::getInt64Ty(Context
), 1);
342 return FixedVectorType::get(Type::getInt64Ty(Context
), 2);
344 return FixedVectorType::get(Type::getInt64Ty(Context
), 3);
346 return FixedVectorType::get(Type::getInt64Ty(Context
), 4);
348 return FixedVectorType::get(Type::getInt64Ty(Context
), 8);
350 return FixedVectorType::get(Type::getInt64Ty(Context
), 16);
352 return FixedVectorType::get(Type::getInt64Ty(Context
), 32);
354 return FixedVectorType::get(Type::getInt64Ty(Context
), 64);
356 return FixedVectorType::get(Type::getInt64Ty(Context
), 128);
358 return FixedVectorType::get(Type::getInt64Ty(Context
), 256);
360 return FixedVectorType::get(Type::getInt128Ty(Context
), 1);
362 return FixedVectorType::get(Type::getHalfTy(Context
), 1);
364 return FixedVectorType::get(Type::getHalfTy(Context
), 2);
366 return FixedVectorType::get(Type::getHalfTy(Context
), 3);
368 return FixedVectorType::get(Type::getHalfTy(Context
), 4);
370 return FixedVectorType::get(Type::getHalfTy(Context
), 8);
372 return FixedVectorType::get(Type::getHalfTy(Context
), 16);
374 return FixedVectorType::get(Type::getHalfTy(Context
), 32);
376 return FixedVectorType::get(Type::getHalfTy(Context
), 64);
378 return FixedVectorType::get(Type::getHalfTy(Context
), 128);
380 return FixedVectorType::get(Type::getHalfTy(Context
), 256);
382 return FixedVectorType::get(Type::getHalfTy(Context
), 512);
384 return FixedVectorType::get(Type::getBFloatTy(Context
), 2);
386 return FixedVectorType::get(Type::getBFloatTy(Context
), 3);
388 return FixedVectorType::get(Type::getBFloatTy(Context
), 4);
390 return FixedVectorType::get(Type::getBFloatTy(Context
), 8);
392 return FixedVectorType::get(Type::getBFloatTy(Context
), 16);
394 return FixedVectorType::get(Type::getBFloatTy(Context
), 32);
396 return FixedVectorType::get(Type::getBFloatTy(Context
), 64);
398 return FixedVectorType::get(Type::getBFloatTy(Context
), 128);
400 return FixedVectorType::get(Type::getFloatTy(Context
), 1);
402 return FixedVectorType::get(Type::getFloatTy(Context
), 2);
404 return FixedVectorType::get(Type::getFloatTy(Context
), 3);
406 return FixedVectorType::get(Type::getFloatTy(Context
), 4);
408 return FixedVectorType::get(Type::getFloatTy(Context
), 5);
410 return FixedVectorType::get(Type::getFloatTy(Context
), 6);
412 return FixedVectorType::get(Type::getFloatTy(Context
), 7);
414 return FixedVectorType::get(Type::getFloatTy(Context
), 8);
416 return FixedVectorType::get(Type::getFloatTy(Context
), 9);
418 return FixedVectorType::get(Type::getFloatTy(Context
), 10);
420 return FixedVectorType::get(Type::getFloatTy(Context
), 11);
422 return FixedVectorType::get(Type::getFloatTy(Context
), 12);
424 return FixedVectorType::get(Type::getFloatTy(Context
), 16);
426 return FixedVectorType::get(Type::getFloatTy(Context
), 32);
428 return FixedVectorType::get(Type::getFloatTy(Context
), 64);
430 return FixedVectorType::get(Type::getFloatTy(Context
), 128);
432 return FixedVectorType::get(Type::getFloatTy(Context
), 256);
434 return FixedVectorType::get(Type::getFloatTy(Context
), 512);
436 return FixedVectorType::get(Type::getFloatTy(Context
), 1024);
438 return FixedVectorType::get(Type::getFloatTy(Context
), 2048);
440 return FixedVectorType::get(Type::getDoubleTy(Context
), 1);
442 return FixedVectorType::get(Type::getDoubleTy(Context
), 2);
444 return FixedVectorType::get(Type::getDoubleTy(Context
), 3);
446 return FixedVectorType::get(Type::getDoubleTy(Context
), 4);
448 return FixedVectorType::get(Type::getDoubleTy(Context
), 8);
450 return FixedVectorType::get(Type::getDoubleTy(Context
), 16);
452 return FixedVectorType::get(Type::getDoubleTy(Context
), 32);
454 return FixedVectorType::get(Type::getDoubleTy(Context
), 64);
456 return FixedVectorType::get(Type::getDoubleTy(Context
), 128);
458 return FixedVectorType::get(Type::getDoubleTy(Context
), 256);
460 return ScalableVectorType::get(Type::getInt1Ty(Context
), 1);
462 return ScalableVectorType::get(Type::getInt1Ty(Context
), 2);
464 return ScalableVectorType::get(Type::getInt1Ty(Context
), 4);
466 return ScalableVectorType::get(Type::getInt1Ty(Context
), 8);
468 return ScalableVectorType::get(Type::getInt1Ty(Context
), 16);
470 return ScalableVectorType::get(Type::getInt1Ty(Context
), 32);
472 return ScalableVectorType::get(Type::getInt1Ty(Context
), 64);
474 return ScalableVectorType::get(Type::getInt8Ty(Context
), 1);
476 return ScalableVectorType::get(Type::getInt8Ty(Context
), 2);
478 return ScalableVectorType::get(Type::getInt8Ty(Context
), 4);
480 return ScalableVectorType::get(Type::getInt8Ty(Context
), 8);
482 return ScalableVectorType::get(Type::getInt8Ty(Context
), 16);
484 return ScalableVectorType::get(Type::getInt8Ty(Context
), 32);
486 return ScalableVectorType::get(Type::getInt8Ty(Context
), 64);
488 return ScalableVectorType::get(Type::getInt16Ty(Context
), 1);
490 return ScalableVectorType::get(Type::getInt16Ty(Context
), 2);
492 return ScalableVectorType::get(Type::getInt16Ty(Context
), 4);
494 return ScalableVectorType::get(Type::getInt16Ty(Context
), 8);
496 return ScalableVectorType::get(Type::getInt16Ty(Context
), 16);
498 return ScalableVectorType::get(Type::getInt16Ty(Context
), 32);
500 return ScalableVectorType::get(Type::getInt32Ty(Context
), 1);
502 return ScalableVectorType::get(Type::getInt32Ty(Context
), 2);
504 return ScalableVectorType::get(Type::getInt32Ty(Context
), 4);
506 return ScalableVectorType::get(Type::getInt32Ty(Context
), 8);
508 return ScalableVectorType::get(Type::getInt32Ty(Context
), 16);
510 return ScalableVectorType::get(Type::getInt32Ty(Context
), 32);
512 return ScalableVectorType::get(Type::getInt64Ty(Context
), 1);
514 return ScalableVectorType::get(Type::getInt64Ty(Context
), 2);
516 return ScalableVectorType::get(Type::getInt64Ty(Context
), 4);
518 return ScalableVectorType::get(Type::getInt64Ty(Context
), 8);
520 return ScalableVectorType::get(Type::getInt64Ty(Context
), 16);
522 return ScalableVectorType::get(Type::getInt64Ty(Context
), 32);
524 return ScalableVectorType::get(Type::getHalfTy(Context
), 1);
526 return ScalableVectorType::get(Type::getHalfTy(Context
), 2);
528 return ScalableVectorType::get(Type::getHalfTy(Context
), 4);
530 return ScalableVectorType::get(Type::getHalfTy(Context
), 8);
532 return ScalableVectorType::get(Type::getHalfTy(Context
), 16);
534 return ScalableVectorType::get(Type::getHalfTy(Context
), 32);
536 return ScalableVectorType::get(Type::getBFloatTy(Context
), 1);
538 return ScalableVectorType::get(Type::getBFloatTy(Context
), 2);
540 return ScalableVectorType::get(Type::getBFloatTy(Context
), 4);
542 return ScalableVectorType::get(Type::getBFloatTy(Context
), 8);
544 return ScalableVectorType::get(Type::getBFloatTy(Context
), 16);
546 return ScalableVectorType::get(Type::getBFloatTy(Context
), 32);
548 return ScalableVectorType::get(Type::getFloatTy(Context
), 1);
550 return ScalableVectorType::get(Type::getFloatTy(Context
), 2);
552 return ScalableVectorType::get(Type::getFloatTy(Context
), 4);
554 return ScalableVectorType::get(Type::getFloatTy(Context
), 8);
556 return ScalableVectorType::get(Type::getFloatTy(Context
), 16);
558 return ScalableVectorType::get(Type::getDoubleTy(Context
), 1);
560 return ScalableVectorType::get(Type::getDoubleTy(Context
), 2);
562 return ScalableVectorType::get(Type::getDoubleTy(Context
), 4);
564 return ScalableVectorType::get(Type::getDoubleTy(Context
), 8);
565 case MVT::Metadata
: return Type::getMetadataTy(Context
);
570 /// Return the value type corresponding to the specified type. This returns all
571 /// pointers as MVT::iPTR. If HandleUnknown is true, unknown types are returned
572 /// as Other, otherwise they are invalid.
573 MVT
MVT::getVT(Type
*Ty
, bool HandleUnknown
){
574 assert(Ty
!= nullptr && "Invalid type");
575 switch (Ty
->getTypeID()) {
577 if (HandleUnknown
) return MVT(MVT::Other
);
578 llvm_unreachable("Unknown type!");
581 case Type::IntegerTyID
:
582 return getIntegerVT(cast
<IntegerType
>(Ty
)->getBitWidth());
583 case Type::HalfTyID
: return MVT(MVT::f16
);
584 case Type::BFloatTyID
: return MVT(MVT::bf16
);
585 case Type::FloatTyID
: return MVT(MVT::f32
);
586 case Type::DoubleTyID
: return MVT(MVT::f64
);
587 case Type::X86_FP80TyID
: return MVT(MVT::f80
);
588 case Type::X86_MMXTyID
: return MVT(MVT::x86mmx
);
589 case Type::TargetExtTyID
: {
590 TargetExtType
*TargetExtTy
= cast
<TargetExtType
>(Ty
);
591 if (TargetExtTy
->getName() == "aarch64.svcount")
592 return MVT(MVT::aarch64svcount
);
593 else if (TargetExtTy
->getName().starts_with("spirv."))
594 return MVT(MVT::spirvbuiltin
);
596 return MVT(MVT::Other
);
597 llvm_unreachable("Unknown target ext type!");
599 case Type::X86_AMXTyID
: return MVT(MVT::x86amx
);
600 case Type::FP128TyID
: return MVT(MVT::f128
);
601 case Type::PPC_FP128TyID
: return MVT(MVT::ppcf128
);
602 case Type::PointerTyID
: return MVT(MVT::iPTR
);
603 case Type::FixedVectorTyID
:
604 case Type::ScalableVectorTyID
: {
605 VectorType
*VTy
= cast
<VectorType
>(Ty
);
607 getVT(VTy
->getElementType(), /*HandleUnknown=*/ false),
608 VTy
->getElementCount());
613 /// getEVT - Return the value type corresponding to the specified type. This
614 /// returns all pointers as MVT::iPTR. If HandleUnknown is true, unknown types
615 /// are returned as Other, otherwise they are invalid.
616 EVT
EVT::getEVT(Type
*Ty
, bool HandleUnknown
){
617 switch (Ty
->getTypeID()) {
619 return MVT::getVT(Ty
, HandleUnknown
);
620 case Type::IntegerTyID
:
621 return getIntegerVT(Ty
->getContext(), cast
<IntegerType
>(Ty
)->getBitWidth());
622 case Type::FixedVectorTyID
:
623 case Type::ScalableVectorTyID
: {
624 VectorType
*VTy
= cast
<VectorType
>(Ty
);
625 return getVectorVT(Ty
->getContext(),
626 getEVT(VTy
->getElementType(), /*HandleUnknown=*/ false),
627 VTy
->getElementCount());
632 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
633 void MVT::dump() const {
639 void MVT::print(raw_ostream
&OS
) const {
640 if (SimpleTy
== INVALID_SIMPLE_VALUE_TYPE
)
643 OS
<< EVT(*this).getEVTString();