Mercurial > projects > ldc
comparison gen/tollvm.cpp @ 945:03d7c4aac654
SWITCHED TO LLVM 2.5 !
Applied patch from ticket #129 to compile against latest LLVM. Thanks Frits van Bommel.
Fixed implicit return by asm block at the end of a function on x86-32. Other architectures will produce an error at the moment. Adding support for new targets is fairly simple.
Fixed return calling convention for complex numbers, ST and ST(1) were switched around.
Added some testcases.
I've run a dstress test and there are no regressions. However, the runtime does not seem to compile with symbolic debug information. -O3 -release -inline works well and is what I used for the dstress run. Tango does not compile, a small workaround is needed in tango.io.digest.Digest.Digest.hexDigest. See ticket #206 .
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Sun, 08 Feb 2009 05:26:54 +0100 |
parents | 39519a1ff603 |
children | 2667e3a145be |
comparison
equal
deleted
inserted
replaced
944:eb310635d80e | 945:03d7c4aac654 |
---|---|
417 | 417 |
418 void DtoMemSetZero(LLValue* dst, LLValue* nbytes) | 418 void DtoMemSetZero(LLValue* dst, LLValue* nbytes) |
419 { | 419 { |
420 dst = DtoBitCast(dst,getVoidPtrType()); | 420 dst = DtoBitCast(dst,getVoidPtrType()); |
421 | 421 |
422 llvm::Function* fn; | 422 const LLType* intTy = DtoSize_t(); |
423 if (global.params.is64bit) | 423 llvm::Function* fn = llvm::Intrinsic::getDeclaration(gIR->module, |
424 fn = GET_INTRINSIC_DECL(memset_i64); | 424 llvm::Intrinsic::memset, &intTy, 1); |
425 else | |
426 fn = GET_INTRINSIC_DECL(memset_i32); | |
427 | 425 |
428 gIR->ir->CreateCall4(fn, dst, DtoConstUbyte(0), nbytes, DtoConstUint(0), ""); | 426 gIR->ir->CreateCall4(fn, dst, DtoConstUbyte(0), nbytes, DtoConstUint(0), ""); |
429 } | 427 } |
430 | 428 |
431 ////////////////////////////////////////////////////////////////////////////////////////// | 429 ////////////////////////////////////////////////////////////////////////////////////////// |
433 void DtoMemCpy(LLValue* dst, LLValue* src, LLValue* nbytes) | 431 void DtoMemCpy(LLValue* dst, LLValue* src, LLValue* nbytes) |
434 { | 432 { |
435 dst = DtoBitCast(dst,getVoidPtrType()); | 433 dst = DtoBitCast(dst,getVoidPtrType()); |
436 src = DtoBitCast(src,getVoidPtrType()); | 434 src = DtoBitCast(src,getVoidPtrType()); |
437 | 435 |
438 llvm::Function* fn; | 436 const LLType* intTy = DtoSize_t(); |
439 if (global.params.is64bit) | 437 llvm::Function* fn = llvm::Intrinsic::getDeclaration(gIR->module, |
440 fn = GET_INTRINSIC_DECL(memcpy_i64); | 438 llvm::Intrinsic::memcpy, &intTy, 1); |
441 else | |
442 fn = GET_INTRINSIC_DECL(memcpy_i32); | |
443 | 439 |
444 gIR->ir->CreateCall4(fn, dst, src, nbytes, DtoConstUint(0), ""); | 440 gIR->ir->CreateCall4(fn, dst, src, nbytes, DtoConstUint(0), ""); |
445 } | 441 } |
446 | 442 |
447 ////////////////////////////////////////////////////////////////////////////////////////// | 443 ////////////////////////////////////////////////////////////////////////////////////////// |
698 size_t getTypeStoreSize(const LLType* t) | 694 size_t getTypeStoreSize(const LLType* t) |
699 { | 695 { |
700 return gTargetData->getTypeStoreSize(t); | 696 return gTargetData->getTypeStoreSize(t); |
701 } | 697 } |
702 | 698 |
703 size_t getABITypeSize(const LLType* t) | 699 size_t getTypePaddedSize(const LLType* t) |
704 { | 700 { |
705 size_t sz = gTargetData->getABITypeSize(t); | 701 size_t sz = gTargetData->getTypePaddedSize(t); |
706 //Logger::cout() << "abi type size of: " << *t << " == " << sz << '\n'; | 702 //Logger::cout() << "abi type size of: " << *t << " == " << sz << '\n'; |
707 return sz; | 703 return sz; |
708 } | 704 } |
709 | 705 |
710 unsigned char getABITypeAlign(const LLType* t) | 706 unsigned char getABITypeAlign(const LLType* t) |
726 const LLType** end = begin+n; | 722 const LLType** end = begin+n; |
727 while (begin != end) | 723 while (begin != end) |
728 { | 724 { |
729 const LLType* T = *begin; | 725 const LLType* T = *begin; |
730 | 726 |
731 size_t sz = getABITypeSize(T); | 727 size_t sz = getTypePaddedSize(T); |
732 size_t ali = getABITypeAlign(T); | 728 size_t ali = getABITypeAlign(T); |
733 if (sz > bigSize || (sz == bigSize && ali > bigAlign)) | 729 if (sz > bigSize || (sz == bigSize && ali > bigAlign)) |
734 { | 730 { |
735 bigTy = T; | 731 bigTy = T; |
736 bigSize = sz; | 732 bigSize = sz; |
879 | 875 |
880 V = gIR->ir->CreateExtractValue(aggr, 1, "tmp");; | 876 V = gIR->ir->CreateExtractValue(aggr, 1, "tmp");; |
881 V = DtoBitCast(V, as->getContainedType(1)); | 877 V = DtoBitCast(V, as->getContainedType(1)); |
882 return gIR->ir->CreateInsertValue(res, V, 1, "tmp"); | 878 return gIR->ir->CreateInsertValue(res, V, 1, "tmp"); |
883 } | 879 } |
880 | |
881 LLValue* DtoAggrPairSwap(LLValue* aggr) | |
882 { | |
883 Logger::println("swapping aggr pair"); | |
884 LLValue* r = gIR->ir->CreateExtractValue(aggr, 0); | |
885 LLValue* i = gIR->ir->CreateExtractValue(aggr, 1); | |
886 return DtoAggrPair(i, r, "swapped"); | |
887 } |