diff options
| author | Jim Laskey <jlaskey@mac.com> | 2007-02-07 20:38:26 +0000 |
|---|---|---|
| committer | Jim Laskey <jlaskey@mac.com> | 2007-02-07 20:38:26 +0000 |
| commit | 2682ea616f1f4079e21ad8dcffeee3b347217b21 (patch) | |
| tree | 4ce27a38474e1ee66a65d3f8a75df2b59773f349 /llvm/lib | |
| parent | 41f5c64ae1b767a257388c3b58bfcecb7f17be0a (diff) | |
| download | bcm5719-llvm-2682ea616f1f4079e21ad8dcffeee3b347217b21.tar.gz bcm5719-llvm-2682ea616f1f4079e21ad8dcffeee3b347217b21.zip | |
Automatically generating intrinsic declarations from Dan Gohman. Modified
to construct FunctionType in separate function, and, have getDeclaration
return a Function instead of a Constant.
llvm-svn: 34008
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/VMCore/Function.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Function.cpp b/llvm/lib/VMCore/Function.cpp index cc0cefad66b..72237eb4404 100644 --- a/llvm/lib/VMCore/Function.cpp +++ b/llvm/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) { |

