# HG changeset patch # User Christian Kamm # Date 1222876490 -7200 # Node ID 0ecdb11ca85e7bb15d8cae7888b264bffa215eef # Parent 722630261d62c80d32a93a3564bc8785f46f2bca# Parent 718ddecc053c9e6248bd6d95e62c357ef333f159 Automated merge with http://hg.dsource.org/projects/llvmdc diff -r 718ddecc053c -r 0ecdb11ca85e dmd/expression.h --- 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); }; diff -r 718ddecc053c -r 0ecdb11ca85e gen/classes.cpp --- 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(); diff -r 718ddecc053c -r 0ecdb11ca85e gen/toir.cpp --- 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()); diff -r 718ddecc053c -r 0ecdb11ca85e gen/tollvm.cpp --- 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; } diff -r 718ddecc053c -r 0ecdb11ca85e tests/mini/const1.d --- /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); +}