[llvm-commits] CVS: llvm/lib/VMCore/Function.cpp IntrinsicLowering.cpp Verifier.cpp
Chris Lattner
lattner at cs.uiuc.edu
Fri Feb 13 20:48:11 PST 2004
Changes in directory llvm/lib/VMCore:
Function.cpp updated: 1.64 -> 1.65
IntrinsicLowering.cpp updated: 1.7 -> 1.8
Verifier.cpp updated: 1.80 -> 1.81
---
Log message:
Add llvm.memset/frameaddress/returnaddress intrinsics.
---
Diffs of the changes: (+43 -9)
Index: llvm/lib/VMCore/Function.cpp
diff -u llvm/lib/VMCore/Function.cpp:1.64 llvm/lib/VMCore/Function.cpp:1.65
--- llvm/lib/VMCore/Function.cpp:1.64 Thu Feb 12 12:11:20 2004
+++ llvm/lib/VMCore/Function.cpp Fri Feb 13 20:47:16 2004
@@ -214,12 +214,19 @@
if (getName() == "llvm.dbg.func.start") return Intrinsic::dbg_func_start;
if (getName() == "llvm.dbg.declare") return Intrinsic::dbg_declare;
break;
+ case 'f':
+ if (getName() == "llvm.frameaddress") return Intrinsic::frameaddress;
+ break;
case 'l':
if (getName() == "llvm.longjmp") return Intrinsic::longjmp;
break;
case 'm':
if (getName() == "llvm.memcpy") return Intrinsic::memcpy;
if (getName() == "llvm.memmove") return Intrinsic::memmove;
+ if (getName() == "llvm.memset") return Intrinsic::memset;
+ break;
+ case 'r':
+ if (getName() == "llvm.returnaddress") return Intrinsic::returnaddress;
break;
case 's':
if (getName() == "llvm.setjmp") return Intrinsic::setjmp;
Index: llvm/lib/VMCore/IntrinsicLowering.cpp
diff -u llvm/lib/VMCore/IntrinsicLowering.cpp:1.7 llvm/lib/VMCore/IntrinsicLowering.cpp:1.8
--- llvm/lib/VMCore/IntrinsicLowering.cpp:1.7 Thu Feb 12 12:11:20 2004
+++ llvm/lib/VMCore/IntrinsicLowering.cpp Fri Feb 13 20:47:17 2004
@@ -12,7 +12,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/IntrinsicLowering.h"
-#include "llvm/Constant.h"
+#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Module.h"
#include "llvm/iOther.h"
@@ -49,6 +49,12 @@
new CallInst(M->getOrInsertFunction("abort", Type::VoidTy, 0), "", CI);
break;
+ case Intrinsic::returnaddress:
+ case Intrinsic::frameaddress:
+ CI->replaceAllUsesWith(ConstantPointerNull::get(
+ cast<PointerType>(CI->getType())));
+ break;
+
case Intrinsic::dbg_stoppoint:
case Intrinsic::dbg_region_start:
case Intrinsic::dbg_region_end:
@@ -72,7 +78,7 @@
break;
}
case Intrinsic::memmove: {
- // The memmove intrinsic take an extra alignment argument that the memcpy
+ // The memmove intrinsic take an extra alignment argument that the memmove
// libc function does not.
const FunctionType *CFT = Callee->getFunctionType();
FunctionType *FT =
@@ -81,6 +87,19 @@
false);
Function *MemMove = M->getOrInsertFunction("memmove", FT);
new CallInst(MemMove, std::vector<Value*>(CI->op_begin()+1, CI->op_end()-1),
+ CI->getName(), CI);
+ break;
+ }
+ case Intrinsic::memset: {
+ // The memset intrinsic take an extra alignment argument that the memset
+ // libc function does not.
+ const FunctionType *CFT = Callee->getFunctionType();
+ FunctionType *FT =
+ FunctionType::get(*CFT->param_begin(),
+ std::vector<const Type*>(CFT->param_begin(), CFT->param_end()-1),
+ false);
+ Function *MemSet = M->getOrInsertFunction("memset", FT);
+ new CallInst(MemSet, std::vector<Value*>(CI->op_begin()+1, CI->op_end()-1),
CI->getName(), CI);
break;
}
Index: llvm/lib/VMCore/Verifier.cpp
diff -u llvm/lib/VMCore/Verifier.cpp:1.80 llvm/lib/VMCore/Verifier.cpp:1.81
--- llvm/lib/VMCore/Verifier.cpp:1.80 Thu Feb 12 12:11:20 2004
+++ llvm/lib/VMCore/Verifier.cpp Fri Feb 13 20:47:17 2004
@@ -41,17 +41,14 @@
#include "llvm/Analysis/Verifier.h"
#include "llvm/Assembly/Writer.h"
+#include "llvm/Constants.h"
#include "llvm/Pass.h"
#include "llvm/Module.h"
#include "llvm/DerivedTypes.h"
-#include "llvm/iPHINode.h"
-#include "llvm/iTerminators.h"
-#include "llvm/iOther.h"
-#include "llvm/iOperators.h"
-#include "llvm/iMemory.h"
-#include "llvm/SymbolTable.h"
-#include "llvm/PassManager.h"
+#include "llvm/Instructions.h"
#include "llvm/Intrinsics.h"
+#include "llvm/PassManager.h"
+#include "llvm/SymbolTable.h"
#include "llvm/Analysis/Dominators.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/InstVisitor.h"
@@ -551,6 +548,16 @@
case Intrinsic::va_end: NumArgs = 1; break;
case Intrinsic::va_copy: NumArgs = 1; break;
+ case Intrinsic::returnaddress:
+ case Intrinsic::frameaddress:
+ Assert1(isa<PointerType>(FT->getReturnType()),
+ "llvm.(frame|return)address must return pointers", IF);
+ Assert1(FT->getNumParams() == 1 && isa<ConstantInt>(CI.getOperand(1)),
+ "llvm.(frame|return)address require a single constant integer argument",
+ &CI);
+ NumArgs = 1;
+ break;
+
case Intrinsic::setjmp: NumArgs = 1; break;
case Intrinsic::longjmp: NumArgs = 2; break;
case Intrinsic::sigsetjmp: NumArgs = 2; break;
@@ -564,6 +571,7 @@
case Intrinsic::memcpy: NumArgs = 4; break;
case Intrinsic::memmove: NumArgs = 4; break;
+ case Intrinsic::memset: NumArgs = 4; break;
case Intrinsic::alpha_ctlz: NumArgs = 1; break;
case Intrinsic::alpha_cttz: NumArgs = 1; break;
More information about the llvm-commits
mailing list