changeset 621:0ecdb11ca85e

Automated merge with http://hg.dsource.org/projects/llvmdc
author Christian Kamm <kamm incasoftware de>
date Wed, 01 Oct 2008 17:54:50 +0200
parents 722630261d62 (diff) 718ddecc053c (current diff)
children fe3c7af578eb
files
diffstat 5 files changed, 36 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/dmd/expression.h	Wed Oct 01 17:54:44 2008 +0200
+++ b/dmd/expression.h	Wed Oct 01 17:54:50 2008 +0200
@@ -1003,6 +1003,9 @@
 
     // For operator overloading
     Identifier *opId();
+
+    // LLVMDC
+    virtual llvm::Constant *toConstElem(IRState *irs);
 };
 
 
--- a/gen/classes.cpp	Wed Oct 01 17:54:44 2008 +0200
+++ b/gen/classes.cpp	Wed Oct 01 17:54:50 2008 +0200
@@ -340,7 +340,7 @@
 #endif
 
     // log
-    Logger::cout() << "final class type: " << *ts->ir.type->get() << '\n';
+    //Logger::cout() << "final class type: " << *ts->ir.type->get() << '\n';
 
     // pop state
     gIR->classes.pop_back();
--- a/gen/toir.cpp	Wed Oct 01 17:54:44 2008 +0200
+++ b/gen/toir.cpp	Wed Oct 01 17:54:50 2008 +0200
@@ -819,6 +819,22 @@
 
 //////////////////////////////////////////////////////////////////////////////////////////
 
+LLConstant* CastExp::toConstElem(IRState* p)
+{
+    Logger::print("CastExp::toConstElem: %s | %s\n", toChars(), type->toChars());
+    LOG_SCOPE;
+
+    LLConstant* c = e1->toConstElem(p);
+    assert(isaPointer(c->getType()));
+
+    const LLType* lltype = DtoType(type);
+    assert(isaPointer(lltype));
+
+    return llvm::ConstantExpr::getBitCast(c, lltype);
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+
 DValue* SymOffExp::toElem(IRState* p)
 {
     Logger::print("SymOffExp::toElem: %s | %s\n", toChars(), type->toChars());
--- a/gen/tollvm.cpp	Wed Oct 01 17:54:44 2008 +0200
+++ b/gen/tollvm.cpp	Wed Oct 01 17:54:50 2008 +0200
@@ -647,7 +647,7 @@
 size_t getABITypeSize(const LLType* t)
 {
     size_t sz = gTargetData->getABITypeSize(t);
-    Logger::cout() << "abi type size of: " << *t << " == " << sz << '\n';
+    //Logger::cout() << "abi type size of: " << *t << " == " << sz << '\n';
     return sz;
 }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/mini/const1.d	Wed Oct 01 17:54:50 2008 +0200
@@ -0,0 +1,15 @@
+module mini.const1;
+
+void* g = cast(void*)&foobar;
+
+int foobar()
+{
+    return 42;
+}
+
+void main()
+{
+    auto fn = cast(int function())g;
+    int i = fn();
+    assert(i == 42);
+}