[LLVMdev] Re: Re: New GCC4-based C/C++/ObjC front-end for LLVM
Chris Lattner
sabre at nondot.org
Thu Mar 2 16:36:10 PST 2006
On Thu, 2 Mar 2006, Chris Lattner wrote:
>> Any ideas what could be wrong?
>
> Sorry for the delay, please try this tarball:
> http://nondot.org/sabre/2006-03-02-llvm-gcc-4.tar.gz
Actually, do to a recent change in CVS, this tarball will probably not
work anymore. Please apply the attached (small) patch on top of it in
the gcc directory.
Worth noting, this front-end only works with LLVM mainline, not LLVM 1.6.
-Chris
--
http://nondot.org/sabre/
http://llvm.org/
-------------- next part --------------
Index: llvm-convert.cpp
===================================================================
--- llvm-convert.cpp (revision 111673)
+++ llvm-convert.cpp (working copy)
@@ -795,14 +795,18 @@ void TreeToLLVM::EmitMemCpy(Value *DestP
unsigned Align) {
const Type *SBP = PointerType::get(Type::SByteTy);
static Function *MemCpy = 0;
- if (!MemCpy)
- MemCpy = TheModule->getOrInsertFunction("llvm.memcpy", Type::VoidTy, SBP,
- SBP, Type::UIntTy, Type::UIntTy,
+ const Type *IntPtr = TD.getIntPtrType();
+ if (!MemCpy) {
+ const char *Name = IntPtr == Type::UIntTy ?
+ "llvm.memcpy.i32" : "llvm.memcpy.i64";
+ MemCpy = TheModule->getOrInsertFunction(Name, Type::VoidTy, SBP,
+ SBP, IntPtr, Type::UIntTy,
NULL);
+ }
std::vector<Value*> Ops;
Ops.push_back(CastToType(DestPtr, SBP));
Ops.push_back(CastToType(SrcPtr, SBP));
- Ops.push_back(CastToType(Size, Type::UIntTy));
+ Ops.push_back(CastToType(Size, IntPtr));
Ops.push_back(ConstantUInt::get(Type::UIntTy, Align));
new CallInst(MemCpy, Ops, "", CurBB);
}
@@ -811,14 +815,17 @@ void TreeToLLVM::EmitMemMove(Value *Dest
unsigned Align) {
const Type *SBP = PointerType::get(Type::SByteTy);
static Function *MemMove = 0;
- if (!MemMove)
- MemMove = TheModule->getOrInsertFunction("llvm.memmove", Type::VoidTy, SBP,
- SBP, Type::UIntTy, Type::UIntTy,
- NULL);
+ const Type *IntPtr = TD.getIntPtrType();
+ if (!MemMove) {
+ const char *Name = IntPtr == Type::UIntTy ?
+ "llvm.memmove.i32" : "llvm.memmove.i64";
+ MemMove = TheModule->getOrInsertFunction(Name, Type::VoidTy, SBP, SBP,
+ IntPtr, Type::UIntTy, NULL);
+ }
std::vector<Value*> Ops;
Ops.push_back(CastToType(DestPtr, SBP));
Ops.push_back(CastToType(SrcPtr, SBP));
- Ops.push_back(CastToType(Size, Type::UIntTy));
+ Ops.push_back(CastToType(Size, IntPtr));
Ops.push_back(ConstantUInt::get(Type::UIntTy, Align));
new CallInst(MemMove, Ops, "", CurBB);
}
@@ -827,14 +834,18 @@ void TreeToLLVM::EmitMemSet(Value *DestP
unsigned Align) {
const Type *SBP = PointerType::get(Type::SByteTy);
static Function *MemSet = 0;
- if (!MemSet)
- MemSet = TheModule->getOrInsertFunction("llvm.memset", Type::VoidTy, SBP,
- Type::UByteTy, Type::UIntTy,
+ const Type *IntPtr = TD.getIntPtrType();
+ if (!MemSet) {
+ const char *Name = IntPtr == Type::UIntTy ?
+ "llvm.memset.i32" : "llvm.memset.i64";
+ MemSet = TheModule->getOrInsertFunction(Name, Type::VoidTy, SBP,
+ Type::UByteTy, IntPtr,
Type::UIntTy, NULL);
+ }
std::vector<Value*> Ops;
Ops.push_back(CastToType(DestPtr, SBP));
Ops.push_back(CastToType(SrcVal, Type::UByteTy));
- Ops.push_back(CastToType(Size, Type::UIntTy));
+ Ops.push_back(CastToType(Size, IntPtr));
Ops.push_back(ConstantUInt::get(Type::UIntTy, Align));
new CallInst(MemSet, Ops, "", CurBB);
}
More information about the llvm-dev
mailing list