diff gen/typinf.cpp @ 275:665b81613475 trunk

[svn r296] Removed: the 'suite' dir, it never took off! Fixed: foreach statement, key-type checks were buggy. Fixed: setting LLVMDC versions on the command line is now an error. Fixed: array compare runtime had incorrect param attrs on call. Fixed: index expressions on dynamic array slices w/o storage was broken. Fixed: scope classes had incorrect finalization in some cases. Fixed: when outputting !ClassInfoS !OffsetTypeInfoS, static class members were trying to be included, crashing the compiler. Fixed: calling LLVMDC with -inline but not any -O option caused assertion failure. Changed: the runtime now uses a single interface to "get" to !TypeInfoS, part of eliminating duplicate !TypeInfo codegen.
author lindquist
date Thu, 19 Jun 2008 17:30:32 +0200
parents a95056b3c996
children ebaf65fc4726
line wrap: on
line diff
--- a/gen/typinf.cpp	Thu Jun 19 13:54:31 2008 +0200
+++ b/gen/typinf.cpp	Thu Jun 19 17:30:32 2008 +0200
@@ -383,19 +383,8 @@
     TypedefDeclaration *sd = tc->sym;
 
     // TypeInfo base
-    //const LLPointerType* basept = isaPointer(initZ->getOperand(1)->getType());
-    //sinits.push_back(llvm::ConstantPointerNull::get(basept));
-    Logger::println("generating base typeinfo");
-    //sd->basetype = sd->basetype->merge();
-
-    sd->basetype->getTypeInfo(NULL);        // generate vtinfo
-    assert(sd->basetype->vtinfo);
-    DtoForceDeclareDsymbol(sd->basetype->vtinfo);
-
-    assert(sd->basetype->vtinfo->ir.irGlobal->value);
-    assert(llvm::isa<llvm::Constant>(sd->basetype->vtinfo->ir.irGlobal->value));
-    LLConstant* castbase = llvm::cast<llvm::Constant>(sd->basetype->vtinfo->ir.irGlobal->value);
-    castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(2));
+    LLConstant* castbase = DtoTypeInfoOf(sd->basetype, true);
+    assert(castbase->getType() == stype->getElementType(2));
     sinits.push_back(castbase);
 
     // char[] name
@@ -468,18 +457,8 @@
     EnumDeclaration *sd = tc->sym;
 
     // TypeInfo base
-    //const LLPointerType* basept = isaPointer(initZ->getOperand(1)->getType());
-    //sinits.push_back(llvm::ConstantPointerNull::get(basept));
-    Logger::println("generating base typeinfo");
-    //sd->basetype = sd->basetype->merge();
-
-    sd->memtype->getTypeInfo(NULL);        // generate vtinfo
-    assert(sd->memtype->vtinfo);
-    DtoForceDeclareDsymbol(sd->memtype->vtinfo);
-
-    assert(llvm::isa<llvm::Constant>(sd->memtype->vtinfo->ir.irGlobal->value));
-    LLConstant* castbase = llvm::cast<llvm::Constant>(sd->memtype->vtinfo->ir.irGlobal->value);
-    castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(2));
+    LLConstant* castbase = DtoTypeInfoOf(sd->memtype, true);
+    assert(castbase->getType() == stype->getElementType(2));
     sinits.push_back(castbase);
 
     // char[] name
@@ -543,13 +522,8 @@
     sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty)));
 
     // TypeInfo base
-    Logger::println("generating base typeinfo");
-    basetype->getTypeInfo(NULL);
-    assert(basetype->vtinfo);
-    DtoForceDeclareDsymbol(basetype->vtinfo);
-    assert(llvm::isa<llvm::Constant>(basetype->vtinfo->ir.irGlobal->value));
-    LLConstant* castbase = llvm::cast<llvm::Constant>(basetype->vtinfo->ir.irGlobal->value);
-    castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(2));
+    LLConstant* castbase = DtoTypeInfoOf(basetype, true);
+    assert(castbase->getType() == stype->getElementType(2));
     sinits.push_back(castbase);
 
     // create the symbol
@@ -656,13 +630,8 @@
     // value typeinfo
     assert(tinfo->ty == Tsarray);
     TypeSArray *tc = (TypeSArray *)tinfo;
-    tc->next->getTypeInfo(NULL);
-
-    // get symbol
-    assert(tc->next->vtinfo);
-    DtoForceDeclareDsymbol(tc->next->vtinfo);
-    LLConstant* castbase = isaConstant(tc->next->vtinfo->ir.irGlobal->value);
-    castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(2));
+    LLConstant* castbase = DtoTypeInfoOf(tc->next, true);
+    assert(castbase->getType() == stype->getElementType(2));
     sinits.push_back(castbase);
 
     // length
@@ -721,23 +690,13 @@
     TypeAArray *tc = (TypeAArray *)tinfo;
 
     // value typeinfo
-    tc->next->getTypeInfo(NULL);
-
-    // get symbol
-    assert(tc->next->vtinfo);
-    DtoForceDeclareDsymbol(tc->next->vtinfo);
-    LLConstant* castbase = isaConstant(tc->next->vtinfo->ir.irGlobal->value);
-    castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(2));
+    LLConstant* castbase = DtoTypeInfoOf(tc->next, true);
+    assert(castbase->getType() == stype->getElementType(2));
     sinits.push_back(castbase);
 
     // key typeinfo
-    tc->index->getTypeInfo(NULL);
-
-    // get symbol
-    assert(tc->index->vtinfo);
-    DtoForceDeclareDsymbol(tc->index->vtinfo);
-    castbase = isaConstant(tc->index->vtinfo->ir.irGlobal->value);
-    castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(3));
+    castbase = DtoTypeInfoOf(tc->index, true);
+    assert(castbase->getType() == stype->getElementType(3));
     sinits.push_back(castbase);
 
     // create the symbol
@@ -1179,12 +1138,9 @@
     for (size_t i = 0; i < dim; i++)
     {
         Argument *arg = (Argument *)tu->arguments->data[i];
-        arg->type->getTypeInfo(NULL);
-        DtoForceDeclareDsymbol(arg->type->vtinfo);
-        assert(arg->type->vtinfo->ir.irGlobal->value);
-        LLConstant* c = isaConstant(arg->type->vtinfo->ir.irGlobal->value);
-        c = llvm::ConstantExpr::getBitCast(c, tiTy);
-        arrInits.push_back(c);
+        LLConstant* castbase = DtoTypeInfoOf(arg->type, true);
+        assert(castbase->getType() == tiTy);
+        arrInits.push_back(castbase);
     }
 
     // build array type