aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2012-05-17 04:30:58 +0000
committerChris Lattner <sabre@nondot.org>2012-05-17 04:30:58 +0000
commit46aaf69e37287a9696b6cc5c49d10d0937ff052b (patch)
tree5946f3d7758b9803d973c48ab66073fda0face28 /lib/VMCore
parent15706cbf8520f7c372e1c2e441e3b5d18f24aafd (diff)
downloadexternal_llvm-46aaf69e37287a9696b6cc5c49d10d0937ff052b.zip
external_llvm-46aaf69e37287a9696b6cc5c49d10d0937ff052b.tar.gz
external_llvm-46aaf69e37287a9696b6cc5c49d10d0937ff052b.tar.bz2
strengthen the intrinsic descriptor stuff to be able to handle sin, cos and other
intrinsics that use passed-in arguments. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156977 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/Function.cpp31
1 files changed, 21 insertions, 10 deletions
diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp
index eb5ffb3..9aa7d0e 100644
--- a/lib/VMCore/Function.cpp
+++ b/lib/VMCore/Function.cpp
@@ -361,11 +361,13 @@ std::string Intrinsic::getName(ID id, ArrayRef<Type*> Tys) {
#include "llvm/Intrinsics.gen"
#undef GET_INTRINSTIC_GENERATOR_GLOBAL
-static Type *DecodeFixedType(unsigned &TableVal, LLVMContext &Context) {
+static Type *DecodeFixedType(unsigned &TableVal, ArrayRef<Type*> Tys,
+ LLVMContext &Context) {
unsigned Nibble = TableVal & 0xF;
TableVal >>= 4;
switch ((IIT_Info)Nibble) {
+ default: assert(0 && "Unknown argument type!");
case IIT_Done: return Type::getVoidTy(Context);
case IIT_I1: return Type::getInt1Ty(Context);
case IIT_I8: return Type::getInt8Ty(Context);
@@ -374,13 +376,23 @@ static Type *DecodeFixedType(unsigned &TableVal, LLVMContext &Context) {
case IIT_I64: return Type::getInt64Ty(Context);
case IIT_F32: return Type::getFloatTy(Context);
case IIT_F64: return Type::getDoubleTy(Context);
- case IIT_V2: return VectorType::get(DecodeFixedType(TableVal, Context), 2);
- case IIT_V4: return VectorType::get(DecodeFixedType(TableVal, Context), 4);
- case IIT_V8: return VectorType::get(DecodeFixedType(TableVal, Context), 8);
- case IIT_V16: return VectorType::get(DecodeFixedType(TableVal, Context), 16);
case IIT_MMX: return Type::getX86_MMXTy(Context);
- case IIT_PTR: return PointerType::get(DecodeFixedType(TableVal, Context),0);
- case IIT_ARG: assert(0 && "Unimp!");
+ case IIT_V2:
+ return VectorType::get(DecodeFixedType(TableVal, Tys, Context), 2);
+ case IIT_V4:
+ return VectorType::get(DecodeFixedType(TableVal, Tys, Context), 4);
+ case IIT_V8:
+ return VectorType::get(DecodeFixedType(TableVal, Tys, Context), 8);
+ case IIT_V16:
+ return VectorType::get(DecodeFixedType(TableVal, Tys, Context), 16);
+ case IIT_PTR:
+ return PointerType::getUnqual(DecodeFixedType(TableVal, Tys, Context));
+ case IIT_ARG: {
+ unsigned ArgNo = TableVal & 0xF;
+ TableVal >>= 4;
+ assert(ArgNo < Tys.size() && "Not enough types specified!");
+ return Tys[ArgNo];
+ }
}
llvm_unreachable("unhandled");
}
@@ -394,15 +406,14 @@ FunctionType *Intrinsic::getType(LLVMContext &Context,
// Check to see if the intrinsic's type was expressible by the table.
unsigned TableVal = IIT_Table[id-1];
if (TableVal != ~0U) {
- ResultTy = DecodeFixedType(TableVal, Context);
+ ResultTy = DecodeFixedType(TableVal, Tys, Context);
while (TableVal)
- ArgTys.push_back(DecodeFixedType(TableVal, Context));
+ ArgTys.push_back(DecodeFixedType(TableVal, Tys, Context));
return FunctionType::get(ResultTy, ArgTys, false);
}
-
#define GET_INTRINSIC_GENERATOR
#include "llvm/Intrinsics.gen"
#undef GET_INTRINSIC_GENERATOR