summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-04-01 07:25:33 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-04-01 07:25:33 +0000
commit2a2117c82d10490d3324ba5b33a30c0331b56fff (patch)
tree2b063b82b5995414de9df035ab3d0ea28d2f1db7 /llvm/lib
parent7c57b88b2782a18ba9c4bf7975febd55de7d1e6f (diff)
downloadbcm5719-llvm-2a2117c82d10490d3324ba5b33a30c0331b56fff.tar.gz
bcm5719-llvm-2a2117c82d10490d3324ba5b33a30c0331b56fff.zip
For PR1297:
Implement "actual" argument types for the Intrinsic member functions. This involves changing the getName, getType, and getDeclaration methods to have optional parameters for the actual types. These are necessary in order for the type/name to be constructed properly for overloaded intrinsics. Only the caller knows the actual argument types desired. llvm-svn: 35541
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/VMCore/Function.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/llvm/lib/VMCore/Function.cpp b/llvm/lib/VMCore/Function.cpp
index 8aa0caa8549..4bf64ed9fbb 100644
--- a/llvm/lib/VMCore/Function.cpp
+++ b/llvm/lib/VMCore/Function.cpp
@@ -176,7 +176,7 @@ unsigned Function::getIntrinsicID() const {
return 0;
}
-const char *Intrinsic::getName(ID id) {
+std::string Intrinsic::getName(ID id, const Type **Tys, unsigned numTys) {
assert(id < num_intrinsics && "Invalid intrinsic ID!");
const char * const Table[] = {
"not_intrinsic",
@@ -184,10 +184,17 @@ const char *Intrinsic::getName(ID id) {
#include "llvm/Intrinsics.gen"
#undef GET_INTRINSIC_NAME_TABLE
};
- return Table[id];
+ if (numTys == 0)
+ return Table[id];
+ std::string Result(Table[id]);
+ for (unsigned i = 0; i < numTys; ++i)
+ if (Tys[i])
+ Result += "." + Tys[i]->getDescription();
+ return Result;
}
-const FunctionType *Intrinsic::getType(ID id) {
+const FunctionType *Intrinsic::getType(ID id, const Type **Tys,
+ uint32_t numTys) {
const Type *ResultTy = NULL;
std::vector<const Type*> ArgTys;
std::vector<FunctionType::ParameterAttributes> Attrs;
@@ -200,10 +207,12 @@ const FunctionType *Intrinsic::getType(ID id) {
return FunctionType::get(ResultTy, ArgTys, IsVarArg, Attrs);
}
-Function *Intrinsic::getDeclaration(Module *M, ID id) {
+Function *Intrinsic::getDeclaration(Module *M, ID id, const Type **Tys,
+ unsigned numTys) {
// There can never be multiple globals with the same name of different types,
// because intrinsics must be a specific type.
- return cast<Function>(M->getOrInsertFunction(getName(id), getType(id)));
+ return cast<Function>(M->getOrInsertFunction(getName(id, Tys, numTys),
+ getType(id, Tys, numTys)));
}
Value *IntrinsicInst::StripPointerCasts(Value *Ptr) {
OpenPOWER on IntegriCloud