@@ -38,7 +38,7 @@ namespace llvm {
38
38
// are considered extended value types.
39
39
INVALID_SIMPLE_VALUE_TYPE = 0 ,
40
40
41
- #define GET_VT_ATTR (Ty, n, sz, Any, Int, FP, Vec, Sc ) Ty = n,
41
+ #define GET_VT_ATTR (Ty, n, sz, Any, Int, FP, Vec, Sc, NElem, EltTy ) Ty = n,
42
42
#define GET_VT_RANGES
43
43
#include " llvm/CodeGen/GenVT.inc"
44
44
#undef GET_VT_ATTR
@@ -171,9 +171,9 @@ namespace llvm {
171
171
// / Return true if this is an overloaded type for TableGen.
172
172
bool isOverloaded () const {
173
173
switch (SimpleTy) {
174
- #define GET_VT_ATTR (Ty, n, sz, Any, Int, FP, Vec, Sc ) \
175
- case Ty: \
176
- return Any;
174
+ #define GET_VT_ATTR (Ty, n, sz, Any, Int, FP, Vec, Sc, NElem, EltTy ) \
175
+ case Ty: \
176
+ return Any;
177
177
#include " llvm/CodeGen/GenVT.inc"
178
178
#undef GET_VT_ATTR
179
179
default :
@@ -252,30 +252,28 @@ namespace llvm {
252
252
}
253
253
254
254
MVT getVectorElementType () const {
255
- switch (SimpleTy) {
256
- default :
257
- llvm_unreachable (" Not a vector MVT!" );
258
-
259
- #define GET_VT_VECATTR (Ty, Sc, nElem, ElTy, ElSz ) \
260
- case Ty: \
261
- return ElTy;
255
+ assert (SimpleTy >= FIRST_VALUETYPE && SimpleTy <= LAST_VALUETYPE);
256
+ static constexpr SimpleValueType EltTyTable[] = {
257
+ #define GET_VT_ATTR (Ty, N, Sz, Any, Int, FP, Vec, Sc, NElem, EltTy ) EltTy,
262
258
#include " llvm/CodeGen/GenVT.inc"
263
- #undef GET_VT_VECATTR
264
- }
259
+ #undef GET_VT_ATTR
260
+ };
261
+ SimpleValueType VT = EltTyTable[SimpleTy - FIRST_VALUETYPE];
262
+ assert (VT != INVALID_SIMPLE_VALUE_TYPE && " Not a vector MVT!" );
263
+ return VT;
265
264
}
266
265
267
266
// / Given a vector type, return the minimum number of elements it contains.
268
267
unsigned getVectorMinNumElements () const {
269
- switch (SimpleTy) {
270
- default :
271
- llvm_unreachable (" Not a vector MVT!" );
272
-
273
- #define GET_VT_VECATTR (Ty, Sc, nElem, ElTy, ElSz ) \
274
- case Ty: \
275
- return nElem;
268
+ assert (SimpleTy >= FIRST_VALUETYPE && SimpleTy <= LAST_VALUETYPE);
269
+ static constexpr uint16_t NElemTable[] = {
270
+ #define GET_VT_ATTR (Ty, N, Sz, Any, Int, FP, Vec, Sc, NElem, EltTy ) NElem,
276
271
#include " llvm/CodeGen/GenVT.inc"
277
- #undef GET_VT_VECATTR
278
- }
272
+ #undef GET_VT_ATTR
273
+ };
274
+ unsigned NElem = NElemTable[SimpleTy - FIRST_VALUETYPE];
275
+ assert (NElem != 0 && " Not a vector MVT!" );
276
+ return NElem;
279
277
}
280
278
281
279
ElementCount getVectorElementCount () const {
@@ -298,8 +296,8 @@ namespace llvm {
298
296
// / base size.
299
297
TypeSize getSizeInBits () const {
300
298
static constexpr TypeSize SizeTable[] = {
301
- #define GET_VT_ATTR (Ty, N, Sz, Any, Int, FP, Vec, Sc ) \
302
- TypeSize (Sz, Sc || Ty == aarch64svcount /* FIXME: Not in the td. */ ),
299
+ #define GET_VT_ATTR (Ty, N, Sz, Any, Int, FP, Vec, Sc, NElem, EltTy ) \
300
+ TypeSize (Sz, Sc || Ty == aarch64svcount /* FIXME: Not in the td. */ ),
303
301
#include " llvm/CodeGen/GenVT.inc"
304
302
#undef GET_VT_ATTR
305
303
};
@@ -420,19 +418,19 @@ namespace llvm {
420
418
}
421
419
422
420
static MVT getFloatingPointVT (unsigned BitWidth) {
423
- #define GET_VT_ATTR (Ty, n, sz, Any, Int, FP, Vec, Sc ) \
424
- if (FP == 3 && sz == BitWidth) \
425
- return Ty;
421
+ #define GET_VT_ATTR (Ty, n, sz, Any, Int, FP, Vec, Sc, NElem, EltTy ) \
422
+ if (FP == 3 && sz == BitWidth) \
423
+ return Ty;
426
424
#include " llvm/CodeGen/GenVT.inc"
427
425
#undef GET_VT_ATTR
428
426
429
427
llvm_unreachable (" Bad bit width!" );
430
428
}
431
429
432
430
static MVT getIntegerVT (unsigned BitWidth) {
433
- #define GET_VT_ATTR (Ty, n, sz, Any, Int, FP, Vec, Sc ) \
434
- if (Int == 3 && sz == BitWidth) \
435
- return Ty;
431
+ #define GET_VT_ATTR (Ty, n, sz, Any, Int, FP, Vec, Sc, NElem, EltTy ) \
432
+ if (Int == 3 && sz == BitWidth) \
433
+ return Ty;
436
434
#include " llvm/CodeGen/GenVT.inc"
437
435
#undef GET_VT_ATTR
438
436
0 commit comments