Mercurial > projects > ldc
comparison gen/tollvm.cpp @ 486:a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Reimplemented support for nested functions/class using a new approach.
Added error on taking address of intrinsic.
Fixed problems with the ->syntaxCopy of TypeFunction delegate exp.
Removed DtoDType and replaced all uses with ->toBasetype() instead.
Removed unused inplace stuff.
Fixed a bunch of issues in the runtime unittests, not complete yet.
Added mini tests.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Sun, 10 Aug 2008 08:37:38 +0200 |
parents | e381e082d5cb |
children | eada571dc8ff |
comparison
equal
deleted
inserted
replaced
485:50f6e2337a6b | 486:a34078905d01 |
---|---|
21 #include "gen/complex.h" | 21 #include "gen/complex.h" |
22 #include "gen/llvmhelpers.h" | 22 #include "gen/llvmhelpers.h" |
23 | 23 |
24 bool DtoIsPassedByRef(Type* type) | 24 bool DtoIsPassedByRef(Type* type) |
25 { | 25 { |
26 Type* typ = DtoDType(type); | 26 Type* typ = type->toBasetype(); |
27 TY t = typ->ty; | 27 TY t = typ->ty; |
28 return (t == Tstruct || t == Tarray || t == Tdelegate || t == Tsarray || typ->iscomplex()); | 28 return (t == Tstruct || t == Tarray || t == Tdelegate || t == Tsarray || typ->iscomplex()); |
29 } | 29 } |
30 | 30 |
31 bool DtoIsReturnedInArg(Type* type) | 31 bool DtoIsReturnedInArg(Type* type) |
32 { | 32 { |
33 Type* typ = DtoDType(type); | 33 Type* typ = type->toBasetype(); |
34 TY t = typ->ty; | 34 TY t = typ->ty; |
35 return (t == Tstruct || t == Tarray || t == Tdelegate || t == Tsarray || typ->iscomplex()); | 35 return (t == Tstruct || t == Tarray || t == Tdelegate || t == Tsarray || typ->iscomplex()); |
36 } | 36 } |
37 | 37 |
38 unsigned DtoShouldExtend(Type* type) | 38 unsigned DtoShouldExtend(Type* type) |
50 case Tuns16: | 50 case Tuns16: |
51 return llvm::ParamAttr::ZExt; | 51 return llvm::ParamAttr::ZExt; |
52 } | 52 } |
53 } | 53 } |
54 return llvm::ParamAttr::None; | 54 return llvm::ParamAttr::None; |
55 } | |
56 | |
57 Type* DtoDType(Type* t) | |
58 { | |
59 if (t->ty == Ttypedef) { | |
60 Type* bt = t->toBasetype(); | |
61 assert(bt); | |
62 return DtoDType(bt); | |
63 } | |
64 return t; | |
65 } | 55 } |
66 | 56 |
67 const LLType* DtoType(Type* t) | 57 const LLType* DtoType(Type* t) |
68 { | 58 { |
69 assert(t); | 59 assert(t); |
141 | 131 |
142 // functions | 132 // functions |
143 case Tfunction: | 133 case Tfunction: |
144 { | 134 { |
145 if (!t->ir.type || *t->ir.type == NULL) { | 135 if (!t->ir.type || *t->ir.type == NULL) { |
146 return DtoFunctionType(t,NULL); | 136 return DtoFunctionType(t,NULL,NULL); |
147 } | 137 } |
148 else { | 138 else { |
149 return t->ir.type->get(); | 139 return t->ir.type->get(); |
150 } | 140 } |
151 } | 141 } |
203 ////////////////////////////////////////////////////////////////////////////////////////// | 193 ////////////////////////////////////////////////////////////////////////////////////////// |
204 | 194 |
205 const LLStructType* DtoDelegateType(Type* t) | 195 const LLStructType* DtoDelegateType(Type* t) |
206 { | 196 { |
207 const LLType* i8ptr = getVoidPtrType(); | 197 const LLType* i8ptr = getVoidPtrType(); |
208 const LLType* func = DtoFunctionType(t->next, i8ptr); | 198 const LLType* func = DtoFunctionType(t->next, NULL, i8ptr); |
209 const LLType* funcptr = getPtrToType(func); | 199 const LLType* funcptr = getPtrToType(func); |
210 return LLStructType::get(i8ptr, funcptr, 0); | 200 return LLStructType::get(i8ptr, funcptr, 0); |
211 } | 201 } |
212 | 202 |
213 ////////////////////////////////////////////////////////////////////////////////////////// | 203 ////////////////////////////////////////////////////////////////////////////////////////// |
664 return gTargetData->getTypeStoreSize(t); | 654 return gTargetData->getTypeStoreSize(t); |
665 } | 655 } |
666 | 656 |
667 size_t getABITypeSize(const LLType* t) | 657 size_t getABITypeSize(const LLType* t) |
668 { | 658 { |
669 Logger::cout() << "getting abi type of: " << *t << '\n'; | 659 size_t sz = gTargetData->getABITypeSize(t); |
670 return gTargetData->getABITypeSize(t); | 660 Logger::cout() << "abi type size of: " << *t << " == " << sz << '\n'; |
661 return sz; | |
671 } | 662 } |
672 | 663 |
673 unsigned char getABITypeAlign(const LLType* t) | 664 unsigned char getABITypeAlign(const LLType* t) |
674 { | 665 { |
675 return gTargetData->getABITypeAlignment(t); | 666 return gTargetData->getABITypeAlignment(t); |