diff gen/tollvm.cpp @ 797:340acf1535d0

Removed KDevelop3 project files, CMake can generate them just fine! Fixed function literals in static initializers. Changed alignment of delegates from 2*PTRSIZE to just PTRSIZE. Changed errors to go to stderr instead of stdout. Fairly major rewriting of struct/union/class handling, STILL A BIT BUGGY !!!
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Sat, 29 Nov 2008 21:25:43 +0100
parents 661384d6a936
children 8e6135be6999
line wrap: on
line diff
--- a/gen/tollvm.cpp	Sat Nov 29 12:28:10 2008 +0100
+++ b/gen/tollvm.cpp	Sat Nov 29 21:25:43 2008 +0100
@@ -119,14 +119,14 @@
         TypeStruct* ts = (TypeStruct*)t;
         assert(ts->sym);
         DtoResolveDsymbol(ts->sym);
-        return ts->sym->ir.irStruct->recty.get(); // t->ir.type->get();
+        return ts->ir.type->get();
     }
 
     case Tclass:    {
         TypeClass* tc = (TypeClass*)t;
         assert(tc->sym);
         DtoResolveDsymbol(tc->sym);
-        return getPtrToType(tc->sym->ir.irStruct->recty.get()); // t->ir.type->get());
+        return getPtrToType(tc->ir.type->get());
     }
 
     // functions
@@ -584,6 +584,13 @@
     return gIR->ir->CreateBitCast(v, t, name ? name : "tmp");
 }
 
+LLConstant* DtoBitCast(LLConstant* v, const LLType* t)
+{
+    if (v->getType() == t)
+        return v;
+    return llvm::ConstantExpr::getBitCast(v, t);
+}
+
 //////////////////////////////////////////////////////////////////////////////////////////
 
 const LLPointerType* isaPointer(LLValue* v)
@@ -695,6 +702,33 @@
     return gTargetData->getPrefTypeAlignment(t);
 }
 
+const LLType* getBiggestType(const LLType** begin, size_t n)
+{
+    const LLType* bigTy = 0;
+    size_t bigSize = 0;
+    size_t bigAlign = 0;
+
+    const LLType** end = begin+n;
+    while (begin != end)
+    {
+        const LLType* T = *begin;
+
+        size_t sz = getABITypeSize(T);
+        size_t ali = getABITypeAlign(T);
+        if (sz > bigSize || (sz == bigSize && ali > bigAlign))
+        {
+            bigTy = T;
+            bigSize = sz;
+            bigAlign = ali;
+        }
+
+        ++begin;
+    }
+
+    // will be null for n==0
+    return bigTy;
+}
+
 //////////////////////////////////////////////////////////////////////////////////////////
 
 const LLStructType* DtoInterfaceInfoType()