Mercurial > projects > ldc
diff gen/tollvm.c @ 58:2c3cd3596187 trunk
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
Added initial support for CatExp aka 'a ~ b'
Fixed global constant static arrays initialized with string literals
Fixed casting any dynamic array to void*
Fixed new expression with temporary storage
Fixed alias declarations in function scope
Fixed relational comparisons of pointers
author | lindquist |
---|---|
date | Thu, 25 Oct 2007 09:02:55 +0200 |
parents | a9d29e9f1fed |
children | b86e00b938a5 |
line wrap: on
line diff
--- a/gen/tollvm.c Thu Oct 25 02:39:53 2007 +0200 +++ b/gen/tollvm.c Thu Oct 25 09:02:55 2007 +0200 @@ -1382,3 +1382,33 @@ llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2) ); } + +////////////////////////////////////////////////////////////////////////////////////////// + +void LLVM_DtoMemCpy(llvm::Value* dst, llvm::Value* src, llvm::Value* nbytes) +{ + assert(dst->getType() == src->getType()); + + llvm::Type* arrty = llvm::PointerType::get(llvm::Type::Int8Ty); + llvm::Value *dstarr, *srcarr; + if (dst->getType() == arrty) + { + dstarr = dst; + srcarr = src; + } + else + { + dstarr = new llvm::BitCastInst(dst,arrty,"tmp",gIR->scopebb()); + srcarr = new llvm::BitCastInst(src,arrty,"tmp",gIR->scopebb()); + } + + llvm::Function* fn = (global.params.is64bit) ? LLVM_DeclareMemCpy64() : LLVM_DeclareMemCpy32(); + std::vector<llvm::Value*> llargs; + llargs.resize(4); + llargs[0] = dstarr; + llargs[1] = srcarr; + llargs[2] = nbytes; + llargs[3] = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false); + + new llvm::CallInst(fn, llargs.begin(), llargs.end(), "", gIR->scopebb()); +}