Mercurial > projects > ldc
comparison gen/tollvm.cpp @ 1364:46f6365a50d7
Added IrTypeFunction and IrTypeDelegate and eliminated IrDType. This means the Type::ir field can be removed. It's the final part needed for the move to a slightly more sane type system. Now the whole thing just needs to be cleaned up :P
Added -v-cg switch, which right now just prints "codegen: module.name (module/name.d)" to stdout, this can really help figuring out where, in some complex build command, things go wrong.
author | Tomas Lindquist Olsen <tomas.l.olsen gmail com> |
---|---|
date | Sat, 16 May 2009 18:19:52 +0200 |
parents | 45aca7e7cc88 |
children | 63f4afd01036 |
comparison
equal
deleted
inserted
replaced
1363:b7c8506e1eed | 1364:46f6365a50d7 |
---|---|
22 #include "gen/linkage.h" | 22 #include "gen/linkage.h" |
23 #include "gen/llvm-version.h" | 23 #include "gen/llvm-version.h" |
24 | 24 |
25 #include "ir/irtype.h" | 25 #include "ir/irtype.h" |
26 #include "ir/irtypeclass.h" | 26 #include "ir/irtypeclass.h" |
27 #include "ir/irtypefunction.h" | |
27 | 28 |
28 bool DtoIsPassedByRef(Type* type) | 29 bool DtoIsPassedByRef(Type* type) |
29 { | 30 { |
30 Type* typ = type->toBasetype(); | 31 Type* typ = type->toBasetype(); |
31 TY t = typ->ty; | 32 TY t = typ->ty; |
129 } | 130 } |
130 | 131 |
131 // functions | 132 // functions |
132 case Tfunction: | 133 case Tfunction: |
133 { | 134 { |
134 if (!t->ir.type || *t->ir.type == NULL) { | 135 t->irtype = new IrTypeFunction(t); |
135 TypeFunction* tf = (TypeFunction*)t; | 136 return t->irtype->buildType(); |
136 if (tf->funcdecl) | |
137 return DtoFunctionType(tf->funcdecl); | |
138 else | |
139 return DtoFunctionType(tf,NULL,NULL); | |
140 } | |
141 else { | |
142 return t->ir.type->get(); | |
143 } | |
144 } | 137 } |
145 | 138 |
146 // delegates | 139 // delegates |
147 case Tdelegate: | 140 case Tdelegate: |
148 { | 141 { |
149 if (!t->ir.type || *t->ir.type == NULL) { | 142 t->irtype = new IrTypeDelegate(t); |
150 return DtoDelegateType(t); | 143 return t->irtype->buildType(); |
151 } | |
152 else { | |
153 return t->ir.type->get(); | |
154 } | |
155 } | 144 } |
156 | 145 |
157 // typedefs | 146 // typedefs |
158 // enum | 147 // enum |
159 | 148 |
214 { | 203 { |
215 const LLType* lt = DtoType(t); | 204 const LLType* lt = DtoType(t); |
216 if (lt == LLType::VoidTy) | 205 if (lt == LLType::VoidTy) |
217 return LLType::Int8Ty; | 206 return LLType::Int8Ty; |
218 return lt; | 207 return lt; |
219 } | |
220 | |
221 ////////////////////////////////////////////////////////////////////////////////////////// | |
222 | |
223 const LLStructType* DtoDelegateType(Type* t) | |
224 { | |
225 assert(t->ty == Tdelegate); | |
226 const LLType* i8ptr = getVoidPtrType(); | |
227 const LLType* func = DtoFunctionType(t->nextOf(), NULL, Type::tvoid->pointerTo()); | |
228 const LLType* funcptr = getPtrToType(func); | |
229 const LLStructType* dgtype = LLStructType::get(i8ptr, funcptr, NULL); | |
230 gIR->module->addTypeName(t->toChars(), dgtype); | |
231 return dgtype; | |
232 } | 208 } |
233 | 209 |
234 ////////////////////////////////////////////////////////////////////////////////////////// | 210 ////////////////////////////////////////////////////////////////////////////////////////// |
235 | 211 |
236 LLValue* DtoDelegateEquals(TOK op, LLValue* lhs, LLValue* rhs) | 212 LLValue* DtoDelegateEquals(TOK op, LLValue* lhs, LLValue* rhs) |
797 // build interface info type | 773 // build interface info type |
798 std::vector<const LLType*> types; | 774 std::vector<const LLType*> types; |
799 // ClassInfo classinfo | 775 // ClassInfo classinfo |
800 ClassDeclaration* cd2 = ClassDeclaration::classinfo; | 776 ClassDeclaration* cd2 = ClassDeclaration::classinfo; |
801 DtoResolveClass(cd2); | 777 DtoResolveClass(cd2); |
802 types.push_back(getPtrToType(cd2->type->ir.type->get())); | 778 types.push_back(DtoType(cd2->type)); |
803 // void*[] vtbl | 779 // void*[] vtbl |
804 std::vector<const LLType*> vtbltypes; | 780 std::vector<const LLType*> vtbltypes; |
805 vtbltypes.push_back(DtoSize_t()); | 781 vtbltypes.push_back(DtoSize_t()); |
806 const LLType* byteptrptrty = getPtrToType(getPtrToType(LLType::Int8Ty)); | 782 const LLType* byteptrptrty = getPtrToType(getPtrToType(LLType::Int8Ty)); |
807 vtbltypes.push_back(byteptrptrty); | 783 vtbltypes.push_back(byteptrptrty); |