Mercurial > projects > ldc
comparison gen/toir.cpp @ 715:30b42a283c8e
Removed TypeOpaque from DMD.
Changed runtime functions taking opaque[] to void[].
Implemented proper type painting, to avoid "resizing" array casts in runtime calls that previously took opaque[].
Implemented dynamic arrays as first class types, this implements proper ABI for these types on x86.
Added dwarf region end after call to assert function, fixes some problems with llvm not allowing this to be missing.
Reverted change to WithStatement from rev [704] it breaks MiniD, mini/with2.d needs to be fixed some other way...
Fixed tango bug 1339 in runtime, problem with _adReverseChar on invalid UTF-8.
Disabled .bc generation in the compiler runtime part, genobj.d triggers some llvm bug when using debug info. the .o seems to work fine.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Wed, 22 Oct 2008 14:55:33 +0200 |
parents | 5a2983f97498 |
children | 7261ff0f95ff |
comparison
equal
deleted
inserted
replaced
714:1e98c99a87cb | 715:30b42a283c8e |
---|---|
781 DValue* CastExp::toElem(IRState* p) | 781 DValue* CastExp::toElem(IRState* p) |
782 { | 782 { |
783 Logger::print("CastExp::toElem: %s | %s\n", toChars(), type->toChars()); | 783 Logger::print("CastExp::toElem: %s | %s\n", toChars(), type->toChars()); |
784 LOG_SCOPE; | 784 LOG_SCOPE; |
785 | 785 |
786 // get the value to cast | |
786 DValue* u = e1->toElem(p); | 787 DValue* u = e1->toElem(p); |
787 DValue* v = DtoCast(loc, u, to); | 788 |
788 // force d type to this->type | 789 // cast it to the 'to' type, if necessary |
789 v->getType() = type; | 790 DValue* v = u; |
790 | 791 if (!to->equals(e1->type)) |
791 if (v->isSlice()) { | 792 v = DtoCast(loc, u, to); |
792 // only valid as rvalue! | 793 |
794 // paint the type, if necessary | |
795 if (!type->equals(to)) | |
796 v = DtoPaintType(loc, v, type); | |
797 | |
798 // slices are not valid lvalues | |
799 if (v->isSlice()) | |
793 return v; | 800 return v; |
794 } | 801 // if we're casting a lvalue, keep it around, we might be in a lvalue cast. |
795 | |
796 else if(u->isLVal()) | 802 else if(u->isLVal()) |
797 return new DLRValue(u, v); | 803 return new DLRValue(u, v); |
798 | 804 // otherwise just return the new value |
799 else | 805 return v; |
800 return v; | |
801 } | 806 } |
802 | 807 |
803 ////////////////////////////////////////////////////////////////////////////////////////// | 808 ////////////////////////////////////////////////////////////////////////////////////////// |
804 | 809 |
805 LLConstant* CastExp::toConstElem(IRState* p) | 810 LLConstant* CastExp::toConstElem(IRState* p) |
809 | 814 |
810 LLConstant* c = e1->toConstElem(p); | 815 LLConstant* c = e1->toConstElem(p); |
811 const LLType* lltype = DtoType(type); | 816 const LLType* lltype = DtoType(type); |
812 | 817 |
813 if(!isaPointer(c->getType()) || !isaPointer(lltype)) { | 818 if(!isaPointer(c->getType()) || !isaPointer(lltype)) { |
814 error("can only cast pointers to pointers at compile time, not %s to %s", type->toChars(), e1->type->toChars()); | 819 error("can only cast pointers to pointers at code generation time, not %s to %s", type->toChars(), e1->type->toChars()); |
815 fatal(); | 820 fatal(); |
816 } | 821 } |
817 | 822 |
818 return llvm::ConstantExpr::getBitCast(c, lltype); | 823 return llvm::ConstantExpr::getBitCast(c, lltype); |
819 } | 824 } |
1550 } | 1555 } |
1551 // dyn array | 1556 // dyn array |
1552 else if (et->ty == Tarray) | 1557 else if (et->ty == Tarray) |
1553 { | 1558 { |
1554 DtoDeleteArray(dval); | 1559 DtoDeleteArray(dval); |
1555 if (!dval->isSlice()) | 1560 if (dval->isLVal()) |
1556 DtoSetArrayToNull(dval->getRVal()); | 1561 DtoSetArrayToNull(dval->getLVal()); |
1557 } | 1562 } |
1558 // unknown/invalid | 1563 // unknown/invalid |
1559 else | 1564 else |
1560 { | 1565 { |
1561 assert(0 && "invalid delete"); | 1566 assert(0 && "invalid delete"); |