Mercurial > projects > ldc
comparison 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 |
comparison
equal
deleted
inserted
replaced
618:c9aa338280ed | 619:722630261d62 |
---|---|
813 else if(u->isLVal()) | 813 else if(u->isLVal()) |
814 return new DLRValue(u, v); | 814 return new DLRValue(u, v); |
815 | 815 |
816 else | 816 else |
817 return v; | 817 return v; |
818 } | |
819 | |
820 ////////////////////////////////////////////////////////////////////////////////////////// | |
821 | |
822 LLConstant* CastExp::toConstElem(IRState* p) | |
823 { | |
824 Logger::print("CastExp::toConstElem: %s | %s\n", toChars(), type->toChars()); | |
825 LOG_SCOPE; | |
826 | |
827 LLConstant* c = e1->toConstElem(p); | |
828 assert(isaPointer(c->getType())); | |
829 | |
830 const LLType* lltype = DtoType(type); | |
831 assert(isaPointer(lltype)); | |
832 | |
833 return llvm::ConstantExpr::getBitCast(c, lltype); | |
818 } | 834 } |
819 | 835 |
820 ////////////////////////////////////////////////////////////////////////////////////////// | 836 ////////////////////////////////////////////////////////////////////////////////////////// |
821 | 837 |
822 DValue* SymOffExp::toElem(IRState* p) | 838 DValue* SymOffExp::toElem(IRState* p) |