Mercurial > projects > ldc
annotate gen/typinf.cpp @ 1634:9cc791423e20
Fix typo for iretq
author | Kelly Wilson <wilsonk cpsc.ucalgary.ca> |
---|---|
date | Thu, 25 Feb 2010 17:12:54 -0700 |
parents | 207a8a438dea |
children |
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 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
622
diff
changeset
|
11 // Modifications for LDC: |
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
|
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" |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
213
diff
changeset
|
38 #include "gen/llvmhelpers.h" |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
39 #include "gen/arrays.h" |
100 | 40 #include "gen/structs.h" |
106 | 41 #include "gen/classes.h" |
1064
f0b6549055ab
Make LDC work with LLVM trunk (s/LinkOnceLinkage/LinkOnceOdrLinkage/)
Frits van Bommel <fvbommel wxs.nl>
parents:
918
diff
changeset
|
42 #include "gen/linkage.h" |
1284
5851c18e4c6d
Add metadata for TypeInfo -> llvm::Type mapping.
Frits van Bommel <fvbommel wxs.nl>
parents:
1283
diff
changeset
|
43 #include "gen/metadata.h" |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
44 #include "gen/rttibuilder.h" |
1 | 45 |
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
|
46 #include "ir/irvar.h" |
1364
46f6365a50d7
Added IrTypeFunction and IrTypeDelegate and eliminated IrDType. This means the Type::ir field can be removed. It's the final part needed for the move to a slightly more sane type system. Now the whole thing just needs to be cleaned up :P
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1358
diff
changeset
|
47 #include "ir/irtype.h" |
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
|
48 |
1 | 49 /******************************************* |
50 * Get a canonicalized form of the TypeInfo for use with the internal | |
51 * runtime library routines. Canonicalized in that static arrays are | |
52 * represented as dynamic arrays, enums are represented by their | |
53 * underlying type, etc. This reduces the number of TypeInfo's needed, | |
54 * so we can use the custom internal ones more. | |
55 */ | |
56 | |
57 Expression *Type::getInternalTypeInfo(Scope *sc) | |
58 { TypeInfoDeclaration *tid; | |
59 Expression *e; | |
60 Type *t; | |
61 static TypeInfoDeclaration *internalTI[TMAX]; | |
62 | |
63 //printf("Type::getInternalTypeInfo() %s\n", toChars()); | |
64 t = toBasetype(); | |
65 switch (t->ty) | |
66 { | |
67 case Tsarray: | |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
68 #if 0 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
69 // convert to corresponding dynamic array type |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
70 t = t->nextOf()->mutableOf()->arrayOf(); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
71 #endif |
1 | 72 break; |
73 | |
74 case Tclass: | |
75 if (((TypeClass *)t)->sym->isInterfaceDeclaration()) | |
76 break; | |
77 goto Linternal; | |
78 | |
79 case Tarray: | |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
80 #if DMDV2 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
81 // convert to corresponding dynamic array type |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
82 t = t->nextOf()->mutableOf()->arrayOf(); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
83 #endif |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
84 if (t->nextOf()->ty != Tclass) |
1 | 85 break; |
86 goto Linternal; | |
87 | |
88 case Tfunction: | |
89 case Tdelegate: | |
90 case Tpointer: | |
91 Linternal: | |
92 tid = internalTI[t->ty]; | |
93 if (!tid) | |
94 { tid = new TypeInfoDeclaration(t, 1); | |
95 internalTI[t->ty] = tid; | |
96 } | |
97 e = new VarExp(0, tid); | |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
98 e = e->addressOf(sc); |
1 | 99 e->type = tid->type; // do this so we don't get redundant dereference |
100 return e; | |
101 | |
102 default: | |
103 break; | |
104 } | |
105 //printf("\tcalling getTypeInfo() %s\n", t->toChars()); | |
106 return t->getTypeInfo(sc); | |
107 } | |
108 | |
109 /**************************************************** | |
110 * Get the exact TypeInfo. | |
111 */ | |
112 | |
113 Expression *Type::getTypeInfo(Scope *sc) | |
114 { | |
115 Expression *e; | |
116 Type *t; | |
117 | |
118 //printf("Type::getTypeInfo() %p, %s\n", this, toChars()); | |
119 t = merge(); // do this since not all Type's are merge'd | |
120 if (!t->vtinfo) | |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
121 { |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
122 #if DMDV2 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
123 if (t->isConst()) |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
124 t->vtinfo = new TypeInfoConstDeclaration(t); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
125 else if (t->isInvariant()) |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
126 t->vtinfo = new TypeInfoInvariantDeclaration(t); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
127 else |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
128 #endif |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
129 t->vtinfo = t->getTypeInfoDeclaration(); |
1 | 130 assert(t->vtinfo); |
131 | |
132 /* If this has a custom implementation in std/typeinfo, then | |
133 * do not generate a COMDAT for it. | |
134 */ | |
135 if (!t->builtinTypeInfo()) | |
136 { // Generate COMDAT | |
137 if (sc) // if in semantic() pass | |
138 { // Find module that will go all the way to an object file | |
139 Module *m = sc->module->importedFrom; | |
140 m->members->push(t->vtinfo); | |
141 } | |
142 else // if in obj generation pass | |
143 { | |
1147
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
144 #if IN_DMD |
336 | 145 t->vtinfo->toObjFile(0); // TODO: multiobj |
1147
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
146 #else |
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
147 t->vtinfo->codegen(sir); |
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
148 #endif |
1 | 149 } |
150 } | |
151 } | |
152 e = new VarExp(0, t->vtinfo); | |
1147
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
153 e = e->addressOf(sc); |
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
154 e->type = t->vtinfo->type; // do this so we don't get redundant dereference |
1 | 155 return e; |
156 } | |
157 | |
52 | 158 enum RET TypeFunction::retStyle() |
159 { | |
160 return RETstack; | |
161 } | |
1 | 162 |
163 TypeInfoDeclaration *Type::getTypeInfoDeclaration() | |
164 { | |
165 //printf("Type::getTypeInfoDeclaration() %s\n", toChars()); | |
166 return new TypeInfoDeclaration(this, 0); | |
167 } | |
168 | |
52 | 169 TypeInfoDeclaration *TypeTypedef::getTypeInfoDeclaration() |
1 | 170 { |
52 | 171 return new TypeInfoTypedefDeclaration(this); |
1 | 172 } |
173 | |
52 | 174 TypeInfoDeclaration *TypePointer::getTypeInfoDeclaration() |
175 { | |
176 return new TypeInfoPointerDeclaration(this); | |
177 } | |
1 | 178 |
179 TypeInfoDeclaration *TypeDArray::getTypeInfoDeclaration() | |
180 { | |
181 return new TypeInfoArrayDeclaration(this); | |
182 } | |
183 | |
184 TypeInfoDeclaration *TypeSArray::getTypeInfoDeclaration() | |
185 { | |
186 return new TypeInfoStaticArrayDeclaration(this); | |
187 } | |
188 | |
189 TypeInfoDeclaration *TypeAArray::getTypeInfoDeclaration() | |
190 { | |
191 return new TypeInfoAssociativeArrayDeclaration(this); | |
192 } | |
193 | |
52 | 194 TypeInfoDeclaration *TypeStruct::getTypeInfoDeclaration() |
195 { | |
196 return new TypeInfoStructDeclaration(this); | |
197 } | |
1 | 198 |
199 TypeInfoDeclaration *TypeClass::getTypeInfoDeclaration() | |
200 { | |
201 if (sym->isInterfaceDeclaration()) | |
202 return new TypeInfoInterfaceDeclaration(this); | |
203 else | |
204 return new TypeInfoClassDeclaration(this); | |
205 } | |
206 | |
207 TypeInfoDeclaration *TypeEnum::getTypeInfoDeclaration() | |
208 { | |
209 return new TypeInfoEnumDeclaration(this); | |
210 } | |
211 | |
212 TypeInfoDeclaration *TypeFunction::getTypeInfoDeclaration() | |
213 { | |
214 return new TypeInfoFunctionDeclaration(this); | |
215 } | |
216 | |
217 TypeInfoDeclaration *TypeDelegate::getTypeInfoDeclaration() | |
218 { | |
219 return new TypeInfoDelegateDeclaration(this); | |
220 } | |
221 | |
222 TypeInfoDeclaration *TypeTuple::getTypeInfoDeclaration() | |
223 { | |
224 return new TypeInfoTupleDeclaration(this); | |
225 } | |
226 | |
227 | |
228 /* ========================================================================= */ | |
229 | |
230 /* These decide if there's an instance for them already in std.typeinfo, | |
231 * because then the compiler doesn't need to build one. | |
232 */ | |
233 | |
234 int Type::builtinTypeInfo() | |
235 { | |
236 return 0; | |
237 } | |
238 | |
239 int TypeBasic::builtinTypeInfo() | |
240 { | |
764
8e7d4ddab66d
Forgot D2 versioning on typeinfo change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
763
diff
changeset
|
241 #if DMDV2 |
763
9a9f403ab399
D2 changes!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
761
diff
changeset
|
242 return !mod; |
764
8e7d4ddab66d
Forgot D2 versioning on typeinfo change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
763
diff
changeset
|
243 #else |
8e7d4ddab66d
Forgot D2 versioning on typeinfo change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
763
diff
changeset
|
244 return 1; |
8e7d4ddab66d
Forgot D2 versioning on typeinfo change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
763
diff
changeset
|
245 #endif |
1 | 246 } |
247 | |
248 int TypeDArray::builtinTypeInfo() | |
249 { | |
763
9a9f403ab399
D2 changes!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
761
diff
changeset
|
250 #if DMDV2 |
9a9f403ab399
D2 changes!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
761
diff
changeset
|
251 return !mod && next->isTypeBasic() != NULL && !next->mod; |
9a9f403ab399
D2 changes!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
761
diff
changeset
|
252 #else |
52 | 253 return next->isTypeBasic() != NULL; |
763
9a9f403ab399
D2 changes!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
761
diff
changeset
|
254 #endif |
1 | 255 } |
256 | |
1367
8026319762be
Merged DMD 1.045 !!!
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1364
diff
changeset
|
257 int TypeClass::builtinTypeInfo() |
8026319762be
Merged DMD 1.045 !!!
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1364
diff
changeset
|
258 { |
8026319762be
Merged DMD 1.045 !!!
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1364
diff
changeset
|
259 /* This is statically put out with the ClassInfo, so |
8026319762be
Merged DMD 1.045 !!!
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1364
diff
changeset
|
260 * claim it is built in so it isn't regenerated by each module. |
8026319762be
Merged DMD 1.045 !!!
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1364
diff
changeset
|
261 */ |
8026319762be
Merged DMD 1.045 !!!
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1364
diff
changeset
|
262 #if IN_DMD |
8026319762be
Merged DMD 1.045 !!!
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1364
diff
changeset
|
263 return 1; |
8026319762be
Merged DMD 1.045 !!!
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1364
diff
changeset
|
264 #elif IN_LLVM |
8026319762be
Merged DMD 1.045 !!!
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1364
diff
changeset
|
265 // FIXME if I enable this, the way LDC does typeinfo will cause a bunch |
8026319762be
Merged DMD 1.045 !!!
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1364
diff
changeset
|
266 // of linker errors to missing class typeinfo definitions. |
8026319762be
Merged DMD 1.045 !!!
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1364
diff
changeset
|
267 return 0; |
8026319762be
Merged DMD 1.045 !!!
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1364
diff
changeset
|
268 #endif |
8026319762be
Merged DMD 1.045 !!!
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1364
diff
changeset
|
269 } |
8026319762be
Merged DMD 1.045 !!!
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1364
diff
changeset
|
270 |
1 | 271 /* ========================================================================= */ |
272 | |
52 | 273 ////////////////////////////////////////////////////////////////////////////// |
274 // MAGIC PLACE | |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
275 // (wut?) |
52 | 276 ////////////////////////////////////////////////////////////////////////////// |
277 | |
1148
3d1b16dabd25
Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
278 void DtoResolveTypeInfo(TypeInfoDeclaration* tid); |
3d1b16dabd25
Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
279 void DtoDeclareTypeInfo(TypeInfoDeclaration* tid); |
3d1b16dabd25
Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
280 |
3d1b16dabd25
Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
281 void TypeInfoDeclaration::codegen(Ir*) |
3d1b16dabd25
Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
282 { |
3d1b16dabd25
Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
283 DtoResolveTypeInfo(this); |
3d1b16dabd25
Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
284 } |
3d1b16dabd25
Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
285 |
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
|
286 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
|
287 { |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
288 if (tid->ir.resolved) return; |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
289 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
|
290 |
132 | 291 Logger::println("DtoResolveTypeInfo(%s)", tid->toChars()); |
52 | 292 LOG_SCOPE; |
65 | 293 |
1148
3d1b16dabd25
Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
294 IrGlobal* irg = new IrGlobal(tid); |
1156
19d4ded7204a
Fixed issue with runtime supplied typeinfo generating multiple symbols.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1148
diff
changeset
|
295 |
19d4ded7204a
Fixed issue with runtime supplied typeinfo generating multiple symbols.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1148
diff
changeset
|
296 std::string mangle(tid->mangle()); |
19d4ded7204a
Fixed issue with runtime supplied typeinfo generating multiple symbols.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1148
diff
changeset
|
297 |
19d4ded7204a
Fixed issue with runtime supplied typeinfo generating multiple symbols.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1148
diff
changeset
|
298 irg->value = gIR->module->getGlobalVariable(mangle); |
19d4ded7204a
Fixed issue with runtime supplied typeinfo generating multiple symbols.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1148
diff
changeset
|
299 if (!irg->value) |
1529
ad7f2f1862d6
Adjust LDC to work with the LLVMContext LLVM changes.
Christian Kamm <kamm incasoftware de>
parents:
1482
diff
changeset
|
300 irg->value = new llvm::GlobalVariable(*gIR->module, irg->type.get(), true, |
ad7f2f1862d6
Adjust LDC to work with the LLVMContext LLVM changes.
Christian Kamm <kamm incasoftware de>
parents:
1482
diff
changeset
|
301 TYPEINFO_LINKAGE_TYPE, NULL, mangle); |
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
|
302 |
1148
3d1b16dabd25
Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
303 tid->ir.irGlobal = irg; |
98
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
96
diff
changeset
|
304 |
1558
3adcb70700cb
Added back option to disable metadata generation and users. Set USE_METADATA to OFF in ccmake.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1557
diff
changeset
|
305 #if USE_METADATA |
1557
d11aeae19b95
Disable metadata for typeid(void).
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1555
diff
changeset
|
306 // don't do this for void or llvm will crash |
d11aeae19b95
Disable metadata for typeid(void).
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1555
diff
changeset
|
307 if (tid->tinfo->ty != Tvoid) { |
d11aeae19b95
Disable metadata for typeid(void).
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1555
diff
changeset
|
308 // Add some metadata for use by optimization passes. |
d11aeae19b95
Disable metadata for typeid(void).
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1555
diff
changeset
|
309 std::string metaname = std::string(TD_PREFIX) + mangle; |
d11aeae19b95
Disable metadata for typeid(void).
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1555
diff
changeset
|
310 llvm::NamedMDNode* meta = gIR->module->getNamedMetadata(metaname); |
d11aeae19b95
Disable metadata for typeid(void).
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1555
diff
changeset
|
311 // Don't generate metadata for non-concrete types |
d11aeae19b95
Disable metadata for typeid(void).
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1555
diff
changeset
|
312 // (such as tuple types, slice types, typeof(expr), etc.) |
d11aeae19b95
Disable metadata for typeid(void).
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1555
diff
changeset
|
313 if (!meta && tid->tinfo->toBasetype()->ty < Terror) { |
d11aeae19b95
Disable metadata for typeid(void).
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1555
diff
changeset
|
314 // Construct the fields |
d11aeae19b95
Disable metadata for typeid(void).
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1555
diff
changeset
|
315 MDNodeField* mdVals[TD_NumFields]; |
d11aeae19b95
Disable metadata for typeid(void).
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1555
diff
changeset
|
316 if (TD_Confirm >= 0) |
d11aeae19b95
Disable metadata for typeid(void).
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1555
diff
changeset
|
317 mdVals[TD_Confirm] = llvm::cast<MDNodeField>(irg->value); |
d11aeae19b95
Disable metadata for typeid(void).
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1555
diff
changeset
|
318 mdVals[TD_Type] = llvm::UndefValue::get(DtoType(tid->tinfo)); |
d11aeae19b95
Disable metadata for typeid(void).
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1555
diff
changeset
|
319 // Construct the metadata |
1562
95d710d405e3
Fixed compiling with llvm rev > 77732
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1561
diff
changeset
|
320 llvm::MetadataBase* metadata = llvm::MDNode::get(gIR->context(), mdVals, TD_NumFields); |
1557
d11aeae19b95
Disable metadata for typeid(void).
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1555
diff
changeset
|
321 // Insert it into the module |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
322 llvm::NamedMDNode::Create(gIR->context(), metaname, &metadata, 1, gIR->module); |
1557
d11aeae19b95
Disable metadata for typeid(void).
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1555
diff
changeset
|
323 } |
1284
5851c18e4c6d
Add metadata for TypeInfo -> llvm::Type mapping.
Frits van Bommel <fvbommel wxs.nl>
parents:
1283
diff
changeset
|
324 } |
1558
3adcb70700cb
Added back option to disable metadata generation and users. Set USE_METADATA to OFF in ccmake.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1557
diff
changeset
|
325 #endif // USE_METADATA |
1284
5851c18e4c6d
Add metadata for TypeInfo -> llvm::Type mapping.
Frits van Bommel <fvbommel wxs.nl>
parents:
1283
diff
changeset
|
326 |
1148
3d1b16dabd25
Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
327 DtoDeclareTypeInfo(tid); |
1147
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
328 } |
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
329 |
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
|
330 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
|
331 { |
1148
3d1b16dabd25
Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
332 DtoResolveTypeInfo(tid); |
3d1b16dabd25
Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
333 |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
334 if (tid->ir.declared) return; |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
335 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
|
336 |
132 | 337 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
|
338 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
|
339 |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
340 if (Logger::enabled()) |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
341 { |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
342 std::string mangled(tid->mangle()); |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
343 Logger::println("type = '%s'", tid->tinfo->toChars()); |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
344 Logger::println("typeinfo mangle: %s", mangled.c_str()); |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
345 } |
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
|
346 |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
347 IrGlobal* irg = tid->ir.irGlobal; |
1148
3d1b16dabd25
Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
348 assert(irg->value != NULL); |
3d1b16dabd25
Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
349 |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
350 // 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
|
351 if (tid->tinfo->builtinTypeInfo()) { |
1148
3d1b16dabd25
Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
352 // fixup the global |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
353 const llvm::Type* rty = Type::typeinfo->type->irtype->getPA(); |
1148
3d1b16dabd25
Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
354 llvm::cast<llvm::OpaqueType>(irg->type.get())->refineAbstractTypeTo(rty); |
3d1b16dabd25
Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
355 LLGlobalVariable* g = isaGlobalVar(irg->value); |
3d1b16dabd25
Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
356 g->setLinkage(llvm::GlobalValue::ExternalLinkage); |
3d1b16dabd25
Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
357 return; |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
358 } |
1148
3d1b16dabd25
Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
359 |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
360 // define custom typedef |
1148
3d1b16dabd25
Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
361 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
|
362 } |
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
|
363 |
52 | 364 /* ========================================================================= */ |
365 | |
106 | 366 void TypeInfoDeclaration::llvmDefine() |
367 { | |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
368 assert(0 && "cannot generate generic typeinfo"); |
52 | 369 } |
370 | |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
371 /* ========================================================================= */ |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
372 |
106 | 373 void TypeInfoTypedefDeclaration::llvmDefine() |
374 { | |
375 Logger::println("TypeInfoTypedefDeclaration::llvmDefine() %s", toChars()); | |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
376 LOG_SCOPE; |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
377 |
1382
a0a4d4dac1a4
Renamed !TypeInfoBuilder to !RTTIBuilder.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1376
diff
changeset
|
378 RTTIBuilder b(Type::typeinfotypedef); |
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 |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
385 sd->basetype = sd->basetype->merge(); // dmd does it ... why? |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
386 b.push_typeinfo(sd->basetype); |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
387 |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
388 // char[] name |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
389 b.push_string(sd->toPrettyChars()); |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
390 |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
391 // void[] init |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
392 // emit null array if we should use the basetype, or if the basetype |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
393 // uses default initialization. |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
394 if (!sd->init || tinfo->isZeroInit(0)) |
69
2b5a2eaa88be
[svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents:
65
diff
changeset
|
395 { |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
396 b.push_null_void_array(); |
69
2b5a2eaa88be
[svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents:
65
diff
changeset
|
397 } |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
398 // otherwise emit a void[] with the default initializer |
69
2b5a2eaa88be
[svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents:
65
diff
changeset
|
399 else |
2b5a2eaa88be
[svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents:
65
diff
changeset
|
400 { |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
401 LLConstant* C = DtoConstInitializer(sd->loc, sd->basetype, sd->init); |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
402 b.push_void_array(C, sd->basetype, sd); |
69
2b5a2eaa88be
[svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents:
65
diff
changeset
|
403 } |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
404 |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
405 // finish |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
406 b.finalize(ir.irGlobal); |
106 | 407 } |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
52
diff
changeset
|
408 |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
409 /* ========================================================================= */ |
52 | 410 |
106 | 411 void TypeInfoEnumDeclaration::llvmDefine() |
412 { | |
413 Logger::println("TypeInfoEnumDeclaration::llvmDefine() %s", toChars()); | |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
414 LOG_SCOPE; |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
415 |
1382
a0a4d4dac1a4
Renamed !TypeInfoBuilder to !RTTIBuilder.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1376
diff
changeset
|
416 RTTIBuilder b(Type::typeinfoenum); |
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
|
417 |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
418 assert(tinfo->ty == Tenum); |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
419 TypeEnum *tc = (TypeEnum *)tinfo; |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
420 EnumDeclaration *sd = tc->sym; |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
421 |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
422 // TypeInfo base |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
423 b.push_typeinfo(sd->memtype); |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
424 |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
425 // char[] name |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
426 b.push_string(sd->toPrettyChars()); |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
427 |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
428 // void[] init |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
429 // emit void[] with the default initialier, the array is null if the default |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
430 // initializer is zero |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
431 if (!sd->defaultval || tinfo->isZeroInit(0)) |
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
|
432 { |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
433 b.push_null_void_array(); |
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
|
434 } |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
435 // otherwise emit a void[] with the default initializer |
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
|
436 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
|
437 { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
438 const LLType* memty = DtoType(sd->memtype); |
1452
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
1382
diff
changeset
|
439 #if DMDV2 |
1554
d6e8d5db259f
LLVMContext changes up to r77366
Benjamin Kramer <benny.kra@gmail.com>
parents:
1547
diff
changeset
|
440 LLConstant* C = LLConstantInt::get(memty, sd->defaultval->toInteger(), !sd->memtype->isunsigned()); |
1452
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
1382
diff
changeset
|
441 #else |
1554
d6e8d5db259f
LLVMContext changes up to r77366
Benjamin Kramer <benny.kra@gmail.com>
parents:
1547
diff
changeset
|
442 LLConstant* C = LLConstantInt::get(memty, sd->defaultval, !sd->memtype->isunsigned()); |
1452
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
1382
diff
changeset
|
443 #endif |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
444 b.push_void_array(C, sd->memtype, sd); |
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
|
445 } |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
446 |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
447 // finish |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
448 b.finalize(ir.irGlobal); |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
449 } |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
450 |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
451 /* ========================================================================= */ |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
452 |
106 | 453 void TypeInfoPointerDeclaration::llvmDefine() |
454 { | |
455 Logger::println("TypeInfoPointerDeclaration::llvmDefine() %s", toChars()); | |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
456 LOG_SCOPE; |
52 | 457 |
1382
a0a4d4dac1a4
Renamed !TypeInfoBuilder to !RTTIBuilder.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1376
diff
changeset
|
458 RTTIBuilder b(Type::typeinfopointer); |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
459 // TypeInfo base |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
460 b.push_typeinfo(tinfo->nextOf()); |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
461 // finish |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
462 b.finalize(ir.irGlobal); |
106 | 463 } |
464 | |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
465 /* ========================================================================= */ |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
466 |
106 | 467 void TypeInfoArrayDeclaration::llvmDefine() |
468 { | |
469 Logger::println("TypeInfoArrayDeclaration::llvmDefine() %s", toChars()); | |
470 LOG_SCOPE; | |
471 | |
1382
a0a4d4dac1a4
Renamed !TypeInfoBuilder to !RTTIBuilder.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1376
diff
changeset
|
472 RTTIBuilder b(Type::typeinfoarray); |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
473 // TypeInfo base |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
474 b.push_typeinfo(tinfo->nextOf()); |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
475 // finish |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
476 b.finalize(ir.irGlobal); |
106 | 477 } |
478 | |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
479 /* ========================================================================= */ |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
480 |
106 | 481 void TypeInfoStaticArrayDeclaration::llvmDefine() |
52 | 482 { |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1064
diff
changeset
|
483 Logger::println("TypeInfoStaticArrayDeclaration::llvmDefine() %s", toChars()); |
105
182b41f56b7f
[svn r109] Fixed support for static array TypeInfo
lindquist
parents:
102
diff
changeset
|
484 LOG_SCOPE; |
182b41f56b7f
[svn r109] Fixed support for static array TypeInfo
lindquist
parents:
102
diff
changeset
|
485 |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
486 assert(tinfo->ty == Tsarray); |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
487 TypeSArray *tc = (TypeSArray *)tinfo; |
52 | 488 |
1382
a0a4d4dac1a4
Renamed !TypeInfoBuilder to !RTTIBuilder.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1376
diff
changeset
|
489 RTTIBuilder b(Type::typeinfostaticarray); |
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
|
490 |
105
182b41f56b7f
[svn r109] Fixed support for static array TypeInfo
lindquist
parents:
102
diff
changeset
|
491 // value typeinfo |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
492 b.push_typeinfo(tc->nextOf()); |
52 | 493 |
105
182b41f56b7f
[svn r109] Fixed support for static array TypeInfo
lindquist
parents:
102
diff
changeset
|
494 // length |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
495 b.push(DtoConstSize_t((size_t)tc->dim->toUInteger())); |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
496 |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
497 // finish |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
498 b.finalize(ir.irGlobal); |
106 | 499 } |
105
182b41f56b7f
[svn r109] Fixed support for static array TypeInfo
lindquist
parents:
102
diff
changeset
|
500 |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
501 /* ========================================================================= */ |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
502 |
106 | 503 void TypeInfoAssociativeArrayDeclaration::llvmDefine() |
504 { | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1064
diff
changeset
|
505 Logger::println("TypeInfoAssociativeArrayDeclaration::llvmDefine() %s", toChars()); |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
506 LOG_SCOPE; |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
507 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
508 assert(tinfo->ty == Taarray); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
509 TypeAArray *tc = (TypeAArray *)tinfo; |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
510 |
1382
a0a4d4dac1a4
Renamed !TypeInfoBuilder to !RTTIBuilder.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1376
diff
changeset
|
511 RTTIBuilder b(Type::typeinfoassociativearray); |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
512 |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
513 // value typeinfo |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
514 b.push_typeinfo(tc->nextOf()); |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
515 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
106
diff
changeset
|
516 // key typeinfo |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
517 b.push_typeinfo(tc->index); |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
518 |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
519 // finish |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
520 b.finalize(ir.irGlobal); |
106 | 521 } |
522 | |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
523 /* ========================================================================= */ |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
524 |
106 | 525 void TypeInfoFunctionDeclaration::llvmDefine() |
52 | 526 { |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1064
diff
changeset
|
527 Logger::println("TypeInfoFunctionDeclaration::llvmDefine() %s", toChars()); |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
528 LOG_SCOPE; |
52 | 529 |
1382
a0a4d4dac1a4
Renamed !TypeInfoBuilder to !RTTIBuilder.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1376
diff
changeset
|
530 RTTIBuilder b(Type::typeinfofunction); |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
531 // TypeInfo base |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
532 b.push_typeinfo(tinfo->nextOf()); |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
533 // finish |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
534 b.finalize(ir.irGlobal); |
106 | 535 } |
536 | |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
537 /* ========================================================================= */ |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
538 |
106 | 539 void TypeInfoDelegateDeclaration::llvmDefine() |
52 | 540 { |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1064
diff
changeset
|
541 Logger::println("TypeInfoDelegateDeclaration::llvmDefine() %s", toChars()); |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
542 LOG_SCOPE; |
52 | 543 |
544 assert(tinfo->ty == Tdelegate); | |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
545 Type* ret_type = tinfo->nextOf()->nextOf(); |
52 | 546 |
1382
a0a4d4dac1a4
Renamed !TypeInfoBuilder to !RTTIBuilder.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1376
diff
changeset
|
547 RTTIBuilder b(Type::typeinfodelegate); |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
548 // TypeInfo base |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
549 b.push_typeinfo(ret_type); |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
550 // finish |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
551 b.finalize(ir.irGlobal); |
106 | 552 } |
553 | |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
554 /* ========================================================================= */ |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
555 |
1375
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
556 static FuncDeclaration* find_method_overload(AggregateDeclaration* ad, Identifier* id, TypeFunction* tf, Module* mod) |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
557 { |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
558 Dsymbol *s = search_function(ad, id); |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
559 FuncDeclaration *fdx = s ? s->isFuncDeclaration() : NULL; |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
560 if (fdx) |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
561 { |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
562 FuncDeclaration *fd = fdx->overloadExactMatch(tf, mod); |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
563 if (fd) |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
564 { |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
565 return fd; |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
566 } |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
567 } |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
568 return NULL; |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
569 } |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
570 |
106 | 571 void TypeInfoStructDeclaration::llvmDefine() |
572 { | |
573 Logger::println("TypeInfoStructDeclaration::llvmDefine() %s", toChars()); | |
72 | 574 LOG_SCOPE; |
575 | |
1245
465a77c904d4
Fixed all issues preventing Tango 0.99.8 to compile with `sh build-tango.sh --verbose ldc'.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1228
diff
changeset
|
576 // make sure struct is resolved |
72 | 577 assert(tinfo->ty == Tstruct); |
578 TypeStruct *tc = (TypeStruct *)tinfo; | |
579 StructDeclaration *sd = tc->sym; | |
1345
712662f45ee4
Added error instead of assertion failure when trying to get !TypeInfo for a forward declared struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1344
diff
changeset
|
580 |
712662f45ee4
Added error instead of assertion failure when trying to get !TypeInfo for a forward declared struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1344
diff
changeset
|
581 // can't emit typeinfo for forward declarations |
712662f45ee4
Added error instead of assertion failure when trying to get !TypeInfo for a forward declared struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1344
diff
changeset
|
582 if (sd->sizeok != 1) |
712662f45ee4
Added error instead of assertion failure when trying to get !TypeInfo for a forward declared struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1344
diff
changeset
|
583 { |
712662f45ee4
Added error instead of assertion failure when trying to get !TypeInfo for a forward declared struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1344
diff
changeset
|
584 sd->error("cannot emit TypeInfo for forward declaration"); |
712662f45ee4
Added error instead of assertion failure when trying to get !TypeInfo for a forward declared struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1344
diff
changeset
|
585 fatal(); |
712662f45ee4
Added error instead of assertion failure when trying to get !TypeInfo for a forward declared struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1344
diff
changeset
|
586 } |
712662f45ee4
Added error instead of assertion failure when trying to get !TypeInfo for a forward declared struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1344
diff
changeset
|
587 |
1148
3d1b16dabd25
Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
588 sd->codegen(Type::sir); |
1375
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
589 IrStruct* irstruct = sd->ir.irStruct; |
72 | 590 |
1382
a0a4d4dac1a4
Renamed !TypeInfoBuilder to !RTTIBuilder.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1376
diff
changeset
|
591 RTTIBuilder b(Type::typeinfostruct); |
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
|
592 |
72 | 593 // char[] name |
1375
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
594 b.push_string(sd->toPrettyChars()); |
72 | 595 |
596 // void[] init | |
1375
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
597 // never emit a null array, even for zero initialized typeinfo |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
598 // the size() method uses this array! |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
599 size_t init_size = getTypeStoreSize(tc->irtype->getPA()); |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
600 b.push_void_array(init_size, irstruct->getInitSymbol()); |
72 | 601 |
602 // toX functions ground work | |
603 static TypeFunction *tftohash; | |
604 static TypeFunction *tftostring; | |
605 | |
606 if (!tftohash) | |
607 { | |
1375
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
608 Scope sc; |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
609 tftohash = new TypeFunction(NULL, Type::thash_t, 0, LINKd); |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
610 tftohash = (TypeFunction *)tftohash->semantic(0, &sc); |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
611 tftostring = new TypeFunction(NULL, Type::tchar->arrayOf(), 0, LINKd); |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
612 tftostring = (TypeFunction *)tftostring->semantic(0, &sc); |
72 | 613 } |
614 | |
1375
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
615 // this one takes a parameter, so we need to build a new one each time |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
616 // to get the right type. can we avoid this? |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
617 TypeFunction *tfeqptr; |
72 | 618 { |
1375
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
619 Scope sc; |
1607
207a8a438dea
Merge DMD r253: refactor: Argument => Parameter
Leandro Lucarella <llucax@gmail.com>
parents:
1571
diff
changeset
|
620 Parameters *arguments = new Parameters; |
207a8a438dea
Merge DMD r253: refactor: Argument => Parameter
Leandro Lucarella <llucax@gmail.com>
parents:
1571
diff
changeset
|
621 Parameter *arg = new Parameter(STCin, tc->pointerTo(), NULL, NULL); |
1375
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
622 arguments->push(arg); |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
623 tfeqptr = new TypeFunction(arguments, Type::tint32, 0, LINKd); |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
624 tfeqptr = (TypeFunction *)tfeqptr->semantic(0, &sc); |
72 | 625 } |
626 | |
1375
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
627 // well use this module for all overload lookups |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
628 Module *gm = getModule(); |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
629 |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
630 // toHash |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
631 FuncDeclaration* fd = find_method_overload(sd, Id::tohash, tftohash, gm); |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
632 b.push_funcptr(fd); |
72 | 633 |
1375
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
634 // opEquals |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
635 fd = find_method_overload(sd, Id::eq, tfeqptr, gm); |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
636 b.push_funcptr(fd); |
72 | 637 |
1375
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
638 // opCmp |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
639 fd = find_method_overload(sd, Id::cmp, tfeqptr, gm); |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
640 b.push_funcptr(fd); |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
641 |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
642 // toString |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
643 fd = find_method_overload(sd, Id::tostring, tftostring, gm); |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
644 b.push_funcptr(fd); |
72 | 645 |
646 // uint m_flags; | |
1375
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
647 unsigned hasptrs = tc->hasPointers() ? 1 : 0; |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
648 b.push_uint(hasptrs); |
72 | 649 |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
650 #if DMDV2 |
1463 | 651 // FIXME: just emit nulls for now |
652 | |
653 ClassDeclaration* tscd = Type::typeinfostruct; | |
654 | |
655 assert(tscd->fields.dim == 10); | |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
656 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
657 // const(MemberInfo[]) function(in char[]) xgetMembers; |
1463 | 658 VarDeclaration* xgetMembers = (VarDeclaration*)tscd->fields.data[7]; |
659 b.push_null(xgetMembers->type); | |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
660 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
661 //void function(void*) xdtor; |
1463 | 662 VarDeclaration* xdtor = (VarDeclaration*)tscd->fields.data[8]; |
663 b.push_null(xdtor->type); | |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
664 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
665 //void function(void*) xpostblit; |
1463 | 666 VarDeclaration* xpostblit = (VarDeclaration*)tscd->fields.data[9]; |
667 b.push_null(xpostblit->type); | |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
668 #endif |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
669 |
1375
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
670 // finish |
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1374
diff
changeset
|
671 b.finalize(ir.irGlobal); |
106 | 672 } |
673 | |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
674 /* ========================================================================= */ |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
675 |
106 | 676 void TypeInfoClassDeclaration::llvmDefine() |
677 { | |
678 Logger::println("TypeInfoClassDeclaration::llvmDefine() %s", toChars()); | |
679 LOG_SCOPE; | |
680 | |
1245
465a77c904d4
Fixed all issues preventing Tango 0.99.8 to compile with `sh build-tango.sh --verbose ldc'.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1228
diff
changeset
|
681 // make sure class is resolved |
465a77c904d4
Fixed all issues preventing Tango 0.99.8 to compile with `sh build-tango.sh --verbose ldc'.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1228
diff
changeset
|
682 assert(tinfo->ty == Tclass); |
465a77c904d4
Fixed all issues preventing Tango 0.99.8 to compile with `sh build-tango.sh --verbose ldc'.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1228
diff
changeset
|
683 TypeClass *tc = (TypeClass *)tinfo; |
465a77c904d4
Fixed all issues preventing Tango 0.99.8 to compile with `sh build-tango.sh --verbose ldc'.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1228
diff
changeset
|
684 tc->sym->codegen(Type::sir); |
465a77c904d4
Fixed all issues preventing Tango 0.99.8 to compile with `sh build-tango.sh --verbose ldc'.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1228
diff
changeset
|
685 |
1382
a0a4d4dac1a4
Renamed !TypeInfoBuilder to !RTTIBuilder.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1376
diff
changeset
|
686 RTTIBuilder b(Type::typeinfoclass); |
106 | 687 |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
688 // TypeInfo base |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
689 b.push_classinfo(tc->sym); |
106 | 690 |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
691 // finish |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
692 b.finalize(ir.irGlobal); |
106 | 693 } |
694 | |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
695 /* ========================================================================= */ |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
696 |
106 | 697 void TypeInfoInterfaceDeclaration::llvmDefine() |
698 { | |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
699 Logger::println("TypeInfoInterfaceDeclaration::llvmDefine() %s", toChars()); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
700 LOG_SCOPE; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
701 |
1245
465a77c904d4
Fixed all issues preventing Tango 0.99.8 to compile with `sh build-tango.sh --verbose ldc'.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1228
diff
changeset
|
702 // make sure interface is resolved |
465a77c904d4
Fixed all issues preventing Tango 0.99.8 to compile with `sh build-tango.sh --verbose ldc'.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1228
diff
changeset
|
703 assert(tinfo->ty == Tclass); |
465a77c904d4
Fixed all issues preventing Tango 0.99.8 to compile with `sh build-tango.sh --verbose ldc'.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1228
diff
changeset
|
704 TypeClass *tc = (TypeClass *)tinfo; |
465a77c904d4
Fixed all issues preventing Tango 0.99.8 to compile with `sh build-tango.sh --verbose ldc'.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1228
diff
changeset
|
705 tc->sym->codegen(Type::sir); |
465a77c904d4
Fixed all issues preventing Tango 0.99.8 to compile with `sh build-tango.sh --verbose ldc'.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1228
diff
changeset
|
706 |
1382
a0a4d4dac1a4
Renamed !TypeInfoBuilder to !RTTIBuilder.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1376
diff
changeset
|
707 RTTIBuilder b(Type::typeinfointerface); |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
708 |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
709 // TypeInfo base |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
710 b.push_classinfo(tc->sym); |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
711 |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
712 // finish |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
713 b.finalize(ir.irGlobal); |
106 | 714 } |
715 | |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
716 /* ========================================================================= */ |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
717 |
106 | 718 void TypeInfoTupleDeclaration::llvmDefine() |
719 { | |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
720 Logger::println("TypeInfoTupleDeclaration::llvmDefine() %s", toChars()); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
721 LOG_SCOPE; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
722 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
723 // create elements array |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
724 assert(tinfo->ty == Ttuple); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
725 TypeTuple *tu = (TypeTuple *)tinfo; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
726 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
727 size_t dim = tu->arguments->dim; |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
173
diff
changeset
|
728 std::vector<LLConstant*> arrInits; |
1376
a5d0e04298a8
Cleaned up TypeInfo_Tuple generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1375
diff
changeset
|
729 arrInits.reserve(dim); |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
730 |
1376
a5d0e04298a8
Cleaned up TypeInfo_Tuple generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1375
diff
changeset
|
731 const LLType* tiTy = DtoType(Type::typeinfo->type); |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
732 |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
733 for (size_t i = 0; i < dim; i++) |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
734 { |
1607
207a8a438dea
Merge DMD r253: refactor: Argument => Parameter
Leandro Lucarella <llucax@gmail.com>
parents:
1571
diff
changeset
|
735 Parameter *arg = (Parameter *)tu->arguments->data[i]; |
1376
a5d0e04298a8
Cleaned up TypeInfo_Tuple generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1375
diff
changeset
|
736 arrInits.push_back(DtoTypeInfoOf(arg->type, true)); |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
737 } |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
738 |
1376
a5d0e04298a8
Cleaned up TypeInfo_Tuple generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1375
diff
changeset
|
739 // build array |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
213
diff
changeset
|
740 const LLArrayType* arrTy = LLArrayType::get(tiTy, dim); |
1554
d6e8d5db259f
LLVMContext changes up to r77366
Benjamin Kramer <benny.kra@gmail.com>
parents:
1547
diff
changeset
|
741 LLConstant* arrC = LLConstantArray::get(arrTy, arrInits); |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
742 |
1382
a0a4d4dac1a4
Renamed !TypeInfoBuilder to !RTTIBuilder.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1376
diff
changeset
|
743 RTTIBuilder b(Type::typeinfotypelist); |
522
cd4eeb6cc5f6
Fix TypeInfo_Tuple array initialization.
Christian Kamm <kamm incasoftware de>
parents:
508
diff
changeset
|
744 |
1376
a5d0e04298a8
Cleaned up TypeInfo_Tuple generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1375
diff
changeset
|
745 // push TypeInfo[] |
a5d0e04298a8
Cleaned up TypeInfo_Tuple generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1375
diff
changeset
|
746 b.push_array(arrC, dim, Type::typeinfo->type, NULL); |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
110
diff
changeset
|
747 |
1376
a5d0e04298a8
Cleaned up TypeInfo_Tuple generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1375
diff
changeset
|
748 // finish |
a5d0e04298a8
Cleaned up TypeInfo_Tuple generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1375
diff
changeset
|
749 b.finalize(ir.irGlobal); |
106 | 750 } |
751 | |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
752 /* ========================================================================= */ |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
753 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
754 #if DMDV2 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
755 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
756 void TypeInfoConstDeclaration::llvmDefine() |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
757 { |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1064
diff
changeset
|
758 Logger::println("TypeInfoConstDeclaration::llvmDefine() %s", toChars()); |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
759 LOG_SCOPE; |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
760 |
1382
a0a4d4dac1a4
Renamed !TypeInfoBuilder to !RTTIBuilder.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1376
diff
changeset
|
761 RTTIBuilder b(Type::typeinfoconst); |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
762 // TypeInfo base |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
763 b.push_typeinfo(tinfo->mutableOf()->merge()); |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
764 // finish |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
765 b.finalize(ir.irGlobal); |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
766 } |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
767 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
768 /* ========================================================================= */ |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
769 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
770 void TypeInfoInvariantDeclaration::llvmDefine() |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
771 { |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1064
diff
changeset
|
772 Logger::println("TypeInfoInvariantDeclaration::llvmDefine() %s", toChars()); |
761
fa306ca8843b
Applied fvbommel's patch from #112
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
758
diff
changeset
|
773 LOG_SCOPE; |
fa306ca8843b
Applied fvbommel's patch from #112
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
758
diff
changeset
|
774 |
1382
a0a4d4dac1a4
Renamed !TypeInfoBuilder to !RTTIBuilder.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1376
diff
changeset
|
775 RTTIBuilder b(Type::typeinfoinvariant); |
1374
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
776 // TypeInfo base |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
777 b.push_typeinfo(tinfo->mutableOf()->merge()); |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
778 // finish |
e630ff79e10d
Cleaned up TypeInfo generation, still need to do TypeInfo_Struct/Tuple. Eventually do ClassInfo and ModuleInfo as well using same interface.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1367
diff
changeset
|
779 b.finalize(ir.irGlobal); |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
780 } |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
663
diff
changeset
|
781 |
766
af04bbae8553
D2: Fixed global constants not initialized until module constructor.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
764
diff
changeset
|
782 #endif |