diff gen/tollvm.cpp @ 715:30b42a283c8e

Removed TypeOpaque from DMD. Changed runtime functions taking opaque[] to void[]. Implemented proper type painting, to avoid "resizing" array casts in runtime calls that previously took opaque[]. Implemented dynamic arrays as first class types, this implements proper ABI for these types on x86. Added dwarf region end after call to assert function, fixes some problems with llvm not allowing this to be missing. Reverted change to WithStatement from rev [704] it breaks MiniD, mini/with2.d needs to be fixed some other way... Fixed tango bug 1339 in runtime, problem with _adReverseChar on invalid UTF-8. Disabled .bc generation in the compiler runtime part, genobj.d triggers some llvm bug when using debug info. the .o seems to work fine.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Wed, 22 Oct 2008 14:55:33 +0200
parents 5a2983f97498
children 7261ff0f95ff
line wrap: on
line diff
--- a/gen/tollvm.cpp	Wed Oct 22 13:48:54 2008 +0200
+++ b/gen/tollvm.cpp	Wed Oct 22 14:55:33 2008 +0200
@@ -25,14 +25,14 @@
 {
     Type* typ = type->toBasetype();
     TY t = typ->ty;
-    return (t == Tstruct || t == Tarray || t == Tdelegate || t == Tsarray);
+    return (t == Tstruct || t == Tdelegate || t == Tsarray);
 }
 
 bool DtoIsReturnedInArg(Type* type)
 {
     Type* typ = type->toBasetype();
     TY t = typ->ty;
-    return (t == Tstruct || t == Tarray || t == Tdelegate || t == Tsarray);
+    return (t == Tstruct || t == Tdelegate || t == Tsarray);
 }
 
 unsigned DtoShouldExtend(Type* type)
@@ -179,9 +179,6 @@
         return DtoStructTypeFromArguments(ttupl->arguments);
     }
 */
-    // opaque type
-    case Topaque:
-        return llvm::OpaqueType::get();
 
     default:
         printf("trying to convert unknown type '%s' with value %d\n", t->toChars(), t->ty);
@@ -560,6 +557,8 @@
 
 LLValue* DtoLoad(LLValue* src, const char* name)
 {
+    if (Logger::enabled())
+        Logger::cout() << "loading " << *src <<  '\n';
     LLValue* ld = gIR->ir->CreateLoad(src, name ? name : "tmp");
     //ld->setVolatile(gIR->func()->inVolatile);
     return ld;
@@ -567,6 +566,8 @@
 
 void DtoStore(LLValue* src, LLValue* dst)
 {
+    if (Logger::enabled())
+        Logger::cout() << "storing " << *src << " into " << *dst << '\n';
     LLValue* st = gIR->ir->CreateStore(src,dst);
     //st->setVolatile(gIR->func()->inVolatile);
 }
@@ -577,6 +578,7 @@
 {
     if (v->getType() == t)
         return v;
+    assert(!(isaStruct(t) || isaStruct(v->getType())));
     return gIR->ir->CreateBitCast(v, t, name ? name : "tmp");
 }
 
@@ -806,3 +808,25 @@
     res = gIR->ir->CreateInsertValue(res, V1, 0, "tmp");
     return gIR->ir->CreateInsertValue(res, V2, 1, name?name:"tmp");
 }
+
+LLValue* DtoAggrPair(LLValue* V1, LLValue* V2, const char* name)
+{
+    const LLType* t = LLStructType::get(V1->getType(), V2->getType(), 0);
+    return DtoAggrPair(t, V1, V2, name);
+}
+
+LLValue* DtoAggrPaint(LLValue* aggr, const LLType* as)
+{
+    if (aggr->getType() == as)
+        return aggr;
+
+    LLValue* res = llvm::UndefValue::get(as);
+
+    LLValue* V = gIR->ir->CreateExtractValue(aggr, 0, "tmp");;
+    V = DtoBitCast(V, as->getContainedType(0));
+    res = gIR->ir->CreateInsertValue(res, V, 0, "tmp");
+
+    V = gIR->ir->CreateExtractValue(aggr, 1, "tmp");;
+    V = DtoBitCast(V, as->getContainedType(1));
+    return gIR->ir->CreateInsertValue(res, V, 1, "tmp");
+}