diff 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
line wrap: on
line diff
--- a/gen/tollvm.cpp	Sun Feb 08 05:14:24 2009 +0100
+++ b/gen/tollvm.cpp	Sun Feb 08 05:26:54 2009 +0100
@@ -419,11 +419,9 @@
 {
     dst = DtoBitCast(dst,getVoidPtrType());
 
-    llvm::Function* fn;
-    if (global.params.is64bit)
-        fn = GET_INTRINSIC_DECL(memset_i64);
-    else
-        fn = GET_INTRINSIC_DECL(memset_i32);
+    const LLType* intTy = DtoSize_t();
+    llvm::Function* fn = llvm::Intrinsic::getDeclaration(gIR->module,
+        llvm::Intrinsic::memset, &intTy, 1);
 
     gIR->ir->CreateCall4(fn, dst, DtoConstUbyte(0), nbytes, DtoConstUint(0), "");
 }
@@ -435,11 +433,9 @@
     dst = DtoBitCast(dst,getVoidPtrType());
     src = DtoBitCast(src,getVoidPtrType());
 
-    llvm::Function* fn;
-    if (global.params.is64bit)
-        fn = GET_INTRINSIC_DECL(memcpy_i64);
-    else
-        fn = GET_INTRINSIC_DECL(memcpy_i32);
+    const LLType* intTy = DtoSize_t();
+    llvm::Function* fn = llvm::Intrinsic::getDeclaration(gIR->module,
+        llvm::Intrinsic::memcpy, &intTy, 1);
 
     gIR->ir->CreateCall4(fn, dst, src, nbytes, DtoConstUint(0), "");
 }
@@ -700,9 +696,9 @@
     return gTargetData->getTypeStoreSize(t);
 }
 
-size_t getABITypeSize(const LLType* t)
+size_t getTypePaddedSize(const LLType* t)
 {
-    size_t sz = gTargetData->getABITypeSize(t);
+    size_t sz = gTargetData->getTypePaddedSize(t);
     //Logger::cout() << "abi type size of: " << *t << " == " << sz << '\n';
     return sz;
 }
@@ -728,7 +724,7 @@
     {
         const LLType* T = *begin;
 
-        size_t sz = getABITypeSize(T);
+        size_t sz = getTypePaddedSize(T);
         size_t ali = getABITypeAlign(T);
         if (sz > bigSize || (sz == bigSize && ali > bigAlign))
         {
@@ -881,3 +877,11 @@
     V = DtoBitCast(V, as->getContainedType(1));
     return gIR->ir->CreateInsertValue(res, V, 1, "tmp");
 }
+
+LLValue* DtoAggrPairSwap(LLValue* aggr)
+{
+    Logger::println("swapping aggr pair");
+    LLValue* r = gIR->ir->CreateExtractValue(aggr, 0);
+    LLValue* i = gIR->ir->CreateExtractValue(aggr, 1);
+    return DtoAggrPair(i, r, "swapped");
+}