Add MVT::fAny for overloading intrinsics on floating-point types.

llvm-svn: 41128
This commit is contained in:
Dan Gohman 2007-08-16 21:57:19 +00:00
parent cdee44c12a
commit febf946ea7
6 changed files with 27 additions and 2 deletions

View File

@ -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!

View File

@ -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>;

View File

@ -68,6 +68,7 @@ class LLVMMatchType<int num>
def llvm_void_ty : LLVMType<isVoid>;
def llvm_anyint_ty : LLVMType<iAny>;
def llvm_anyfloat_ty : LLVMType<fAny>;
def llvm_i1_ty : LLVMType<i1>;
def llvm_i8_ty : LLVMType<i8>;
def llvm_i16_ty : LLVMType<i16>;

View File

@ -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<PointerType>(Ty)) {
CheckFailed("Intrinsic parameter #" + utostr(ArgNo-1) + " is not a "

View File

@ -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);
}

View File

@ -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