Mercurial > projects > ldc
comparison gen/tollvm.cpp @ 797:340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Fixed function literals in static initializers.
Changed alignment of delegates from 2*PTRSIZE to just PTRSIZE.
Changed errors to go to stderr instead of stdout.
Fairly major rewriting of struct/union/class handling, STILL A BIT BUGGY !!!
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Sat, 29 Nov 2008 21:25:43 +0100 |
parents | 661384d6a936 |
children | 8e6135be6999 |
comparison
equal
deleted
inserted
replaced
796:6e7a4c3b64d2 | 797:340acf1535d0 |
---|---|
117 // aggregates | 117 // aggregates |
118 case Tstruct: { | 118 case Tstruct: { |
119 TypeStruct* ts = (TypeStruct*)t; | 119 TypeStruct* ts = (TypeStruct*)t; |
120 assert(ts->sym); | 120 assert(ts->sym); |
121 DtoResolveDsymbol(ts->sym); | 121 DtoResolveDsymbol(ts->sym); |
122 return ts->sym->ir.irStruct->recty.get(); // t->ir.type->get(); | 122 return ts->ir.type->get(); |
123 } | 123 } |
124 | 124 |
125 case Tclass: { | 125 case Tclass: { |
126 TypeClass* tc = (TypeClass*)t; | 126 TypeClass* tc = (TypeClass*)t; |
127 assert(tc->sym); | 127 assert(tc->sym); |
128 DtoResolveDsymbol(tc->sym); | 128 DtoResolveDsymbol(tc->sym); |
129 return getPtrToType(tc->sym->ir.irStruct->recty.get()); // t->ir.type->get()); | 129 return getPtrToType(tc->ir.type->get()); |
130 } | 130 } |
131 | 131 |
132 // functions | 132 // functions |
133 case Tfunction: | 133 case Tfunction: |
134 { | 134 { |
582 return v; | 582 return v; |
583 assert(!(isaStruct(t) || isaStruct(v->getType()))); | 583 assert(!(isaStruct(t) || isaStruct(v->getType()))); |
584 return gIR->ir->CreateBitCast(v, t, name ? name : "tmp"); | 584 return gIR->ir->CreateBitCast(v, t, name ? name : "tmp"); |
585 } | 585 } |
586 | 586 |
587 LLConstant* DtoBitCast(LLConstant* v, const LLType* t) | |
588 { | |
589 if (v->getType() == t) | |
590 return v; | |
591 return llvm::ConstantExpr::getBitCast(v, t); | |
592 } | |
593 | |
587 ////////////////////////////////////////////////////////////////////////////////////////// | 594 ////////////////////////////////////////////////////////////////////////////////////////// |
588 | 595 |
589 const LLPointerType* isaPointer(LLValue* v) | 596 const LLPointerType* isaPointer(LLValue* v) |
590 { | 597 { |
591 return llvm::dyn_cast<LLPointerType>(v->getType()); | 598 return llvm::dyn_cast<LLPointerType>(v->getType()); |
691 } | 698 } |
692 | 699 |
693 unsigned char getPrefTypeAlign(const LLType* t) | 700 unsigned char getPrefTypeAlign(const LLType* t) |
694 { | 701 { |
695 return gTargetData->getPrefTypeAlignment(t); | 702 return gTargetData->getPrefTypeAlignment(t); |
703 } | |
704 | |
705 const LLType* getBiggestType(const LLType** begin, size_t n) | |
706 { | |
707 const LLType* bigTy = 0; | |
708 size_t bigSize = 0; | |
709 size_t bigAlign = 0; | |
710 | |
711 const LLType** end = begin+n; | |
712 while (begin != end) | |
713 { | |
714 const LLType* T = *begin; | |
715 | |
716 size_t sz = getABITypeSize(T); | |
717 size_t ali = getABITypeAlign(T); | |
718 if (sz > bigSize || (sz == bigSize && ali > bigAlign)) | |
719 { | |
720 bigTy = T; | |
721 bigSize = sz; | |
722 bigAlign = ali; | |
723 } | |
724 | |
725 ++begin; | |
726 } | |
727 | |
728 // will be null for n==0 | |
729 return bigTy; | |
696 } | 730 } |
697 | 731 |
698 ////////////////////////////////////////////////////////////////////////////////////////// | 732 ////////////////////////////////////////////////////////////////////////////////////////// |
699 | 733 |
700 const LLStructType* DtoInterfaceInfoType() | 734 const LLStructType* DtoInterfaceInfoType() |