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