Mercurial > projects > ldc
comparison gen/tollvm.cpp @ 1480:b3ba2c6ff038
Use `llvm.memset` instead of `_d_array_init_i1` and `_d_array_init_i8`.
This exposes what's happening to LLVM, and memset is probably faster than the
runtime functions we were using anyway.
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Sun, 07 Jun 2009 13:57:59 +0200 |
parents | 83bdf7bed9c5 |
children | d9c5f5a43403 |
comparison
equal
deleted
inserted
replaced
1479:4f7d50c744ed | 1480:b3ba2c6ff038 |
---|---|
409 return llvm::ConstantExpr::getGetElementPtr(ptr, v, 2); | 409 return llvm::ConstantExpr::getGetElementPtr(ptr, v, 2); |
410 } | 410 } |
411 | 411 |
412 ////////////////////////////////////////////////////////////////////////////////////////// | 412 ////////////////////////////////////////////////////////////////////////////////////////// |
413 | 413 |
414 void DtoMemSetZero(LLValue* dst, LLValue* nbytes) | 414 void DtoMemSet(LLValue* dst, LLValue* val, LLValue* nbytes) |
415 { | 415 { |
416 dst = DtoBitCast(dst,getVoidPtrType()); | 416 dst = DtoBitCast(dst,getVoidPtrType()); |
417 | 417 |
418 const LLType* intTy = DtoSize_t(); | 418 const LLType* intTy = DtoSize_t(); |
419 llvm::Function* fn = llvm::Intrinsic::getDeclaration(gIR->module, | 419 llvm::Function* fn = llvm::Intrinsic::getDeclaration(gIR->module, |
420 llvm::Intrinsic::memset, &intTy, 1); | 420 llvm::Intrinsic::memset, &intTy, 1); |
421 | 421 |
422 gIR->ir->CreateCall4(fn, dst, DtoConstUbyte(0), nbytes, DtoConstUint(0), ""); | 422 gIR->ir->CreateCall4(fn, dst, val, nbytes, DtoConstUint(0), ""); |
423 } | |
424 | |
425 ////////////////////////////////////////////////////////////////////////////////////////// | |
426 | |
427 void DtoMemSetZero(LLValue* dst, LLValue* nbytes) | |
428 { | |
429 DtoMemSet(dst, DtoConstUbyte(0), nbytes); | |
423 } | 430 } |
424 | 431 |
425 ////////////////////////////////////////////////////////////////////////////////////////// | 432 ////////////////////////////////////////////////////////////////////////////////////////// |
426 | 433 |
427 void DtoMemCpy(LLValue* dst, LLValue* src, LLValue* nbytes, unsigned align) | 434 void DtoMemCpy(LLValue* dst, LLValue* src, LLValue* nbytes, unsigned align) |