1 //===- CodeGen/ValueTypes.h - Low-Level Target independ. types --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the set of low-level target independent types which various
11 // values in the code generator are. This allows the target specific behavior
12 // of instructions to be described to target independent passes.
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_CODEGEN_VALUETYPES_H
17 #define LLVM_CODEGEN_VALUETYPES_H
19 #include "llvm/Support/DataTypes.h"
20 #include "llvm/Support/ErrorHandling.h"
21 #include "llvm/Support/MathExtras.h"
30 /// MVT - Machine Value Type. Every type that is supported natively by some
31 /// processor targeted by LLVM occurs here. This means that any legal value
32 /// type can be represented by an MVT.
35 enum SimpleValueType {
36 // INVALID_SIMPLE_VALUE_TYPE - Simple value types less than zero are
37 // considered extended value types.
38 INVALID_SIMPLE_VALUE_TYPE = -1,
40 // If you change this numbering, you must change the values in
41 // ValueTypes.td as well!
42 Other = 0, // This is a non-standard value
43 i1 = 1, // This is a 1 bit integer value
44 i8 = 2, // This is an 8 bit integer value
45 i16 = 3, // This is a 16 bit integer value
46 i32 = 4, // This is a 32 bit integer value
47 i64 = 5, // This is a 64 bit integer value
48 i128 = 6, // This is a 128 bit integer value
50 FIRST_INTEGER_VALUETYPE = i1,
51 LAST_INTEGER_VALUETYPE = i128,
53 f16 = 7, // This is a 16 bit floating point value
54 f32 = 8, // This is a 32 bit floating point value
55 f64 = 9, // This is a 64 bit floating point value
56 f80 = 10, // This is a 80 bit floating point value
57 f128 = 11, // This is a 128 bit floating point value
58 ppcf128 = 12, // This is a PPC 128-bit floating point value
60 FIRST_FP_VALUETYPE = f16,
61 LAST_FP_VALUETYPE = ppcf128,
66 v16i1 = 16, // 16 x i1
67 v32i1 = 17, // 32 x i1
68 v64i1 = 18, // 64 x i1
74 v16i8 = 23, // 16 x i8
75 v32i8 = 24, // 32 x i8
76 v64i8 = 25, // 64 x i8
77 v1i16 = 26, // 1 x i16
78 v2i16 = 27, // 2 x i16
79 v4i16 = 28, // 4 x i16
80 v8i16 = 29, // 8 x i16
81 v16i16 = 30, // 16 x i16
82 v32i16 = 31, // 32 x i16
83 v1i32 = 32, // 1 x i32
84 v2i32 = 33, // 2 x i32
85 v4i32 = 34, // 4 x i32
86 v8i32 = 35, // 8 x i32
87 v16i32 = 36, // 16 x i32
88 v1i64 = 37, // 1 x i64
89 v2i64 = 38, // 2 x i64
90 v4i64 = 39, // 4 x i64
91 v8i64 = 40, // 8 x i64
92 v16i64 = 41, // 16 x i64
94 FIRST_INTEGER_VECTOR_VALUETYPE = v2i1,
95 LAST_INTEGER_VECTOR_VALUETYPE = v16i64,
97 v2f16 = 42, // 2 x f16
98 v4f16 = 43, // 4 x f16
99 v8f16 = 44, // 8 x f16
100 v1f32 = 45, // 1 x f32
101 v2f32 = 46, // 2 x f32
102 v4f32 = 47, // 4 x f32
103 v8f32 = 48, // 8 x f32
104 v16f32 = 49, // 16 x f32
105 v1f64 = 50, // 1 x f64
106 v2f64 = 51, // 2 x f64
107 v4f64 = 52, // 4 x f64
108 v8f64 = 53, // 8 x f64
110 FIRST_FP_VECTOR_VALUETYPE = v2f16,
111 LAST_FP_VECTOR_VALUETYPE = v8f64,
113 FIRST_VECTOR_VALUETYPE = v2i1,
114 LAST_VECTOR_VALUETYPE = v8f64,
116 x86mmx = 54, // This is an X86 MMX value
118 Glue = 55, // This glues nodes together during pre-RA sched
120 isVoid = 56, // This has no value
122 Untyped = 57, // This value takes a register, but has
123 // unspecified type. The register class
124 // will be determined by the opcode.
126 LAST_VALUETYPE = 58, // This always remains at the end of the list.
128 // This is the current maximum for LAST_VALUETYPE.
129 // MVT::MAX_ALLOWED_VALUETYPE is used for asserts and to size bit vectors
130 // This value must be a multiple of 32.
131 MAX_ALLOWED_VALUETYPE = 64,
133 // Metadata - This is MDNode or MDString.
136 // iPTRAny - An int value the size of the pointer of the current
137 // target to any address space. This must only be used internal to
138 // tblgen. Other than for overloading, we treat iPTRAny the same as iPTR.
141 // vAny - A vector with any length and element size. This is used
142 // for intrinsics that have overloadings based on vector types.
143 // This is only for tblgen's consumption!
146 // fAny - Any floating-point or vector floating-point value. This is used
147 // for intrinsics that have overloadings based on floating-point types.
148 // This is only for tblgen's consumption!
151 // iAny - An integer or vector integer value of any bit width. This is
152 // used for intrinsics that have overloadings based on integer bit widths.
153 // This is only for tblgen's consumption!
156 // iPTR - An int value the size of the pointer of the current
157 // target. This should only be used internal to tblgen!
161 SimpleValueType SimpleTy;
163 MVT() : SimpleTy((SimpleValueType)(INVALID_SIMPLE_VALUE_TYPE)) {}
164 MVT(SimpleValueType SVT) : SimpleTy(SVT) { }
166 bool operator>(const MVT& S) const { return SimpleTy > S.SimpleTy; }
167 bool operator<(const MVT& S) const { return SimpleTy < S.SimpleTy; }
168 bool operator==(const MVT& S) const { return SimpleTy == S.SimpleTy; }
169 bool operator!=(const MVT& S) const { return SimpleTy != S.SimpleTy; }
170 bool operator>=(const MVT& S) const { return SimpleTy >= S.SimpleTy; }
171 bool operator<=(const MVT& S) const { return SimpleTy <= S.SimpleTy; }
173 /// isFloatingPoint - Return true if this is a FP, or a vector FP type.
174 bool isFloatingPoint() const {
175 return ((SimpleTy >= MVT::FIRST_FP_VALUETYPE &&
176 SimpleTy <= MVT::LAST_FP_VALUETYPE) ||
177 (SimpleTy >= MVT::FIRST_FP_VECTOR_VALUETYPE &&
178 SimpleTy <= MVT::LAST_FP_VECTOR_VALUETYPE));
181 /// isInteger - Return true if this is an integer, or a vector integer type.
182 bool isInteger() const {
183 return ((SimpleTy >= MVT::FIRST_INTEGER_VALUETYPE &&
184 SimpleTy <= MVT::LAST_INTEGER_VALUETYPE) ||
185 (SimpleTy >= MVT::FIRST_INTEGER_VECTOR_VALUETYPE &&
186 SimpleTy <= MVT::LAST_INTEGER_VECTOR_VALUETYPE));
189 /// isVector - Return true if this is a vector value type.
190 bool isVector() const {
191 return (SimpleTy >= MVT::FIRST_VECTOR_VALUETYPE &&
192 SimpleTy <= MVT::LAST_VECTOR_VALUETYPE);
195 /// is16BitVector - Return true if this is a 16-bit vector type.
196 bool is16BitVector() const {
197 return (SimpleTy == MVT::v2i8 || SimpleTy == MVT::v1i16 ||
198 SimpleTy == MVT::v16i1);
201 /// is32BitVector - Return true if this is a 32-bit vector type.
202 bool is32BitVector() const {
203 return (SimpleTy == MVT::v4i8 || SimpleTy == MVT::v2i16 ||
204 SimpleTy == MVT::v1i32);
207 /// is64BitVector - Return true if this is a 64-bit vector type.
208 bool is64BitVector() const {
209 return (SimpleTy == MVT::v8i8 || SimpleTy == MVT::v4i16 ||
210 SimpleTy == MVT::v2i32 || SimpleTy == MVT::v1i64 ||
211 SimpleTy == MVT::v1f64 || SimpleTy == MVT::v2f32);
214 /// is128BitVector - Return true if this is a 128-bit vector type.
215 bool is128BitVector() const {
216 return (SimpleTy == MVT::v16i8 || SimpleTy == MVT::v8i16 ||
217 SimpleTy == MVT::v4i32 || SimpleTy == MVT::v2i64 ||
218 SimpleTy == MVT::v4f32 || SimpleTy == MVT::v2f64);
221 /// is256BitVector - Return true if this is a 256-bit vector type.
222 bool is256BitVector() const {
223 return (SimpleTy == MVT::v8f32 || SimpleTy == MVT::v4f64 ||
224 SimpleTy == MVT::v32i8 || SimpleTy == MVT::v16i16 ||
225 SimpleTy == MVT::v8i32 || SimpleTy == MVT::v4i64);
228 /// is512BitVector - Return true if this is a 512-bit vector type.
229 bool is512BitVector() const {
230 return (SimpleTy == MVT::v8f64 || SimpleTy == MVT::v16f32 ||
231 SimpleTy == MVT::v64i8 || SimpleTy == MVT::v32i16 ||
232 SimpleTy == MVT::v8i64 || SimpleTy == MVT::v16i32);
235 /// is1024BitVector - Return true if this is a 1024-bit vector type.
236 bool is1024BitVector() const {
237 return (SimpleTy == MVT::v16i64);
240 /// isOverloaded - Return true if this is an overloaded type for TableGen.
241 bool isOverloaded() const {
242 return (SimpleTy==MVT::iAny || SimpleTy==MVT::fAny ||
243 SimpleTy==MVT::vAny || SimpleTy==MVT::iPTRAny);
246 /// isPow2VectorType - Returns true if the given vector is a power of 2.
247 bool isPow2VectorType() const {
248 unsigned NElts = getVectorNumElements();
249 return !(NElts & (NElts - 1));
252 /// getPow2VectorType - Widens the length of the given vector MVT up to
253 /// the nearest power of 2 and returns that type.
254 MVT getPow2VectorType() const {
255 if (isPow2VectorType())
258 unsigned NElts = getVectorNumElements();
259 unsigned Pow2NElts = 1 << Log2_32_Ceil(NElts);
260 return MVT::getVectorVT(getVectorElementType(), Pow2NElts);
263 /// getScalarType - If this is a vector type, return the element type,
264 /// otherwise return this.
265 MVT getScalarType() const {
266 return isVector() ? getVectorElementType() : *this;
269 MVT getVectorElementType() const {
272 llvm_unreachable("Not a vector MVT!");
278 case v64i1: return i1;
285 case v64i8: return i8;
291 case v32i16: return i16;
296 case v16i32: return i32;
301 case v16i64: return i64;
304 case v8f16: return f16;
309 case v16f32: return f32;
313 case v8f64: return f64;
317 unsigned getVectorNumElements() const {
320 llvm_unreachable("Not a vector MVT!");
323 case v32i16: return 32;
325 case v64i8: return 64;
331 case v16f32: return 16;
339 case v8f64: return 8;
347 case v4f64: return 4;
355 case v2f64: return 2;
361 case v1f64: return 1;
365 unsigned getSizeInBits() const {
368 llvm_unreachable("getSizeInBits called on extended MVT.");
370 llvm_unreachable("Value type is non-standard value, Other.");
372 llvm_unreachable("Value type size is target-dependent. Ask TLI.");
377 llvm_unreachable("Value type is overloaded.");
379 llvm_unreachable("Value type is metadata.");
390 case v1i16: return 16;
398 case v1i32: return 32;
409 case v1f64: return 64;
410 case f80 : return 80;
420 case v2f64: return 128;
426 case v4f64: return 256;
432 case v8f64: return 512;
433 case v16i64:return 1024;
437 unsigned getScalarSizeInBits() const {
438 return getScalarType().getSizeInBits();
441 /// getStoreSize - Return the number of bytes overwritten by a store
442 /// of the specified value type.
443 unsigned getStoreSize() const {
444 return (getSizeInBits() + 7) / 8;
447 /// getStoreSizeInBits - Return the number of bits overwritten by a store
448 /// of the specified value type.
449 unsigned getStoreSizeInBits() const {
450 return getStoreSize() * 8;
453 /// Return true if this has more bits than VT.
454 bool bitsGT(MVT VT) const {
455 return getSizeInBits() > VT.getSizeInBits();
458 /// Return true if this has no less bits than VT.
459 bool bitsGE(MVT VT) const {
460 return getSizeInBits() >= VT.getSizeInBits();
463 /// Return true if this has less bits than VT.
464 bool bitsLT(MVT VT) const {
465 return getSizeInBits() < VT.getSizeInBits();
468 /// Return true if this has no more bits than VT.
469 bool bitsLE(MVT VT) const {
470 return getSizeInBits() <= VT.getSizeInBits();
474 static MVT getFloatingPointVT(unsigned BitWidth) {
477 llvm_unreachable("Bad bit width!");
491 static MVT getIntegerVT(unsigned BitWidth) {
494 return (MVT::SimpleValueType)(MVT::INVALID_SIMPLE_VALUE_TYPE);
510 static MVT getVectorVT(MVT VT, unsigned NumElements) {
511 switch (VT.SimpleTy) {
515 if (NumElements == 2) return MVT::v2i1;
516 if (NumElements == 4) return MVT::v4i1;
517 if (NumElements == 8) return MVT::v8i1;
518 if (NumElements == 16) return MVT::v16i1;
519 if (NumElements == 32) return MVT::v32i1;
520 if (NumElements == 64) return MVT::v64i1;
523 if (NumElements == 1) return MVT::v1i8;
524 if (NumElements == 2) return MVT::v2i8;
525 if (NumElements == 4) return MVT::v4i8;
526 if (NumElements == 8) return MVT::v8i8;
527 if (NumElements == 16) return MVT::v16i8;
528 if (NumElements == 32) return MVT::v32i8;
529 if (NumElements == 64) return MVT::v64i8;
532 if (NumElements == 1) return MVT::v1i16;
533 if (NumElements == 2) return MVT::v2i16;
534 if (NumElements == 4) return MVT::v4i16;
535 if (NumElements == 8) return MVT::v8i16;
536 if (NumElements == 16) return MVT::v16i16;
537 if (NumElements == 32) return MVT::v32i16;
540 if (NumElements == 1) return MVT::v1i32;
541 if (NumElements == 2) return MVT::v2i32;
542 if (NumElements == 4) return MVT::v4i32;
543 if (NumElements == 8) return MVT::v8i32;
544 if (NumElements == 16) return MVT::v16i32;
547 if (NumElements == 1) return MVT::v1i64;
548 if (NumElements == 2) return MVT::v2i64;
549 if (NumElements == 4) return MVT::v4i64;
550 if (NumElements == 8) return MVT::v8i64;
551 if (NumElements == 16) return MVT::v16i64;
554 if (NumElements == 2) return MVT::v2f16;
555 if (NumElements == 4) return MVT::v4f16;
556 if (NumElements == 8) return MVT::v8f16;
559 if (NumElements == 1) return MVT::v1f32;
560 if (NumElements == 2) return MVT::v2f32;
561 if (NumElements == 4) return MVT::v4f32;
562 if (NumElements == 8) return MVT::v8f32;
563 if (NumElements == 16) return MVT::v16f32;
566 if (NumElements == 1) return MVT::v1f64;
567 if (NumElements == 2) return MVT::v2f64;
568 if (NumElements == 4) return MVT::v4f64;
569 if (NumElements == 8) return MVT::v8f64;
572 return (MVT::SimpleValueType)(MVT::INVALID_SIMPLE_VALUE_TYPE);
575 /// Return the value type corresponding to the specified type. This returns
576 /// all pointers as iPTR. If HandleUnknown is true, unknown types are
577 /// returned as Other, otherwise they are invalid.
578 static MVT getVT(Type *Ty, bool HandleUnknown = false);
583 /// EVT - Extended Value Type. Capable of holding value types which are not
584 /// native for any processor (such as the i12345 type), as well as the types
585 /// a MVT can represent.
592 EVT() : V((MVT::SimpleValueType)(MVT::INVALID_SIMPLE_VALUE_TYPE)),
594 EVT(MVT::SimpleValueType SVT) : V(SVT), LLVMTy(0) { }
595 EVT(MVT S) : V(S), LLVMTy(0) {}
597 bool operator==(EVT VT) const {
598 return !(*this != VT);
600 bool operator!=(EVT VT) const {
601 if (V.SimpleTy != VT.V.SimpleTy)
604 return LLVMTy != VT.LLVMTy;
608 /// getFloatingPointVT - Returns the EVT that represents a floating point
609 /// type with the given number of bits. There are two floating point types
610 /// with 128 bits - this returns f128 rather than ppcf128.
611 static EVT getFloatingPointVT(unsigned BitWidth) {
612 return MVT::getFloatingPointVT(BitWidth);
615 /// getIntegerVT - Returns the EVT that represents an integer with the given
617 static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth) {
618 MVT M = MVT::getIntegerVT(BitWidth);
621 return getExtendedIntegerVT(Context, BitWidth);
624 /// getVectorVT - Returns the EVT that represents a vector NumElements in
625 /// length, where each element is of type VT.
626 static EVT getVectorVT(LLVMContext &Context, EVT VT, unsigned NumElements) {
627 MVT M = MVT::getVectorVT(VT.V, NumElements);
630 return getExtendedVectorVT(Context, VT, NumElements);
633 /// changeVectorElementTypeToInteger - Return a vector with the same number
634 /// of elements as this vector, but with the element type converted to an
635 /// integer type with the same bitwidth.
636 EVT changeVectorElementTypeToInteger() const {
638 return changeExtendedVectorElementTypeToInteger();
639 MVT EltTy = getSimpleVT().getVectorElementType();
640 unsigned BitWidth = EltTy.getSizeInBits();
641 MVT IntTy = MVT::getIntegerVT(BitWidth);
642 MVT VecTy = MVT::getVectorVT(IntTy, getVectorNumElements());
643 assert(VecTy.SimpleTy >= 0 &&
644 "Simple vector VT not representable by simple integer vector VT!");
648 /// isSimple - Test if the given EVT is simple (as opposed to being
650 bool isSimple() const {
651 return V.SimpleTy >= 0;
654 /// isExtended - Test if the given EVT is extended (as opposed to
656 bool isExtended() const {
660 /// isFloatingPoint - Return true if this is a FP, or a vector FP type.
661 bool isFloatingPoint() const {
662 return isSimple() ? V.isFloatingPoint() : isExtendedFloatingPoint();
665 /// isInteger - Return true if this is an integer, or a vector integer type.
666 bool isInteger() const {
667 return isSimple() ? V.isInteger() : isExtendedInteger();
670 /// isVector - Return true if this is a vector value type.
671 bool isVector() const {
672 return isSimple() ? V.isVector() : isExtendedVector();
675 /// is16BitVector - Return true if this is a 16-bit vector type.
676 bool is16BitVector() const {
677 return isSimple() ? V.is16BitVector() : isExtended16BitVector();
680 /// is32BitVector - Return true if this is a 32-bit vector type.
681 bool is32BitVector() const {
682 return isSimple() ? V.is32BitVector() : isExtended32BitVector();
685 /// is64BitVector - Return true if this is a 64-bit vector type.
686 bool is64BitVector() const {
687 return isSimple() ? V.is64BitVector() : isExtended64BitVector();
690 /// is128BitVector - Return true if this is a 128-bit vector type.
691 bool is128BitVector() const {
692 return isSimple() ? V.is128BitVector() : isExtended128BitVector();
695 /// is256BitVector - Return true if this is a 256-bit vector type.
696 bool is256BitVector() const {
697 return isSimple() ? V.is256BitVector() : isExtended256BitVector();
700 /// is512BitVector - Return true if this is a 512-bit vector type.
701 bool is512BitVector() const {
702 return isSimple() ? V.is512BitVector() : isExtended512BitVector();
705 /// is1024BitVector - Return true if this is a 1024-bit vector type.
706 bool is1024BitVector() const {
707 return isSimple() ? V.is1024BitVector() : isExtended1024BitVector();
710 /// isOverloaded - Return true if this is an overloaded type for TableGen.
711 bool isOverloaded() const {
712 return (V==MVT::iAny || V==MVT::fAny || V==MVT::vAny || V==MVT::iPTRAny);
715 /// isByteSized - Return true if the bit size is a multiple of 8.
716 bool isByteSized() const {
717 return (getSizeInBits() & 7) == 0;
720 /// isRound - Return true if the size is a power-of-two number of bytes.
721 bool isRound() const {
722 unsigned BitSize = getSizeInBits();
723 return BitSize >= 8 && !(BitSize & (BitSize - 1));
726 /// bitsEq - Return true if this has the same number of bits as VT.
727 bool bitsEq(EVT VT) const {
728 if (EVT::operator==(VT)) return true;
729 return getSizeInBits() == VT.getSizeInBits();
732 /// bitsGT - Return true if this has more bits than VT.
733 bool bitsGT(EVT VT) const {
734 if (EVT::operator==(VT)) return false;
735 return getSizeInBits() > VT.getSizeInBits();
738 /// bitsGE - Return true if this has no less bits than VT.
739 bool bitsGE(EVT VT) const {
740 if (EVT::operator==(VT)) return true;
741 return getSizeInBits() >= VT.getSizeInBits();
744 /// bitsLT - Return true if this has less bits than VT.
745 bool bitsLT(EVT VT) const {
746 if (EVT::operator==(VT)) return false;
747 return getSizeInBits() < VT.getSizeInBits();
750 /// bitsLE - Return true if this has no more bits than VT.
751 bool bitsLE(EVT VT) const {
752 if (EVT::operator==(VT)) return true;
753 return getSizeInBits() <= VT.getSizeInBits();
757 /// getSimpleVT - Return the SimpleValueType held in the specified
759 MVT getSimpleVT() const {
760 assert(isSimple() && "Expected a SimpleValueType!");
764 /// getScalarType - If this is a vector type, return the element type,
765 /// otherwise return this.
766 EVT getScalarType() const {
767 return isVector() ? getVectorElementType() : *this;
770 /// getVectorElementType - Given a vector type, return the type of
772 EVT getVectorElementType() const {
773 assert(isVector() && "Invalid vector type!");
775 return V.getVectorElementType();
776 return getExtendedVectorElementType();
779 /// getVectorNumElements - Given a vector type, return the number of
780 /// elements it contains.
781 unsigned getVectorNumElements() const {
782 assert(isVector() && "Invalid vector type!");
784 return V.getVectorNumElements();
785 return getExtendedVectorNumElements();
788 /// getSizeInBits - Return the size of the specified value type in bits.
789 unsigned getSizeInBits() const {
791 return V.getSizeInBits();
792 return getExtendedSizeInBits();
795 unsigned getScalarSizeInBits() const {
796 return getScalarType().getSizeInBits();
799 /// getStoreSize - Return the number of bytes overwritten by a store
800 /// of the specified value type.
801 unsigned getStoreSize() const {
802 return (getSizeInBits() + 7) / 8;
805 /// getStoreSizeInBits - Return the number of bits overwritten by a store
806 /// of the specified value type.
807 unsigned getStoreSizeInBits() const {
808 return getStoreSize() * 8;
811 /// getRoundIntegerType - Rounds the bit-width of the given integer EVT up
812 /// to the nearest power of two (and at least to eight), and returns the
813 /// integer EVT with that number of bits.
814 EVT getRoundIntegerType(LLVMContext &Context) const {
815 assert(isInteger() && !isVector() && "Invalid integer type!");
816 unsigned BitWidth = getSizeInBits();
819 return getIntegerVT(Context, 1 << Log2_32_Ceil(BitWidth));
822 /// getHalfSizedIntegerVT - Finds the smallest simple value type that is
823 /// greater than or equal to half the width of this EVT. If no simple
824 /// value type can be found, an extended integer value type of half the
825 /// size (rounded up) is returned.
826 EVT getHalfSizedIntegerVT(LLVMContext &Context) const {
827 assert(isInteger() && !isVector() && "Invalid integer type!");
828 unsigned EVTSize = getSizeInBits();
829 for (unsigned IntVT = MVT::FIRST_INTEGER_VALUETYPE;
830 IntVT <= MVT::LAST_INTEGER_VALUETYPE; ++IntVT) {
831 EVT HalfVT = EVT((MVT::SimpleValueType)IntVT);
832 if (HalfVT.getSizeInBits() * 2 >= EVTSize)
835 return getIntegerVT(Context, (EVTSize + 1) / 2);
838 /// isPow2VectorType - Returns true if the given vector is a power of 2.
839 bool isPow2VectorType() const {
840 unsigned NElts = getVectorNumElements();
841 return !(NElts & (NElts - 1));
844 /// getPow2VectorType - Widens the length of the given vector EVT up to
845 /// the nearest power of 2 and returns that type.
846 EVT getPow2VectorType(LLVMContext &Context) const {
847 if (!isPow2VectorType()) {
848 unsigned NElts = getVectorNumElements();
849 unsigned Pow2NElts = 1 << Log2_32_Ceil(NElts);
850 return EVT::getVectorVT(Context, getVectorElementType(), Pow2NElts);
857 /// getEVTString - This function returns value type as a string,
859 std::string getEVTString() const;
861 /// getTypeForEVT - This method returns an LLVM type corresponding to the
862 /// specified EVT. For integer types, this returns an unsigned type. Note
863 /// that this will abort for types that cannot be represented.
864 Type *getTypeForEVT(LLVMContext &Context) const;
866 /// getEVT - Return the value type corresponding to the specified type.
867 /// This returns all pointers as iPTR. If HandleUnknown is true, unknown
868 /// types are returned as Other, otherwise they are invalid.
869 static EVT getEVT(Type *Ty, bool HandleUnknown = false);
871 intptr_t getRawBits() const {
875 return (intptr_t)(LLVMTy);
878 /// compareRawBits - A meaningless but well-behaved order, useful for
879 /// constructing containers.
880 struct compareRawBits {
881 bool operator()(EVT L, EVT R) const {
882 if (L.V.SimpleTy == R.V.SimpleTy)
883 return L.LLVMTy < R.LLVMTy;
885 return L.V.SimpleTy < R.V.SimpleTy;
890 // Methods for handling the Extended-type case in functions above.
891 // These are all out-of-line to prevent users of this header file
892 // from having a dependency on Type.h.
893 EVT changeExtendedVectorElementTypeToInteger() const;
894 static EVT getExtendedIntegerVT(LLVMContext &C, unsigned BitWidth);
895 static EVT getExtendedVectorVT(LLVMContext &C, EVT VT,
896 unsigned NumElements);
897 bool isExtendedFloatingPoint() const LLVM_READONLY;
898 bool isExtendedInteger() const LLVM_READONLY;
899 bool isExtendedVector() const LLVM_READONLY;
900 bool isExtended16BitVector() const LLVM_READONLY;
901 bool isExtended32BitVector() const LLVM_READONLY;
902 bool isExtended64BitVector() const LLVM_READONLY;
903 bool isExtended128BitVector() const LLVM_READONLY;
904 bool isExtended256BitVector() const LLVM_READONLY;
905 bool isExtended512BitVector() const LLVM_READONLY;
906 bool isExtended1024BitVector() const LLVM_READONLY;
907 EVT getExtendedVectorElementType() const;
908 unsigned getExtendedVectorNumElements() const LLVM_READONLY;
909 unsigned getExtendedSizeInBits() const;
912 } // End llvm namespace