Mercurial > projects > ldc
diff gen/toir.cpp @ 619:722630261d62
Implemented constant pointer casts (like casting function pointer to void* as a constant global initializer)
author | tomas@myhost |
---|---|
date | Sun, 28 Sep 2008 21:09:21 +0200 |
parents | 5ced42a55aa9 |
children | 26fce59fe80a |
line wrap: on
line diff
--- a/gen/toir.cpp Sun Sep 28 15:22:39 2008 +0200 +++ b/gen/toir.cpp Sun Sep 28 21:09:21 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());