Mercurial > projects > ldc
annotate gen/typinf.cpp @ 213:7816aafeea3c trunk
[svn r229] Updated the object.d implementation to the latest Tango.
Fixed a bunch of the built-in typeinfos for arrays, they did not inherit TypeInfo_Array.
Applied patch to tango/text/convert/Layout.d by fvbommel, closes #47 .
Cleaned up some type code.
Replaced uses of llvm::Type with LLType (a typedef), same for Value and Constant.
Fixed a few cases where typeinfo for user structs could be emitted multiple times, seems to still be some cases of this :/
author | lindquist |
---|---|
date | Fri, 30 May 2008 19:32:04 +0200 |
parents | db9890b3fb64 |
children | a95056b3c996 |
rev | line source |
---|---|
1 | 1 |
2 | |
3 // Copyright (c) 1999-2004 by Digital Mars | |
4 // All Rights Reserved | |
5 // written by Walter Bright | |
6 // www.digitalmars.com | |
7 // License for redistribution is by either the Artistic License | |
8 // in artistic.txt, or the GNU General Public License in gnu.txt. | |
9 // See the included readme.txt for details. | |
10 | |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
11 // Modifications for LLVMDC: |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
12 // Copyright (c) 2007 by Tomas Lindquist Olsen |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
13 // tomas at famolsen dk |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
14 |
1 | 15 #include <cstdio> |
16 #include <cassert> | |
17 | |
52 | 18 #include "gen/llvm.h" |
19 | |
1 | 20 #include "mars.h" |
21 #include "module.h" | |
22 #include "mtype.h" | |
23 #include "scope.h" | |
24 #include "init.h" | |
25 #include "expression.h" | |
26 #include "attrib.h" | |
27 #include "declaration.h" | |
28 #include "template.h" | |
29 #include "id.h" | |
30 #include "enum.h" | |
31 #include "import.h" | |
32 #include "aggregate.h" | |
33 | |
52 | 34 #include "gen/irstate.h" |
4
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
35 #include "gen/logger.h" |
52 | 36 #include "gen/runtime.h" |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
37 #include "gen/tollvm.h" |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
38 #include "gen/arrays.h" |
100 | 39 #include "gen/structs.h" |
106 | 40 #include "gen/classes.h" |
1 | 41 |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
133
diff
changeset
|
42 #include "ir/irvar.h" |
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
133
diff
changeset
|
43 |
1 | 44 /******************************************* |
45 * Get a canonicalized form of the TypeInfo for use with the internal | |
46 * runtime library routines. Canonicalized in that static arrays are | |
47 * represented as dynamic arrays, enums are represented by their | |
48 * underlying type, etc. This reduces the number of TypeInfo's needed, | |
49 * so we can use the custom internal ones more. | |
50 */ | |
51 | |
52 Expression *Type::getInternalTypeInfo(Scope *sc) | |
53 { TypeInfoDeclaration *tid; | |
54 Expression *e; | |
55 Type *t; | |
56 static TypeInfoDeclaration *internalTI[TMAX]; | |
57 | |
58 //printf("Type::getInternalTypeInfo() %s\n", toChars()); | |
59 t = toBasetype(); | |
60 switch (t->ty) | |
61 { | |
62 case Tsarray: | |
63 t = t->next->arrayOf(); // convert to corresponding dynamic array type | |
64 break; | |
65 | |
66 case Tclass: | |
67 if (((TypeClass *)t)->sym->isInterfaceDeclaration()) | |
68 break; | |
69 goto Linternal; | |
70 | |
71 case Tarray: | |
72 if (t->next->ty != Tclass) | |
73 break; | |
74 goto Linternal; | |
75 | |
76 case Tfunction: | |
77 case Tdelegate: | |
78 case Tpointer: | |
79 Linternal: | |
80 tid = internalTI[t->ty]; | |
81 if (!tid) | |
82 { tid = new TypeInfoDeclaration(t, 1); | |
83 internalTI[t->ty] = tid; | |
84 } | |
85 e = new VarExp(0, tid); | |
52 | 86 //e = e->addressOf(sc); |
1 | 87 e->type = tid->type; // do this so we don't get redundant dereference |
88 return e; | |
89 | |
90 default: | |
91 break; | |
92 } | |
93 //printf("\tcalling getTypeInfo() %s\n", t->toChars()); | |
94 return t->getTypeInfo(sc); | |
95 } | |
96 | |
97 | |
98 /**************************************************** | |
99 * Get the exact TypeInfo. | |
100 */ | |
101 | |
102 Expression *Type::getTypeInfo(Scope *sc) | |
103 { | |
104 Expression *e; | |
105 Type *t; | |
106 | |
107 //printf("Type::getTypeInfo() %p, %s\n", this, toChars()); | |
108 t = merge(); // do this since not all Type's are merge'd | |
109 if (!t->vtinfo) | |
110 { t->vtinfo = t->getTypeInfoDeclaration(); | |
111 assert(t->vtinfo); | |
112 | |
113 /* If this has a custom implementation in std/typeinfo, then | |
114 * do not generate a COMDAT for it. | |
115 */ | |
116 if (!t->builtinTypeInfo()) | |
117 { // Generate COMDAT | |
118 if (sc) // if in semantic() pass | |
119 { // Find module that will go all the way to an object file | |
120 Module *m = sc->module->importedFrom; | |
121 m->members->push(t->vtinfo); | |
122 } | |
123 else // if in obj generation pass | |
124 { | |
125 t->vtinfo->toObjFile(); | |
126 } | |
127 } | |
128 } | |
129 e = new VarExp(0, t->vtinfo); | |
130 //e = e->addressOf(sc); | |
131 e->type = t->vtinfo->type; // do this so we don't get redundant dereference | |
132 return e; | |
133 } | |
134 | |
52 | 135 enum RET TypeFunction::retStyle() |
136 { | |
137 return RETstack; | |
138 } | |
1 | 139 |
140 TypeInfoDeclaration *Type::getTypeInfoDeclaration() | |
141 { | |
142 //printf("Type::getTypeInfoDeclaration() %s\n", toChars()); | |
143 return new TypeInfoDeclaration(this, 0); | |
144 } | |
145 | |
52 | 146 TypeInfoDeclaration *TypeTypedef::getTypeInfoDeclaration() |
1 | 147 { |
52 | 148 return new TypeInfoTypedefDeclaration(this); |
1 | 149 } |
150 | |
52 | 151 TypeInfoDeclaration *TypePointer::getTypeInfoDeclaration() |
152 { | |
153 return new TypeInfoPointerDeclaration(this); | |
154 } | |
1 | 155 |
156 TypeInfoDeclaration *TypeDArray::getTypeInfoDeclaration() | |
157 { | |
158 return new TypeInfoArrayDeclaration(this); | |
159 } | |
160 | |
161 TypeInfoDeclaration *TypeSArray::getTypeInfoDeclaration() | |
162 { | |
163 return new TypeInfoStaticArrayDeclaration(this); | |
164 } | |
165 | |
166 TypeInfoDeclaration *TypeAArray::getTypeInfoDeclaration() | |
167 { | |
168 return new TypeInfoAssociativeArrayDeclaration(this); | |
169 } | |
170 | |
52 | 171 TypeInfoDeclaration *TypeStruct::getTypeInfoDeclaration() |
172 { | |
173 return new TypeInfoStructDeclaration(this); | |
174 } | |
1 | 175 |
176 TypeInfoDeclaration *TypeClass::getTypeInfoDeclaration() | |
177 { | |
178 if (sym->isInterfaceDeclaration()) | |
179 return new TypeInfoInterfaceDeclaration(this); | |
180 else | |
181 return new TypeInfoClassDeclaration(this); | |
182 } | |
183 | |
184 TypeInfoDeclaration *TypeEnum::getTypeInfoDeclaration() | |
185 { | |
186 return new TypeInfoEnumDeclaration(this); | |
187 } | |
188 | |
189 TypeInfoDeclaration *TypeFunction::getTypeInfoDeclaration() | |
190 { | |
191 return new TypeInfoFunctionDeclaration(this); | |
192 } | |
193 | |
194 TypeInfoDeclaration *TypeDelegate::getTypeInfoDeclaration() | |
195 { | |
196 return new TypeInfoDelegateDeclaration(this); | |
197 } | |
198 | |
199 TypeInfoDeclaration *TypeTuple::getTypeInfoDeclaration() | |
200 { | |
201 return new TypeInfoTupleDeclaration(this); | |
202 } | |
203 | |
204 | |
205 /* ========================================================================= */ | |
206 | |
207 /* These decide if there's an instance for them already in std.typeinfo, | |
208 * because then the compiler doesn't need to build one. | |
209 */ | |
210 | |
211 int Type::builtinTypeInfo() | |
212 { | |
213 return 0; | |
214 } | |
215 | |
216 int TypeBasic::builtinTypeInfo() | |
217 { | |
218 return 1; | |
219 } | |
220 | |
221 int TypeDArray::builtinTypeInfo() | |
222 { | |
52 | 223 return next->isTypeBasic() != NULL; |
1 | 224 } |
225 | |
226 /* ========================================================================= */ | |
227 | |
228 /*************************************** | |
229 * Create a static array of TypeInfo references | |
230 * corresponding to an array of Expression's. | |
231 * Used to supply hidden _arguments[] value for variadic D functions. | |
232 */ | |
233 | |
57
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
54
diff
changeset
|
234 Expression *createTypeInfoArray(Scope *sc, Expression *exps[], int dim) |
1 | 235 { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
236 assert(0); // done elsewhere in llvmdc |
57
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
54
diff
changeset
|
237 return NULL; |
1 | 238 } |
239 | |
52 | 240 /* ========================================================================= */ |
241 | |
242 ////////////////////////////////////////////////////////////////////////////// | |
243 // MAGIC PLACE | |
244 ////////////////////////////////////////////////////////////////////////////// | |
245 | |
246 void TypeInfoDeclaration::toObjFile() | |
247 { | |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
248 gIR->resolveList.push_back(this); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
249 } |
57
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
54
diff
changeset
|
250 |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
251 void DtoResolveTypeInfo(TypeInfoDeclaration* tid) |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
252 { |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
253 if (tid->ir.resolved) return; |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
254 tid->ir.resolved = true; |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
255 |
132 | 256 Logger::println("DtoResolveTypeInfo(%s)", tid->toChars()); |
52 | 257 LOG_SCOPE; |
65 | 258 |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
259 tid->ir.irGlobal = new IrGlobal(tid); |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
260 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
261 gIR->declareList.push_back(tid); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
262 } |
98
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
96
diff
changeset
|
263 |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
264 void DtoDeclareTypeInfo(TypeInfoDeclaration* tid) |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
265 { |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
266 if (tid->ir.declared) return; |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
267 tid->ir.declared = true; |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
268 |
132 | 269 Logger::println("DtoDeclareTypeInfo(%s)", tid->toChars()); |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
270 LOG_SCOPE; |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
271 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
272 std::string mangled(tid->mangle()); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
273 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
274 Logger::println("type = '%s'", tid->tinfo->toChars()); |
98
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
96
diff
changeset
|
275 Logger::println("typeinfo mangle: %s", mangled.c_str()); |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
276 |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
277 // this is a declaration of a builtin __initZ var |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
278 if (tid->tinfo->builtinTypeInfo()) { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
279 LLValue* found = gIR->module->getNamedGlobal(mangled); |
132 | 280 if (!found) |
281 { | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
282 const LLType* t = llvm::OpaqueType::get(); |
132 | 283 llvm::GlobalVariable* g = new llvm::GlobalVariable(t, true, llvm::GlobalValue::ExternalLinkage, NULL, mangled, gIR->module); |
284 assert(g); | |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
285 /*if (!tid->ir.irGlobal) |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
286 tid->ir.irGlobal = new IrGlobal(tid);*/ |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
287 tid->ir.irGlobal->value = g; |
132 | 288 mangled.append("__TYPE"); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
289 gIR->module->addTypeName(mangled, tid->ir.irGlobal->value->getType()->getContainedType(0)); |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
290 Logger::println("Got typeinfo var: %s", tid->ir.irGlobal->value->getName().c_str()); |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
291 tid->ir.initialized = true; |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
292 tid->ir.defined = true; |
132 | 293 } |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
294 else if (!tid->ir.irGlobal->value) { |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
295 tid->ir.irGlobal->value = found; |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
296 tid->ir.initialized = true; |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
297 tid->ir.defined = true; |
132 | 298 } |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
299 } |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
300 // custom typedef |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
301 else { |
106 | 302 tid->llvmDeclare(); |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
303 gIR->constInitList.push_back(tid); |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
304 } |
52 | 305 } |
306 | |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
307 void DtoConstInitTypeInfo(TypeInfoDeclaration* tid) |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
308 { |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
309 if (tid->ir.initialized) return; |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
310 tid->ir.initialized = true; |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
311 |
132 | 312 Logger::println("DtoConstInitTypeInfo(%s)", tid->toChars()); |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
313 LOG_SCOPE; |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
314 |
106 | 315 gIR->defineList.push_back(tid); |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
316 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
317 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
318 void DtoDefineTypeInfo(TypeInfoDeclaration* tid) |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
319 { |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
320 if (tid->ir.defined) return; |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
321 tid->ir.defined = true; |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
322 |
132 | 323 Logger::println("DtoDefineTypeInfo(%s)", tid->toChars()); |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
324 LOG_SCOPE; |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
325 |
106 | 326 tid->llvmDefine(); |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
327 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
328 |
52 | 329 /* ========================================================================= */ |
330 | |
331 void TypeInfoDeclaration::toDt(dt_t **pdt) | |
332 { | |
106 | 333 assert(0 && "TypeInfoDeclaration::toDt"); |
334 } | |
335 | |
336 void TypeInfoDeclaration::llvmDeclare() | |
337 { | |
338 assert(0 && "TypeInfoDeclaration::llvmDeclare"); | |
339 } | |
340 | |
341 void TypeInfoDeclaration::llvmDefine() | |
342 { | |
343 assert(0 && "TypeInfoDeclaration::llvmDeclare"); | |
52 | 344 } |
345 | |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
346 /* ========================================================================= */ |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
347 |
106 | 348 void TypeInfoTypedefDeclaration::llvmDeclare() |
52 | 349 { |
106 | 350 Logger::println("TypeInfoTypedefDeclaration::llvmDeclare() %s", toChars()); |
351 LOG_SCOPE; | |
352 | |
353 ClassDeclaration* base = Type::typeinfotypedef; | |
354 DtoResolveClass(base); | |
355 | |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
356 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); |
106 | 357 |
358 // create the symbol | |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
359 this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); |
106 | 360 } |
361 | |
362 void TypeInfoTypedefDeclaration::llvmDefine() | |
363 { | |
364 Logger::println("TypeInfoTypedefDeclaration::llvmDefine() %s", toChars()); | |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
365 LOG_SCOPE; |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
366 |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
367 ClassDeclaration* base = Type::typeinfotypedef; |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
368 DtoForceConstInitDsymbol(base); |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
369 |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
370 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
371 Logger::cout() << "got stype: " << *stype << '\n'; |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
372 |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
373 // vtbl |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
374 std::vector<LLConstant*> sinits; |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
375 sinits.push_back(base->ir.irStruct->vtbl); |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
376 |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
377 // monitor |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
378 sinits.push_back(getNullPtr(getPtrToType(llvm::Type::Int8Ty))); |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
379 |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
380 assert(tinfo->ty == Ttypedef); |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
381 TypeTypedef *tc = (TypeTypedef *)tinfo; |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
382 TypedefDeclaration *sd = tc->sym; |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
383 |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
384 // TypeInfo base |
96 | 385 //const llvm::PointerType* basept = isaPointer(initZ->getOperand(1)->getType()); |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
386 //sinits.push_back(llvm::ConstantPointerNull::get(basept)); |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
387 Logger::println("generating base typeinfo"); |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
388 //sd->basetype = sd->basetype->merge(); |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
389 |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
390 sd->basetype->getTypeInfo(NULL); // generate vtinfo |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
391 assert(sd->basetype->vtinfo); |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
133
diff
changeset
|
392 DtoForceDeclareDsymbol(sd->basetype->vtinfo); |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
393 |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
394 assert(sd->basetype->vtinfo->ir.irGlobal->value); |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
395 assert(llvm::isa<llvm::Constant>(sd->basetype->vtinfo->ir.irGlobal->value)); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
396 LLConstant* castbase = llvm::cast<llvm::Constant>(sd->basetype->vtinfo->ir.irGlobal->value); |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
397 castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(2)); |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
398 sinits.push_back(castbase); |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
399 |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
400 // char[] name |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
401 char *name = sd->toPrettyChars(); |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
73
diff
changeset
|
402 sinits.push_back(DtoConstString(name)); |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
403 assert(sinits.back()->getType() == stype->getElementType(3)); |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
404 |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
405 // void[] init |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
406 const llvm::PointerType* initpt = getPtrToType(llvm::Type::Int8Ty); |
69
2b5a2eaa88be
[svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents:
65
diff
changeset
|
407 if (tinfo->isZeroInit() || !sd->init) // 0 initializer, or the same as the base type |
2b5a2eaa88be
[svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents:
65
diff
changeset
|
408 { |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
409 sinits.push_back(DtoConstSlice(DtoConstSize_t(0), getNullPtr(initpt))); |
69
2b5a2eaa88be
[svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents:
65
diff
changeset
|
410 } |
2b5a2eaa88be
[svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents:
65
diff
changeset
|
411 else |
2b5a2eaa88be
[svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents:
65
diff
changeset
|
412 { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
413 LLConstant* ci = DtoConstInitializer(sd->basetype, sd->init); |
69
2b5a2eaa88be
[svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents:
65
diff
changeset
|
414 std::string ciname(sd->mangle()); |
2b5a2eaa88be
[svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents:
65
diff
changeset
|
415 ciname.append("__init"); |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
73
diff
changeset
|
416 llvm::GlobalVariable* civar = new llvm::GlobalVariable(DtoType(sd->basetype),true,llvm::GlobalValue::InternalLinkage,ci,ciname,gIR->module); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
417 LLConstant* cicast = llvm::ConstantExpr::getBitCast(civar, initpt); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
418 size_t cisize = getTypeStoreSize(DtoType(sd->basetype)); |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
73
diff
changeset
|
419 sinits.push_back(DtoConstSlice(DtoConstSize_t(cisize), cicast)); |
69
2b5a2eaa88be
[svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents:
65
diff
changeset
|
420 } |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
421 |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
422 // create the symbol |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
423 LLConstant* tiInit = llvm::ConstantStruct::get(stype, sinits); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
424 isaGlobalVar(this->ir.irGlobal->value)->setInitializer(tiInit); |
106 | 425 } |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
426 |
106 | 427 void TypeInfoTypedefDeclaration::toDt(dt_t **pdt) |
428 { | |
429 assert(0); | |
52 | 430 } |
431 | |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
432 /* ========================================================================= */ |
52 | 433 |
106 | 434 void TypeInfoEnumDeclaration::llvmDeclare() |
52 | 435 { |
106 | 436 Logger::println("TypeInfoEnumDeclaration::llvmDeclare() %s", toChars()); |
437 LOG_SCOPE; | |
438 | |
439 ClassDeclaration* base = Type::typeinfoenum; | |
440 DtoResolveClass(base); | |
441 | |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
442 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); |
106 | 443 |
444 // create the symbol | |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
445 this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); |
106 | 446 } |
447 | |
448 void TypeInfoEnumDeclaration::llvmDefine() | |
449 { | |
450 Logger::println("TypeInfoEnumDeclaration::llvmDefine() %s", toChars()); | |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
451 LOG_SCOPE; |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
452 |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
453 ClassDeclaration* base = Type::typeinfoenum; |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
454 DtoForceConstInitDsymbol(base); |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
455 |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
456 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
457 |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
458 // vtbl |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
459 std::vector<LLConstant*> sinits; |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
460 sinits.push_back(base->ir.irStruct->vtbl); |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
461 |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
462 // monitor |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
463 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty))); |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
464 |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
465 assert(tinfo->ty == Tenum); |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
466 TypeEnum *tc = (TypeEnum *)tinfo; |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
467 EnumDeclaration *sd = tc->sym; |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
468 |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
469 // TypeInfo base |
96 | 470 //const llvm::PointerType* basept = isaPointer(initZ->getOperand(1)->getType()); |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
471 //sinits.push_back(llvm::ConstantPointerNull::get(basept)); |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
472 Logger::println("generating base typeinfo"); |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
473 //sd->basetype = sd->basetype->merge(); |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
474 |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
475 sd->memtype->getTypeInfo(NULL); // generate vtinfo |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
476 assert(sd->memtype->vtinfo); |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
133
diff
changeset
|
477 DtoForceDeclareDsymbol(sd->memtype->vtinfo); |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
478 |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
479 assert(llvm::isa<llvm::Constant>(sd->memtype->vtinfo->ir.irGlobal->value)); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
480 LLConstant* castbase = llvm::cast<llvm::Constant>(sd->memtype->vtinfo->ir.irGlobal->value); |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
481 castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(2)); |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
482 sinits.push_back(castbase); |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
483 |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
484 // char[] name |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
485 char *name = sd->toPrettyChars(); |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
73
diff
changeset
|
486 sinits.push_back(DtoConstString(name)); |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
487 assert(sinits.back()->getType() == stype->getElementType(3)); |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
488 |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
489 // void[] init |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
490 const llvm::PointerType* initpt = getPtrToType(llvm::Type::Int8Ty); |
71
53d3086b5ad3
[svn r75] Fixed the init member in custom enum typeinfo. I don't see any way this could actually need emmision though :/
lindquist
parents:
69
diff
changeset
|
491 if (tinfo->isZeroInit() || !sd->defaultval) // 0 initializer, or the same as the base type |
53d3086b5ad3
[svn r75] Fixed the init member in custom enum typeinfo. I don't see any way this could actually need emmision though :/
lindquist
parents:
69
diff
changeset
|
492 { |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
73
diff
changeset
|
493 sinits.push_back(DtoConstSlice(DtoConstSize_t(0), llvm::ConstantPointerNull::get(initpt))); |
71
53d3086b5ad3
[svn r75] Fixed the init member in custom enum typeinfo. I don't see any way this could actually need emmision though :/
lindquist
parents:
69
diff
changeset
|
494 } |
53d3086b5ad3
[svn r75] Fixed the init member in custom enum typeinfo. I don't see any way this could actually need emmision though :/
lindquist
parents:
69
diff
changeset
|
495 else |
53d3086b5ad3
[svn r75] Fixed the init member in custom enum typeinfo. I don't see any way this could actually need emmision though :/
lindquist
parents:
69
diff
changeset
|
496 { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
497 const LLType* memty = DtoType(sd->memtype); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
498 LLConstant* ci = llvm::ConstantInt::get(memty, sd->defaultval, !sd->memtype->isunsigned()); |
71
53d3086b5ad3
[svn r75] Fixed the init member in custom enum typeinfo. I don't see any way this could actually need emmision though :/
lindquist
parents:
69
diff
changeset
|
499 std::string ciname(sd->mangle()); |
53d3086b5ad3
[svn r75] Fixed the init member in custom enum typeinfo. I don't see any way this could actually need emmision though :/
lindquist
parents:
69
diff
changeset
|
500 ciname.append("__init"); |
53d3086b5ad3
[svn r75] Fixed the init member in custom enum typeinfo. I don't see any way this could actually need emmision though :/
lindquist
parents:
69
diff
changeset
|
501 llvm::GlobalVariable* civar = new llvm::GlobalVariable(memty,true,llvm::GlobalValue::InternalLinkage,ci,ciname,gIR->module); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
502 LLConstant* cicast = llvm::ConstantExpr::getBitCast(civar, initpt); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
503 size_t cisize = getTypeStoreSize(memty); |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
73
diff
changeset
|
504 sinits.push_back(DtoConstSlice(DtoConstSize_t(cisize), cicast)); |
71
53d3086b5ad3
[svn r75] Fixed the init member in custom enum typeinfo. I don't see any way this could actually need emmision though :/
lindquist
parents:
69
diff
changeset
|
505 } |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
506 |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
507 // create the symbol |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
508 LLConstant* tiInit = llvm::ConstantStruct::get(stype, sinits); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
509 isaGlobalVar(this->ir.irGlobal->value)->setInitializer(tiInit); |
106 | 510 } |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
511 |
106 | 512 void TypeInfoEnumDeclaration::toDt(dt_t **pdt) |
513 { | |
514 assert(0); | |
52 | 515 } |
516 | |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
517 /* ========================================================================= */ |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
518 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
519 static LLConstant* LLVM_D_Declare_TypeInfoBase(TypeInfoDeclaration* tid, ClassDeclaration* cd) |
106 | 520 { |
521 ClassDeclaration* base = cd; | |
522 DtoResolveClass(base); | |
523 | |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
524 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); |
106 | 525 |
526 // create the symbol | |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
527 tid->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,tid->toChars(),gIR->module); |
106 | 528 } |
529 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
530 static LLConstant* LLVM_D_Define_TypeInfoBase(Type* basetype, TypeInfoDeclaration* tid, ClassDeclaration* cd) |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
531 { |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
532 ClassDeclaration* base = cd; |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
533 DtoForceConstInitDsymbol(base); |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
534 |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
535 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
536 |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
537 // vtbl |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
538 std::vector<LLConstant*> sinits; |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
539 sinits.push_back(base->ir.irStruct->vtbl); |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
540 |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
541 // monitor |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
542 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty))); |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
543 |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
544 // TypeInfo base |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
545 Logger::println("generating base typeinfo"); |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
546 basetype->getTypeInfo(NULL); |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
547 assert(basetype->vtinfo); |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
133
diff
changeset
|
548 DtoForceDeclareDsymbol(basetype->vtinfo); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
549 assert(llvm::isa<llvm::Constant>(basetype->vtinfo->ir.irGlobal->value)); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
550 LLConstant* castbase = llvm::cast<llvm::Constant>(basetype->vtinfo->ir.irGlobal->value); |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
551 castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(2)); |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
552 sinits.push_back(castbase); |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
553 |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
554 // create the symbol |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
555 LLConstant* tiInit = llvm::ConstantStruct::get(stype, sinits); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
556 isaGlobalVar(tid->ir.irGlobal->value)->setInitializer(tiInit); |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
557 } |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
558 |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
559 /* ========================================================================= */ |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
560 |
106 | 561 void TypeInfoPointerDeclaration::llvmDeclare() |
52 | 562 { |
106 | 563 Logger::println("TypeInfoPointerDeclaration::llvmDeclare() %s", toChars()); |
564 LOG_SCOPE; | |
565 | |
566 assert(tinfo->ty == Tpointer); | |
567 TypePointer *tc = (TypePointer *)tinfo; | |
568 | |
569 LLVM_D_Declare_TypeInfoBase(this, Type::typeinfopointer); | |
570 } | |
571 | |
572 void TypeInfoPointerDeclaration::llvmDefine() | |
573 { | |
574 Logger::println("TypeInfoPointerDeclaration::llvmDefine() %s", toChars()); | |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
575 LOG_SCOPE; |
52 | 576 |
577 assert(tinfo->ty == Tpointer); | |
578 TypePointer *tc = (TypePointer *)tinfo; | |
579 | |
106 | 580 LLVM_D_Define_TypeInfoBase(tc->next, this, Type::typeinfopointer); |
581 } | |
582 | |
583 void TypeInfoPointerDeclaration::toDt(dt_t **pdt) | |
584 { | |
585 assert(0); | |
52 | 586 } |
587 | |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
588 /* ========================================================================= */ |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
589 |
106 | 590 void TypeInfoArrayDeclaration::llvmDeclare() |
52 | 591 { |
106 | 592 Logger::println("TypeInfoArrayDeclaration::llvmDeclare() %s", toChars()); |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
593 LOG_SCOPE; |
52 | 594 |
595 assert(tinfo->ty == Tarray); | |
596 TypeDArray *tc = (TypeDArray *)tinfo; | |
597 | |
106 | 598 LLVM_D_Declare_TypeInfoBase(this, Type::typeinfoarray); |
599 } | |
600 | |
601 void TypeInfoArrayDeclaration::llvmDefine() | |
602 { | |
603 Logger::println("TypeInfoArrayDeclaration::llvmDefine() %s", toChars()); | |
604 LOG_SCOPE; | |
605 | |
606 assert(tinfo->ty == Tarray); | |
607 TypeDArray *tc = (TypeDArray *)tinfo; | |
608 | |
609 LLVM_D_Define_TypeInfoBase(tc->next, this, Type::typeinfoarray); | |
610 } | |
611 | |
612 void TypeInfoArrayDeclaration::toDt(dt_t **pdt) | |
613 { | |
614 assert(0); | |
52 | 615 } |
616 | |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
617 /* ========================================================================= */ |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
618 |
106 | 619 void TypeInfoStaticArrayDeclaration::llvmDeclare() |
620 { | |
621 Logger::println("TypeInfoStaticArrayDeclaration::toDt() %s", toChars()); | |
622 LOG_SCOPE; | |
623 | |
624 // init typeinfo class | |
625 ClassDeclaration* base = Type::typeinfostaticarray; | |
626 DtoResolveClass(base); | |
627 | |
628 // get type of typeinfo class | |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
629 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); |
106 | 630 |
631 // create the symbol | |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
632 this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); |
106 | 633 } |
634 | |
635 void TypeInfoStaticArrayDeclaration::llvmDefine() | |
52 | 636 { |
105
182b41f56b7f
[svn r109] Fixed support for static array TypeInfo
lindquist
parents:
102
diff
changeset
|
637 Logger::println("TypeInfoStaticArrayDeclaration::toDt() %s", toChars()); |
182b41f56b7f
[svn r109] Fixed support for static array TypeInfo
lindquist
parents:
102
diff
changeset
|
638 LOG_SCOPE; |
182b41f56b7f
[svn r109] Fixed support for static array TypeInfo
lindquist
parents:
102
diff
changeset
|
639 |
182b41f56b7f
[svn r109] Fixed support for static array TypeInfo
lindquist
parents:
102
diff
changeset
|
640 // init typeinfo class |
182b41f56b7f
[svn r109] Fixed support for static array TypeInfo
lindquist
parents:
102
diff
changeset
|
641 ClassDeclaration* base = Type::typeinfostaticarray; |
182b41f56b7f
[svn r109] Fixed support for static array TypeInfo
lindquist
parents:
102
diff
changeset
|
642 DtoForceConstInitDsymbol(base); |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
643 |
105
182b41f56b7f
[svn r109] Fixed support for static array TypeInfo
lindquist
parents:
102
diff
changeset
|
644 // get type of typeinfo class |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
645 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); |
52 | 646 |
105
182b41f56b7f
[svn r109] Fixed support for static array TypeInfo
lindquist
parents:
102
diff
changeset
|
647 // initializer vector |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
648 std::vector<LLConstant*> sinits; |
105
182b41f56b7f
[svn r109] Fixed support for static array TypeInfo
lindquist
parents:
102
diff
changeset
|
649 // first is always the vtable |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
650 sinits.push_back(base->ir.irStruct->vtbl); |
105
182b41f56b7f
[svn r109] Fixed support for static array TypeInfo
lindquist
parents:
102
diff
changeset
|
651 |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
652 // monitor |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
653 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty))); |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
654 |
105
182b41f56b7f
[svn r109] Fixed support for static array TypeInfo
lindquist
parents:
102
diff
changeset
|
655 // value typeinfo |
52 | 656 assert(tinfo->ty == Tsarray); |
657 TypeSArray *tc = (TypeSArray *)tinfo; | |
658 tc->next->getTypeInfo(NULL); | |
105
182b41f56b7f
[svn r109] Fixed support for static array TypeInfo
lindquist
parents:
102
diff
changeset
|
659 |
182b41f56b7f
[svn r109] Fixed support for static array TypeInfo
lindquist
parents:
102
diff
changeset
|
660 // get symbol |
182b41f56b7f
[svn r109] Fixed support for static array TypeInfo
lindquist
parents:
102
diff
changeset
|
661 assert(tc->next->vtinfo); |
106 | 662 DtoForceDeclareDsymbol(tc->next->vtinfo); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
663 LLConstant* castbase = isaConstant(tc->next->vtinfo->ir.irGlobal->value); |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
664 castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(2)); |
105
182b41f56b7f
[svn r109] Fixed support for static array TypeInfo
lindquist
parents:
102
diff
changeset
|
665 sinits.push_back(castbase); |
52 | 666 |
105
182b41f56b7f
[svn r109] Fixed support for static array TypeInfo
lindquist
parents:
102
diff
changeset
|
667 // length |
182b41f56b7f
[svn r109] Fixed support for static array TypeInfo
lindquist
parents:
102
diff
changeset
|
668 sinits.push_back(DtoConstSize_t(tc->dim->toInteger())); |
182b41f56b7f
[svn r109] Fixed support for static array TypeInfo
lindquist
parents:
102
diff
changeset
|
669 |
182b41f56b7f
[svn r109] Fixed support for static array TypeInfo
lindquist
parents:
102
diff
changeset
|
670 // create the symbol |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
671 LLConstant* tiInit = llvm::ConstantStruct::get(stype, sinits); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
672 isaGlobalVar(this->ir.irGlobal->value)->setInitializer(tiInit); |
106 | 673 } |
105
182b41f56b7f
[svn r109] Fixed support for static array TypeInfo
lindquist
parents:
102
diff
changeset
|
674 |
106 | 675 void TypeInfoStaticArrayDeclaration::toDt(dt_t **pdt) |
676 { | |
677 assert(0); | |
52 | 678 } |
679 | |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
680 /* ========================================================================= */ |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
681 |
106 | 682 void TypeInfoAssociativeArrayDeclaration::llvmDeclare() |
683 { | |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
684 Logger::println("TypeInfoAssociativeArrayDeclaration::toDt() %s", toChars()); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
685 LOG_SCOPE; |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
686 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
687 // init typeinfo class |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
688 ClassDeclaration* base = Type::typeinfoassociativearray; |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
689 DtoResolveClass(base); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
690 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
691 // get type of typeinfo class |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
692 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
693 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
694 // create the symbol |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
695 this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); |
106 | 696 } |
697 | |
698 void TypeInfoAssociativeArrayDeclaration::llvmDefine() | |
699 { | |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
700 Logger::println("TypeInfoAssociativeArrayDeclaration::toDt() %s", toChars()); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
701 LOG_SCOPE; |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
702 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
703 // init typeinfo class |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
704 ClassDeclaration* base = Type::typeinfoassociativearray; |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
705 DtoForceConstInitDsymbol(base); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
706 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
707 // get type of typeinfo class |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
708 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
709 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
710 // initializer vector |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
711 std::vector<LLConstant*> sinits; |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
712 // first is always the vtable |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
713 sinits.push_back(base->ir.irStruct->vtbl); |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
714 |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
715 // monitor |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
716 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty))); |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
717 |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
718 // get type |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
719 assert(tinfo->ty == Taarray); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
720 TypeAArray *tc = (TypeAArray *)tinfo; |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
721 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
722 // value typeinfo |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
723 tc->next->getTypeInfo(NULL); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
724 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
725 // get symbol |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
726 assert(tc->next->vtinfo); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
727 DtoForceDeclareDsymbol(tc->next->vtinfo); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
728 LLConstant* castbase = isaConstant(tc->next->vtinfo->ir.irGlobal->value); |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
729 castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(2)); |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
730 sinits.push_back(castbase); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
731 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
732 // key typeinfo |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
733 tc->index->getTypeInfo(NULL); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
734 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
735 // get symbol |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
736 assert(tc->index->vtinfo); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
737 DtoForceDeclareDsymbol(tc->index->vtinfo); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
738 castbase = isaConstant(tc->index->vtinfo->ir.irGlobal->value); |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
739 castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(3)); |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
740 sinits.push_back(castbase); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
741 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
742 // create the symbol |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
743 LLConstant* tiInit = llvm::ConstantStruct::get(stype, sinits); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
744 isaGlobalVar(this->ir.irGlobal->value)->setInitializer(tiInit); |
106 | 745 } |
746 | |
52 | 747 void TypeInfoAssociativeArrayDeclaration::toDt(dt_t **pdt) |
748 { | |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
749 assert(0); |
52 | 750 } |
751 | |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
752 /* ========================================================================= */ |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
753 |
106 | 754 void TypeInfoFunctionDeclaration::llvmDeclare() |
755 { | |
756 Logger::println("TypeInfoFunctionDeclaration::toDt() %s", toChars()); | |
757 LOG_SCOPE; | |
758 | |
759 assert(tinfo->ty == Tfunction); | |
760 TypeFunction *tc = (TypeFunction *)tinfo; | |
761 | |
762 LLVM_D_Declare_TypeInfoBase(this, Type::typeinfofunction); | |
763 } | |
764 | |
765 void TypeInfoFunctionDeclaration::llvmDefine() | |
52 | 766 { |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
767 Logger::println("TypeInfoFunctionDeclaration::toDt() %s", toChars()); |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
768 LOG_SCOPE; |
52 | 769 |
770 assert(tinfo->ty == Tfunction); | |
771 TypeFunction *tc = (TypeFunction *)tinfo; | |
772 | |
106 | 773 LLVM_D_Define_TypeInfoBase(tc->next, this, Type::typeinfofunction); |
774 } | |
775 | |
776 void TypeInfoFunctionDeclaration::toDt(dt_t **pdt) | |
777 { | |
778 assert(0); | |
52 | 779 } |
780 | |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
781 /* ========================================================================= */ |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
782 |
106 | 783 void TypeInfoDelegateDeclaration::llvmDeclare() |
784 { | |
785 Logger::println("TypeInfoDelegateDeclaration::toDt() %s", toChars()); | |
786 LOG_SCOPE; | |
787 | |
788 assert(tinfo->ty == Tdelegate); | |
789 TypeDelegate *tc = (TypeDelegate *)tinfo; | |
790 | |
791 LLVM_D_Declare_TypeInfoBase(this, Type::typeinfodelegate); | |
792 } | |
793 | |
794 void TypeInfoDelegateDeclaration::llvmDefine() | |
52 | 795 { |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
796 Logger::println("TypeInfoDelegateDeclaration::toDt() %s", toChars()); |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
797 LOG_SCOPE; |
52 | 798 |
799 assert(tinfo->ty == Tdelegate); | |
800 TypeDelegate *tc = (TypeDelegate *)tinfo; | |
801 | |
106 | 802 LLVM_D_Define_TypeInfoBase(tc->next->next, this, Type::typeinfodelegate); |
803 } | |
804 | |
805 void TypeInfoDelegateDeclaration::toDt(dt_t **pdt) | |
806 { | |
807 assert(0); | |
52 | 808 } |
809 | |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
810 /* ========================================================================= */ |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
811 |
106 | 812 void TypeInfoStructDeclaration::llvmDeclare() |
52 | 813 { |
106 | 814 Logger::println("TypeInfoStructDeclaration::llvmDeclare() %s", toChars()); |
815 LOG_SCOPE; | |
816 | |
817 assert(tinfo->ty == Tstruct); | |
818 TypeStruct *tc = (TypeStruct *)tinfo; | |
819 StructDeclaration *sd = tc->sym; | |
820 DtoResolveDsymbol(sd); | |
821 | |
822 ClassDeclaration* base = Type::typeinfostruct; | |
823 DtoResolveClass(base); | |
824 | |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
825 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); |
106 | 826 |
827 // create the symbol | |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
828 this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); |
106 | 829 } |
830 | |
831 void TypeInfoStructDeclaration::llvmDefine() | |
832 { | |
833 Logger::println("TypeInfoStructDeclaration::llvmDefine() %s", toChars()); | |
72 | 834 LOG_SCOPE; |
835 | |
836 assert(tinfo->ty == Tstruct); | |
837 TypeStruct *tc = (TypeStruct *)tinfo; | |
838 StructDeclaration *sd = tc->sym; | |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
839 DtoForceConstInitDsymbol(sd); |
72 | 840 |
841 ClassDeclaration* base = Type::typeinfostruct; | |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
842 DtoForceConstInitDsymbol(base); |
72 | 843 |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
844 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); |
72 | 845 |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
846 // vtbl |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
847 std::vector<LLConstant*> sinits; |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
848 sinits.push_back(base->ir.irStruct->vtbl); |
72 | 849 |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
850 // monitor |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
851 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty))); |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
852 |
72 | 853 // char[] name |
854 char *name = sd->toPrettyChars(); | |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
73
diff
changeset
|
855 sinits.push_back(DtoConstString(name)); |
110
e8da7856a260
[svn r114] Implemented the ClassInfo.offTi member.
lindquist
parents:
109
diff
changeset
|
856 //Logger::println("************** A"); |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
857 assert(sinits.back()->getType() == stype->getElementType(2)); |
72 | 858 |
859 // void[] init | |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
860 const llvm::PointerType* initpt = getPtrToType(llvm::Type::Int8Ty); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
861 #if 0 |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
862 // the implementation of TypeInfo_Struct uses this to determine size. :/ |
72 | 863 if (sd->zeroInit) // 0 initializer, or the same as the base type |
864 { | |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
73
diff
changeset
|
865 sinits.push_back(DtoConstSlice(DtoConstSize_t(0), llvm::ConstantPointerNull::get(initpt))); |
72 | 866 } |
867 else | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
868 #endif |
72 | 869 { |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
870 size_t cisize = getTypeStoreSize(tc->ir.type->get()); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
871 LLConstant* cicast = llvm::ConstantExpr::getBitCast(sd->ir.irStruct->init, initpt); |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
73
diff
changeset
|
872 sinits.push_back(DtoConstSlice(DtoConstSize_t(cisize), cicast)); |
72 | 873 } |
874 | |
875 // toX functions ground work | |
876 FuncDeclaration *fd; | |
877 FuncDeclaration *fdx; | |
878 TypeFunction *tf; | |
879 Type *ta; | |
880 Dsymbol *s; | |
881 | |
882 static TypeFunction *tftohash; | |
883 static TypeFunction *tftostring; | |
884 | |
885 if (!tftohash) | |
886 { | |
887 Scope sc; | |
888 | |
889 tftohash = new TypeFunction(NULL, Type::thash_t, 0, LINKd); | |
890 tftohash = (TypeFunction *)tftohash->semantic(0, &sc); | |
891 | |
892 tftostring = new TypeFunction(NULL, Type::tchar->arrayOf(), 0, LINKd); | |
893 tftostring = (TypeFunction *)tftostring->semantic(0, &sc); | |
894 } | |
895 | |
896 TypeFunction *tfeqptr; | |
897 { | |
898 Scope sc; | |
899 Arguments *arguments = new Arguments; | |
900 Argument *arg = new Argument(STCin, tc->pointerTo(), NULL, NULL); | |
901 | |
902 arguments->push(arg); | |
903 tfeqptr = new TypeFunction(arguments, Type::tint32, 0, LINKd); | |
904 tfeqptr = (TypeFunction *)tfeqptr->semantic(0, &sc); | |
905 } | |
906 | |
907 #if 0 | |
908 TypeFunction *tfeq; | |
909 { | |
910 Scope sc; | |
911 Array *arguments = new Array; | |
912 Argument *arg = new Argument(In, tc, NULL, NULL); | |
913 | |
914 arguments->push(arg); | |
915 tfeq = new TypeFunction(arguments, Type::tint32, 0, LINKd); | |
916 tfeq = (TypeFunction *)tfeq->semantic(0, &sc); | |
917 } | |
918 #endif | |
919 | |
110
e8da7856a260
[svn r114] Implemented the ClassInfo.offTi member.
lindquist
parents:
109
diff
changeset
|
920 //Logger::println("************** B"); |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
921 const llvm::PointerType* ptty = isaPointer(stype->getElementType(4)); |
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
922 assert(ptty); |
72 | 923 |
924 s = search_function(sd, Id::tohash); | |
925 fdx = s ? s->isFuncDeclaration() : NULL; | |
926 if (fdx) | |
927 { | |
928 fd = fdx->overloadExactMatch(tftohash); | |
929 if (fd) { | |
132 | 930 DtoForceDeclareDsymbol(fd); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
931 assert(fd->ir.irFunc->func != 0); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
932 LLConstant* c = isaConstant(fd->ir.irFunc->func); |
72 | 933 assert(c); |
934 c = llvm::ConstantExpr::getBitCast(c, ptty); | |
935 sinits.push_back(c); | |
936 } | |
937 else { | |
938 //fdx->error("must be declared as extern (D) uint toHash()"); | |
939 sinits.push_back(llvm::ConstantPointerNull::get(ptty)); | |
940 } | |
941 } | |
942 else { | |
943 sinits.push_back(llvm::ConstantPointerNull::get(ptty)); | |
944 } | |
945 | |
946 s = search_function(sd, Id::eq); | |
947 fdx = s ? s->isFuncDeclaration() : NULL; | |
948 for (int i = 0; i < 2; i++) | |
949 { | |
110
e8da7856a260
[svn r114] Implemented the ClassInfo.offTi member.
lindquist
parents:
109
diff
changeset
|
950 //Logger::println("************** C %d", i); |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
951 ptty = isaPointer(stype->getElementType(5+i)); |
72 | 952 if (fdx) |
953 { | |
954 fd = fdx->overloadExactMatch(tfeqptr); | |
955 if (fd) { | |
132 | 956 DtoForceDeclareDsymbol(fd); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
957 assert(fd->ir.irFunc->func != 0); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
958 LLConstant* c = isaConstant(fd->ir.irFunc->func); |
72 | 959 assert(c); |
960 c = llvm::ConstantExpr::getBitCast(c, ptty); | |
961 sinits.push_back(c); | |
962 } | |
963 else { | |
964 //fdx->error("must be declared as extern (D) int %s(%s*)", fdx->toChars(), sd->toChars()); | |
965 sinits.push_back(llvm::ConstantPointerNull::get(ptty)); | |
966 } | |
967 } | |
968 else { | |
969 sinits.push_back(llvm::ConstantPointerNull::get(ptty)); | |
970 } | |
971 | |
972 s = search_function(sd, Id::cmp); | |
973 fdx = s ? s->isFuncDeclaration() : NULL; | |
974 } | |
975 | |
110
e8da7856a260
[svn r114] Implemented the ClassInfo.offTi member.
lindquist
parents:
109
diff
changeset
|
976 //Logger::println("************** D"); |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
977 ptty = isaPointer(stype->getElementType(7)); |
72 | 978 s = search_function(sd, Id::tostring); |
979 fdx = s ? s->isFuncDeclaration() : NULL; | |
980 if (fdx) | |
981 { | |
982 fd = fdx->overloadExactMatch(tftostring); | |
983 if (fd) { | |
132 | 984 DtoForceDeclareDsymbol(fd); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
985 assert(fd->ir.irFunc->func != 0); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
986 LLConstant* c = isaConstant(fd->ir.irFunc->func); |
72 | 987 assert(c); |
988 c = llvm::ConstantExpr::getBitCast(c, ptty); | |
989 sinits.push_back(c); | |
990 } | |
991 else { | |
992 //fdx->error("must be declared as extern (D) char[] toString()"); | |
993 sinits.push_back(llvm::ConstantPointerNull::get(ptty)); | |
994 } | |
995 } | |
996 else { | |
997 sinits.push_back(llvm::ConstantPointerNull::get(ptty)); | |
998 } | |
999 | |
1000 // uint m_flags; | |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
73
diff
changeset
|
1001 sinits.push_back(DtoConstUint(tc->hasPointers())); |
72 | 1002 |
1003 // create the symbol | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
1004 LLConstant* tiInit = llvm::ConstantStruct::get(stype, sinits); |
73 | 1005 llvm::GlobalVariable* gvar = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,tiInit,toChars(),gIR->module); |
72 | 1006 |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
1007 isaGlobalVar(this->ir.irGlobal->value)->setInitializer(tiInit); |
106 | 1008 } |
1009 | |
1010 void TypeInfoStructDeclaration::toDt(dt_t **pdt) | |
1011 { | |
1012 assert(0); | |
52 | 1013 } |
1014 | |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1015 /* ========================================================================= */ |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1016 |
106 | 1017 void TypeInfoClassDeclaration::llvmDeclare() |
1018 { | |
1019 Logger::println("TypeInfoClassDeclaration::llvmDeclare() %s", toChars()); | |
1020 LOG_SCOPE; | |
1021 | |
1022 // init typeinfo class | |
1023 ClassDeclaration* base = Type::typeinfoclass; | |
1024 assert(base); | |
1025 DtoResolveClass(base); | |
1026 | |
1027 // get type of typeinfo class | |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
1028 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); |
106 | 1029 |
1030 // create the symbol | |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
1031 this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); |
106 | 1032 } |
1033 | |
1034 void TypeInfoClassDeclaration::llvmDefine() | |
1035 { | |
1036 Logger::println("TypeInfoClassDeclaration::llvmDefine() %s", toChars()); | |
1037 LOG_SCOPE; | |
1038 | |
1039 // init typeinfo class | |
1040 ClassDeclaration* base = Type::typeinfoclass; | |
1041 assert(base); | |
1042 DtoForceConstInitDsymbol(base); | |
1043 | |
1044 // get type of typeinfo class | |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
1045 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); |
106 | 1046 |
1047 // initializer vector | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
1048 std::vector<LLConstant*> sinits; |
106 | 1049 // first is always the vtable |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
1050 sinits.push_back(base->ir.irStruct->vtbl); |
106 | 1051 |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
1052 // monitor |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1053 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty))); |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
1054 |
106 | 1055 // get classinfo |
1056 assert(tinfo->ty == Tclass); | |
1057 TypeClass *tc = (TypeClass *)tinfo; | |
163
a8cd9bc1021a
[svn r179] lots and lots of fixes, much more of tango now compiles/works.
lindquist
parents:
157
diff
changeset
|
1058 DtoForceDeclareDsymbol(tc->sym); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
1059 assert(tc->sym->ir.irStruct->classInfo); |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
1060 sinits.push_back(tc->sym->ir.irStruct->classInfo); |
106 | 1061 |
1062 // create the symbol | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
1063 LLConstant* tiInit = llvm::ConstantStruct::get(stype, sinits); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
1064 isaGlobalVar(this->ir.irGlobal->value)->setInitializer(tiInit); |
106 | 1065 } |
1066 | |
52 | 1067 void TypeInfoClassDeclaration::toDt(dt_t **pdt) |
1068 { | |
106 | 1069 assert(0); |
52 | 1070 } |
1071 | |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1072 /* ========================================================================= */ |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1073 |
106 | 1074 void TypeInfoInterfaceDeclaration::llvmDeclare() |
1075 { | |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1076 Logger::println("TypeInfoInterfaceDeclaration::llvmDeclare() %s", toChars()); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1077 LOG_SCOPE; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1078 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1079 // init typeinfo class |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1080 ClassDeclaration* base = Type::typeinfointerface; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1081 assert(base); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1082 DtoResolveClass(base); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1083 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1084 // get type of typeinfo class |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
1085 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1086 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1087 // create the symbol |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
1088 this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); |
106 | 1089 } |
1090 | |
1091 void TypeInfoInterfaceDeclaration::llvmDefine() | |
1092 { | |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1093 Logger::println("TypeInfoInterfaceDeclaration::llvmDefine() %s", toChars()); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1094 LOG_SCOPE; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1095 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1096 // init typeinfo class |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1097 ClassDeclaration* base = Type::typeinfointerface; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1098 assert(base); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1099 DtoForceConstInitDsymbol(base); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1100 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1101 // get type of typeinfo class |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
1102 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1103 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1104 // initializer vector |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
1105 std::vector<LLConstant*> sinits; |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1106 // first is always the vtable |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
1107 sinits.push_back(base->ir.irStruct->vtbl); |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1108 |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
1109 // monitor |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1110 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty))); |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
1111 |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1112 // get classinfo |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1113 assert(tinfo->ty == Tclass); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1114 TypeClass *tc = (TypeClass *)tinfo; |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
1115 assert(tc->sym->ir.irStruct->classInfo); |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
1116 sinits.push_back(tc->sym->ir.irStruct->classInfo); |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1117 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1118 // create the symbol |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
1119 LLConstant* tiInit = llvm::ConstantStruct::get(stype, sinits); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
1120 isaGlobalVar(this->ir.irGlobal->value)->setInitializer(tiInit); |
106 | 1121 } |
1122 | |
52 | 1123 void TypeInfoInterfaceDeclaration::toDt(dt_t **pdt) |
1124 { | |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1125 assert(0); |
52 | 1126 } |
1127 | |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1128 /* ========================================================================= */ |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1129 |
106 | 1130 void TypeInfoTupleDeclaration::llvmDeclare() |
1131 { | |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1132 Logger::println("TypeInfoTupleDeclaration::llvmDeclare() %s", toChars()); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1133 LOG_SCOPE; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1134 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1135 // init typeinfo class |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1136 ClassDeclaration* base = Type::typeinfotypelist; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1137 assert(base); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1138 DtoResolveClass(base); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1139 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1140 // get type of typeinfo class |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
1141 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1142 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1143 // create the symbol |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
1144 this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); |
106 | 1145 } |
1146 | |
1147 void TypeInfoTupleDeclaration::llvmDefine() | |
1148 { | |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1149 Logger::println("TypeInfoTupleDeclaration::llvmDefine() %s", toChars()); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1150 LOG_SCOPE; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1151 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1152 // init typeinfo class |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1153 ClassDeclaration* base = Type::typeinfotypelist; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1154 assert(base); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1155 DtoForceConstInitDsymbol(base); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1156 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1157 // get type of typeinfo class |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
1158 const llvm::StructType* stype = isaStruct(base->type->ir.type->get()); |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1159 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1160 // initializer vector |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
1161 std::vector<LLConstant*> sinits; |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1162 // first is always the vtable |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
1163 sinits.push_back(base->ir.irStruct->vtbl); |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1164 |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
1165 // monitor |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1166 sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty))); |
115
5ba6d286c941
[svn r119] Added the monitor data field that comes after the vtable pointer to all classes. Represented as a void* initialized to zero.
lindquist
parents:
113
diff
changeset
|
1167 |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1168 // create elements array |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1169 assert(tinfo->ty == Ttuple); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1170 TypeTuple *tu = (TypeTuple *)tinfo; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1171 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1172 size_t dim = tu->arguments->dim; |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
1173 std::vector<LLConstant*> arrInits; |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1174 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
1175 const LLType* tiTy = Type::typeinfo->type->ir.type->get(); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1176 tiTy = getPtrToType(tiTy); |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1177 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1178 for (size_t i = 0; i < dim; i++) |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1179 { |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1180 Argument *arg = (Argument *)tu->arguments->data[i]; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1181 arg->type->getTypeInfo(NULL); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1182 DtoForceDeclareDsymbol(arg->type->vtinfo); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
1183 assert(arg->type->vtinfo->ir.irGlobal->value); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
1184 LLConstant* c = isaConstant(arg->type->vtinfo->ir.irGlobal->value); |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1185 c = llvm::ConstantExpr::getBitCast(c, tiTy); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1186 arrInits.push_back(c); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1187 } |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1188 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1189 // build array type |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1190 const llvm::ArrayType* arrTy = llvm::ArrayType::get(tiTy, dim); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
1191 LLConstant* arrC = llvm::ConstantArray::get(arrTy, arrInits); |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1192 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1193 // build the slice |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
1194 LLConstant* slice = DtoConstSlice(DtoConstSize_t(dim), arrC); |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1195 sinits.push_back(slice); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1196 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1197 // create the symbol |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
1198 LLConstant* tiInit = llvm::ConstantStruct::get(stype, sinits); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
1199 isaGlobalVar(this->ir.irGlobal->value)->setInitializer(tiInit); |
106 | 1200 } |
1201 | |
52 | 1202 void TypeInfoTupleDeclaration::toDt(dt_t **pdt) |
1203 { | |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
1204 assert(0); |
52 | 1205 } |