diff --git a/include/llvm/CodeGen/ValueTypes.h b/include/llvm/CodeGen/ValueTypes.h index 4ddacba3191..965043a1093 100644 --- a/include/llvm/CodeGen/ValueTypes.h +++ b/include/llvm/CodeGen/ValueTypes.h @@ -67,6 +67,11 @@ namespace MVT { // MVT = Machine Value Types LAST_VALUETYPE = 27, // This always remains at the end of the list. + // fAny - Any floating-point or vector floating-point value. This is used + // for intrinsics that have overloadings based on floating-point types. + // This is only for tblgen's consumption! + fAny = 253, + // iAny - An integer or vector integer value of any bit width. This is // used for intrinsics that have overloadings based on integer bit widths. // This is only for tblgen's consumption! diff --git a/include/llvm/CodeGen/ValueTypes.td b/include/llvm/CodeGen/ValueTypes.td index 47678d1de96..19ebf5df395 100644 --- a/include/llvm/CodeGen/ValueTypes.td +++ b/include/llvm/CodeGen/ValueTypes.td @@ -49,6 +49,9 @@ def v3f32 : ValueType<96 , 24>; // 3 x f32 vector value def v4f32 : ValueType<128, 25>; // 4 x f32 vector value def v2f64 : ValueType<128, 26>; // 2 x f64 vector value +// Pseudo valuetype to represent "float of any format" +def fAny : ValueType<0 , 253>; + // Pseudo valuetype to represent "integer of any bit width" def iAny : ValueType<0 , 254>; diff --git a/include/llvm/Intrinsics.td b/include/llvm/Intrinsics.td index 91f12841f4b..6f21a1c7bd0 100644 --- a/include/llvm/Intrinsics.td +++ b/include/llvm/Intrinsics.td @@ -68,6 +68,7 @@ class LLVMMatchType def llvm_void_ty : LLVMType; def llvm_anyint_ty : LLVMType; +def llvm_anyfloat_ty : LLVMType; def llvm_i1_ty : LLVMType; def llvm_i8_ty : LLVMType; def llvm_i16_ty : LLVMType; diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index c01f0fe9cc1..0c4ca642098 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -1157,6 +1157,20 @@ void Verifier::VerifyIntrinsicPrototype(Intrinsic::ID ID, CheckFailed("Intrinsic requires even byte width argument", F); break; } + } else if (VT == MVT::fAny) { + Suffix += "."; + if (EltTy != Ty) + Suffix += "v" + utostr(NumElts); + Suffix += MVT::getValueTypeString(MVT::getValueType(EltTy)); + if (!EltTy->isFloatingPoint()) { + if (ArgNo == 0) + CheckFailed("Intrinsic result type is not " + "a floating-point type.", F); + else + CheckFailed("Intrinsic parameter #" + utostr(ArgNo-1) + " is not " + "a floating-point type.", F); + break; + } } else if (VT == MVT::iPTR) { if (!isa(Ty)) { CheckFailed("Intrinsic parameter #" + utostr(ArgNo-1) + " is not a " diff --git a/utils/TableGen/CodeGenTarget.cpp b/utils/TableGen/CodeGenTarget.cpp index 78b850b43ca..1fee306e9f8 100644 --- a/utils/TableGen/CodeGenTarget.cpp +++ b/utils/TableGen/CodeGenTarget.cpp @@ -44,6 +44,7 @@ std::string llvm::getName(MVT::ValueType T) { case MVT::i64: return "MVT::i64"; case MVT::i128: return "MVT::i128"; case MVT::iAny: return "MVT::iAny"; + case MVT::fAny: return "MVT::fAny"; case MVT::f32: return "MVT::f32"; case MVT::f64: return "MVT::f64"; case MVT::f80: return "MVT::f80"; @@ -78,6 +79,7 @@ std::string llvm::getEnumName(MVT::ValueType T) { case MVT::i64: return "MVT::i64"; case MVT::i128: return "MVT::i128"; case MVT::iAny: return "MVT::iAny"; + case MVT::fAny: return "MVT::fAny"; case MVT::f32: return "MVT::f32"; case MVT::f64: return "MVT::f64"; case MVT::f80: return "MVT::f80"; @@ -652,7 +654,7 @@ CodeGenIntrinsic::CodeGenIntrinsic(Record *R, CodeGenTarget *CGT) { Record *TyEl = TypeList->getElementAsRecord(i); assert(TyEl->isSubClassOf("LLVMType") && "Expected a type!"); MVT::ValueType VT = getValueType(TyEl->getValueAsDef("VT")); - isOverloaded |= VT == MVT::iAny; + isOverloaded |= VT == MVT::iAny || VT == MVT::fAny; ArgVTs.push_back(VT); ArgTypeDefs.push_back(TyEl); } diff --git a/utils/TableGen/IntrinsicEmitter.cpp b/utils/TableGen/IntrinsicEmitter.cpp index f5df933f2ea..c3db273ce60 100644 --- a/utils/TableGen/IntrinsicEmitter.cpp +++ b/utils/TableGen/IntrinsicEmitter.cpp @@ -146,7 +146,7 @@ static void EmitTypeGenerate(std::ostream &OS, Record *ArgType, unsigned Number = ArgType->getValueAsInt("Number"); assert(Number < ArgNo && "Invalid matching number!"); OS << "Tys[" << Number << "]"; - } else if (VT == MVT::iAny) { + } else if (VT == MVT::iAny || VT == MVT::fAny) { // NOTE: The ArgNo variable here is not the absolute argument number, it is // the index of the "arbitrary" type in the Tys array passed to the // Intrinsic::getDeclaration function. Consequently, we only want to