llvm.org GIT mirror llvm / 61fc4cf
Add a new overloaded EVT::vAny type for use in TableGen to allow intrinsic arguments that are vectors of any size and element type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78631 91177308-0d34-0410-b5e6-96231b3b80d8 Bob Wilson 10 years ago
8 changed file(s) with 54 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
8282 MAX_ALLOWED_VALUETYPE = 64,
8383
8484 // Metadata - This is MDNode or MDString.
85 Metadata = 251,
85 Metadata = 250,
8686
8787 // iPTRAny - An int value the size of the pointer of the current
8888 // target to any address space. This must only be used internal to
8989 // tblgen. Other than for overloading, we treat iPTRAny the same as iPTR.
90 iPTRAny = 252,
90 iPTRAny = 251,
91
92 // vAny - A vector with any length and element size. This is used
93 // for intrinsics that have overloadings based on vector types.
94 // This is only for tblgen's consumption!
95 vAny = 252,
9196
9297 // fAny - Any floating-point or vector floating-point value. This is used
9398 // for intrinsics that have overloadings based on floating-point types.
9499 // This is only for tblgen's consumption!
95 fAny = 253,
100 fAny = 253,
96101
97102 // iAny - An integer or vector integer value of any bit width. This is
98103 // used for intrinsics that have overloadings based on integer bit widths.
99104 // This is only for tblgen's consumption!
100 iAny = 254,
105 iAny = 254,
101106
102107 // iPTR - An int value the size of the pointer of the current
103108 // target. This should only be used internal to tblgen!
104 iPTR = 255,
109 iPTR = 255,
105110
106111 // LastSimpleValueType - The greatest valid SimpleValueType value.
107112 LastSimpleValueType = 255
281286 return isSimple() ?
282287 (V==v8f32 || V==v4f64 || V==v32i8 || V==v16i16 || V==v8i32 ||
283288 V==v4i64) : isExtended256BitVector();
289 }
290
291 /// isOverloaded - Return true if this is an overloaded type for TableGen.
292 bool isOverloaded() const {
293 return (V==iAny || V==fAny || V==vAny || V==iPTRAny);
284294 }
285295
286296 /// isByteSized - Return true if the bit size is a multiple of 8.
395405 case iPTRAny:
396406 case iAny:
397407 case fAny:
408 case vAny:
398409 assert(0 && "Value type is overloaded.");
399410 default:
400411 return getExtendedSizeInBits();
5555 def v2f64 : ValueType<128, 32>; // 2 x f64 vector value
5656 def v4f64 : ValueType<256, 33>; // 4 x f64 vector value
5757
58 def MetadataVT: ValueType<0, 251>; // Metadata
58 def MetadataVT: ValueType<0, 250>; // Metadata
5959
6060 // Pseudo valuetype mapped to the current pointer size to any address space.
6161 // Should only be used in TableGen.
62 def iPTRAny : ValueType<0, 252>;
62 def iPTRAny : ValueType<0, 251>;
63
64 // Pseudo valuetype to represent "vector of any size"
65 def vAny : ValueType<0 , 252>;
6366
6467 // Pseudo valuetype to represent "float of any format"
6568 def fAny : ValueType<0 , 253>;
6262 /// declaration for an intrinsic, and return it.
6363 ///
6464 /// The Tys and numTys parameters are for intrinsics with overloaded types
65 /// (i.e., those using iAny or fAny). For a declaration for an overloaded
65 /// (e.g., those using iAny or fAny). For a declaration for an overloaded
6666 /// intrinsic, Tys should point to an array of numTys pointers to Type,
6767 /// and must provide exactly one type for each overloaded type in the
6868 /// intrinsic.
9393 def llvm_void_ty : LLVMType;
9494 def llvm_anyint_ty : LLVMType;
9595 def llvm_anyfloat_ty : LLVMType;
96 def llvm_anyvector_ty : LLVMType;
9697 def llvm_i1_ty : LLVMType;
9798 def llvm_i8_ty : LLVMType;
9899 def llvm_i16_ty : LLVMType;
15961596 Suffix += "v" + utostr(NumElts);
15971597
15981598 Suffix += EVT::getEVT(EltTy).getEVTString();
1599 } else if (VT == EVT::vAny) {
1600 if (!VTy) {
1601 CheckFailed(IntrinsicParam(ArgNo, NumRets) + " is not a vector type.", F);
1602 return false;
1603 }
1604 Suffix += ".v" + utostr(NumElts) + EVT::getEVT(EltTy).getEVTString();
15991605 } else if (VT == EVT::iPTR) {
16001606 if (!isa(Ty)) {
16011607 CheckFailed(IntrinsicParam(ArgNo, NumRets) + " is not a "
8686 /// isExtFloatingPointInVTs - Return true if the specified extended value type
8787 /// vector contains isFP or a FP value type.
8888 bool isExtFloatingPointInVTs(const std::vector &EVTs) {
89 assert(!EVTs.empty() && "Cannot check for integer in empty ExtVT list!");
89 assert(!EVTs.empty() && "Cannot check for FP in empty ExtVT list!");
9090 return EVTs[0] == isFP || !(FilterEVTs(EVTs, isFloatingPoint).empty());
91 }
92
93 /// isExtVectorInVTs - Return true if the specified extended value type
94 /// vector contains a vector value type.
95 bool isExtVectorInVTs(const std::vector &EVTs) {
96 assert(!EVTs.empty() && "Cannot check for vector in empty ExtVT list!");
97 return !(FilterEVTs(EVTs, isVector).empty());
9198 }
9299 } // end namespace EEVT.
93100 } // end namespace llvm.
494501 setTypes(FVTs);
495502 return true;
496503 }
504 if (ExtVTs[0] == EVT::vAny && EEVT::isExtVectorInVTs(getExtTypes())) {
505 assert(hasTypeSet() && "should be handled above!");
506 std::vector FVTs = FilterEVTs(getExtTypes(), isVector);
507 if (getExtTypes() == FVTs)
508 return false;
509 setTypes(FVTs);
510 return true;
511 }
497512
498513 // If we know this is an int or fp type, and we are told it is a specific one,
499514 // take the advice.
503518 if (((getExtTypeNum(0) == EEVT::isInt || getExtTypeNum(0) == EVT::iAny) &&
504519 EEVT::isExtIntegerInVTs(ExtVTs)) ||
505520 ((getExtTypeNum(0) == EEVT::isFP || getExtTypeNum(0) == EVT::fAny) &&
506 EEVT::isExtFloatingPointInVTs(ExtVTs))) {
521 EEVT::isExtFloatingPointInVTs(ExtVTs)) ||
522 (getExtTypeNum(0) == EVT::vAny &&
523 EEVT::isExtVectorInVTs(ExtVTs))) {
507524 setTypes(ExtVTs);
508525 return true;
509526 }
5555 case EVT::i128: return "EVT::i128";
5656 case EVT::iAny: return "EVT::iAny";
5757 case EVT::fAny: return "EVT::fAny";
58 case EVT::vAny: return "EVT::vAny";
5859 case EVT::f32: return "EVT::f32";
5960 case EVT::f64: return "EVT::f64";
6061 case EVT::f80: return "EVT::f80";
495496 } else {
496497 VT = getValueType(TyEl->getValueAsDef("VT"));
497498 }
498 if (VT == EVT::iAny || VT == EVT::fAny || VT == EVT::iPTRAny) {
499 if (EVT(VT).isOverloaded()) {
499500 OverloadedVTs.push_back(VT);
500501 isOverloaded |= true;
501502 }
525526 VT == EVT::iAny) && "Expected iAny type");
526527 } else
527528 VT = getValueType(TyEl->getValueAsDef("VT"));
528 if (VT == EVT::iAny || VT == EVT::fAny || VT == EVT::iPTRAny) {
529 if (EVT(VT).isOverloaded()) {
529530 OverloadedVTs.push_back(VT);
530531 isOverloaded |= true;
531532 }
202202 << "(dyn_cast(Tys[" << Number << "]))";
203203 else
204204 OS << "Tys[" << Number << "]";
205 } else if (VT == EVT::iAny || VT == EVT::fAny) {
205 } else if (VT == EVT::iAny || VT == EVT::fAny || VT == EVT::vAny) {
206206 // NOTE: The ArgNo variable here is not the absolute argument number, it is
207207 // the index of the "arbitrary" type in the Tys array passed to the
208208 // Intrinsic::getDeclaration function. Consequently, we only want to
328328 EVT::SimpleValueType VT = getValueType(ArgType->getValueAsDef("VT"));
329329 OS << getEnumName(VT);
330330
331 if (VT == EVT::iAny || VT == EVT::fAny || VT == EVT::iPTRAny)
331 if (EVT(VT).isOverloaded())
332332 OverloadedTypeIndices.push_back(j);
333333
334334 if (VT == EVT::isVoid && j != 0 && j != je - 1)
356356 EVT::SimpleValueType VT = getValueType(ArgType->getValueAsDef("VT"));
357357 OS << getEnumName(VT);
358358
359 if (VT == EVT::iAny || VT == EVT::fAny || VT == EVT::iPTRAny)
359 if (EVT(VT).isOverloaded())
360360 OverloadedTypeIndices.push_back(j + RetTys.size());
361361
362362 if (VT == EVT::isVoid && j != 0 && j != je - 1)