diff gen/tollvm.c @ 82:d8dd47ef3973 trunk

[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes. Initial support for debug information. Very limited, but MUCH better than nothing :)
author lindquist
date Fri, 02 Nov 2007 01:17:26 +0100
parents 3587401b6eeb
children 339422268de1
line wrap: on
line diff
--- a/gen/tollvm.c	Thu Nov 01 17:27:18 2007 +0100
+++ b/gen/tollvm.c	Fri Nov 02 01:17:26 2007 +0100
@@ -482,6 +482,7 @@
 
 llvm::Value* DtoStructCopy(llvm::Value* dst, llvm::Value* src)
 {
+    Logger::cout() << "dst = " << *dst << " src = " << *src << '\n';
     assert(dst->getType() == src->getType());
     assert(gIR);
 
@@ -1093,20 +1094,6 @@
 
 //////////////////////////////////////////////////////////////////////////////////////////
 
-void DtoGiveArgumentStorage(elem* l)
-{
-    assert(l->mem == 0);
-    assert(l->val);
-    assert(llvm::isa<llvm::Argument>(l->val));
-    assert(l->vardecl != 0);
-
-    llvm::AllocaInst* allocainst = new llvm::AllocaInst(l->val->getType(), l->val->getName()+"_storage", gIR->topallocapoint());
-    l->mem = allocainst;
-    l->vardecl->llvmValue = l->mem;
-}
-
-//////////////////////////////////////////////////////////////////////////////////////////
-
 llvm::Value* DtoRealloc(llvm::Value* ptr, const llvm::Type* ty)
 {
     /*size_t sz = gTargetData->getTypeSize(ty);
@@ -1235,7 +1222,6 @@
         if (paramtype && retval->getType() != paramtype)
         {
             assert(retval->getType() == paramtype->getContainedType(0));
-            DtoGiveArgumentStorage(arg);
             new llvm::StoreInst(retval, arg->mem, gIR->scopebb());
             retval = arg->mem;
         }
@@ -1373,6 +1359,16 @@
         llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2)
     );
 }
+llvm::Constant* DtoConstStringPtr(const char* str, const char* section)
+{
+    std::string s(str);
+    llvm::Constant* init = llvm::ConstantArray::get(s, true);
+    llvm::GlobalVariable* gvar = new llvm::GlobalVariable(
+        init->getType(), true,llvm::GlobalValue::InternalLinkage, init, "stringliteral", gIR->module);
+    if (section) gvar->setSection(section);
+    llvm::Constant* idxs[2] = { DtoConstUint(0), DtoConstUint(0) };
+    return llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2);
+}
 
 //////////////////////////////////////////////////////////////////////////////////////////