annotate gen/typinf.cpp @ 1283:450897f5aae9

Remove some dead code.
author Frits van Bommel <fvbommel wxs.nl>
date Sat, 02 May 2009 11:58:50 +0200
parents 465a77c904d4
children 5851c18e4c6d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3 // Copyright (c) 1999-2004 by Digital Mars
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
4 // All Rights Reserved
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
5 // written by Walter Bright
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
6 // www.digitalmars.com
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
7 // License for redistribution is by either the Artistic License
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
8 // in artistic.txt, or the GNU General Public License in gnu.txt.
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
9 // See the included readme.txt for details.
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
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
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
15 #include <cstdio>
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
16 #include <cassert>
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
17
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
18 #include "gen/llvm.h"
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
19
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
20 #include "mars.h"
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
21 #include "module.h"
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
22 #include "mtype.h"
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
23 #include "scope.h"
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
24 #include "init.h"
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
25 #include "expression.h"
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
26 #include "attrib.h"
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
27 #include "declaration.h"
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
28 #include "template.h"
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
29 #include "id.h"
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
30 #include "enum.h"
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
31 #include "import.h"
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
32 #include "aggregate.h"
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
33
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
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
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
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
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 98
diff changeset
40 #include "gen/structs.h"
106
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
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
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
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
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
46 /*******************************************
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
47 * Get a canonicalized form of the TypeInfo for use with the internal
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
48 * runtime library routines. Canonicalized in that static arrays are
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
49 * represented as dynamic arrays, enums are represented by their
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
50 * underlying type, etc. This reduces the number of TypeInfo's needed,
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
51 * so we can use the custom internal ones more.
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
52 */
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
53
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
54 Expression *Type::getInternalTypeInfo(Scope *sc)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
55 { TypeInfoDeclaration *tid;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
56 Expression *e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
57 Type *t;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
58 static TypeInfoDeclaration *internalTI[TMAX];
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
59
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
60 //printf("Type::getInternalTypeInfo() %s\n", toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
61 t = toBasetype();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
62 switch (t->ty)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
63 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
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
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
69 break;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
70
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
71 case Tclass:
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
72 if (((TypeClass *)t)->sym->isInterfaceDeclaration())
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
73 break;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
74 goto Linternal;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
75
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
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
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
82 break;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
83 goto Linternal;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
84
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
85 case Tfunction:
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
86 case Tdelegate:
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
87 case Tpointer:
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
88 Linternal:
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
89 tid = internalTI[t->ty];
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
90 if (!tid)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
91 { tid = new TypeInfoDeclaration(t, 1);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
92 internalTI[t->ty] = tid;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
93 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
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
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
96 e->type = tid->type; // do this so we don't get redundant dereference
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
97 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
98
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
99 default:
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
100 break;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
101 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
102 //printf("\tcalling getTypeInfo() %s\n", t->toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
103 return t->getTypeInfo(sc);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
104 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
105
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
106 /****************************************************
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
107 * Get the exact TypeInfo.
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
108 */
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
109
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
110 Expression *Type::getTypeInfo(Scope *sc)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
111 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
112 Expression *e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
113 Type *t;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
114
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
115 //printf("Type::getTypeInfo() %p, %s\n", this, toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
116 t = merge(); // do this since not all Type's are merge'd
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
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
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
127 assert(t->vtinfo);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
128
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
129 /* If this has a custom implementation in std/typeinfo, then
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
130 * do not generate a COMDAT for it.
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
131 */
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
132 if (!t->builtinTypeInfo())
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
133 { // Generate COMDAT
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
134 if (sc) // if in semantic() pass
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
135 { // Find module that will go all the way to an object file
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
136 Module *m = sc->module->importedFrom;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
137 m->members->push(t->vtinfo);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
138 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
139 else // if in obj generation pass
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
140 {
1147
dbe4af57b240 Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1146
diff changeset
141 #if IN_DMD
336
aaade6ded589 [svn r357] Merged DMD 1.033
lindquist
parents: 290
diff changeset
142 t->vtinfo->toObjFile(0); // TODO: multiobj
1147
dbe4af57b240 Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1146
diff changeset
143 #else
dbe4af57b240 Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1146
diff changeset
144 t->vtinfo->codegen(sir);
dbe4af57b240 Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1146
diff changeset
145 #endif
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
146 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
147 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
148 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
149 e = new VarExp(0, t->vtinfo);
1147
dbe4af57b240 Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1146
diff changeset
150 e = e->addressOf(sc);
dbe4af57b240 Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1146
diff changeset
151 e->type = t->vtinfo->type; // do this so we don't get redundant dereference
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
152 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
153 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
154
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
155 enum RET TypeFunction::retStyle()
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
156 {
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
157 return RETstack;
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
158 }
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
159
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
160 TypeInfoDeclaration *Type::getTypeInfoDeclaration()
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
161 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
162 //printf("Type::getTypeInfoDeclaration() %s\n", toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
163 return new TypeInfoDeclaration(this, 0);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
164 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
165
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
166 TypeInfoDeclaration *TypeTypedef::getTypeInfoDeclaration()
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
167 {
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
168 return new TypeInfoTypedefDeclaration(this);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
169 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
170
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
171 TypeInfoDeclaration *TypePointer::getTypeInfoDeclaration()
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
172 {
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
173 return new TypeInfoPointerDeclaration(this);
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
174 }
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
175
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
176 TypeInfoDeclaration *TypeDArray::getTypeInfoDeclaration()
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
177 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
178 return new TypeInfoArrayDeclaration(this);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
179 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
180
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
181 TypeInfoDeclaration *TypeSArray::getTypeInfoDeclaration()
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
182 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
183 return new TypeInfoStaticArrayDeclaration(this);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
184 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
185
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
186 TypeInfoDeclaration *TypeAArray::getTypeInfoDeclaration()
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
187 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
188 return new TypeInfoAssociativeArrayDeclaration(this);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
189 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
190
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
191 TypeInfoDeclaration *TypeStruct::getTypeInfoDeclaration()
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
192 {
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
193 return new TypeInfoStructDeclaration(this);
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
194 }
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
195
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
196 TypeInfoDeclaration *TypeClass::getTypeInfoDeclaration()
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
197 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
198 if (sym->isInterfaceDeclaration())
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
199 return new TypeInfoInterfaceDeclaration(this);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
200 else
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
201 return new TypeInfoClassDeclaration(this);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
202 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
203
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
204 TypeInfoDeclaration *TypeEnum::getTypeInfoDeclaration()
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
205 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
206 return new TypeInfoEnumDeclaration(this);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
207 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
208
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
209 TypeInfoDeclaration *TypeFunction::getTypeInfoDeclaration()
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
210 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
211 return new TypeInfoFunctionDeclaration(this);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
212 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
213
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
214 TypeInfoDeclaration *TypeDelegate::getTypeInfoDeclaration()
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
215 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
216 return new TypeInfoDelegateDeclaration(this);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
217 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
218
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
219 TypeInfoDeclaration *TypeTuple::getTypeInfoDeclaration()
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
220 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
221 return new TypeInfoTupleDeclaration(this);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
222 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
223
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
224
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
225 /* ========================================================================= */
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
226
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
227 /* These decide if there's an instance for them already in std.typeinfo,
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
228 * because then the compiler doesn't need to build one.
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
229 */
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
230
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
231 int Type::builtinTypeInfo()
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
232 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
233 return 0;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
234 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
235
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
236 int TypeBasic::builtinTypeInfo()
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
237 {
764
8e7d4ddab66d Forgot D2 versioning on typeinfo change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 763
diff changeset
238 #if DMDV2
763
9a9f403ab399 D2 changes!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 761
diff changeset
239 return !mod;
764
8e7d4ddab66d Forgot D2 versioning on typeinfo change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 763
diff changeset
240 #else
8e7d4ddab66d Forgot D2 versioning on typeinfo change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 763
diff changeset
241 return 1;
8e7d4ddab66d Forgot D2 versioning on typeinfo change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 763
diff changeset
242 #endif
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
243 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
244
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
245 int TypeDArray::builtinTypeInfo()
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
246 {
763
9a9f403ab399 D2 changes!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 761
diff changeset
247 #if DMDV2
9a9f403ab399 D2 changes!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 761
diff changeset
248 return !mod && next->isTypeBasic() != NULL && !next->mod;
9a9f403ab399 D2 changes!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 761
diff changeset
249 #else
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
250 return next->isTypeBasic() != NULL;
763
9a9f403ab399 D2 changes!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 761
diff changeset
251 #endif
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
252 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
253
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
254 /* ========================================================================= */
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
255
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
256 //////////////////////////////////////////////////////////////////////////////
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
257 // MAGIC PLACE
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
258 //////////////////////////////////////////////////////////////////////////////
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
259
1148
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
260 void DtoResolveTypeInfo(TypeInfoDeclaration* tid);
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
261 void DtoDeclareTypeInfo(TypeInfoDeclaration* tid);
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
262 void DtoConstInitTypeInfo(TypeInfoDeclaration* tid);
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
263
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
264 void TypeInfoDeclaration::codegen(Ir*)
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
265 {
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
266 DtoResolveTypeInfo(this);
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
267 }
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
268
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
269 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
270 {
173
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
271 if (tid->ir.resolved) return;
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
272 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
273
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 121
diff changeset
274 Logger::println("DtoResolveTypeInfo(%s)", tid->toChars());
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
275 LOG_SCOPE;
65
d4a678905d5e [svn r69] forgot std.stdarg
lindquist
parents: 58
diff changeset
276
1148
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
277 IrGlobal* irg = new IrGlobal(tid);
1156
19d4ded7204a Fixed issue with runtime supplied typeinfo generating multiple symbols.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1148
diff changeset
278
19d4ded7204a Fixed issue with runtime supplied typeinfo generating multiple symbols.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1148
diff changeset
279 std::string mangle(tid->mangle());
19d4ded7204a Fixed issue with runtime supplied typeinfo generating multiple symbols.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1148
diff changeset
280
19d4ded7204a Fixed issue with runtime supplied typeinfo generating multiple symbols.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1148
diff changeset
281 irg->value = gIR->module->getGlobalVariable(mangle);
19d4ded7204a Fixed issue with runtime supplied typeinfo generating multiple symbols.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1148
diff changeset
282 if (!irg->value)
19d4ded7204a Fixed issue with runtime supplied typeinfo generating multiple symbols.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1148
diff changeset
283 irg->value = new llvm::GlobalVariable(irg->type.get(), true,
19d4ded7204a Fixed issue with runtime supplied typeinfo generating multiple symbols.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1148
diff changeset
284 TYPEINFO_LINKAGE_TYPE, NULL, mangle, gIR->module);
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
285
1148
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
286 tid->ir.irGlobal = irg;
98
6789050b5ad1 [svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents: 96
diff changeset
287
1148
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
288 DtoDeclareTypeInfo(tid);
1147
dbe4af57b240 Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1146
diff changeset
289 }
dbe4af57b240 Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1146
diff changeset
290
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
291 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
292 {
1148
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
293 DtoResolveTypeInfo(tid);
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
294
173
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
295 if (tid->ir.declared) return;
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
296 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
297
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 121
diff changeset
298 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
299 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
300
1148
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
301 IrGlobal* irg = tid->ir.irGlobal;
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
302
102
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
303 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
304
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
305 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
306 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
307
1148
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
308 assert(irg->value != NULL);
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
309
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
310 // 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
311 if (tid->tinfo->builtinTypeInfo()) {
1148
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
312 // fixup the global
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
313 const llvm::Type* rty = Type::typeinfo->type->ir.type->get();
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
314 llvm::cast<llvm::OpaqueType>(irg->type.get())->refineAbstractTypeTo(rty);
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
315 LLGlobalVariable* g = isaGlobalVar(irg->value);
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
316 g->setLinkage(llvm::GlobalValue::ExternalLinkage);
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
317 return;
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 52
diff changeset
318 }
1148
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
319
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
320 // custom typedef
1148
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
321 DtoConstInitTypeInfo(tid);
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
322 }
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
323
102
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 100
diff changeset
324 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
325 {
173
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
326 if (tid->ir.initialized) return;
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
327 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
328
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 121
diff changeset
329 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
330 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
331
1148
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
332 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
333 }
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
334
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
335 /* ========================================================================= */
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
336
106
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
337 void TypeInfoDeclaration::llvmDefine()
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
338 {
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
339 assert(0 && "TypeInfoDeclaration::llvmDeclare");
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
340 }
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
341
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
342 /* ========================================================================= */
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
343
106
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
344 void TypeInfoTypedefDeclaration::llvmDefine()
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
345 {
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
346 Logger::println("TypeInfoTypedefDeclaration::llvmDefine() %s", toChars());
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 52
diff changeset
347 LOG_SCOPE;
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 52
diff changeset
348
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 52
diff changeset
349 ClassDeclaration* base = Type::typeinfotypedef;
1148
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
350 base->codegen(Type::sir);
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 52
diff changeset
351
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
352 // vtbl
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 173
diff changeset
353 std::vector<LLConstant*> sinits;
1228
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1156
diff changeset
354 sinits.push_back(base->ir.irStruct->getVtblSymbol());
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 52
diff changeset
355
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
356 // 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
357 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
358
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 52
diff changeset
359 assert(tinfo->ty == Ttypedef);
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 52
diff changeset
360 TypeTypedef *tc = (TypeTypedef *)tinfo;
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 52
diff changeset
361 TypedefDeclaration *sd = tc->sym;
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 52
diff changeset
362
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 52
diff changeset
363 // TypeInfo base
290
ebaf65fc4726 [svn r311] Fixed: structs no longer output two static typeinfos.
lindquist
parents: 275
diff changeset
364 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
365 LLConstant* castbase = DtoTypeInfoOf(sd->basetype, true);
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 52
diff changeset
366 sinits.push_back(castbase);
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 52
diff changeset
367
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 52
diff changeset
368 // char[] name
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 52
diff changeset
369 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
370 sinits.push_back(DtoConstString(name));
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 52
diff changeset
371
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 52
diff changeset
372 // 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
373 const LLPointerType* initpt = getPtrToType(LLType::Int8Ty);
69
2b5a2eaa88be [svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents: 65
diff changeset
374 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
375 {
133
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents: 132
diff changeset
376 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
377 }
2b5a2eaa88be [svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents: 65
diff changeset
378 else
2b5a2eaa88be [svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents: 65
diff changeset
379 {
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
380 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
381 std::string ciname(sd->mangle());
2b5a2eaa88be [svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents: 65
diff changeset
382 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
383 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
384 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
385 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
386 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
387 }
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 52
diff changeset
388
797
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 796
diff changeset
389 // 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
390 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
391
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 796
diff changeset
392 // 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
393 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
394
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 796
diff changeset
395 // 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
396 isaGlobalVar(ir.irGlobal->value)->setInitializer(tiInit);
106
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
397 }
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 52
diff changeset
398
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
399 /* ========================================================================= */
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
400
106
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
401 void TypeInfoEnumDeclaration::llvmDefine()
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
402 {
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
403 Logger::println("TypeInfoEnumDeclaration::llvmDefine() %s", toChars());
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
404 LOG_SCOPE;
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
405
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
406 ClassDeclaration* base = Type::typeinfoenum;
1148
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
407 base->codegen(Type::sir);
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
408
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
409 // vtbl
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 173
diff changeset
410 std::vector<LLConstant*> sinits;
1228
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1156
diff changeset
411 sinits.push_back(base->ir.irStruct->getVtblSymbol());
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
412
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
413 // 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
414 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
415
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
416 assert(tinfo->ty == Tenum);
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
417 TypeEnum *tc = (TypeEnum *)tinfo;
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
418 EnumDeclaration *sd = tc->sym;
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
419
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
420 // TypeInfo base
275
665b81613475 [svn r296] Removed: the 'suite' dir, it never took off!
lindquist
parents: 244
diff changeset
421 LLConstant* castbase = DtoTypeInfoOf(sd->memtype, true);
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
422 sinits.push_back(castbase);
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
423
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
424 // char[] name
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
425 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
426 sinits.push_back(DtoConstString(name));
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
427
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
428 // void[] init
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 213
diff changeset
429 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
430 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
431 {
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
432 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
433 }
53d3086b5ad3 [svn r75] Fixed the init member in custom enum typeinfo. I don't see any way this could actually need emmision though :/
lindquist
parents: 69
diff changeset
434 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
435 {
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
436 #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
437 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
438 #else
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 173
diff changeset
439 const LLType* memty = DtoType(sd->memtype);
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 173
diff changeset
440 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
441 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
442 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
443 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
444 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
445 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
446 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
447 #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
448 }
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
449
797
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 796
diff changeset
450 // 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
451 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
452
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 796
diff changeset
453 // 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
454 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
455
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 796
diff changeset
456 // 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
457 isaGlobalVar(ir.irGlobal->value)->setInitializer(tiInit);
106
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
458 }
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
459
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
460 /* ========================================================================= */
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
461
880
2dfd05525e2e Fixed bad return types in typinf.cpp
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 797
diff changeset
462 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
463 {
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
464 ClassDeclaration* base = cd;
1148
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
465 base->codegen(Type::sir);
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
466
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
467 // vtbl
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 173
diff changeset
468 std::vector<LLConstant*> sinits;
1228
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1156
diff changeset
469 sinits.push_back(base->ir.irStruct->getVtblSymbol());
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
470
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
471 // 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
472 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
473
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
474 // TypeInfo base
275
665b81613475 [svn r296] Removed: the 'suite' dir, it never took off!
lindquist
parents: 244
diff changeset
475 LLConstant* castbase = DtoTypeInfoOf(basetype, true);
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
476 sinits.push_back(castbase);
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
477
797
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 796
diff changeset
478 // 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
479 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
480
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 796
diff changeset
481 // 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
482 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
483
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 796
diff changeset
484 // set the initializer
173
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
485 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
486 }
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
487
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
488 /* ========================================================================= */
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
489
106
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
490 void TypeInfoPointerDeclaration::llvmDefine()
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
491 {
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
492 Logger::println("TypeInfoPointerDeclaration::llvmDefine() %s", toChars());
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
493 LOG_SCOPE;
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
494
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
495 assert(tinfo->ty == Tpointer);
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
496 TypePointer *tc = (TypePointer *)tinfo;
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
497
106
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
498 LLVM_D_Define_TypeInfoBase(tc->next, this, Type::typeinfopointer);
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
499 }
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
500
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
501 /* ========================================================================= */
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
502
106
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
503 void TypeInfoArrayDeclaration::llvmDefine()
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
504 {
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
505 Logger::println("TypeInfoArrayDeclaration::llvmDefine() %s", toChars());
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
506 LOG_SCOPE;
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
507
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
508 assert(tinfo->ty == Tarray);
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
509 TypeDArray *tc = (TypeDArray *)tinfo;
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
510
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
511 LLVM_D_Define_TypeInfoBase(tc->next, this, Type::typeinfoarray);
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
512 }
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
513
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
514 /* ========================================================================= */
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
515
106
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
516 void TypeInfoStaticArrayDeclaration::llvmDefine()
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
517 {
1146
1860414bf3b7 * Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1064
diff changeset
518 Logger::println("TypeInfoStaticArrayDeclaration::llvmDefine() %s", toChars());
105
182b41f56b7f [svn r109] Fixed support for static array TypeInfo
lindquist
parents: 102
diff changeset
519 LOG_SCOPE;
182b41f56b7f [svn r109] Fixed support for static array TypeInfo
lindquist
parents: 102
diff changeset
520
182b41f56b7f [svn r109] Fixed support for static array TypeInfo
lindquist
parents: 102
diff changeset
521 // init typeinfo class
182b41f56b7f [svn r109] Fixed support for static array TypeInfo
lindquist
parents: 102
diff changeset
522 ClassDeclaration* base = Type::typeinfostaticarray;
1148
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
523 base->codegen(Type::sir);
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
524
105
182b41f56b7f [svn r109] Fixed support for static array TypeInfo
lindquist
parents: 102
diff changeset
525 // 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
526 const LLStructType* stype = isaStruct(base->type->ir.type->get());
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
527
105
182b41f56b7f [svn r109] Fixed support for static array TypeInfo
lindquist
parents: 102
diff changeset
528 // initializer vector
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 173
diff changeset
529 std::vector<LLConstant*> sinits;
105
182b41f56b7f [svn r109] Fixed support for static array TypeInfo
lindquist
parents: 102
diff changeset
530 // first is always the vtable
1228
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1156
diff changeset
531 sinits.push_back(base->ir.irStruct->getVtblSymbol());
105
182b41f56b7f [svn r109] Fixed support for static array TypeInfo
lindquist
parents: 102
diff changeset
532
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
533 // 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
534 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
535
105
182b41f56b7f [svn r109] Fixed support for static array TypeInfo
lindquist
parents: 102
diff changeset
536 // value typeinfo
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
537 assert(tinfo->ty == Tsarray);
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
538 TypeSArray *tc = (TypeSArray *)tinfo;
275
665b81613475 [svn r296] Removed: the 'suite' dir, it never took off!
lindquist
parents: 244
diff changeset
539 LLConstant* castbase = DtoTypeInfoOf(tc->next, true);
665b81613475 [svn r296] Removed: the 'suite' dir, it never took off!
lindquist
parents: 244
diff changeset
540 assert(castbase->getType() == stype->getElementType(2));
105
182b41f56b7f [svn r109] Fixed support for static array TypeInfo
lindquist
parents: 102
diff changeset
541 sinits.push_back(castbase);
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
542
105
182b41f56b7f [svn r109] Fixed support for static array TypeInfo
lindquist
parents: 102
diff changeset
543 // length
182b41f56b7f [svn r109] Fixed support for static array TypeInfo
lindquist
parents: 102
diff changeset
544 sinits.push_back(DtoConstSize_t(tc->dim->toInteger()));
182b41f56b7f [svn r109] Fixed support for static array TypeInfo
lindquist
parents: 102
diff changeset
545
797
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 796
diff changeset
546 // 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
547 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
548
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 796
diff changeset
549 // 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
550 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
551
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 796
diff changeset
552 // 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
553 isaGlobalVar(ir.irGlobal->value)->setInitializer(tiInit);
106
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
554 }
105
182b41f56b7f [svn r109] Fixed support for static array TypeInfo
lindquist
parents: 102
diff changeset
555
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
556 /* ========================================================================= */
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
557
106
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
558 void TypeInfoAssociativeArrayDeclaration::llvmDefine()
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
559 {
1146
1860414bf3b7 * Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1064
diff changeset
560 Logger::println("TypeInfoAssociativeArrayDeclaration::llvmDefine() %s", toChars());
109
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 106
diff changeset
561 LOG_SCOPE;
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 106
diff changeset
562
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 106
diff changeset
563 // init typeinfo class
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 106
diff changeset
564 ClassDeclaration* base = Type::typeinfoassociativearray;
1148
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
565 base->codegen(Type::sir);
109
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 106
diff changeset
566
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 106
diff changeset
567 // initializer vector
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 173
diff changeset
568 std::vector<LLConstant*> sinits;
109
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 106
diff changeset
569 // first is always the vtable
1228
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1156
diff changeset
570 sinits.push_back(base->ir.irStruct->getVtblSymbol());
109
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 106
diff changeset
571
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
572 // 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
573 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
574
109
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 106
diff changeset
575 // get type
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 106
diff changeset
576 assert(tinfo->ty == Taarray);
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 106
diff changeset
577 TypeAArray *tc = (TypeAArray *)tinfo;
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 106
diff changeset
578
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 106
diff changeset
579 // value typeinfo
275
665b81613475 [svn r296] Removed: the 'suite' dir, it never took off!
lindquist
parents: 244
diff changeset
580 LLConstant* castbase = DtoTypeInfoOf(tc->next, true);
109
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 106
diff changeset
581 sinits.push_back(castbase);
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 106
diff changeset
582
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 106
diff changeset
583 // key typeinfo
275
665b81613475 [svn r296] Removed: the 'suite' dir, it never took off!
lindquist
parents: 244
diff changeset
584 castbase = DtoTypeInfoOf(tc->index, true);
109
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 106
diff changeset
585 sinits.push_back(castbase);
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 106
diff changeset
586
797
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 796
diff changeset
587 // 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
588 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
589
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 796
diff changeset
590 // 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
591 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
592
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 796
diff changeset
593 // 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
594 isaGlobalVar(ir.irGlobal->value)->setInitializer(tiInit);
106
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
595 }
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
596
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
597 /* ========================================================================= */
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
598
106
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
599 void TypeInfoFunctionDeclaration::llvmDefine()
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
600 {
1146
1860414bf3b7 * Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1064
diff changeset
601 Logger::println("TypeInfoFunctionDeclaration::llvmDefine() %s", toChars());
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
602 LOG_SCOPE;
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
603
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
604 assert(tinfo->ty == Tfunction);
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
605 TypeFunction *tc = (TypeFunction *)tinfo;
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
606
106
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
607 LLVM_D_Define_TypeInfoBase(tc->next, this, Type::typeinfofunction);
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
608 }
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
609
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
610 /* ========================================================================= */
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
611
106
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
612 void TypeInfoDelegateDeclaration::llvmDefine()
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
613 {
1146
1860414bf3b7 * Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1064
diff changeset
614 Logger::println("TypeInfoDelegateDeclaration::llvmDefine() %s", toChars());
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
615 LOG_SCOPE;
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
616
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
617 assert(tinfo->ty == Tdelegate);
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
618 TypeDelegate *tc = (TypeDelegate *)tinfo;
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 4
diff changeset
619
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
620 LLVM_D_Define_TypeInfoBase(tc->nextOf()->nextOf(), this, Type::typeinfodelegate);
106
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
621 }
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
622
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
623 /* ========================================================================= */
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
624
106
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
625 void TypeInfoStructDeclaration::llvmDefine()
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
626 {
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
627 Logger::println("TypeInfoStructDeclaration::llvmDefine() %s", toChars());
72
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
628 LOG_SCOPE;
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
629
1245
465a77c904d4 Fixed all issues preventing Tango 0.99.8 to compile with `sh build-tango.sh --verbose ldc'.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1228
diff changeset
630 // make sure struct is resolved
72
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
631 assert(tinfo->ty == Tstruct);
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
632 TypeStruct *tc = (TypeStruct *)tinfo;
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
633 StructDeclaration *sd = tc->sym;
1148
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
634 sd->codegen(Type::sir);
72
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
635
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
636 ClassDeclaration* base = Type::typeinfostruct;
1148
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
637 base->codegen(Type::sir);
72
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
638
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 213
diff changeset
639 const LLStructType* stype = isaStruct(base->type->ir.type->get());
72
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
640
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
641 // vtbl
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 173
diff changeset
642 std::vector<LLConstant*> sinits;
1228
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1156
diff changeset
643 sinits.push_back(base->ir.irStruct->getVtblSymbol());
72
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
644
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
645 // 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
646 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
647
72
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
648 // char[] name
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
649 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
650 sinits.push_back(DtoConstString(name));
110
e8da7856a260 [svn r114] Implemented the ClassInfo.offTi member.
lindquist
parents: 109
diff changeset
651 //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
652 assert(sinits.back()->getType() == stype->getElementType(2));
72
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
653
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
654 // 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
655 const LLPointerType* initpt = getPtrToType(LLType::Int8Ty);
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 173
diff changeset
656 #if 0
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 173
diff changeset
657 // the implementation of TypeInfo_Struct uses this to determine size. :/
72
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
658 if (sd->zeroInit) // 0 initializer, or the same as the base type
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
659 {
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
660 sinits.push_back(DtoConstSlice(DtoConstSize_t(0), llvm::ConstantPointerNull::get(initpt)));
72
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
661 }
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
662 else
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 173
diff changeset
663 #endif
72
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
664 {
173
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
665 size_t cisize = getTypeStoreSize(tc->ir.type->get());
1228
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1156
diff changeset
666 LLConstant* cicast = llvm::ConstantExpr::getBitCast(sd->ir.irStruct->getInitSymbol(), 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
667 sinits.push_back(DtoConstSlice(DtoConstSize_t(cisize), cicast));
72
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
668 }
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
669
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
670 // toX functions ground work
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
671 FuncDeclaration *fd;
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
672 FuncDeclaration *fdx;
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
673 TypeFunction *tf;
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
674 Type *ta;
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
675 Dsymbol *s;
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
676
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
677 static TypeFunction *tftohash;
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
678 static TypeFunction *tftostring;
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
679
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
680 if (!tftohash)
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
681 {
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
682 Scope sc;
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
683
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
684 tftohash = new TypeFunction(NULL, Type::thash_t, 0, LINKd);
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
685 tftohash = (TypeFunction *)tftohash->semantic(0, &sc);
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
686
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
687 tftostring = new TypeFunction(NULL, Type::tchar->arrayOf(), 0, LINKd);
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
688 tftostring = (TypeFunction *)tftostring->semantic(0, &sc);
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
689 }
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
690
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
691 TypeFunction *tfeqptr;
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
692 {
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
693 Scope sc;
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
694 Arguments *arguments = new Arguments;
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
695 Argument *arg = new Argument(STCin, tc->pointerTo(), NULL, NULL);
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
696
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
697 arguments->push(arg);
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
698 tfeqptr = new TypeFunction(arguments, Type::tint32, 0, LINKd);
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
699 tfeqptr = (TypeFunction *)tfeqptr->semantic(0, &sc);
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
700 }
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
701
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
702 #if 0
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
703 TypeFunction *tfeq;
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
704 {
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
705 Scope sc;
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
706 Array *arguments = new Array;
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
707 Argument *arg = new Argument(In, tc, NULL, NULL);
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
708
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
709 arguments->push(arg);
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
710 tfeq = new TypeFunction(arguments, Type::tint32, 0, LINKd);
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
711 tfeq = (TypeFunction *)tfeq->semantic(0, &sc);
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
712 }
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
713 #endif
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
714
110
e8da7856a260 [svn r114] Implemented the ClassInfo.offTi member.
lindquist
parents: 109
diff changeset
715 //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
716 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
717 assert(ptty);
72
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
718
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
719 s = search_function(sd, Id::tohash);
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
720 fdx = s ? s->isFuncDeclaration() : NULL;
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
721 if (fdx)
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
722 {
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
723 fd = fdx->overloadExactMatch(tftohash);
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
724 if (fd) {
1148
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
725 fd->codegen(Type::sir);
173
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
726 assert(fd->ir.irFunc->func != 0);
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 173
diff changeset
727 LLConstant* c = isaConstant(fd->ir.irFunc->func);
72
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
728 assert(c);
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
729 c = llvm::ConstantExpr::getBitCast(c, ptty);
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
730 sinits.push_back(c);
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
731 }
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
732 else {
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
733 //fdx->error("must be declared as extern (D) uint toHash()");
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
734 sinits.push_back(llvm::ConstantPointerNull::get(ptty));
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
735 }
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
736 }
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
737 else {
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
738 sinits.push_back(llvm::ConstantPointerNull::get(ptty));
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
739 }
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
740
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
741 s = search_function(sd, Id::eq);
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
742 fdx = s ? s->isFuncDeclaration() : NULL;
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
743 for (int i = 0; i < 2; i++)
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
744 {
110
e8da7856a260 [svn r114] Implemented the ClassInfo.offTi member.
lindquist
parents: 109
diff changeset
745 //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
746 ptty = isaPointer(stype->getElementType(5+i));
72
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
747 if (fdx)
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
748 {
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
749 fd = fdx->overloadExactMatch(tfeqptr);
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
750 if (fd) {
1148
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
751 fd->codegen(Type::sir);
173
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
752 assert(fd->ir.irFunc->func != 0);
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 173
diff changeset
753 LLConstant* c = isaConstant(fd->ir.irFunc->func);
72
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
754 assert(c);
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
755 c = llvm::ConstantExpr::getBitCast(c, ptty);
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
756 sinits.push_back(c);
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
757 }
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
758 else {
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
759 //fdx->error("must be declared as extern (D) int %s(%s*)", fdx->toChars(), sd->toChars());
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
760 sinits.push_back(llvm::ConstantPointerNull::get(ptty));
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
761 }
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
762 }
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
763 else {
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
764 sinits.push_back(llvm::ConstantPointerNull::get(ptty));
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
765 }
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
766
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
767 s = search_function(sd, Id::cmp);
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
768 fdx = s ? s->isFuncDeclaration() : NULL;
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
769 }
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
770
110
e8da7856a260 [svn r114] Implemented the ClassInfo.offTi member.
lindquist
parents: 109
diff changeset
771 //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
772 ptty = isaPointer(stype->getElementType(7));
72
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
773 s = search_function(sd, Id::tostring);
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
774 fdx = s ? s->isFuncDeclaration() : NULL;
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
775 if (fdx)
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
776 {
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
777 fd = fdx->overloadExactMatch(tftostring);
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
778 if (fd) {
1148
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
779 fd->codegen(Type::sir);
173
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
780 assert(fd->ir.irFunc->func != 0);
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 173
diff changeset
781 LLConstant* c = isaConstant(fd->ir.irFunc->func);
72
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
782 assert(c);
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
783 c = llvm::ConstantExpr::getBitCast(c, ptty);
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
784 sinits.push_back(c);
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
785 }
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
786 else {
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
787 //fdx->error("must be declared as extern (D) char[] toString()");
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
788 sinits.push_back(llvm::ConstantPointerNull::get(ptty));
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
789 }
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
790 }
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
791 else {
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
792 sinits.push_back(llvm::ConstantPointerNull::get(ptty));
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
793 }
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
794
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
795 // 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
796 sinits.push_back(DtoConstUint(tc->hasPointers()));
72
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 71
diff changeset
797
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
798 #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
799
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
800 // 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
801 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
802
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
803 //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
804 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
805
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
806 //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
807 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
808
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
809 #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
810
797
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 796
diff changeset
811 // 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
812 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
813
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 796
diff changeset
814 // 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
815 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
816
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 796
diff changeset
817 // 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
818 isaGlobalVar(ir.irGlobal->value)->setInitializer(tiInit);
106
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
819 }
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
820
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
821 /* ========================================================================= */
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
822
106
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
823 void TypeInfoClassDeclaration::llvmDefine()
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
824 {
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
825 Logger::println("TypeInfoClassDeclaration::llvmDefine() %s", toChars());
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
826 LOG_SCOPE;
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
827
1245
465a77c904d4 Fixed all issues preventing Tango 0.99.8 to compile with `sh build-tango.sh --verbose ldc'.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1228
diff changeset
828 // make sure class is resolved
465a77c904d4 Fixed all issues preventing Tango 0.99.8 to compile with `sh build-tango.sh --verbose ldc'.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1228
diff changeset
829 assert(tinfo->ty == Tclass);
465a77c904d4 Fixed all issues preventing Tango 0.99.8 to compile with `sh build-tango.sh --verbose ldc'.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1228
diff changeset
830 TypeClass *tc = (TypeClass *)tinfo;
465a77c904d4 Fixed all issues preventing Tango 0.99.8 to compile with `sh build-tango.sh --verbose ldc'.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1228
diff changeset
831 tc->sym->codegen(Type::sir);
465a77c904d4 Fixed all issues preventing Tango 0.99.8 to compile with `sh build-tango.sh --verbose ldc'.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1228
diff changeset
832
106
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
833 // init typeinfo class
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
834 ClassDeclaration* base = Type::typeinfoclass;
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
835 assert(base);
1148
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
836 base->codegen(Type::sir);
106
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
837
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
838 // initializer vector
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 173
diff changeset
839 std::vector<LLConstant*> sinits;
106
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
840 // first is always the vtable
1228
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1156
diff changeset
841 sinits.push_back(base->ir.irStruct->getVtblSymbol());
106
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
842
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
843 // 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
844 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
845
106
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
846 // get classinfo
1228
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1156
diff changeset
847 sinits.push_back(tc->sym->ir.irStruct->getClassInfoSymbol());
106
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
848
797
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 796
diff changeset
849 // 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
850 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
851
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 796
diff changeset
852 // 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
853 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
854
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 796
diff changeset
855 // 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
856 isaGlobalVar(ir.irGlobal->value)->setInitializer(tiInit);
106
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
857 }
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
858
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
859 /* ========================================================================= */
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
860
106
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
861 void TypeInfoInterfaceDeclaration::llvmDefine()
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
862 {
113
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
863 Logger::println("TypeInfoInterfaceDeclaration::llvmDefine() %s", toChars());
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
864 LOG_SCOPE;
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
865
1245
465a77c904d4 Fixed all issues preventing Tango 0.99.8 to compile with `sh build-tango.sh --verbose ldc'.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1228
diff changeset
866 // make sure interface is resolved
465a77c904d4 Fixed all issues preventing Tango 0.99.8 to compile with `sh build-tango.sh --verbose ldc'.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1228
diff changeset
867 assert(tinfo->ty == Tclass);
465a77c904d4 Fixed all issues preventing Tango 0.99.8 to compile with `sh build-tango.sh --verbose ldc'.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1228
diff changeset
868 TypeClass *tc = (TypeClass *)tinfo;
465a77c904d4 Fixed all issues preventing Tango 0.99.8 to compile with `sh build-tango.sh --verbose ldc'.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1228
diff changeset
869 tc->sym->codegen(Type::sir);
465a77c904d4 Fixed all issues preventing Tango 0.99.8 to compile with `sh build-tango.sh --verbose ldc'.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1228
diff changeset
870
113
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
871 // init typeinfo class
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
872 ClassDeclaration* base = Type::typeinfointerface;
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
873 assert(base);
1148
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
874 base->codegen(Type::sir);
113
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
875
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
876 // 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
877 const LLStructType* stype = isaStruct(base->type->ir.type->get());
113
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
878
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
879 // initializer vector
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 173
diff changeset
880 std::vector<LLConstant*> sinits;
113
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
881 // first is always the vtable
1228
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1156
diff changeset
882 sinits.push_back(base->ir.irStruct->getVtblSymbol());
113
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
883
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
884 // 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
885 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
886
113
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
887 // get classinfo
1228
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1156
diff changeset
888 sinits.push_back(tc->sym->ir.irStruct->getClassInfoSymbol());
113
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
889
797
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 796
diff changeset
890 // 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
891 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
892
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 796
diff changeset
893 // 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
894 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
895
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 796
diff changeset
896 // 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
897 isaGlobalVar(ir.irGlobal->value)->setInitializer(tiInit);
106
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
898 }
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
899
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
900 /* ========================================================================= */
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
901
106
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
902 void TypeInfoTupleDeclaration::llvmDefine()
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
903 {
113
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
904 Logger::println("TypeInfoTupleDeclaration::llvmDefine() %s", toChars());
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
905 LOG_SCOPE;
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
906
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
907 // init typeinfo class
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
908 ClassDeclaration* base = Type::typeinfotypelist;
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
909 assert(base);
1148
3d1b16dabd25 Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1147
diff changeset
910 base->codegen(Type::sir);
113
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
911
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
912 // 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
913 const LLStructType* stype = isaStruct(base->type->ir.type->get());
113
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
914
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
915 // initializer vector
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 173
diff changeset
916 std::vector<LLConstant*> sinits;
113
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
917 // first is always the vtable
1228
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1156
diff changeset
918 sinits.push_back(base->ir.irStruct->getVtblSymbol());
113
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
919
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
920 // 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
921 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
922
113
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
923 // create elements array
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
924 assert(tinfo->ty == Ttuple);
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
925 TypeTuple *tu = (TypeTuple *)tinfo;
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
926
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
927 size_t dim = tu->arguments->dim;
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 173
diff changeset
928 std::vector<LLConstant*> arrInits;
113
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
929
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 173
diff changeset
930 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
931 tiTy = getPtrToType(tiTy);
113
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
932
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
933 for (size_t i = 0; i < dim; i++)
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
934 {
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
935 Argument *arg = (Argument *)tu->arguments->data[i];
275
665b81613475 [svn r296] Removed: the 'suite' dir, it never took off!
lindquist
parents: 244
diff changeset
936 LLConstant* castbase = DtoTypeInfoOf(arg->type, true);
665b81613475 [svn r296] Removed: the 'suite' dir, it never took off!
lindquist
parents: 244
diff changeset
937 assert(castbase->getType() == tiTy);
665b81613475 [svn r296] Removed: the 'suite' dir, it never took off!
lindquist
parents: 244
diff changeset
938 arrInits.push_back(castbase);
113
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
939 }
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
940
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
941 // 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
942 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
943 LLConstant* arrC = llvm::ConstantArray::get(arrTy, arrInits);
113
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
944
522
cd4eeb6cc5f6 Fix TypeInfo_Tuple array initialization.
Christian Kamm <kamm incasoftware de>
parents: 508
diff changeset
945 // 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
946 llvm::GlobalValue::LinkageTypes _linkage = llvm::GlobalValue::InternalLinkage;
522
cd4eeb6cc5f6 Fix TypeInfo_Tuple array initialization.
Christian Kamm <kamm incasoftware de>
parents: 508
diff changeset
947 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
948
cd4eeb6cc5f6 Fix TypeInfo_Tuple array initialization.
Christian Kamm <kamm incasoftware de>
parents: 508
diff changeset
949 // get pointer to first element
cd4eeb6cc5f6 Fix TypeInfo_Tuple array initialization.
Christian Kamm <kamm incasoftware de>
parents: 508
diff changeset
950 llvm::ConstantInt* zero = DtoConstSize_t(0);
cd4eeb6cc5f6 Fix TypeInfo_Tuple array initialization.
Christian Kamm <kamm incasoftware de>
parents: 508
diff changeset
951 LLConstant* idxs[2] = { zero, zero };
cd4eeb6cc5f6 Fix TypeInfo_Tuple array initialization.
Christian Kamm <kamm incasoftware de>
parents: 508
diff changeset
952 LLConstant* arrptr = llvm::ConstantExpr::getGetElementPtr(gvar, idxs, 2);
cd4eeb6cc5f6 Fix TypeInfo_Tuple array initialization.
Christian Kamm <kamm incasoftware de>
parents: 508
diff changeset
953
113
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
954 // build the slice
522
cd4eeb6cc5f6 Fix TypeInfo_Tuple array initialization.
Christian Kamm <kamm incasoftware de>
parents: 508
diff changeset
955 LLConstant* slice = DtoConstSlice(DtoConstSize_t(dim), arrptr);
113
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
956 sinits.push_back(slice);
27b9f749d9fe [svn r117] Initial working implementation of interfaces.
lindquist
parents: 110
diff changeset
957
797
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 796
diff changeset
958 // 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
959 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
960
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 796
diff changeset
961 // 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
962 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
963
340acf1535d0 Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 796
diff changeset
964 // 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
965 isaGlobalVar(ir.irGlobal->value)->setInitializer(tiInit);
106
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
966 }
5b5194b25f33 [svn r110] Fixed typeinfo for classes.
lindquist
parents: 105
diff changeset
967
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
968 /* ========================================================================= */
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
969
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
970 #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
971
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
972 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
973 {
1146
1860414bf3b7 * Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1064
diff changeset
974 Logger::println("TypeInfoConstDeclaration::llvmDefine() %s", toChars());
758
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 663
diff changeset
975 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
976
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
977 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
978 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
979
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
980 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
981 }
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
982
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
983 /* ========================================================================= */
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
984
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
985 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
986 {
1146
1860414bf3b7 * Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1064
diff changeset
987 Logger::println("TypeInfoInvariantDeclaration::llvmDefine() %s", toChars());
761
fa306ca8843b Applied fvbommel's patch from #112
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 758
diff changeset
988 LOG_SCOPE;
fa306ca8843b Applied fvbommel's patch from #112
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 758
diff changeset
989
fa306ca8843b Applied fvbommel's patch from #112
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 758
diff changeset
990 Type *tm = tinfo->mutableOf();
fa306ca8843b Applied fvbommel's patch from #112
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 758
diff changeset
991 tm = tm->merge();
fa306ca8843b Applied fvbommel's patch from #112
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 758
diff changeset
992
fa306ca8843b Applied fvbommel's patch from #112
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 758
diff changeset
993 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
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
766
af04bbae8553 D2: Fixed global constants not initialized until module constructor.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 764
diff changeset
996 #endif