llvm.org GIT mirror llvm / f347454
Replace tablegen uses of EVT with MVT. Add isOverloaded() to MVT to facilitate. Remove TGValueTypes.cpp since its unused now (and may have been before). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200036 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 6 years ago
5 changed file(s) with 14 addition(s) and 137 deletion(s). Raw diff Collapse all Expand all
234234 /// is1024BitVector - Return true if this is a 1024-bit vector type.
235235 bool is1024BitVector() const {
236236 return (SimpleTy == MVT::v16i64);
237 }
238
239 /// isOverloaded - Return true if this is an overloaded type for TableGen.
240 bool isOverloaded() const {
241 return (SimpleTy==MVT::iAny || SimpleTy==MVT::fAny ||
242 SimpleTy==MVT::vAny || SimpleTy==MVT::iPTRAny);
237243 }
238244
239245 /// isPow2VectorType - Returns true if the given vector is a power of 2.
711711 unsigned Size = R->getValueAsInt("Size");
712712
713713 Namespace = R->getValueAsString("Namespace");
714 SpillSize = Size ? Size : EVT(VTs[0]).getSizeInBits();
714 SpillSize = Size ? Size : MVT(VTs[0]).getSizeInBits();
715715 SpillAlignment = R->getValueAsInt("Alignment");
716716 CopyCost = R->getValueAsInt("CopyCost");
717717 Allocatable = R->getValueAsBit("isAllocatable");
527527 } else {
528528 VT = getValueType(TyEl->getValueAsDef("VT"));
529529 }
530 if (EVT(VT).isOverloaded()) {
530 if (MVT(VT).isOverloaded()) {
531531 OverloadedVTs.push_back(VT);
532532 isOverloaded = true;
533533 }
561561 } else
562562 VT = getValueType(TyEl->getValueAsDef("VT"));
563563
564 if (EVT(VT).isOverloaded()) {
564 if (MVT(VT).isOverloaded()) {
565565 OverloadedVTs.push_back(VT);
566566 isOverloaded = true;
567567 }
267267
268268 static void EncodeFixedValueType(MVT::SimpleValueType VT,
269269 std::vector &Sig) {
270 if (EVT(VT).isInteger()) {
271 unsigned BitWidth = EVT(VT).getSizeInBits();
270 if (MVT(VT).isInteger()) {
271 unsigned BitWidth = MVT(VT).getSizeInBits();
272272 switch (BitWidth) {
273273 default: PrintFatalError("unhandled integer type width in intrinsic!");
274274 case 1: return Sig.push_back(IIT_I1);
349349 }
350350 }
351351
352 if (EVT(VT).isVector()) {
353 EVT VVT = VT;
352 if (MVT(VT).isVector()) {
353 MVT VVT = VT;
354354 switch (VVT.getVectorNumElements()) {
355355 default: PrintFatalError("unhandled vector type width in intrinsic!");
356356 case 1: Sig.push_back(IIT_V1); break;
361361 case 32: Sig.push_back(IIT_V32); break;
362362 }
363363
364 return EncodeFixedValueType(VVT.getVectorElementType().
365 getSimpleVT().SimpleTy, Sig);
364 return EncodeFixedValueType(VVT.getVectorElementType().SimpleTy, Sig);
366365 }
367366
368367 EncodeFixedValueType(VT, Sig);
+0
-128
utils/TableGen/TGValueTypes.cpp less more
None //===- ValueTypes.cpp - Tablegen extended ValueType implementation --------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // The EVT type is used by tablegen as well as in LLVM. In order to handle
10 // extended types, the EVT type uses support functions that call into
11 // LLVM's type system code. These aren't accessible in tablegen, so this
12 // file provides simple replacements.
13 //
14 //===----------------------------------------------------------------------===//
15
16 #include "llvm/CodeGen/ValueTypes.h"
17 #include "llvm/Support/Casting.h"
18 #include
19 using namespace llvm;
20
21 namespace llvm {
22
23 class Type {
24 protected:
25 enum TypeKind {
26 TK_ExtendedIntegerType,
27 TK_ExtendedVectorType
28 };
29 private:
30 TypeKind Kind;
31 public:
32 TypeKind getKind() const {
33 return Kind;
34 }
35 Type(TypeKind K) : Kind(K) {}
36 virtual unsigned getSizeInBits() const = 0;
37 virtual ~Type();
38 };
39
40 // Provide out-of-line definition to prevent weak vtable.
41 Type::~Type() {}
42
43 }
44
45 namespace {
46 class ExtendedIntegerType : public Type {
47 unsigned BitWidth;
48 public:
49 explicit ExtendedIntegerType(unsigned bits)
50 : Type(TK_ExtendedIntegerType), BitWidth(bits) {}
51 static bool classof(const Type *T) {
52 return T->getKind() == TK_ExtendedIntegerType;
53 }
54 virtual unsigned getSizeInBits() const {
55 return getBitWidth();
56 }
57 unsigned getBitWidth() const {
58 return BitWidth;
59 }
60 };
61
62 class ExtendedVectorType : public Type {
63 EVT ElementType;
64 unsigned NumElements;
65 public:
66 ExtendedVectorType(EVT elty, unsigned num)
67 : Type(TK_ExtendedVectorType), ElementType(elty), NumElements(num) {}
68 static bool classof(const Type *T) {
69 return T->getKind() == TK_ExtendedVectorType;
70 }
71 virtual unsigned getSizeInBits() const {
72 return getNumElements() * getElementType().getSizeInBits();
73 }
74 EVT getElementType() const {
75 return ElementType;
76 }
77 unsigned getNumElements() const {
78 return NumElements;
79 }
80 };
81 } // end anonymous namespace
82
83 static std::map
84 ExtendedIntegerTypeMap;
85 static std::map, const Type *>
86 ExtendedVectorTypeMap;
87
88 bool EVT::isExtendedFloatingPoint() const {
89 assert(isExtended() && "Type is not extended!");
90 // Extended floating-point types are not supported yet.
91 return false;
92 }
93
94 bool EVT::isExtendedInteger() const {
95 assert(isExtended() && "Type is not extended!");
96 return isa(LLVMTy);
97 }
98
99 bool EVT::isExtendedVector() const {
100 assert(isExtended() && "Type is not extended!");
101 return isa(LLVMTy);
102 }
103
104 bool EVT::isExtended64BitVector() const {
105 assert(isExtended() && "Type is not extended!");
106 return isExtendedVector() && getSizeInBits() == 64;
107 }
108
109 bool EVT::isExtended128BitVector() const {
110 assert(isExtended() && "Type is not extended!");
111 return isExtendedVector() && getSizeInBits() == 128;
112 }
113
114 EVT EVT::getExtendedVectorElementType() const {
115 assert(isExtendedVector() && "Type is not an extended vector!");
116 return static_cast(LLVMTy)->getElementType();
117 }
118
119 unsigned EVT::getExtendedVectorNumElements() const {
120 assert(isExtendedVector() && "Type is not an extended vector!");
121 return static_cast(LLVMTy)->getNumElements();
122 }
123
124 unsigned EVT::getExtendedSizeInBits() const {
125 assert(isExtended() && "Type is not extended!");
126 return LLVMTy->getSizeInBits();
127 }