diff gen/classes.cpp @ 244:a95056b3c996 trunk

[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB. Did a lot of smaller cleans up here and there. Replaced more llvm::Foo with LLFoo for common stuff. Split up tollvm.cpp.
author lindquist
date Mon, 09 Jun 2008 09:37:08 +0200
parents 0806379a5eca
children 23d0d9855cad
line wrap: on
line diff
--- a/gen/classes.cpp	Mon Jun 09 03:02:14 2008 +0200
+++ b/gen/classes.cpp	Mon Jun 09 09:37:08 2008 +0200
@@ -8,6 +8,7 @@
 
 #include "gen/irstate.h"
 #include "gen/tollvm.h"
+#include "gen/llvmhelpers.h"
 #include "gen/arrays.h"
 #include "gen/logger.h"
 #include "gen/classes.h"
@@ -199,7 +200,7 @@
                 fieldtypes.push_back(fieldtype);
                 irstruct->defaultFields.push_back(fieldinit);
                 if (fieldpad) {
-                    fieldtypes.push_back(llvm::ArrayType::get(llvm::Type::Int8Ty, fieldpad));
+                    fieldtypes.push_back(llvm::ArrayType::get(LLType::Int8Ty, fieldpad));
                     irstruct->defaultFields.push_back(NULL);
                     idx++;
                 }
@@ -218,7 +219,7 @@
         fieldtypes.push_back(fieldtype);
         irstruct->defaultFields.push_back(fieldinit);
         if (fieldpad) {
-            fieldtypes.push_back(llvm::ArrayType::get(llvm::Type::Int8Ty, fieldpad));
+            fieldtypes.push_back(llvm::ArrayType::get(LLType::Int8Ty, fieldpad));
             irstruct->defaultFields.push_back(NULL);
         }
     }
@@ -498,7 +499,7 @@
     }
 
     // then comes monitor
-    fieldinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty)));
+    fieldinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty)));
 
     // go through the field inits and build the default initializer
     size_t nfi = irstruct->defaultFields.size();
@@ -511,7 +512,7 @@
         else {
             const llvm::ArrayType* arrty = isaArray(structtype->getElementType(i+2));
             assert(arrty);
-            std::vector<LLConstant*> vals(arrty->getNumElements(), llvm::ConstantInt::get(llvm::Type::Int8Ty, 0, false));
+            std::vector<LLConstant*> vals(arrty->getNumElements(), llvm::ConstantInt::get(LLType::Int8Ty, 0, false));
             c = llvm::ConstantArray::get(arrty, vals);
         }
         fieldinits.push_back(c);
@@ -628,7 +629,7 @@
             infoInits.push_back(c);
 
             // vtbl
-            const LLType* byteptrptrty = getPtrToType(getPtrToType(llvm::Type::Int8Ty));
+            const LLType* byteptrptrty = getPtrToType(getPtrToType(LLType::Int8Ty));
             c = llvm::ConstantExpr::getBitCast(iri->vtbl, byteptrptrty);
             c = DtoConstSlice(DtoConstSize_t(b->vtbl.dim), c);
             infoInits.push_back(c);
@@ -706,7 +707,7 @@
             infoInits.push_back(c);
 
             // vtbl
-            const LLType* byteptrptrty = getPtrToType(getPtrToType(llvm::Type::Int8Ty));
+            const LLType* byteptrptrty = getPtrToType(getPtrToType(LLType::Int8Ty));
             c = DtoConstSlice(DtoConstSize_t(0), getNullPtr(byteptrptrty));
             infoInits.push_back(c);
 
@@ -865,23 +866,10 @@
     assert(tc->sym->ir.irStruct->init);
     assert(dst->getType() == tc->sym->ir.irStruct->init->getType());
 
-    const LLType* arrty = getPtrToType(llvm::Type::Int8Ty);
-
     LLValue* dstarr = DtoGEPi(dst,0,2,"tmp");
-    dstarr = DtoBitCast(dstarr, arrty);
-
     LLValue* srcarr = DtoGEPi(tc->sym->ir.irStruct->init,0,2,"tmp");
-    srcarr = DtoBitCast(srcarr, arrty);
 
-    llvm::Function* fn = LLVM_DeclareMemCpy32();
-    std::vector<LLValue*> llargs;
-    llargs.resize(4);
-    llargs[0] = dstarr;
-    llargs[1] = srcarr;
-    llargs[2] = llvm::ConstantInt::get(llvm::Type::Int32Ty, n, false);
-    llargs[3] = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false);
-
-    llvm::CallInst::Create(fn, llargs.begin(), llargs.end(), "", gIR->scopebb());
+    DtoMemCpy(dstarr, srcarr, DtoConstSize_t(n));
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
@@ -1343,16 +1331,16 @@
     std::vector<const LLType*> paramTypes;
     paramTypes.push_back(getPtrToType(cd->type->ir.type->get()));
 
-    const llvm::FunctionType* fnTy = llvm::FunctionType::get(llvm::Type::VoidTy, paramTypes, false);
+    const llvm::FunctionType* fnTy = llvm::FunctionType::get(LLType::VoidTy, paramTypes, false);
 
     if (cd->dtors.dim == 0) {
-        return llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty));
+        return llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty));
     }
     else if (cd->dtors.dim == 1) {
         DtorDeclaration *d = (DtorDeclaration *)cd->dtors.data[0];
         DtoForceDeclareDsymbol(d);
         assert(d->ir.irFunc->func);
-        return llvm::ConstantExpr::getBitCast(isaConstant(d->ir.irFunc->func), getPtrToType(llvm::Type::Int8Ty));
+        return llvm::ConstantExpr::getBitCast(isaConstant(d->ir.irFunc->func), getPtrToType(LLType::Int8Ty));
     }
 
     std::string gname("_D");
@@ -1375,7 +1363,7 @@
     }
     builder.CreateRetVoid();
 
-    return llvm::ConstantExpr::getBitCast(func, getPtrToType(llvm::Type::Int8Ty));
+    return llvm::ConstantExpr::getBitCast(func, getPtrToType(LLType::Int8Ty));
 }
 
 static uint build_classinfo_flags(ClassDeclaration* cd)
@@ -1462,7 +1450,7 @@
     inits.push_back(c);
 
     // byte[] init
-    const LLType* byteptrty = getPtrToType(llvm::Type::Int8Ty);
+    const LLType* byteptrty = getPtrToType(LLType::Int8Ty);
     if (cd->isInterfaceDeclaration() || cd->isAbstract()) {
         c = cinfo->ir.irStruct->constInit->getOperand(2);
     }