summaryrefslogtreecommitdiff
path: root/lib/VMCore/Function.cpp
diff options
context:
space:
mode:
authorJim Laskey <jlaskey@mac.com>2007-02-07 20:38:26 +0000
committerJim Laskey <jlaskey@mac.com>2007-02-07 20:38:26 +0000
commit95af592a631f403e1458ec1155f89fc31011572c (patch)
treea94263cf593b27cab111ee994ccd56c3e0b4fb94 /lib/VMCore/Function.cpp
parent0d3382ac921c27a702dcd5c14a74d6313334f62e (diff)
downloadllvm-95af592a631f403e1458ec1155f89fc31011572c.tar.gz
llvm-95af592a631f403e1458ec1155f89fc31011572c.tar.bz2
llvm-95af592a631f403e1458ec1155f89fc31011572c.tar.xz
Automatically generating intrinsic declarations from Dan Gohman. Modified
to construct FunctionType in separate function, and, have getDeclaration return a Function instead of a Constant. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34008 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Function.cpp')
-rw-r--r--lib/VMCore/Function.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp
index cc0cefad66..72237eb440 100644
--- a/lib/VMCore/Function.cpp
+++ b/lib/VMCore/Function.cpp
@@ -183,6 +183,25 @@ const char *Intrinsic::getName(ID id) {
return Table[id];
}
+const FunctionType *Intrinsic::getType(ID id) {
+ const Type *ResultTy = NULL;
+ std::vector<const Type*> ArgTys;
+ std::vector<FunctionType::ParameterAttributes> Attrs;
+ bool IsVarArg = false;
+
+#define GET_INTRINSIC_GENERATOR
+#include "llvm/Intrinsics.gen"
+#undef GET_INTRINSIC_GENERATOR
+
+ return FunctionType::get(ResultTy, ArgTys, IsVarArg, Attrs);
+}
+
+Function *Intrinsic::getDeclaration(Module *M, ID id) {
+// 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)));
+}
+
Value *IntrinsicInst::StripPointerCasts(Value *Ptr) {
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(Ptr)) {
if (CE->getOpcode() == Instruction::BitCast) {