Mercurial > projects > ldc
annotate gen/toir.cpp @ 262:88252a1af660 trunk
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
author | lindquist |
---|---|
date | Sat, 14 Jun 2008 05:13:49 +0200 |
parents | 2e652b8ad1fd |
children | a9dae3da4e87 |
rev | line source |
---|---|
1 | 1 // Backend stubs |
2 | |
3 /* DMDFE backend stubs | |
4 * This file contains the implementations of the backend routines. | |
5 * For dmdfe these do nothing but print a message saying the module | |
6 * has been parsed. Substitute your own behaviors for these routimes. | |
7 */ | |
8 | |
9 #include <stdio.h> | |
10 #include <math.h> | |
11 #include <sstream> | |
12 #include <fstream> | |
13 #include <iostream> | |
14 | |
40 | 15 #include "gen/llvm.h" |
1 | 16 |
132 | 17 #include "attrib.h" |
1 | 18 #include "total.h" |
19 #include "init.h" | |
20 #include "mtype.h" | |
21 #include "hdrgen.h" | |
22 #include "port.h" | |
4
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
23 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
24 #include "gen/irstate.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
25 #include "gen/logger.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
26 #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:
243
diff
changeset
|
27 #include "gen/llvmhelpers.h" |
4
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
28 #include "gen/runtime.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
29 #include "gen/arrays.h" |
88
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
30 #include "gen/structs.h" |
100 | 31 #include "gen/classes.h" |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
101
diff
changeset
|
32 #include "gen/typeinf.h" |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
33 #include "gen/complex.h" |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
34 #include "gen/dvalue.h" |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
35 #include "gen/aa.h" |
131 | 36 #include "gen/functions.h" |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
37 #include "gen/todebug.h" |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
38 |
1 | 39 ////////////////////////////////////////////////////////////////////////////////////////// |
40 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
41 DValue* DeclarationExp::toElem(IRState* p) |
1 | 42 { |
43 Logger::print("DeclarationExp::toElem: %s | T=%s\n", toChars(), type->toChars()); | |
44 LOG_SCOPE; | |
45 | |
46 // variable declaration | |
47 if (VarDeclaration* vd = declaration->isVarDeclaration()) | |
48 { | |
49 Logger::println("VarDeclaration"); | |
50 | |
50
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
51 // static |
26
99737f94abfb
[svn r30] * Fixed static function-local variables.
lindquist
parents:
25
diff
changeset
|
52 if (vd->isDataseg()) |
99737f94abfb
[svn r30] * Fixed static function-local variables.
lindquist
parents:
25
diff
changeset
|
53 { |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
101
diff
changeset
|
54 vd->toObjFile(); // TODO |
26
99737f94abfb
[svn r30] * Fixed static function-local variables.
lindquist
parents:
25
diff
changeset
|
55 } |
99737f94abfb
[svn r30] * Fixed static function-local variables.
lindquist
parents:
25
diff
changeset
|
56 else |
99737f94abfb
[svn r30] * Fixed static function-local variables.
lindquist
parents:
25
diff
changeset
|
57 { |
131 | 58 if (global.params.llvmAnnotate) |
59 DtoAnnotation(toChars()); | |
60 | |
26
99737f94abfb
[svn r30] * Fixed static function-local variables.
lindquist
parents:
25
diff
changeset
|
61 Logger::println("vdtype = %s", vd->type->toChars()); |
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
|
62 |
50
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
63 // referenced by nested delegate? |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
64 if (vd->nestedref) { |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
65 Logger::println("has nestedref set"); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
66 assert(vd->ir.irLocal); |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
67 vd->ir.irLocal->value = p->func()->decl->ir.irFunc->nestedVar; |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
68 assert(vd->ir.irLocal->value); |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
69 assert(vd->ir.irLocal->nestedIndex >= 0); |
50
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
70 } |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
71 // normal stack variable |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
72 else { |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
73 // allocate storage on the stack |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
74 const LLType* lltype = DtoType(vd->type); |
50
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
75 llvm::AllocaInst* allocainst = new llvm::AllocaInst(lltype, vd->toChars(), p->topallocapoint()); |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
76 //allocainst->setAlignment(vd->type->alignsize()); // TODO |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
77 assert(!vd->ir.irLocal); |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
78 vd->ir.irLocal = new IrLocal(vd); |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
79 vd->ir.irLocal->value = allocainst; |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
80 |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
81 if (global.params.symdebug) |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
82 { |
245
d61ce72c39ab
[svn r262] Fixed debug info for normal function parameters.
lindquist
parents:
244
diff
changeset
|
83 DtoDwarfLocalVariable(allocainst, vd); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
84 } |
50
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
85 } |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
86 |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
87 Logger::cout() << "llvm value for decl: " << *vd->ir.irLocal->value << '\n'; |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
88 DValue* ie = DtoInitializer(vd->init); |
26
99737f94abfb
[svn r30] * Fixed static function-local variables.
lindquist
parents:
25
diff
changeset
|
89 } |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
90 |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
91 return new DVarValue(vd, vd->ir.getIrValue(), true); |
1 | 92 } |
93 // struct declaration | |
94 else if (StructDeclaration* s = declaration->isStructDeclaration()) | |
95 { | |
96 Logger::println("StructDeclaration"); | |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
101
diff
changeset
|
97 DtoForceConstInitDsymbol(s); |
1 | 98 } |
40 | 99 // function declaration |
100 else if (FuncDeclaration* f = declaration->isFuncDeclaration()) | |
101 { | |
102 Logger::println("FuncDeclaration"); | |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
101
diff
changeset
|
103 DtoForceDeclareDsymbol(f); |
40 | 104 } |
105 // alias declaration | |
106 else if (AliasDeclaration* a = declaration->isAliasDeclaration()) | |
107 { | |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
108 Logger::println("AliasDeclaration - no work"); |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
109 // do nothing |
52 | 110 } |
122 | 111 // enum |
52 | 112 else if (EnumDeclaration* e = declaration->isEnumDeclaration()) |
113 { | |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
114 Logger::println("EnumDeclaration - no work"); |
52 | 115 // do nothing |
40 | 116 } |
122 | 117 // class |
118 else if (ClassDeclaration* e = declaration->isClassDeclaration()) | |
119 { | |
120 Logger::println("ClassDeclaration"); | |
121 DtoForceConstInitDsymbol(e); | |
122 } | |
124
a939ec89fc72
[svn r128] function local typedefs were not working
lindquist
parents:
123
diff
changeset
|
123 // typedef |
a939ec89fc72
[svn r128] function local typedefs were not working
lindquist
parents:
123
diff
changeset
|
124 else if (TypedefDeclaration* tdef = declaration->isTypedefDeclaration()) |
a939ec89fc72
[svn r128] function local typedefs were not working
lindquist
parents:
123
diff
changeset
|
125 { |
a939ec89fc72
[svn r128] function local typedefs were not working
lindquist
parents:
123
diff
changeset
|
126 Logger::println("TypedefDeclaration"); |
a939ec89fc72
[svn r128] function local typedefs were not working
lindquist
parents:
123
diff
changeset
|
127 tdef->type->getTypeInfo(NULL); |
a939ec89fc72
[svn r128] function local typedefs were not working
lindquist
parents:
123
diff
changeset
|
128 } |
132 | 129 // attribute declaration |
130 else if (AttribDeclaration* a = declaration->isAttribDeclaration()) | |
131 { | |
132 Logger::println("AttribDeclaration"); | |
133 for (int i=0; i < a->decl->dim; ++i) | |
134 { | |
135 DtoForceDeclareDsymbol((Dsymbol*)a->decl->data[i]); | |
136 } | |
137 } | |
1 | 138 // unsupported declaration |
139 else | |
140 { | |
132 | 141 error("Unimplemented DeclarationExp type. kind: %s", declaration->kind()); |
52 | 142 assert(0); |
1 | 143 } |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
144 return 0; |
1 | 145 } |
146 | |
147 ////////////////////////////////////////////////////////////////////////////////////////// | |
148 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
149 DValue* VarExp::toElem(IRState* p) |
1 | 150 { |
151 Logger::print("VarExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
152 LOG_SCOPE; | |
153 | |
154 assert(var); | |
155 if (VarDeclaration* vd = var->isVarDeclaration()) | |
156 { | |
57
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
55
diff
changeset
|
157 Logger::println("VarDeclaration %s", vd->toChars()); |
50
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
158 |
57
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
55
diff
changeset
|
159 // _arguments |
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
55
diff
changeset
|
160 if (vd->ident == Id::_arguments) |
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
55
diff
changeset
|
161 { |
72 | 162 Logger::println("Id::_arguments"); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
163 /*if (!vd->ir.getIrValue()) |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
164 vd->ir.getIrValue() = p->func()->decl->irFunc->_arguments; |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
165 assert(vd->ir.getIrValue()); |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
166 return new DVarValue(vd, vd->ir.getIrValue(), true);*/ |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
167 LLValue* v = p->func()->decl->ir.irFunc->_arguments; |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
168 assert(v); |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
169 return new DVarValue(vd, v, true); |
57
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
55
diff
changeset
|
170 } |
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
55
diff
changeset
|
171 // _argptr |
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
55
diff
changeset
|
172 else if (vd->ident == Id::_argptr) |
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
55
diff
changeset
|
173 { |
72 | 174 Logger::println("Id::_argptr"); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
175 /*if (!vd->ir.getIrValue()) |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
176 vd->ir.getIrValue() = p->func()->decl->irFunc->_argptr; |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
177 assert(vd->ir.getIrValue()); |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
178 return new DVarValue(vd, vd->ir.getIrValue(), true);*/ |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
179 LLValue* v = p->func()->decl->ir.irFunc->_argptr; |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
180 assert(v); |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
181 return new DVarValue(vd, v, true); |
57
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
55
diff
changeset
|
182 } |
67
f918f3e2e99e
[svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents:
66
diff
changeset
|
183 // _dollar |
f918f3e2e99e
[svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents:
66
diff
changeset
|
184 else if (vd->ident == Id::dollar) |
f918f3e2e99e
[svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents:
66
diff
changeset
|
185 { |
72 | 186 Logger::println("Id::dollar"); |
67
f918f3e2e99e
[svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents:
66
diff
changeset
|
187 assert(!p->arrays.empty()); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
188 LLValue* tmp = DtoArrayLen(p->arrays.back()); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
189 return new DVarValue(vd, tmp, false); |
67
f918f3e2e99e
[svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents:
66
diff
changeset
|
190 } |
f918f3e2e99e
[svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents:
66
diff
changeset
|
191 // typeinfo |
f918f3e2e99e
[svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents:
66
diff
changeset
|
192 else if (TypeInfoDeclaration* tid = vd->isTypeInfoDeclaration()) |
1 | 193 { |
194 Logger::println("TypeInfoDeclaration"); | |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
101
diff
changeset
|
195 DtoForceDeclareDsymbol(tid); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
196 assert(tid->ir.getIrValue()); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
197 const LLType* vartype = DtoType(type); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
198 LLValue* m; |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
199 if (tid->ir.getIrValue()->getType() != getPtrToType(vartype)) |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
200 m = p->ir->CreateBitCast(tid->ir.getIrValue(), vartype, "tmp"); |
67
f918f3e2e99e
[svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents:
66
diff
changeset
|
201 else |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
202 m = tid->ir.getIrValue(); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
203 return new DVarValue(vd, m, true); |
1 | 204 } |
100 | 205 // classinfo |
206 else if (ClassInfoDeclaration* cid = vd->isClassInfoDeclaration()) | |
207 { | |
208 Logger::println("ClassInfoDeclaration: %s", cid->cd->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:
101
diff
changeset
|
209 DtoDeclareClassInfo(cid->cd); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
210 assert(cid->cd->ir.irStruct->classInfo); |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
211 return new DVarValue(vd, cid->cd->ir.irStruct->classInfo, true); |
100 | 212 } |
67
f918f3e2e99e
[svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents:
66
diff
changeset
|
213 // nested variable |
f918f3e2e99e
[svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents:
66
diff
changeset
|
214 else if (vd->nestedref) { |
72 | 215 Logger::println("nested variable"); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
216 return new DVarValue(vd, DtoNestedVariable(vd), true); |
1 | 217 } |
218 // function parameter | |
67
f918f3e2e99e
[svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents:
66
diff
changeset
|
219 else if (vd->isParameter()) { |
1 | 220 Logger::println("function param"); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
221 if (vd->isRef() || vd->isOut() || DtoIsPassedByRef(vd->type) || llvm::isa<llvm::AllocaInst>(vd->ir.getIrValue())) { |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
222 return new DVarValue(vd, vd->ir.getIrValue(), true); |
1 | 223 } |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
224 else if (llvm::isa<llvm::Argument>(vd->ir.getIrValue())) { |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
225 return new DImValue(type, vd->ir.getIrValue()); |
1 | 226 } |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
81
diff
changeset
|
227 else assert(0); |
1 | 228 } |
229 else { | |
67
f918f3e2e99e
[svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents:
66
diff
changeset
|
230 // take care of forward references of global variables |
100 | 231 if (vd->isDataseg() || (vd->storage_class & STCextern)) { |
67
f918f3e2e99e
[svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents:
66
diff
changeset
|
232 vd->toObjFile(); |
100 | 233 DtoConstInitGlobal(vd); |
234 } | |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
235 if (!vd->ir.getIrValue() || DtoType(vd->type)->isAbstract()) { |
88
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
236 Logger::println("global variable not resolved :/ %s", vd->toChars()); |
163
a8cd9bc1021a
[svn r179] lots and lots of fixes, much more of tango now compiles/works.
lindquist
parents:
162
diff
changeset
|
237 Logger::cout() << *DtoType(vd->type) << '\n'; |
88
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
238 assert(0); |
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
239 } |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
240 return new DVarValue(vd, vd->ir.getIrValue(), true); |
1 | 241 } |
242 } | |
243 else if (FuncDeclaration* fdecl = var->isFuncDeclaration()) | |
244 { | |
245 Logger::println("FuncDeclaration"); | |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
101
diff
changeset
|
246 if (fdecl->llvmInternal != LLVMva_arg) {// && fdecl->llvmValue == 0) |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
101
diff
changeset
|
247 DtoForceDeclareDsymbol(fdecl); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
101
diff
changeset
|
248 } |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
249 return new DFuncValue(fdecl, fdecl->ir.irFunc->func); |
1 | 250 } |
251 else if (SymbolDeclaration* sdecl = var->isSymbolDeclaration()) | |
252 { | |
253 // this seems to be the static initialiser for structs | |
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:
78
diff
changeset
|
254 Type* sdecltype = DtoDType(sdecl->type); |
40 | 255 Logger::print("Sym: type=%s\n", sdecltype->toChars()); |
256 assert(sdecltype->ty == Tstruct); | |
257 TypeStruct* ts = (TypeStruct*)sdecltype; | |
121
9c79b61fb638
[svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents:
120
diff
changeset
|
258 assert(ts->sym); |
162
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
156
diff
changeset
|
259 DtoForceConstInitDsymbol(ts->sym); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
260 assert(ts->sym->ir.irStruct->init); |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
261 return new DVarValue(type, ts->sym->ir.irStruct->init, true); |
1 | 262 } |
263 else | |
264 { | |
265 assert(0 && "Unimplemented VarExp type"); | |
266 } | |
267 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
268 return 0; |
1 | 269 } |
270 | |
271 ////////////////////////////////////////////////////////////////////////////////////////// | |
272 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
273 LLConstant* VarExp::toConstElem(IRState* p) |
40 | 274 { |
275 Logger::print("VarExp::toConstElem: %s | %s\n", toChars(), type->toChars()); | |
276 LOG_SCOPE; | |
277 if (SymbolDeclaration* sdecl = var->isSymbolDeclaration()) | |
278 { | |
279 // this seems to be the static initialiser for structs | |
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:
78
diff
changeset
|
280 Type* sdecltype = DtoDType(sdecl->type); |
40 | 281 Logger::print("Sym: type=%s\n", sdecltype->toChars()); |
282 assert(sdecltype->ty == Tstruct); | |
283 TypeStruct* ts = (TypeStruct*)sdecltype; | |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
101
diff
changeset
|
284 DtoForceConstInitDsymbol(ts->sym); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
285 assert(ts->sym->ir.irStruct->constInit); |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
286 return ts->sym->ir.irStruct->constInit; |
40 | 287 } |
132 | 288 else if (TypeInfoDeclaration* ti = var->isTypeInfoDeclaration()) |
289 { | |
290 DtoForceDeclareDsymbol(ti); | |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
291 assert(ti->ir.getIrValue()); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
292 const LLType* vartype = DtoType(type); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
293 LLConstant* m = isaConstant(ti->ir.getIrValue()); |
132 | 294 assert(m); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
295 if (ti->ir.getIrValue()->getType() != getPtrToType(vartype)) |
132 | 296 m = llvm::ConstantExpr::getBitCast(m, vartype); |
297 return m; | |
298 } | |
299 assert(0 && "Unsupported const VarExp kind"); | |
40 | 300 return NULL; |
301 } | |
302 | |
303 ////////////////////////////////////////////////////////////////////////////////////////// | |
304 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
305 DValue* IntegerExp::toElem(IRState* p) |
1 | 306 { |
307 Logger::print("IntegerExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
308 LOG_SCOPE; | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
309 LLConstant* c = toConstElem(p); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
310 return new DConstValue(type, c); |
40 | 311 } |
312 | |
313 ////////////////////////////////////////////////////////////////////////////////////////// | |
314 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
315 LLConstant* IntegerExp::toConstElem(IRState* p) |
40 | 316 { |
317 Logger::print("IntegerExp::toConstElem: %s | %s\n", toChars(), type->toChars()); | |
318 LOG_SCOPE; | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
319 const LLType* t = DtoType(type); |
96 | 320 if (isaPointer(t)) { |
88
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
321 Logger::println("pointer"); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
322 LLConstant* i = llvm::ConstantInt::get(DtoSize_t(),(uint64_t)value,false); |
40 | 323 return llvm::ConstantExpr::getIntToPtr(i, t); |
1 | 324 } |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
325 assert(llvm::isa<LLIntegerType>(t)); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
326 LLConstant* c = llvm::ConstantInt::get(t,(uint64_t)value,!type->isunsigned()); |
88
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
327 assert(c); |
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
328 Logger::cout() << "value = " << *c << '\n'; |
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
329 return c; |
1 | 330 } |
331 | |
332 ////////////////////////////////////////////////////////////////////////////////////////// | |
333 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
334 DValue* RealExp::toElem(IRState* p) |
1 | 335 { |
336 Logger::print("RealExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
337 LOG_SCOPE; | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
338 LLConstant* c = toConstElem(p); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
339 return new DConstValue(type, c); |
40 | 340 } |
341 | |
342 ////////////////////////////////////////////////////////////////////////////////////////// | |
343 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
344 LLConstant* RealExp::toConstElem(IRState* p) |
40 | 345 { |
346 Logger::print("RealExp::toConstElem: %s | %s\n", toChars(), type->toChars()); | |
347 LOG_SCOPE; | |
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:
78
diff
changeset
|
348 Type* t = DtoDType(type); |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
349 return DtoConstFP(t, value); |
1 | 350 } |
351 | |
352 ////////////////////////////////////////////////////////////////////////////////////////// | |
353 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
354 DValue* NullExp::toElem(IRState* p) |
1 | 355 { |
356 Logger::print("NullExp::toElem(type=%s): %s\n", type->toChars(),toChars()); | |
357 LOG_SCOPE; | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
358 LLConstant* c = toConstElem(p); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
359 return new DNullValue(type, c); |
40 | 360 } |
361 | |
362 ////////////////////////////////////////////////////////////////////////////////////////// | |
363 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
364 LLConstant* NullExp::toConstElem(IRState* p) |
40 | 365 { |
366 Logger::print("NullExp::toConstElem(type=%s): %s\n", type->toChars(),toChars()); | |
367 LOG_SCOPE; | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
368 const LLType* t = DtoType(type); |
28
1c80c18f3c82
[svn r32] * Fixed problems with arrays members of aggregates
lindquist
parents:
27
diff
changeset
|
369 if (type->ty == Tarray) { |
96 | 370 assert(isaStruct(t)); |
40 | 371 return llvm::ConstantAggregateZero::get(t); |
28
1c80c18f3c82
[svn r32] * Fixed problems with arrays members of aggregates
lindquist
parents:
27
diff
changeset
|
372 } |
40 | 373 else { |
374 return llvm::Constant::getNullValue(t); | |
375 } | |
376 assert(0); | |
377 return NULL; | |
1 | 378 } |
379 | |
380 ////////////////////////////////////////////////////////////////////////////////////////// | |
381 | |
90 | 382 DValue* ComplexExp::toElem(IRState* p) |
383 { | |
384 Logger::print("ComplexExp::toElem(): %s | %s\n", toChars(), type->toChars()); | |
385 LOG_SCOPE; | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
386 LLConstant* c = toConstElem(p); |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
387 |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
388 if (c->isNullValue()) { |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
389 Type* t = DtoDType(type); |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
390 if (t->ty == Tcomplex32) |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
391 c = DtoConstFP(Type::tfloat32, 0); |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
392 else |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
393 c = DtoConstFP(Type::tfloat64, 0); |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
394 return new DComplexValue(type, c, c); |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
395 } |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
396 |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
397 return new DComplexValue(type, c->getOperand(0), c->getOperand(1)); |
90 | 398 } |
399 | |
400 ////////////////////////////////////////////////////////////////////////////////////////// | |
401 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
402 LLConstant* ComplexExp::toConstElem(IRState* p) |
90 | 403 { |
404 Logger::print("ComplexExp::toConstElem(): %s | %s\n", toChars(), type->toChars()); | |
405 LOG_SCOPE; | |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
406 return DtoConstComplex(type, value.re, value.im); |
90 | 407 } |
408 | |
409 ////////////////////////////////////////////////////////////////////////////////////////// | |
410 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
411 DValue* StringExp::toElem(IRState* p) |
1 | 412 { |
52 | 413 Logger::print("StringExp::toElem: %s | %s\n", toChars(), type->toChars()); |
1 | 414 LOG_SCOPE; |
415 | |
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:
78
diff
changeset
|
416 Type* dtype = DtoDType(type); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
417 Type* cty = DtoDType(dtype->next); |
1 | 418 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
419 const LLType* ct = DtoType(cty); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
420 if (ct == LLType::VoidTy) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
421 ct = LLType::Int8Ty; |
1 | 422 //printf("ct = %s\n", type->next->toChars()); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
423 const LLArrayType* at = LLArrayType::get(ct,len+1); |
1 | 424 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
425 LLConstant* _init; |
183
3cdf4b0c75a1
[svn r199] Fixed: still some small issues with string literals implicitly converting to different pointer types. Should be fixed now!
lindquist
parents:
178
diff
changeset
|
426 if (cty->size() == 1) { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
427 uint8_t* str = (uint8_t*)string; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
428 std::string cont((char*)str, len); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
429 _init = llvm::ConstantArray::get(cont,true); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
430 } |
183
3cdf4b0c75a1
[svn r199] Fixed: still some small issues with string literals implicitly converting to different pointer types. Should be fixed now!
lindquist
parents:
178
diff
changeset
|
431 else if (cty->size() == 2) { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
432 uint16_t* str = (uint16_t*)string; |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
433 std::vector<LLConstant*> vals; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
434 for(size_t i=0; i<len; ++i) { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
435 vals.push_back(llvm::ConstantInt::get(ct, str[i], false));; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
436 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
437 vals.push_back(llvm::ConstantInt::get(ct, 0, false)); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
438 _init = llvm::ConstantArray::get(at,vals); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
439 } |
183
3cdf4b0c75a1
[svn r199] Fixed: still some small issues with string literals implicitly converting to different pointer types. Should be fixed now!
lindquist
parents:
178
diff
changeset
|
440 else if (cty->size() == 4) { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
441 uint32_t* str = (uint32_t*)string; |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
442 std::vector<LLConstant*> vals; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
443 for(size_t i=0; i<len; ++i) { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
444 vals.push_back(llvm::ConstantInt::get(ct, str[i], false));; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
445 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
446 vals.push_back(llvm::ConstantInt::get(ct, 0, false)); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
447 _init = llvm::ConstantArray::get(at,vals); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
448 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
449 else |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
450 assert(0); |
1 | 451 |
452 llvm::GlobalValue::LinkageTypes _linkage = llvm::GlobalValue::InternalLinkage;//WeakLinkage; | |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
453 Logger::cout() << "type: " << *at << "\ninit: " << *_init << '\n'; |
212
4c2689d57ba4
[svn r228] Fixed: when new'ing basic types, the storage was not default initialized.
lindquist
parents:
210
diff
changeset
|
454 llvm::GlobalVariable* gvar = new llvm::GlobalVariable(at,true,_linkage,_init,".stringliteral",gIR->module); |
1 | 455 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
456 llvm::ConstantInt* zero = llvm::ConstantInt::get(LLType::Int32Ty, 0, false); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
457 LLConstant* idxs[2] = { zero, zero }; |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
458 LLConstant* arrptr = llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2); |
1 | 459 |
40 | 460 if (dtype->ty == Tarray) { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
461 LLConstant* clen = llvm::ConstantInt::get(DtoSize_t(),len,false); |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
462 if (!p->topexp() || p->topexp()->e2 != this) { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
463 LLValue* tmpmem = new llvm::AllocaInst(DtoType(dtype),"tempstring",p->topallocapoint()); |
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:
78
diff
changeset
|
464 DtoSetArray(tmpmem, clen, arrptr); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
465 return new DVarValue(type, tmpmem, true); |
4
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
466 } |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
467 else if (p->topexp()->e2 == this) { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
468 DValue* arr = p->topexp()->v; |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
469 assert(arr); |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
470 if (arr->isSlice()) { |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
471 return new DSliceValue(type, clen, arrptr); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
472 } |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
473 else { |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
474 DtoSetArray(arr->getRVal(), clen, arrptr); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
475 return new DImValue(type, arr->getLVal(), true); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
476 } |
4
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
477 } |
40 | 478 assert(0); |
1 | 479 } |
40 | 480 else if (dtype->ty == Tsarray) { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
481 const LLType* dstType = getPtrToType(LLArrayType::get(ct, len)); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
482 LLValue* emem = (gvar->getType() == dstType) ? gvar : DtoBitCast(gvar, dstType); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
483 return new DVarValue(type, emem, true); |
21
8d45266bbabe
[svn r25] * Fixed a lot of problems with string literals
lindquist
parents:
18
diff
changeset
|
484 } |
40 | 485 else if (dtype->ty == Tpointer) { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
486 return new DImValue(type, arrptr); |
1 | 487 } |
488 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
489 assert(0); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
490 return 0; |
1 | 491 } |
492 | |
493 ////////////////////////////////////////////////////////////////////////////////////////// | |
494 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
495 LLConstant* StringExp::toConstElem(IRState* p) |
40 | 496 { |
497 Logger::print("StringExp::toConstElem: %s | %s\n", toChars(), type->toChars()); | |
498 LOG_SCOPE; | |
499 | |
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:
78
diff
changeset
|
500 Type* t = DtoDType(type); |
176
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
501 Type* cty = DtoDType(t->next); |
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
502 |
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
503 bool nullterm = (t->ty != Tsarray); |
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
504 size_t endlen = nullterm ? len+1 : len; |
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
505 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
506 const LLType* ct = DtoType(cty); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
507 const LLArrayType* at = LLArrayType::get(ct,endlen); |
176
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
508 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
509 LLConstant* _init; |
183
3cdf4b0c75a1
[svn r199] Fixed: still some small issues with string literals implicitly converting to different pointer types. Should be fixed now!
lindquist
parents:
178
diff
changeset
|
510 if (cty->size() == 1) { |
176
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
511 uint8_t* str = (uint8_t*)string; |
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
512 std::string cont((char*)str, len); |
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
513 _init = llvm::ConstantArray::get(cont, nullterm); |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
514 } |
183
3cdf4b0c75a1
[svn r199] Fixed: still some small issues with string literals implicitly converting to different pointer types. Should be fixed now!
lindquist
parents:
178
diff
changeset
|
515 else if (cty->size() == 2) { |
176
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
516 uint16_t* str = (uint16_t*)string; |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
517 std::vector<LLConstant*> vals; |
176
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
518 for(size_t i=0; i<len; ++i) { |
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
519 vals.push_back(llvm::ConstantInt::get(ct, str[i], false));; |
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
520 } |
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
521 if (nullterm) |
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
522 vals.push_back(llvm::ConstantInt::get(ct, 0, false)); |
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
523 _init = llvm::ConstantArray::get(at,vals); |
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
524 } |
183
3cdf4b0c75a1
[svn r199] Fixed: still some small issues with string literals implicitly converting to different pointer types. Should be fixed now!
lindquist
parents:
178
diff
changeset
|
525 else if (cty->size() == 4) { |
176
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
526 uint32_t* str = (uint32_t*)string; |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
527 std::vector<LLConstant*> vals; |
176
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
528 for(size_t i=0; i<len; ++i) { |
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
529 vals.push_back(llvm::ConstantInt::get(ct, str[i], false));; |
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
530 } |
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
531 if (nullterm) |
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
532 vals.push_back(llvm::ConstantInt::get(ct, 0, false)); |
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
533 _init = llvm::ConstantArray::get(at,vals); |
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
534 } |
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
535 else |
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
536 assert(0); |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
537 |
178
8873b7f1457e
[svn r194] Fixed: string literal constant expressions with static array type was broken.
lindquist
parents:
177
diff
changeset
|
538 if (t->ty == Tsarray) |
8873b7f1457e
[svn r194] Fixed: string literal constant expressions with static array type was broken.
lindquist
parents:
177
diff
changeset
|
539 { |
8873b7f1457e
[svn r194] Fixed: string literal constant expressions with static array type was broken.
lindquist
parents:
177
diff
changeset
|
540 return _init; |
8873b7f1457e
[svn r194] Fixed: string literal constant expressions with static array type was broken.
lindquist
parents:
177
diff
changeset
|
541 } |
8873b7f1457e
[svn r194] Fixed: string literal constant expressions with static array type was broken.
lindquist
parents:
177
diff
changeset
|
542 |
40 | 543 llvm::GlobalValue::LinkageTypes _linkage = llvm::GlobalValue::InternalLinkage;//WeakLinkage; |
212
4c2689d57ba4
[svn r228] Fixed: when new'ing basic types, the storage was not default initialized.
lindquist
parents:
210
diff
changeset
|
544 llvm::GlobalVariable* gvar = new llvm::GlobalVariable(_init->getType(),true,_linkage,_init,".stringliteral",gIR->module); |
40 | 545 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
546 llvm::ConstantInt* zero = llvm::ConstantInt::get(LLType::Int32Ty, 0, false); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
547 LLConstant* idxs[2] = { zero, zero }; |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
548 LLConstant* arrptr = llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2); |
40 | 549 |
550 if (t->ty == Tpointer) { | |
551 return arrptr; | |
552 } | |
178
8873b7f1457e
[svn r194] Fixed: string literal constant expressions with static array type was broken.
lindquist
parents:
177
diff
changeset
|
553 else if (t->ty == Tarray) { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
554 LLConstant* clen = llvm::ConstantInt::get(DtoSize_t(),len,false); |
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:
78
diff
changeset
|
555 return DtoConstSlice(clen, arrptr); |
40 | 556 } |
557 | |
558 assert(0); | |
559 return NULL; | |
560 } | |
561 | |
562 ////////////////////////////////////////////////////////////////////////////////////////// | |
563 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
564 DValue* AssignExp::toElem(IRState* p) |
1 | 565 { |
57
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
55
diff
changeset
|
566 Logger::print("AssignExp::toElem: %s | %s = %s\n", toChars(), e1->type->toChars(), e2->type ? e2->type->toChars() : 0); |
1 | 567 LOG_SCOPE; |
568 | |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
569 p->exps.push_back(IRExp(e1,e2,NULL)); |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
570 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
571 DValue* l = e1->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
572 p->topexp()->v = l; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
573 DValue* r = e2->toElem(p); |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
574 |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
575 p->exps.pop_back(); |
1 | 576 |
169
2df270e1ba59
[svn r185] Fixed broken nested classes with data members, did DMD change the class layout? tango.text.Regex now compiles.
lindquist
parents:
167
diff
changeset
|
577 Logger::println("performing assignment"); |
2df270e1ba59
[svn r185] Fixed broken nested classes with data members, did DMD change the class layout? tango.text.Regex now compiles.
lindquist
parents:
167
diff
changeset
|
578 |
92 | 579 DImValue* im = r->isIm(); |
580 if (!im || !im->inPlace()) { | |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
581 Logger::println("assignment not inplace"); |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
582 if (DArrayLenValue* al = l->isArrayLen()) |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
583 { |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
584 DSliceValue* slice = DtoResizeDynArray(l->getType(), l, r); |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
585 DtoAssign(l, slice); |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
586 } |
92 | 587 else |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
588 { |
92 | 589 DtoAssign(l, r); |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
590 } |
92 | 591 } |
592 | |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
593 if (l->isSlice() || l->isComplex()) |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
594 return l; |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
595 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
596 LLValue* v; |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
597 if (l->isVar() && l->isVar()->lval) |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
598 v = l->getLVal(); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
599 else |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
600 v = l->getRVal(); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
601 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
602 return new DVarValue(type, v, true); |
1 | 603 } |
604 | |
605 ////////////////////////////////////////////////////////////////////////////////////////// | |
606 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
607 DValue* AddExp::toElem(IRState* p) |
1 | 608 { |
23 | 609 Logger::print("AddExp::toElem: %s | %s\n", toChars(), type->toChars()); |
1 | 610 LOG_SCOPE; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
611 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
612 DValue* l = e1->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
613 DValue* r = e2->toElem(p); |
1 | 614 |
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:
78
diff
changeset
|
615 Type* t = DtoDType(type); |
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:
78
diff
changeset
|
616 Type* e1type = DtoDType(e1->type); |
92 | 617 Type* e1next = e1type->next ? DtoDType(e1type->next) : NULL; |
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:
78
diff
changeset
|
618 Type* e2type = DtoDType(e2->type); |
40 | 619 |
620 if (e1type != e2type) { | |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
621 if (llvmFieldIndex) { |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
622 assert(e1type->ty == Tpointer && e1next && e1next->ty == Tstruct); |
92 | 623 Logger::println("add to AddrExp of struct"); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
624 assert(r->isConst()); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
625 llvm::ConstantInt* cofs = llvm::cast<llvm::ConstantInt>(r->isConst()->c); |
1 | 626 |
92 | 627 TypeStruct* ts = (TypeStruct*)e1next; |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
628 DStructIndexVector offsets; |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
629 LLValue* v = DtoIndexStruct(l->getRVal(), ts->sym, t->next, cofs->getZExtValue(), offsets); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
630 return new DFieldValue(type, v, true); |
1 | 631 } |
92 | 632 else if (e1type->ty == Tpointer) { |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
633 Logger::println("add to pointer"); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
634 if (r->isConst()) { |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
635 llvm::ConstantInt* cofs = llvm::cast<llvm::ConstantInt>(r->isConst()->c); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
636 if (cofs->isZero()) { |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
637 Logger::println("is zero"); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
638 return new DImValue(type, l->getRVal()); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
639 } |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
640 } |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
641 LLValue* v = llvm::GetElementPtrInst::Create(l->getRVal(), r->getRVal(), "tmp", p->scopebb()); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
642 return new DImValue(type, v); |
1 | 643 } |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
644 else if (t->iscomplex()) { |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
645 return DtoComplexAdd(type, l, r); |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
646 } |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
647 assert(0); |
1 | 648 } |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
649 else if (t->iscomplex()) { |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
650 return DtoComplexAdd(type, l, r); |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
651 } |
1 | 652 else { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
653 return DtoBinAdd(l,r); |
1 | 654 } |
655 } | |
656 | |
657 ////////////////////////////////////////////////////////////////////////////////////////// | |
658 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
659 DValue* AddAssignExp::toElem(IRState* p) |
1 | 660 { |
661 Logger::print("AddAssignExp::toElem: %s\n", toChars()); | |
662 LOG_SCOPE; | |
663 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
664 p->exps.push_back(IRExp(e1,e2,NULL)); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
665 DValue* l = e1->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
666 DValue* r = e2->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
667 p->exps.pop_back(); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
668 |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
669 Type* t = DtoDType(type); |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
670 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
671 DValue* res; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
672 if (DtoDType(e1->type)->ty == Tpointer) { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
673 LLValue* gep = llvm::GetElementPtrInst::Create(l->getRVal(),r->getRVal(),"tmp",p->scopebb()); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
674 res = new DImValue(type, gep); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
675 } |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
676 else if (t->iscomplex()) { |
107
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
104
diff
changeset
|
677 res = DtoComplexAdd(e1->type, l, r); |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
678 } |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
679 else { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
680 res = DtoBinAdd(l,r); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
681 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
682 DtoAssign(l, res); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
683 |
131 | 684 // used as lvalue :/ |
685 if (p->topexp() && p->topexp()->e1 == this) | |
686 { | |
687 assert(!l->isLRValue()); | |
688 return l; | |
689 } | |
690 else | |
691 { | |
692 return res; | |
693 } | |
1 | 694 } |
695 | |
696 ////////////////////////////////////////////////////////////////////////////////////////// | |
697 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
698 DValue* MinExp::toElem(IRState* p) |
1 | 699 { |
700 Logger::print("MinExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
701 LOG_SCOPE; | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
702 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
703 DValue* l = e1->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
704 DValue* r = e2->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
705 |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
706 Type* t = DtoDType(type); |
167
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
707 Type* t1 = DtoDType(e1->type); |
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
708 Type* t2 = DtoDType(e2->type); |
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
709 |
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
710 if (t1->ty == Tpointer && t2->ty == Tpointer) { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
711 LLValue* lv = l->getRVal(); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
712 LLValue* rv = r->getRVal(); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
713 Logger::cout() << "lv: " << *lv << " rv: " << *rv << '\n'; |
167
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
714 lv = p->ir->CreatePtrToInt(lv, DtoSize_t(), "tmp"); |
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
715 rv = p->ir->CreatePtrToInt(rv, DtoSize_t(), "tmp"); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
716 LLValue* diff = p->ir->CreateSub(lv,rv,"tmp"); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
717 if (diff->getType() != DtoType(type)) |
167
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
718 diff = p->ir->CreateIntToPtr(diff, DtoType(type), "tmp"); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
719 return new DImValue(type, diff); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
720 } |
167
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
721 else if (t1->ty == Tpointer) { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
722 LLValue* idx = p->ir->CreateNeg(r->getRVal(), "tmp"); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
723 LLValue* v = llvm::GetElementPtrInst::Create(l->getRVal(), idx, "tmp", p->scopebb()); |
167
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
724 return new DImValue(type, v); |
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
725 } |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
726 else if (t->iscomplex()) { |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
727 return DtoComplexSub(type, l, r); |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
728 } |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
729 else { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
730 return DtoBinSub(l,r); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
731 } |
1 | 732 } |
733 | |
734 ////////////////////////////////////////////////////////////////////////////////////////// | |
735 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
736 DValue* MinAssignExp::toElem(IRState* p) |
1 | 737 { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
738 Logger::print("MinAssignExp::toElem: %s | %s\n", toChars(), type->toChars()); |
1 | 739 LOG_SCOPE; |
740 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
741 DValue* l = e1->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
742 DValue* r = e2->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
743 |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
744 Type* t = DtoDType(type); |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
745 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
746 DValue* res; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
747 if (DtoDType(e1->type)->ty == Tpointer) { |
131 | 748 Logger::println("ptr"); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
749 LLValue* tmp = r->getRVal(); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
750 LLValue* zero = llvm::ConstantInt::get(tmp->getType(),0,false); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
751 tmp = llvm::BinaryOperator::createSub(zero,tmp,"tmp",p->scopebb()); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
752 tmp = llvm::GetElementPtrInst::Create(l->getRVal(),tmp,"tmp",p->scopebb()); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
753 res = new DImValue(type, tmp); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
754 } |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
755 else if (t->iscomplex()) { |
131 | 756 Logger::println("complex"); |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
757 res = DtoComplexSub(type, l, r); |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
758 } |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
759 else { |
131 | 760 Logger::println("basic"); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
761 res = DtoBinSub(l,r); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
762 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
763 DtoAssign(l, res); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
764 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
765 return l; |
1 | 766 } |
767 | |
768 ////////////////////////////////////////////////////////////////////////////////////////// | |
769 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
770 DValue* MulExp::toElem(IRState* p) |
1 | 771 { |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
772 Logger::print("MulExp::toElem: %s | %s\n", toChars(), type->toChars()); |
1 | 773 LOG_SCOPE; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
774 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
775 DValue* l = e1->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
776 DValue* r = e2->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
777 |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
778 if (type->iscomplex()) { |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
779 return DtoComplexMul(type, l, r); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
780 } |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
781 |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
782 return DtoBinMul(l,r); |
1 | 783 } |
784 | |
785 ////////////////////////////////////////////////////////////////////////////////////////// | |
786 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
787 DValue* MulAssignExp::toElem(IRState* p) |
1 | 788 { |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
789 Logger::print("MulAssignExp::toElem: %s | %s\n", toChars(), type->toChars()); |
1 | 790 LOG_SCOPE; |
791 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
792 DValue* l = e1->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
793 DValue* r = e2->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
794 |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
795 DValue* res; |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
796 if (type->iscomplex()) { |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
797 res = DtoComplexMul(type, l, r); |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
798 } |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
799 else { |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
800 res = DtoBinMul(l,r); |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
801 } |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
802 DtoAssign(l, res); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
803 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
804 return l; |
1 | 805 } |
806 | |
807 ////////////////////////////////////////////////////////////////////////////////////////// | |
808 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
809 DValue* DivExp::toElem(IRState* p) |
1 | 810 { |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
811 Logger::print("DivExp::toElem: %s | %s\n", toChars(), type->toChars()); |
1 | 812 LOG_SCOPE; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
813 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
814 DValue* l = e1->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
815 DValue* r = e2->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
816 |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
817 if (type->iscomplex()) { |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
818 return DtoComplexDiv(type, l, r); |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
819 } |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
820 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
821 return DtoBinDiv(l, r); |
1 | 822 } |
823 | |
824 ////////////////////////////////////////////////////////////////////////////////////////// | |
825 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
826 DValue* DivAssignExp::toElem(IRState* p) |
1 | 827 { |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
828 Logger::print("DivAssignExp::toElem: %s | %s\n", toChars(), type->toChars()); |
1 | 829 LOG_SCOPE; |
830 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
831 DValue* l = e1->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
832 DValue* r = e2->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
833 |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
834 DValue* res; |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
835 if (type->iscomplex()) { |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
836 res = DtoComplexDiv(type, l, r); |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
837 } |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
838 else { |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
839 res = DtoBinDiv(l,r); |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
840 } |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
841 DtoAssign(l, res); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
842 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
843 return l; |
1 | 844 } |
845 | |
846 ////////////////////////////////////////////////////////////////////////////////////////// | |
847 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
848 DValue* ModExp::toElem(IRState* p) |
1 | 849 { |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
850 Logger::print("ModExp::toElem: %s | %s\n", toChars(), type->toChars()); |
1 | 851 LOG_SCOPE; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
852 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
853 DValue* l = e1->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
854 DValue* r = e2->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
855 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
856 return DtoBinRem(l, r); |
1 | 857 } |
858 | |
859 ////////////////////////////////////////////////////////////////////////////////////////// | |
860 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
861 DValue* ModAssignExp::toElem(IRState* p) |
1 | 862 { |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
863 Logger::print("ModAssignExp::toElem: %s | %s\n", toChars(), type->toChars()); |
1 | 864 LOG_SCOPE; |
865 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
866 DValue* l = e1->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
867 DValue* r = e2->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
868 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
869 DValue* res = DtoBinRem(l, r); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
870 DtoAssign(l, res); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
871 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
872 return l; |
1 | 873 } |
874 | |
875 ////////////////////////////////////////////////////////////////////////////////////////// | |
876 | |
215
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
877 // TODO: the method below could really use a cleanup/splitup |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
878 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
879 DValue* CallExp::toElem(IRState* p) |
1 | 880 { |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
881 Logger::print("CallExp::toElem: %s | %s\n", toChars(), type->toChars()); |
1 | 882 LOG_SCOPE; |
55
0ccfae271c45
[svn r59] Added support for C-style variadic functions. Currently only works on x86, x86-64 va_arg is broken in LLVM 2.1. PPC and PPC64 unknown.
lindquist
parents:
54
diff
changeset
|
883 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
884 DValue* fn = e1->toElem(p); |
55
0ccfae271c45
[svn r59] Added support for C-style variadic functions. Currently only works on x86, x86-64 va_arg is broken in LLVM 2.1. PPC and PPC64 unknown.
lindquist
parents:
54
diff
changeset
|
885 |
0ccfae271c45
[svn r59] Added support for C-style variadic functions. Currently only works on x86, x86-64 va_arg is broken in LLVM 2.1. PPC and PPC64 unknown.
lindquist
parents:
54
diff
changeset
|
886 TypeFunction* tf = 0; |
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:
78
diff
changeset
|
887 Type* e1type = DtoDType(e1->type); |
18 | 888 |
1 | 889 bool delegateCall = false; |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
101
diff
changeset
|
890 LINK dlink = LINKd; |
1 | 891 |
892 // hidden struct return parameter handling | |
893 bool retinptr = false; | |
18 | 894 |
1 | 895 // regular functions |
40 | 896 if (e1type->ty == Tfunction) { |
897 tf = (TypeFunction*)e1type; | |
1 | 898 if (tf->llvmRetInPtr) { |
899 retinptr = true; | |
900 } | |
901 dlink = tf->linkage; | |
902 } | |
18 | 903 |
1 | 904 // delegates |
40 | 905 else if (e1type->ty == Tdelegate) { |
906 Logger::println("delegateTy = %s\n", e1type->toChars()); | |
907 assert(e1type->next->ty == Tfunction); | |
908 tf = (TypeFunction*)e1type->next; | |
1 | 909 if (tf->llvmRetInPtr) { |
910 retinptr = true; | |
911 } | |
912 dlink = tf->linkage; | |
913 delegateCall = true; | |
914 } | |
18 | 915 |
1 | 916 // invalid |
917 else { | |
918 assert(tf); | |
919 } | |
920 | |
215
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
921 // handling of special intrinsics |
55
0ccfae271c45
[svn r59] Added support for C-style variadic functions. Currently only works on x86, x86-64 va_arg is broken in LLVM 2.1. PPC and PPC64 unknown.
lindquist
parents:
54
diff
changeset
|
922 bool va_magic = false; |
0ccfae271c45
[svn r59] Added support for C-style variadic functions. Currently only works on x86, x86-64 va_arg is broken in LLVM 2.1. PPC and PPC64 unknown.
lindquist
parents:
54
diff
changeset
|
923 bool va_intrinsic = false; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
924 DFuncValue* dfv = fn->isFunc(); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
925 if (dfv && dfv->func) { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
926 FuncDeclaration* fndecl = dfv->func; |
215
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
927 // vararg intrinsic |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
928 if (fndecl->llvmInternal == LLVMva_intrinsic) { |
55
0ccfae271c45
[svn r59] Added support for C-style variadic functions. Currently only works on x86, x86-64 va_arg is broken in LLVM 2.1. PPC and PPC64 unknown.
lindquist
parents:
54
diff
changeset
|
929 va_magic = true; |
0ccfae271c45
[svn r59] Added support for C-style variadic functions. Currently only works on x86, x86-64 va_arg is broken in LLVM 2.1. PPC and PPC64 unknown.
lindquist
parents:
54
diff
changeset
|
930 va_intrinsic = true; |
0ccfae271c45
[svn r59] Added support for C-style variadic functions. Currently only works on x86, x86-64 va_arg is broken in LLVM 2.1. PPC and PPC64 unknown.
lindquist
parents:
54
diff
changeset
|
931 } |
215
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
932 // va_start instruction |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
933 else if (fndecl->llvmInternal == LLVMva_start) { |
55
0ccfae271c45
[svn r59] Added support for C-style variadic functions. Currently only works on x86, x86-64 va_arg is broken in LLVM 2.1. PPC and PPC64 unknown.
lindquist
parents:
54
diff
changeset
|
934 va_magic = true; |
0ccfae271c45
[svn r59] Added support for C-style variadic functions. Currently only works on x86, x86-64 va_arg is broken in LLVM 2.1. PPC and PPC64 unknown.
lindquist
parents:
54
diff
changeset
|
935 } |
215
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
936 // va_arg instruction |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
937 else if (fndecl->llvmInternal == LLVMva_arg) { |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
81
diff
changeset
|
938 //Argument* fnarg = Argument::getNth(tf->parameters, 0); |
55
0ccfae271c45
[svn r59] Added support for C-style variadic functions. Currently only works on x86, x86-64 va_arg is broken in LLVM 2.1. PPC and PPC64 unknown.
lindquist
parents:
54
diff
changeset
|
939 Expression* exp = (Expression*)arguments->data[0]; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
940 DValue* expelem = exp->toElem(p); |
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:
78
diff
changeset
|
941 Type* t = DtoDType(type); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
942 const LLType* llt = DtoType(type); |
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:
78
diff
changeset
|
943 if (DtoIsPassedByRef(t)) |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
944 llt = getPtrToType(llt); |
96 | 945 // TODO |
215
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
946 // issue a warning for broken va_arg instruction. |
96 | 947 if (strcmp(global.params.llvmArch, "x86") != 0) { |
215
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
948 warning("%s: va_arg for C variadic functions is probably broken for anything but x86", loc.toChars()); |
96 | 949 } |
215
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
950 // done |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
951 return new DImValue(type, p->ir->CreateVAArg(expelem->getLVal(),llt,"tmp")); |
55
0ccfae271c45
[svn r59] Added support for C-style variadic functions. Currently only works on x86, x86-64 va_arg is broken in LLVM 2.1. PPC and PPC64 unknown.
lindquist
parents:
54
diff
changeset
|
952 } |
215
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
953 // alloca |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
954 else if (fndecl->llvmInternal == LLVMalloca) { |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
955 //Argument* fnarg = Argument::getNth(tf->parameters, 0); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
956 Expression* exp = (Expression*)arguments->data[0]; |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
957 DValue* expv = exp->toElem(p); |
132 | 958 if (expv->getType()->toBasetype()->ty != Tint32) |
959 expv = DtoCast(expv, Type::tint32); | |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
960 LLValue* alloc = new llvm::AllocaInst(LLType::Int8Ty, expv->getRVal(), "alloca", p->scopebb()); |
215
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
961 // done |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
962 return new DImValue(type, alloc); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
963 } |
55
0ccfae271c45
[svn r59] Added support for C-style variadic functions. Currently only works on x86, x86-64 va_arg is broken in LLVM 2.1. PPC and PPC64 unknown.
lindquist
parents:
54
diff
changeset
|
964 } |
0ccfae271c45
[svn r59] Added support for C-style variadic functions. Currently only works on x86, x86-64 va_arg is broken in LLVM 2.1. PPC and PPC64 unknown.
lindquist
parents:
54
diff
changeset
|
965 |
0ccfae271c45
[svn r59] Added support for C-style variadic functions. Currently only works on x86, x86-64 va_arg is broken in LLVM 2.1. PPC and PPC64 unknown.
lindquist
parents:
54
diff
changeset
|
966 // args |
1 | 967 size_t n = arguments->dim; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
968 DFuncValue* dfn = fn->isFunc(); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
969 if (dfn && dfn->func && dfn->func->llvmInternal == LLVMva_start) |
55
0ccfae271c45
[svn r59] Added support for C-style variadic functions. Currently only works on x86, x86-64 va_arg is broken in LLVM 2.1. PPC and PPC64 unknown.
lindquist
parents:
54
diff
changeset
|
970 n = 1; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
971 if (delegateCall || (dfn && dfn->vthis)) n++; |
1 | 972 if (retinptr) n++; |
57
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
55
diff
changeset
|
973 if (tf->linkage == LINKd && tf->varargs == 1) n+=2; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
974 if (dfn && dfn->func && dfn->func->isNested()) n++; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
975 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
976 LLValue* funcval = fn->getRVal(); |
18 | 977 assert(funcval != 0); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
978 std::vector<LLValue*> llargs(n, 0); |
1 | 979 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
980 const LLFunctionType* llfnty = 0; |
18 | 981 |
215
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
982 // TODO: review the stuff below, using the llvm type to choose seem like a bad idea. the D type should be used. |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
983 // |
1 | 984 // normal function call |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
985 if (llvm::isa<LLFunctionType>(funcval->getType())) { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
986 llfnty = llvm::cast<LLFunctionType>(funcval->getType()); |
1 | 987 } |
988 // pointer to something | |
96 | 989 else if (isaPointer(funcval->getType())) { |
1 | 990 // pointer to function pointer - I think this not really supposed to happen, but does :/ |
991 // seems like sometimes we get a func* other times a func** | |
96 | 992 if (isaPointer(funcval->getType()->getContainedType(0))) { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
993 funcval = DtoLoad(funcval); |
1 | 994 } |
995 // function pointer | |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
996 if (llvm::isa<LLFunctionType>(funcval->getType()->getContainedType(0))) { |
1 | 997 //Logger::cout() << "function pointer type:\n" << *funcval << '\n'; |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
998 llfnty = llvm::cast<LLFunctionType>(funcval->getType()->getContainedType(0)); |
1 | 999 } |
1000 // struct pointer - delegate | |
96 | 1001 else if (isaStruct(funcval->getType()->getContainedType(0))) { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1002 funcval = DtoGEPi(funcval,0,1); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1003 funcval = DtoLoad(funcval); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1004 const LLType* ty = funcval->getType()->getContainedType(0); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1005 llfnty = llvm::cast<LLFunctionType>(ty); |
1 | 1006 } |
1007 // unknown | |
1008 else { | |
1009 Logger::cout() << "what kind of pointer are we calling? : " << *funcval->getType() << '\n'; | |
1010 } | |
1011 } | |
1012 else { | |
1013 Logger::cout() << "what are we calling? : " << *funcval << '\n'; | |
1014 } | |
1015 assert(llfnty); | |
131 | 1016 //Logger::cout() << "Function LLVM type: " << *llfnty << '\n'; |
1 | 1017 |
1018 // argument handling | |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1019 LLFunctionType::param_iterator argiter = llfnty->param_begin(); |
1 | 1020 int j = 0; |
1021 | |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
1022 IRExp* topexp = p->topexp(); |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
1023 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1024 bool isInPlace = false; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1025 |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
1026 // attrs |
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
1027 llvm::PAListPtr palist; |
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
1028 |
40 | 1029 // hidden struct return arguments |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
1030 // TODO: use sret param attr |
1 | 1031 if (retinptr) { |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
1032 if (topexp && topexp->e2 == this) { |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
1033 assert(topexp->v); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1034 LLValue* tlv = topexp->v->getLVal(); |
96 | 1035 assert(isaStruct(tlv->getType()->getContainedType(0))); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1036 llargs[j] = tlv; |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1037 isInPlace = true; |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1038 /*if (DtoIsPassedByRef(tf->next)) { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1039 isInPlace = true; |
1 | 1040 } |
1041 else | |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1042 assert(0);*/ |
1 | 1043 } |
1044 else { | |
1045 llargs[j] = new llvm::AllocaInst(argiter->get()->getContainedType(0),"rettmp",p->topallocapoint()); | |
1046 } | |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1047 |
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
|
1048 if (dfn && dfn->func && dfn->func->runTimeHack) { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1049 const LLType* rettype = getPtrToType(DtoType(type)); |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1050 if (llargs[j]->getType() != llfnty->getParamType(j)) { |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1051 Logger::println("llvmRunTimeHack==true - force casting return value param"); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1052 Logger::cout() << "casting: " << *llargs[j] << " to type: " << *llfnty->getParamType(j) << '\n'; |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1053 llargs[j] = DtoBitCast(llargs[j], llfnty->getParamType(j)); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1054 } |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1055 } |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1056 |
1 | 1057 ++j; |
1058 ++argiter; | |
1059 } | |
1060 | |
40 | 1061 // this arguments |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1062 if (dfn && dfn->vthis) { |
169
2df270e1ba59
[svn r185] Fixed broken nested classes with data members, did DMD change the class layout? tango.text.Regex now compiles.
lindquist
parents:
167
diff
changeset
|
1063 Logger::cout() << "This Call" << '\n';// func val:" << *funcval << '\n'; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1064 if (dfn->vthis->getType() != argiter->get()) { |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1065 //Logger::cout() << "value: " << *dfn->vthis << " totype: " << *argiter->get() << '\n'; |
120
5ce8ab11e75a
[svn r124] Fixed another D vararg + return in ptr bug.
lindquist
parents:
119
diff
changeset
|
1066 llargs[j] = DtoBitCast(dfn->vthis, argiter->get()); |
1 | 1067 } |
1068 else { | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1069 llargs[j] = dfn->vthis; |
1 | 1070 } |
1071 ++j; | |
1072 ++argiter; | |
1073 } | |
40 | 1074 // delegate context arguments |
1 | 1075 else if (delegateCall) { |
1076 Logger::println("Delegate Call"); | |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1077 LLValue* contextptr = DtoGEPi(fn->getRVal(),0,0); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1078 llargs[j] = DtoLoad(contextptr); |
1 | 1079 ++j; |
1080 ++argiter; | |
1081 } | |
68
c4b3f5d2cd9b
[svn r72] Calling a nested function that is not a delegate was not working.
lindquist
parents:
67
diff
changeset
|
1082 // nested call |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1083 else if (dfn && dfn->func && dfn->func->isNested()) { |
68
c4b3f5d2cd9b
[svn r72] Calling a nested function that is not a delegate was not working.
lindquist
parents:
67
diff
changeset
|
1084 Logger::println("Nested Call"); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1085 LLValue* contextptr = DtoNestedContext(dfn->func->toParent2()->isFuncDeclaration()); |
120
5ce8ab11e75a
[svn r124] Fixed another D vararg + return in ptr bug.
lindquist
parents:
119
diff
changeset
|
1086 if (!contextptr) |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1087 contextptr = llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty)); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1088 llargs[j] = DtoBitCast(contextptr, getPtrToType(LLType::Int8Ty)); |
68
c4b3f5d2cd9b
[svn r72] Calling a nested function that is not a delegate was not working.
lindquist
parents:
67
diff
changeset
|
1089 ++j; |
c4b3f5d2cd9b
[svn r72] Calling a nested function that is not a delegate was not working.
lindquist
parents:
67
diff
changeset
|
1090 ++argiter; |
c4b3f5d2cd9b
[svn r72] Calling a nested function that is not a delegate was not working.
lindquist
parents:
67
diff
changeset
|
1091 } |
1 | 1092 |
55
0ccfae271c45
[svn r59] Added support for C-style variadic functions. Currently only works on x86, x86-64 va_arg is broken in LLVM 2.1. PPC and PPC64 unknown.
lindquist
parents:
54
diff
changeset
|
1093 // va arg function special argument passing |
131 | 1094 if (va_magic) |
1095 { | |
55
0ccfae271c45
[svn r59] Added support for C-style variadic functions. Currently only works on x86, x86-64 va_arg is broken in LLVM 2.1. PPC and PPC64 unknown.
lindquist
parents:
54
diff
changeset
|
1096 size_t n = va_intrinsic ? arguments->dim : 1; |
0ccfae271c45
[svn r59] Added support for C-style variadic functions. Currently only works on x86, x86-64 va_arg is broken in LLVM 2.1. PPC and PPC64 unknown.
lindquist
parents:
54
diff
changeset
|
1097 for (int i=0; i<n; i++,j++) |
0ccfae271c45
[svn r59] Added support for C-style variadic functions. Currently only works on x86, x86-64 va_arg is broken in LLVM 2.1. PPC and PPC64 unknown.
lindquist
parents:
54
diff
changeset
|
1098 { |
0ccfae271c45
[svn r59] Added support for C-style variadic functions. Currently only works on x86, x86-64 va_arg is broken in LLVM 2.1. PPC and PPC64 unknown.
lindquist
parents:
54
diff
changeset
|
1099 Argument* fnarg = Argument::getNth(tf->parameters, i); |
0ccfae271c45
[svn r59] Added support for C-style variadic functions. Currently only works on x86, x86-64 va_arg is broken in LLVM 2.1. PPC and PPC64 unknown.
lindquist
parents:
54
diff
changeset
|
1100 Expression* exp = (Expression*)arguments->data[i]; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1101 DValue* expelem = exp->toElem(p); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1102 llargs[j] = DtoBitCast(expelem->getLVal(), getPtrToType(LLType::Int8Ty)); |
55
0ccfae271c45
[svn r59] Added support for C-style variadic functions. Currently only works on x86, x86-64 va_arg is broken in LLVM 2.1. PPC and PPC64 unknown.
lindquist
parents:
54
diff
changeset
|
1103 } |
0ccfae271c45
[svn r59] Added support for C-style variadic functions. Currently only works on x86, x86-64 va_arg is broken in LLVM 2.1. PPC and PPC64 unknown.
lindquist
parents:
54
diff
changeset
|
1104 } |
215
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1105 // d variadic function |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1106 else if (tf->linkage == LINKd && tf->varargs == 1) |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1107 { |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1108 Logger::println("doing d-style variadic arguments"); |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1109 |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1110 size_t nimplicit = j; |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1111 |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1112 std::vector<const LLType*> vtypes; |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1113 |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1114 // number of non variadic args |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1115 int begin = tf->parameters->dim; |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1116 Logger::println("num non vararg params = %d", begin); |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1117 |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1118 // build struct with argument types |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1119 for (int i=begin; i<arguments->dim; i++) |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1120 { |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1121 Argument* argu = Argument::getNth(tf->parameters, i); |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1122 Expression* argexp = (Expression*)arguments->data[i]; |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1123 vtypes.push_back(DtoType(argexp->type)); |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1124 } |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1125 const LLStructType* vtype = LLStructType::get(vtypes); |
215
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1126 Logger::cout() << "d-variadic argument struct type:\n" << *vtype << '\n'; |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1127 LLValue* mem = new llvm::AllocaInst(vtype,"_argptr_storage",p->topallocapoint()); |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1128 |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1129 // store arguments in the struct |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1130 for (int i=begin,k=0; i<arguments->dim; i++,k++) |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1131 { |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1132 Expression* argexp = (Expression*)arguments->data[i]; |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1133 if (global.params.llvmAnnotate) |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1134 DtoAnnotation(argexp->toChars()); |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1135 DtoVariadicArgument(argexp, DtoGEPi(mem,0,k,"tmp")); |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1136 } |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1137 |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1138 // build type info array |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1139 assert(Type::typeinfo->ir.irStruct->constInit); |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1140 const LLType* typeinfotype = DtoType(Type::typeinfo->type); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1141 const LLArrayType* typeinfoarraytype = LLArrayType::get(typeinfotype,vtype->getNumElements()); |
215
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1142 |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1143 llvm::GlobalVariable* typeinfomem = |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1144 new llvm::GlobalVariable(typeinfoarraytype, true, llvm::GlobalValue::InternalLinkage, NULL, "._arguments.storage", gIR->module); |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1145 Logger::cout() << "_arguments storage: " << *typeinfomem << '\n'; |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1146 |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1147 std::vector<LLConstant*> vtypeinfos; |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1148 for (int i=begin,k=0; i<arguments->dim; i++,k++) |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1149 { |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1150 Expression* argexp = (Expression*)arguments->data[i]; |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1151 vtypeinfos.push_back(DtoTypeInfoOf(argexp->type)); |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1152 } |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1153 |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1154 // apply initializer |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1155 LLConstant* tiinits = llvm::ConstantArray::get(typeinfoarraytype, vtypeinfos); |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1156 typeinfomem->setInitializer(tiinits); |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1157 |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1158 // put data in d-array |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1159 std::vector<LLConstant*> pinits; |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1160 pinits.push_back(DtoConstSize_t(vtype->getNumElements())); |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1161 pinits.push_back(llvm::ConstantExpr::getBitCast(typeinfomem, getPtrToType(typeinfotype))); |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1162 const LLType* tiarrty = llfnty->getParamType(j)->getContainedType(0); |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1163 tiinits = llvm::ConstantStruct::get(pinits); |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1164 LLValue* typeinfoarrayparam = new llvm::GlobalVariable(tiarrty, |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1165 true, llvm::GlobalValue::InternalLinkage, tiinits, "._arguments.array", gIR->module); |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1166 |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1167 // specify arguments |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1168 llargs[j] = typeinfoarrayparam;; |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1169 j++; |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1170 llargs[j] = p->ir->CreateBitCast(mem, getPtrToType(LLType::Int8Ty), "tmp"); |
215
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1171 j++; |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1172 |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1173 // pass non variadic args |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1174 for (int i=0; i<begin; i++) |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1175 { |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1176 Argument* fnarg = Argument::getNth(tf->parameters, i); |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1177 DValue* argval = DtoArgument(fnarg, (Expression*)arguments->data[i]); |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1178 llargs[j] = argval->getRVal(); |
218
df641a27e9fd
[svn r234] Fixed: missed a few bogus #ifs in last revision.
lindquist
parents:
217
diff
changeset
|
1179 |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
1180 if (fnarg->llvmByVal) |
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
1181 palist = palist.addAttr(j, llvm::ParamAttr::ByVal); |
218
df641a27e9fd
[svn r234] Fixed: missed a few bogus #ifs in last revision.
lindquist
parents:
217
diff
changeset
|
1182 |
215
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1183 j++; |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1184 } |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1185 |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1186 // make sure arg vector has the right size |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1187 llargs.resize(nimplicit+begin+2); |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1188 } |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1189 // normal function call |
131 | 1190 else |
1191 { | |
215
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1192 Logger::println("doing normal arguments"); |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1193 for (int i=0; i<arguments->dim; i++,j++) { |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1194 Argument* fnarg = Argument::getNth(tf->parameters, i); |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1195 if (global.params.llvmAnnotate) |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1196 DtoAnnotation(((Expression*)arguments->data[i])->toChars()); |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1197 DValue* argval = DtoArgument(fnarg, (Expression*)arguments->data[i]); |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1198 llargs[j] = argval->getRVal(); |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1199 if (fnarg && llargs[j]->getType() != llfnty->getParamType(j)) { |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1200 llargs[j] = DtoBitCast(llargs[j], llfnty->getParamType(j)); |
57
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
55
diff
changeset
|
1201 } |
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
55
diff
changeset
|
1202 |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
1203 if (fnarg && fnarg->llvmByVal) |
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
1204 palist = palist.addAttr(j+1, llvm::ParamAttr::ByVal); |
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
1205 |
215
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1206 // this hack is necessary :/ |
243
4d006f7b2ada
[svn r260] Changed some of the LLVMDC specific code in the Tango core and did some minor cleanups.
lindquist
parents:
240
diff
changeset
|
1207 // thing is DMD doesn't create correct signatures for the DMD generated calls to the runtime. |
4d006f7b2ada
[svn r260] Changed some of the LLVMDC specific code in the Tango core and did some minor cleanups.
lindquist
parents:
240
diff
changeset
|
1208 // only the return type is right, no arguments (parameters==NULL) ... |
215
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1209 if (dfn && dfn->func && dfn->func->runTimeHack) { |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
219
diff
changeset
|
1210 llvm::Function* fn = dfn->func->ir.irFunc->func; |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
219
diff
changeset
|
1211 assert(fn); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
219
diff
changeset
|
1212 if (fn->getParamAttrs().paramHasAttr(j+1, llvm::ParamAttr::ByVal)) |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
219
diff
changeset
|
1213 palist = palist.addAttr(j+1, llvm::ParamAttr::ByVal); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
219
diff
changeset
|
1214 |
215
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1215 if (llfnty->getParamType(j) != NULL) { |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1216 if (llargs[j]->getType() != llfnty->getParamType(j)) { |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1217 Logger::println("llvmRunTimeHack==true - force casting argument"); |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1218 Logger::cout() << "casting: " << *llargs[j] << " to type: " << *llfnty->getParamType(j) << '\n'; |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1219 llargs[j] = DtoBitCast(llargs[j], llfnty->getParamType(j)); |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
101
diff
changeset
|
1220 } |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1221 } |
57
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
55
diff
changeset
|
1222 } |
55
0ccfae271c45
[svn r59] Added support for C-style variadic functions. Currently only works on x86, x86-64 va_arg is broken in LLVM 2.1. PPC and PPC64 unknown.
lindquist
parents:
54
diff
changeset
|
1223 } |
1 | 1224 } |
1225 | |
169
2df270e1ba59
[svn r185] Fixed broken nested classes with data members, did DMD change the class layout? tango.text.Regex now compiles.
lindquist
parents:
167
diff
changeset
|
1226 #if 0 |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
1227 Logger::println("%d params passed", n); |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
1228 for (int i=0; i<llargs.size(); ++i) { |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
1229 assert(llargs[i]); |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
1230 Logger::cout() << "arg["<<i<<"] = " << *llargs[i] << '\n'; |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
1231 } |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
1232 #endif |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
1233 |
1 | 1234 // void returns cannot not be named |
1235 const char* varname = ""; | |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1236 if (llfnty->getReturnType() != LLType::VoidTy) |
1 | 1237 varname = "tmp"; |
1238 | |
169
2df270e1ba59
[svn r185] Fixed broken nested classes with data members, did DMD change the class layout? tango.text.Regex now compiles.
lindquist
parents:
167
diff
changeset
|
1239 //Logger::cout() << "Calling: " << *funcval << '\n'; |
1 | 1240 |
1241 // call the function | |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
1242 llvm::CallInst* call = llvm::CallInst::Create(funcval, llargs.begin(), llargs.end(), varname, p->scopebb()); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1243 LLValue* retllval = (retinptr) ? llargs[0] : call; |
1 | 1244 |
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
|
1245 if (retinptr && dfn && dfn->func && dfn->func->runTimeHack) { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1246 const LLType* rettype = getPtrToType(DtoType(type)); |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1247 if (retllval->getType() != rettype) { |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1248 Logger::println("llvmRunTimeHack==true - force casting return value"); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1249 Logger::cout() << "from: " << *retllval->getType() << " to: " << *rettype << '\n'; |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1250 retllval = DtoBitCast(retllval, rettype); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1251 } |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1252 } |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1253 |
1 | 1254 // set calling convention |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1255 if (dfn && dfn->func) { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1256 int li = dfn->func->llvmInternal; |
66
0c5f410d973c
[svn r70] Fixed bug where correct calling convention was not set on calling aggregate methods
lindquist
parents:
64
diff
changeset
|
1257 if (li != LLVMintrinsic && li != LLVMva_start && li != LLVMva_intrinsic) { |
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:
78
diff
changeset
|
1258 call->setCallingConv(DtoCallingConv(dlink)); |
66
0c5f410d973c
[svn r70] Fixed bug where correct calling convention was not set on calling aggregate methods
lindquist
parents:
64
diff
changeset
|
1259 } |
0c5f410d973c
[svn r70] Fixed bug where correct calling convention was not set on calling aggregate methods
lindquist
parents:
64
diff
changeset
|
1260 } |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
101
diff
changeset
|
1261 /*else if (delegateCall) { |
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:
78
diff
changeset
|
1262 call->setCallingConv(DtoCallingConv(dlink)); |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
101
diff
changeset
|
1263 }*/ |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1264 else if (dfn && dfn->cc != (unsigned)-1) { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1265 call->setCallingConv(dfn->cc); |
67
f918f3e2e99e
[svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents:
66
diff
changeset
|
1266 } |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
101
diff
changeset
|
1267 else { |
100 | 1268 call->setCallingConv(DtoCallingConv(dlink)); |
1269 } | |
1 | 1270 |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
1271 // param attrs |
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
1272 call->setParamAttrs(palist); |
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
1273 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1274 return new DImValue(type, retllval, isInPlace); |
1 | 1275 } |
1276 | |
1277 ////////////////////////////////////////////////////////////////////////////////////////// | |
1278 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1279 DValue* CastExp::toElem(IRState* p) |
1 | 1280 { |
53
06ccc817acd4
[svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents:
52
diff
changeset
|
1281 Logger::print("CastExp::toElem: %s | %s\n", toChars(), type->toChars()); |
1 | 1282 LOG_SCOPE; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1283 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1284 DValue* u = e1->toElem(p); |
97
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1285 DValue* v = DtoCast(u, to); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1286 |
107
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
104
diff
changeset
|
1287 if (v->isSlice()) { |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
104
diff
changeset
|
1288 assert(!gIR->topexp() || gIR->topexp()->e1 != this); |
97
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1289 return v; |
1 | 1290 } |
97
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1291 |
201 | 1292 else if (DLRValue* lr = u->isLRValue()) |
1293 return new DLRValue(lr->getLType(), lr->getLVal(), to, v->getRVal()); | |
1294 | |
1295 else if (u->isVar() && u->isVar()->lval) | |
107
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
104
diff
changeset
|
1296 return new DLRValue(e1->type, u->getLVal(), to, v->getRVal()); |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
104
diff
changeset
|
1297 |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
104
diff
changeset
|
1298 else if (gIR->topexp() && gIR->topexp()->e1 == this) |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
104
diff
changeset
|
1299 return new DLRValue(e1->type, u->getLVal(), to, v->getRVal()); |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
104
diff
changeset
|
1300 |
97
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1301 return v; |
1 | 1302 } |
1303 | |
1304 ////////////////////////////////////////////////////////////////////////////////////////// | |
1305 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1306 DValue* SymOffExp::toElem(IRState* p) |
1 | 1307 { |
1308 Logger::print("SymOffExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1309 LOG_SCOPE; | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1310 |
98
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
97
diff
changeset
|
1311 assert(0 && "SymOffExp::toElem should no longer be called :/"); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
1312 return 0; |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
1313 } |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
1314 |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
1315 ////////////////////////////////////////////////////////////////////////////////////////// |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
1316 |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
1317 DValue* AddrExp::toElem(IRState* p) |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
1318 { |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
1319 Logger::println("AddrExp::toElem: %s | %s", toChars(), type->toChars()); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
1320 LOG_SCOPE; |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
1321 DValue* v = e1->toElem(p); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
1322 if (v->isField()) { |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
1323 Logger::println("is field"); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
1324 return v; |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
1325 } |
100 | 1326 else if (DFuncValue* fv = v->isFunc()) { |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
1327 Logger::println("is func"); |
100 | 1328 //Logger::println("FuncDeclaration"); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
1329 FuncDeclaration* fd = fv->func; |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
1330 assert(fd); |
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
|
1331 DtoForceDeclareDsymbol(fd); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
1332 return new DFuncValue(fd, fd->ir.irFunc->func); |
1 | 1333 } |
101
169fda3a77d4
[svn r105] -inline does nothing for now, the -On setting can already be used to trigger it.
lindquist
parents:
100
diff
changeset
|
1334 else if (DImValue* im = v->isIm()) { |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
1335 Logger::println("is immediate"); |
101
169fda3a77d4
[svn r105] -inline does nothing for now, the -On setting can already be used to trigger it.
lindquist
parents:
100
diff
changeset
|
1336 return v; |
169fda3a77d4
[svn r105] -inline does nothing for now, the -On setting can already be used to trigger it.
lindquist
parents:
100
diff
changeset
|
1337 } |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
1338 Logger::println("is nothing special"); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
1339 return new DFieldValue(type, v->getLVal(), false); |
1 | 1340 } |
1341 | |
1342 ////////////////////////////////////////////////////////////////////////////////////////// | |
1343 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1344 DValue* PtrExp::toElem(IRState* p) |
1 | 1345 { |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
1346 Logger::println("PtrExp::toElem: %s | %s", toChars(), type->toChars()); |
1 | 1347 LOG_SCOPE; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1348 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1349 DValue* a = e1->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1350 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1351 if (p->topexp() && p->topexp()->e1 == this) { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1352 Logger::println("lval PtrExp"); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1353 return new DVarValue(type, a->getRVal(), true); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1354 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1355 |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1356 // this should be deterministic but right now lvalue casts don't propagate lvalueness !?! |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1357 LLValue* lv = a->getRVal(); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1358 LLValue* v = lv; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1359 if (DtoCanLoad(v)) |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1360 v = DtoLoad(v); |
107
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
104
diff
changeset
|
1361 return new DLRValue(e1->type, lv, type, v); |
1 | 1362 } |
1363 | |
1364 ////////////////////////////////////////////////////////////////////////////////////////// | |
1365 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1366 DValue* DotVarExp::toElem(IRState* p) |
1 | 1367 { |
1368 Logger::print("DotVarExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1369 LOG_SCOPE; | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1370 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1371 DValue* l = e1->toElem(p); |
1 | 1372 |
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:
78
diff
changeset
|
1373 Type* t = DtoDType(type); |
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:
78
diff
changeset
|
1374 Type* e1type = DtoDType(e1->type); |
40 | 1375 |
172
68a7dd38c03c
[svn r188] Fixed using a dereferenced pointer argument as both l- and r-value. fixes tango.io.FileRoots.
lindquist
parents:
170
diff
changeset
|
1376 //Logger::println("e1type=%s", e1type->toChars()); |
68a7dd38c03c
[svn r188] Fixed using a dereferenced pointer argument as both l- and r-value. fixes tango.io.FileRoots.
lindquist
parents:
170
diff
changeset
|
1377 //Logger::cout() << *DtoType(e1type) << '\n'; |
1 | 1378 |
1379 if (VarDeclaration* vd = var->isVarDeclaration()) { | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1380 LLValue* arrptr; |
40 | 1381 if (e1type->ty == Tpointer) { |
1382 assert(e1type->next->ty == Tstruct); | |
1383 TypeStruct* ts = (TypeStruct*)e1type->next; | |
8
5e69b77a5c51
[svn r12] fixed accessing aggregate fields of aggregates
lindquist
parents:
6
diff
changeset
|
1384 Logger::println("Struct member offset:%d", vd->offset); |
132 | 1385 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1386 LLValue* src = l->getRVal(); |
132 | 1387 |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
1388 DStructIndexVector vdoffsets; |
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:
78
diff
changeset
|
1389 arrptr = DtoIndexStruct(src, ts->sym, vd->type, vd->offset, vdoffsets); |
1 | 1390 } |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1391 else if (e1type->ty == Tclass) { |
40 | 1392 TypeClass* tc = (TypeClass*)e1type; |
1 | 1393 Logger::println("Class member offset: %d", vd->offset); |
132 | 1394 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1395 LLValue* src = l->getRVal(); |
132 | 1396 |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
1397 DStructIndexVector vdoffsets; |
132 | 1398 arrptr = DtoIndexClass(src, tc->sym, vd->type, vd->offset, vdoffsets); |
1 | 1399 } |
77
714057ff2dbb
[svn r81] Fixed: Union support was very buggy. Should be fairly solid now.
lindquist
parents:
76
diff
changeset
|
1400 else |
714057ff2dbb
[svn r81] Fixed: Union support was very buggy. Should be fairly solid now.
lindquist
parents:
76
diff
changeset
|
1401 assert(0); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1402 |
123
7f9a0a58394b
[svn r127] Updated the lphobos build scripts a little. Created a new rebuild profile.
lindquist
parents:
122
diff
changeset
|
1403 //Logger::cout() << "mem: " << *arrptr << '\n'; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1404 return new DVarValue(vd, arrptr, true); |
1 | 1405 } |
1406 else if (FuncDeclaration* fdecl = var->isFuncDeclaration()) | |
1407 { | |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1408 DtoResolveDsymbol(fdecl); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1409 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1410 LLValue* funcval; |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1411 LLValue* vthis2 = 0; |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1412 if (e1type->ty == Tclass) { |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1413 TypeClass* tc = (TypeClass*)e1type; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1414 if (tc->sym->isInterfaceDeclaration()) { |
114 | 1415 vthis2 = DtoCastInterfaceToObject(l, NULL)->getRVal(); |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1416 } |
1 | 1417 } |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1418 LLValue* vthis = l->getRVal(); |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1419 if (!vthis2) vthis2 = vthis; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1420 //unsigned cc = (unsigned)-1; |
1 | 1421 |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1422 // super call |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1423 if (e1->op == TOKsuper) { |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1424 DtoForceDeclareDsymbol(fdecl); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
1425 funcval = fdecl->ir.irFunc->func; |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1426 assert(funcval); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1427 } |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1428 // normal virtual call |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1429 else if (fdecl->isAbstract() || (!fdecl->isFinal() && fdecl->isVirtual())) { |
1 | 1430 assert(fdecl->vtblIndex > 0); |
40 | 1431 assert(e1type->ty == Tclass); |
1 | 1432 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1433 LLValue* zero = llvm::ConstantInt::get(LLType::Int32Ty, 0, false); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1434 LLValue* vtblidx = llvm::ConstantInt::get(LLType::Int32Ty, (size_t)fdecl->vtblIndex, false); |
123
7f9a0a58394b
[svn r127] Updated the lphobos build scripts a little. Created a new rebuild profile.
lindquist
parents:
122
diff
changeset
|
1435 //Logger::cout() << "vthis: " << *vthis << '\n'; |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1436 funcval = DtoGEP(vthis, zero, zero); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1437 funcval = DtoLoad(funcval); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1438 funcval = DtoGEP(funcval, zero, vtblidx, toChars()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1439 funcval = DtoLoad(funcval); |
193
aca17e55b7a5
[svn r209] Fixed: exotic array to pointer casts were broken.
lindquist
parents:
183
diff
changeset
|
1440 #if OPAQUE_VTBLS |
aca17e55b7a5
[svn r209] Fixed: exotic array to pointer casts were broken.
lindquist
parents:
183
diff
changeset
|
1441 funcval = DtoBitCast(funcval, getPtrToType(DtoType(fdecl->type))); |
aca17e55b7a5
[svn r209] Fixed: exotic array to pointer casts were broken.
lindquist
parents:
183
diff
changeset
|
1442 Logger::cout() << "funcval casted: " << *funcval << '\n'; |
aca17e55b7a5
[svn r209] Fixed: exotic array to pointer casts were broken.
lindquist
parents:
183
diff
changeset
|
1443 #endif |
1 | 1444 } |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1445 // static call |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1446 else { |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1447 DtoForceDeclareDsymbol(fdecl); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
1448 funcval = fdecl->ir.irFunc->func; |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1449 assert(funcval); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1450 //assert(funcval->getType() == DtoType(fdecl->type)); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1451 } |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1452 return new DFuncValue(fdecl, funcval, vthis2); |
1 | 1453 } |
1454 else { | |
123
7f9a0a58394b
[svn r127] Updated the lphobos build scripts a little. Created a new rebuild profile.
lindquist
parents:
122
diff
changeset
|
1455 printf("unsupported dotvarexp: %s\n", var->toChars()); |
1 | 1456 } |
1457 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1458 assert(0); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1459 return 0; |
1 | 1460 } |
1461 | |
1462 ////////////////////////////////////////////////////////////////////////////////////////// | |
1463 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1464 DValue* ThisExp::toElem(IRState* p) |
1 | 1465 { |
1466 Logger::print("ThisExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1467 LOG_SCOPE; | |
1468 | |
1469 if (VarDeclaration* vd = var->isVarDeclaration()) { | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1470 LLValue* v; |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
1471 v = p->func()->decl->ir.irFunc->thisVar; |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
1472 if (llvm::isa<llvm::AllocaInst>(v)) |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1473 v = DtoLoad(v); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1474 const LLType* t = DtoType(type); |
197
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
193
diff
changeset
|
1475 if (v->getType() != t) |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1476 v = DtoBitCast(v, t); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1477 return new DThisValue(vd, v); |
1 | 1478 } |
1479 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1480 assert(0); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1481 return 0; |
1 | 1482 } |
1483 | |
1484 ////////////////////////////////////////////////////////////////////////////////////////// | |
1485 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1486 DValue* IndexExp::toElem(IRState* p) |
1 | 1487 { |
1488 Logger::print("IndexExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1489 LOG_SCOPE; | |
1490 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1491 DValue* l = e1->toElem(p); |
1 | 1492 |
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:
78
diff
changeset
|
1493 Type* e1type = DtoDType(e1->type); |
40 | 1494 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1495 p->arrays.push_back(l); // if $ is used it must be an array so this is fine. |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1496 DValue* r = e2->toElem(p); |
1 | 1497 p->arrays.pop_back(); |
1498 | |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1499 LLValue* zero = DtoConstUint(0); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1500 LLValue* one = DtoConstUint(1); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1501 |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1502 LLValue* arrptr = 0; |
40 | 1503 if (e1type->ty == Tpointer) { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1504 arrptr = DtoGEP1(l->getRVal(),r->getRVal()); |
1 | 1505 } |
40 | 1506 else if (e1type->ty == Tsarray) { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1507 arrptr = DtoGEP(l->getRVal(), zero, r->getRVal()); |
1 | 1508 } |
40 | 1509 else if (e1type->ty == Tarray) { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1510 arrptr = DtoGEP(l->getRVal(),zero,one); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1511 arrptr = DtoLoad(arrptr); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1512 arrptr = DtoGEP1(arrptr,r->getRVal()); |
1 | 1513 } |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1514 else if (e1type->ty == Taarray) { |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1515 return DtoAAIndex(type, l, r); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1516 } |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1517 else { |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1518 Logger::println("invalid index exp! e1type: %s", e1type->toChars()); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1519 assert(0); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1520 } |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1521 return new DVarValue(type, arrptr, true); |
1 | 1522 } |
1523 | |
1524 ////////////////////////////////////////////////////////////////////////////////////////// | |
1525 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1526 DValue* SliceExp::toElem(IRState* p) |
1 | 1527 { |
1528 Logger::print("SliceExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1529 LOG_SCOPE; | |
1530 | |
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:
78
diff
changeset
|
1531 Type* t = DtoDType(type); |
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:
78
diff
changeset
|
1532 Type* e1type = DtoDType(e1->type); |
1 | 1533 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1534 DValue* v = e1->toElem(p); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1535 LLValue* vmem = v->getRVal(); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1536 assert(vmem); |
1 | 1537 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1538 LLValue* zero = DtoConstUint(0); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1539 LLValue* one = DtoConstUint(1); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1540 |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1541 LLValue* emem = 0; |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1542 LLValue* earg = 0; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1543 |
1 | 1544 // partial slice |
1545 if (lwr) | |
1546 { | |
1547 assert(upr); | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1548 p->arrays.push_back(v); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1549 DValue* lo = lwr->toElem(p); |
1 | 1550 |
1551 bool lwr_is_zero = false; | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1552 if (DConstValue* cv = lo->isConst()) |
1 | 1553 { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1554 assert(llvm::isa<llvm::ConstantInt>(cv->c)); |
1 | 1555 |
40 | 1556 if (e1type->ty == Tpointer) { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1557 emem = v->getRVal(); |
1 | 1558 } |
40 | 1559 else if (e1type->ty == Tarray) { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1560 LLValue* tmp = DtoGEP(vmem,zero,one); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1561 emem = DtoLoad(tmp); |
1 | 1562 } |
40 | 1563 else if (e1type->ty == Tsarray) { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1564 emem = DtoGEP(vmem,zero,zero); |
40 | 1565 } |
1 | 1566 else |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1567 assert(emem); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1568 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1569 llvm::ConstantInt* c = llvm::cast<llvm::ConstantInt>(cv->c); |
1 | 1570 if (!(lwr_is_zero = c->isZero())) { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1571 emem = DtoGEP1(emem,cv->c); |
1 | 1572 } |
1573 } | |
1574 else | |
1575 { | |
40 | 1576 if (e1type->ty == Tarray) { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1577 LLValue* tmp = DtoGEP(vmem,zero,one); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1578 tmp = DtoLoad(tmp); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1579 emem = DtoGEP1(tmp,lo->getRVal()); |
40 | 1580 } |
1581 else if (e1type->ty == Tsarray) { | |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1582 emem = DtoGEP(vmem,zero,lo->getRVal()); |
40 | 1583 } |
73 | 1584 else if (e1type->ty == Tpointer) { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1585 emem = DtoGEP1(v->getRVal(),lo->getRVal()); |
73 | 1586 } |
1587 else { | |
1588 Logger::println("type = %s", e1type->toChars()); | |
1589 assert(0); | |
1590 } | |
1 | 1591 } |
1592 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1593 DValue* up = upr->toElem(p); |
1 | 1594 p->arrays.pop_back(); |
1595 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1596 if (DConstValue* cv = up->isConst()) |
1 | 1597 { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1598 assert(llvm::isa<llvm::ConstantInt>(cv->c)); |
1 | 1599 if (lwr_is_zero) { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1600 earg = cv->c; |
1 | 1601 } |
1602 else { | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1603 if (lo->isConst()) { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1604 LLConstant* clo = llvm::cast<llvm::Constant>(lo->getRVal()); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1605 LLConstant* cup = llvm::cast<llvm::Constant>(cv->c); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1606 earg = llvm::ConstantExpr::getSub(cup, clo); |
1 | 1607 } |
1608 else { | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1609 earg = llvm::BinaryOperator::createSub(cv->c, lo->getRVal(), "tmp", p->scopebb()); |
1 | 1610 } |
1611 } | |
1612 } | |
1613 else | |
1614 { | |
1615 if (lwr_is_zero) { | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1616 earg = up->getRVal(); |
1 | 1617 } |
1618 else { | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1619 earg = llvm::BinaryOperator::createSub(up->getRVal(), lo->getRVal(), "tmp", p->scopebb()); |
1 | 1620 } |
1621 } | |
1622 } | |
1623 // full slice | |
1624 else | |
1625 { | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1626 emem = vmem; |
1 | 1627 } |
1628 | |
116
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1629 if (earg) Logger::cout() << "slice exp result, length = " << *earg << '\n'; |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1630 Logger::cout() << "slice exp result, ptr = " << *emem << '\n'; |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1631 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1632 return new DSliceValue(type,earg,emem); |
1 | 1633 } |
1634 | |
1635 ////////////////////////////////////////////////////////////////////////////////////////// | |
1636 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1637 DValue* CmpExp::toElem(IRState* p) |
1 | 1638 { |
1639 Logger::print("CmpExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1640 LOG_SCOPE; | |
1641 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1642 DValue* l = e1->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1643 DValue* r = e2->toElem(p); |
1 | 1644 |
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:
78
diff
changeset
|
1645 Type* t = DtoDType(e1->type); |
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:
78
diff
changeset
|
1646 Type* e2t = DtoDType(e2->type); |
197
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
193
diff
changeset
|
1647 assert(DtoType(t) == DtoType(e2t)); |
1 | 1648 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1649 LLValue* eval = 0; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1650 |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1651 if (t->isintegral() || t->ty == Tpointer) |
1 | 1652 { |
1653 llvm::ICmpInst::Predicate cmpop; | |
40 | 1654 bool skip = false; |
1 | 1655 switch(op) |
1656 { | |
1657 case TOKlt: | |
40 | 1658 case TOKul: |
1 | 1659 cmpop = t->isunsigned() ? llvm::ICmpInst::ICMP_ULT : llvm::ICmpInst::ICMP_SLT; |
1660 break; | |
1661 case TOKle: | |
40 | 1662 case TOKule: |
1 | 1663 cmpop = t->isunsigned() ? llvm::ICmpInst::ICMP_ULE : llvm::ICmpInst::ICMP_SLE; |
1664 break; | |
1665 case TOKgt: | |
40 | 1666 case TOKug: |
1 | 1667 cmpop = t->isunsigned() ? llvm::ICmpInst::ICMP_UGT : llvm::ICmpInst::ICMP_SGT; |
1668 break; | |
1669 case TOKge: | |
40 | 1670 case TOKuge: |
1 | 1671 cmpop = t->isunsigned() ? llvm::ICmpInst::ICMP_UGE : llvm::ICmpInst::ICMP_SGE; |
1672 break; | |
40 | 1673 case TOKue: |
1674 cmpop = llvm::ICmpInst::ICMP_EQ; | |
1675 break; | |
1676 case TOKlg: | |
1677 cmpop = llvm::ICmpInst::ICMP_NE; | |
1678 break; | |
1679 case TOKleg: | |
1680 skip = true; | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1681 eval = llvm::ConstantInt::getTrue(); |
40 | 1682 break; |
1683 case TOKunord: | |
1684 skip = true; | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1685 eval = llvm::ConstantInt::getFalse(); |
40 | 1686 break; |
1687 | |
1 | 1688 default: |
1689 assert(0); | |
1690 } | |
40 | 1691 if (!skip) |
1692 { | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1693 LLValue* a = l->getRVal(); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1694 LLValue* b = r->getRVal(); |
132 | 1695 Logger::cout() << "type 1: " << *a << '\n'; |
1696 Logger::cout() << "type 2: " << *b << '\n'; | |
1697 eval = new llvm::ICmpInst(cmpop, a, b, "tmp", p->scopebb()); | |
40 | 1698 } |
1 | 1699 } |
1700 else if (t->isfloating()) | |
1701 { | |
1702 llvm::FCmpInst::Predicate cmpop; | |
1703 switch(op) | |
1704 { | |
1705 case TOKlt: | |
1706 cmpop = llvm::FCmpInst::FCMP_OLT;break; | |
1707 case TOKle: | |
1708 cmpop = llvm::FCmpInst::FCMP_OLE;break; | |
1709 case TOKgt: | |
1710 cmpop = llvm::FCmpInst::FCMP_OGT;break; | |
1711 case TOKge: | |
1712 cmpop = llvm::FCmpInst::FCMP_OGE;break; | |
1713 case TOKunord: | |
1714 cmpop = llvm::FCmpInst::FCMP_UNO;break; | |
1715 case TOKule: | |
1716 cmpop = llvm::FCmpInst::FCMP_ULE;break; | |
1717 case TOKul: | |
1718 cmpop = llvm::FCmpInst::FCMP_ULT;break; | |
1719 case TOKuge: | |
1720 cmpop = llvm::FCmpInst::FCMP_UGE;break; | |
1721 case TOKug: | |
1722 cmpop = llvm::FCmpInst::FCMP_UGT;break; | |
1723 case TOKue: | |
1724 cmpop = llvm::FCmpInst::FCMP_UEQ;break; | |
1725 case TOKlg: | |
1726 cmpop = llvm::FCmpInst::FCMP_ONE;break; | |
1727 case TOKleg: | |
1728 cmpop = llvm::FCmpInst::FCMP_ORD;break; | |
1729 | |
1730 default: | |
1731 assert(0); | |
1732 } | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1733 eval = new llvm::FCmpInst(cmpop, l->getRVal(), r->getRVal(), "tmp", p->scopebb()); |
1 | 1734 } |
99
a676a7743642
[svn r103] Array comparisons are now fully implemented, that is - to the extent that TypeInfo is.
lindquist
parents:
98
diff
changeset
|
1735 else if (t->ty == Tsarray || t->ty == Tarray) |
a676a7743642
[svn r103] Array comparisons are now fully implemented, that is - to the extent that TypeInfo is.
lindquist
parents:
98
diff
changeset
|
1736 { |
a676a7743642
[svn r103] Array comparisons are now fully implemented, that is - to the extent that TypeInfo is.
lindquist
parents:
98
diff
changeset
|
1737 Logger::println("static or dynamic array"); |
a676a7743642
[svn r103] Array comparisons are now fully implemented, that is - to the extent that TypeInfo is.
lindquist
parents:
98
diff
changeset
|
1738 eval = DtoArrayCompare(op,l,r); |
a676a7743642
[svn r103] Array comparisons are now fully implemented, that is - to the extent that TypeInfo is.
lindquist
parents:
98
diff
changeset
|
1739 } |
1 | 1740 else |
1741 { | |
1742 assert(0 && "Unsupported CmpExp type"); | |
1743 } | |
1744 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1745 return new DImValue(type, eval); |
1 | 1746 } |
1747 | |
1748 ////////////////////////////////////////////////////////////////////////////////////////// | |
1749 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1750 DValue* EqualExp::toElem(IRState* p) |
1 | 1751 { |
1752 Logger::print("EqualExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1753 LOG_SCOPE; | |
1754 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1755 DValue* l = e1->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1756 DValue* r = e2->toElem(p); |
1 | 1757 |
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:
78
diff
changeset
|
1758 Type* t = DtoDType(e1->type); |
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:
78
diff
changeset
|
1759 Type* e2t = DtoDType(e2->type); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
1760 //assert(t == e2t); |
1 | 1761 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1762 LLValue* eval = 0; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1763 |
1 | 1764 if (t->isintegral() || t->ty == Tpointer) |
1765 { | |
64
b688ad419f8c
[svn r68] Added support for multi-dimensional static arrays.
lindquist
parents:
62
diff
changeset
|
1766 Logger::println("integral or pointer"); |
1 | 1767 llvm::ICmpInst::Predicate cmpop; |
1768 switch(op) | |
1769 { | |
1770 case TOKequal: | |
1771 cmpop = llvm::ICmpInst::ICMP_EQ; | |
1772 break; | |
1773 case TOKnotequal: | |
1774 cmpop = llvm::ICmpInst::ICMP_NE; | |
1775 break; | |
1776 default: | |
1777 assert(0); | |
1778 } | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1779 LLValue* lv = l->getRVal(); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1780 LLValue* rv = r->getRVal(); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
1781 if (rv->getType() != lv->getType()) { |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
1782 rv = DtoBitCast(rv, lv->getType()); |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
1783 } |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
1784 eval = new llvm::ICmpInst(cmpop, lv, rv, "tmp", p->scopebb()); |
1 | 1785 } |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
1786 else if (t->iscomplex()) |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
1787 { |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
1788 Logger::println("complex"); |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
1789 eval = DtoComplexEquals(op, l, r); |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
1790 } |
1 | 1791 else if (t->isfloating()) |
1792 { | |
64
b688ad419f8c
[svn r68] Added support for multi-dimensional static arrays.
lindquist
parents:
62
diff
changeset
|
1793 Logger::println("floating"); |
1 | 1794 llvm::FCmpInst::Predicate cmpop; |
1795 switch(op) | |
1796 { | |
1797 case TOKequal: | |
1798 cmpop = llvm::FCmpInst::FCMP_OEQ; | |
1799 break; | |
1800 case TOKnotequal: | |
1801 cmpop = llvm::FCmpInst::FCMP_UNE; | |
1802 break; | |
1803 default: | |
1804 assert(0); | |
1805 } | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1806 eval = new llvm::FCmpInst(cmpop, l->getRVal(), r->getRVal(), "tmp", p->scopebb()); |
1 | 1807 } |
98
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
97
diff
changeset
|
1808 else if (t->ty == Tsarray || t->ty == Tarray) |
40 | 1809 { |
98
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
97
diff
changeset
|
1810 Logger::println("static or dynamic array"); |
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
97
diff
changeset
|
1811 eval = DtoArrayEquals(op,l,r); |
1 | 1812 } |
53
06ccc817acd4
[svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents:
52
diff
changeset
|
1813 else if (t->ty == Tdelegate) |
06ccc817acd4
[svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents:
52
diff
changeset
|
1814 { |
64
b688ad419f8c
[svn r68] Added support for multi-dimensional static arrays.
lindquist
parents:
62
diff
changeset
|
1815 Logger::println("delegate"); |
177
cea8dcfa76df
[svn r193] Fixed: abstract classes implementing interfaces now output proper Interface info arrays. (null vtables).
lindquist
parents:
176
diff
changeset
|
1816 eval = DtoDelegateCompare(op,l->getRVal(),r->getRVal()); |
53
06ccc817acd4
[svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents:
52
diff
changeset
|
1817 } |
1 | 1818 else |
1819 { | |
1820 assert(0 && "Unsupported EqualExp type"); | |
1821 } | |
1822 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1823 return new DImValue(type, eval); |
1 | 1824 } |
1825 | |
1826 ////////////////////////////////////////////////////////////////////////////////////////// | |
1827 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1828 DValue* PostExp::toElem(IRState* p) |
1 | 1829 { |
1830 Logger::print("PostExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1831 LOG_SCOPE; | |
1832 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1833 DValue* l = e1->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1834 DValue* r = e2->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1835 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1836 LLValue* val = l->getRVal(); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1837 LLValue* post = 0; |
1 | 1838 |
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:
78
diff
changeset
|
1839 Type* e1type = DtoDType(e1->type); |
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:
78
diff
changeset
|
1840 Type* e2type = DtoDType(e2->type); |
40 | 1841 |
1842 if (e1type->isintegral()) | |
1 | 1843 { |
40 | 1844 assert(e2type->isintegral()); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1845 LLValue* one = llvm::ConstantInt::get(val->getType(), 1, !e2type->isunsigned()); |
1 | 1846 if (op == TOKplusplus) { |
1847 post = llvm::BinaryOperator::createAdd(val,one,"tmp",p->scopebb()); | |
1848 } | |
1849 else if (op == TOKminusminus) { | |
1850 post = llvm::BinaryOperator::createSub(val,one,"tmp",p->scopebb()); | |
1851 } | |
1852 } | |
40 | 1853 else if (e1type->ty == Tpointer) |
1 | 1854 { |
40 | 1855 assert(e2type->isintegral()); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1856 LLConstant* minusone = llvm::ConstantInt::get(DtoSize_t(),(uint64_t)-1,true); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1857 LLConstant* plusone = llvm::ConstantInt::get(DtoSize_t(),(uint64_t)1,false); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1858 LLConstant* whichone = (op == TOKplusplus) ? plusone : minusone; |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
1859 post = llvm::GetElementPtrInst::Create(val, whichone, "tmp", p->scopebb()); |
1 | 1860 } |
40 | 1861 else if (e1type->isfloating()) |
1 | 1862 { |
40 | 1863 assert(e2type->isfloating()); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1864 LLValue* one = DtoConstFP(e1type, 1.0); |
1 | 1865 if (op == TOKplusplus) { |
1866 post = llvm::BinaryOperator::createAdd(val,one,"tmp",p->scopebb()); | |
1867 } | |
1868 else if (op == TOKminusminus) { | |
1869 post = llvm::BinaryOperator::createSub(val,one,"tmp",p->scopebb()); | |
1870 } | |
1871 } | |
1872 else | |
1873 assert(post); | |
1874 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1875 DtoStore(post,l->getLVal()); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1876 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1877 return new DImValue(type,val,true); |
1 | 1878 } |
1879 | |
1880 ////////////////////////////////////////////////////////////////////////////////////////// | |
1881 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1882 DValue* NewExp::toElem(IRState* p) |
1 | 1883 { |
1884 Logger::print("NewExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1885 LOG_SCOPE; | |
1886 | |
123
7f9a0a58394b
[svn r127] Updated the lphobos build scripts a little. Created a new rebuild profile.
lindquist
parents:
122
diff
changeset
|
1887 assert(!newargs && "arguments to new not yet supported"); |
1 | 1888 assert(newtype); |
123
7f9a0a58394b
[svn r127] Updated the lphobos build scripts a little. Created a new rebuild profile.
lindquist
parents:
122
diff
changeset
|
1889 assert(!allocator && "custom allocators not yet supported"); |
1 | 1890 |
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:
78
diff
changeset
|
1891 Type* ntype = DtoDType(newtype); |
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:
78
diff
changeset
|
1892 |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1893 // new class |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1894 if (ntype->ty == Tclass) { |
169
2df270e1ba59
[svn r185] Fixed broken nested classes with data members, did DMD change the class layout? tango.text.Regex now compiles.
lindquist
parents:
167
diff
changeset
|
1895 Logger::println("new class"); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1896 return DtoNewClass((TypeClass*)ntype, this); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1897 } |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1898 // new dynamic array |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1899 else if (ntype->ty == Tarray) |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1900 { |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1901 Logger::println("new dynamic array: %s", newtype->toChars()); |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1902 // get dim |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1903 assert(arguments); |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1904 assert(arguments->dim == 1); |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1905 DValue* sz = ((Expression*)arguments->data[0])->toElem(p); |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1906 // allocate & init |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1907 return DtoNewDynArray(newtype, sz, true); |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1908 } |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1909 // new static array |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1910 else if (ntype->ty == Tsarray) |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1911 { |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1912 assert(0); |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1913 } |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1914 // new struct |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1915 else if (ntype->ty == Tstruct) |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1916 { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1917 Logger::println("new struct on heap: %s\n", newtype->toChars()); |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1918 // allocate |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1919 LLValue* mem = DtoNew(newtype); |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1920 // init |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1921 TypeStruct* ts = (TypeStruct*)ntype; |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1922 if (ts->isZeroInit()) { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1923 DtoAggrZeroInit(mem); |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1924 } |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1925 else { |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1926 assert(ts->sym); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1927 DtoAggrCopy(mem,ts->sym->ir.irStruct->init); |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1928 } |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1929 return new DImValue(type, mem, false); |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1930 } |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1931 // new basic type |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1932 else |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1933 { |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1934 // allocate |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1935 LLValue* mem = DtoNew(newtype); |
212
4c2689d57ba4
[svn r228] Fixed: when new'ing basic types, the storage was not default initialized.
lindquist
parents:
210
diff
changeset
|
1936 DVarValue tmpvar(newtype, mem, true); |
4c2689d57ba4
[svn r228] Fixed: when new'ing basic types, the storage was not default initialized.
lindquist
parents:
210
diff
changeset
|
1937 |
4c2689d57ba4
[svn r228] Fixed: when new'ing basic types, the storage was not default initialized.
lindquist
parents:
210
diff
changeset
|
1938 // default initialize |
4c2689d57ba4
[svn r228] Fixed: when new'ing basic types, the storage was not default initialized.
lindquist
parents:
210
diff
changeset
|
1939 Expression* exp = newtype->defaultInit(loc); |
4c2689d57ba4
[svn r228] Fixed: when new'ing basic types, the storage was not default initialized.
lindquist
parents:
210
diff
changeset
|
1940 DValue* iv = exp->toElem(gIR); |
4c2689d57ba4
[svn r228] Fixed: when new'ing basic types, the storage was not default initialized.
lindquist
parents:
210
diff
changeset
|
1941 DtoAssign(&tmpvar, iv); |
4c2689d57ba4
[svn r228] Fixed: when new'ing basic types, the storage was not default initialized.
lindquist
parents:
210
diff
changeset
|
1942 |
4c2689d57ba4
[svn r228] Fixed: when new'ing basic types, the storage was not default initialized.
lindquist
parents:
210
diff
changeset
|
1943 // return as pointer-to |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1944 return new DImValue(type, mem, false); |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1945 } |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1946 |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1947 assert(0); |
1 | 1948 } |
1949 | |
1950 ////////////////////////////////////////////////////////////////////////////////////////// | |
1951 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1952 DValue* DeleteExp::toElem(IRState* p) |
1 | 1953 { |
1954 Logger::print("DeleteExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1955 LOG_SCOPE; | |
1956 | |
209
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
1957 DValue* dval = e1->toElem(p); |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
1958 Type* et = DtoDType(e1->type); |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
1959 |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
1960 // simple pointer |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
1961 if (et->ty == Tpointer) |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
1962 { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1963 LLValue* rval = dval->getRVal(); |
209
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
1964 DtoDeleteMemory(rval); |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
1965 if (dval->isVar() && dval->isVar()->lval) |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
1966 DtoStore(llvm::Constant::getNullValue(rval->getType()), dval->getLVal()); |
1 | 1967 } |
209
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
1968 // class |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
1969 else if (et->ty == Tclass) |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
1970 { |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
1971 bool onstack = false; |
210 | 1972 TypeClass* tc = (TypeClass*)et; |
1973 if (tc->sym->isInterfaceDeclaration()) | |
1974 { | |
1975 DtoDeleteInterface(dval->getRVal()); | |
1976 onstack = true; | |
1977 } | |
1978 else if (DVarValue* vv = dval->isVar()) { | |
209
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
1979 if (vv->var && vv->var->onstack) { |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
1980 if (tc->sym->dtors.dim > 0) { |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
1981 DtoFinalizeClass(dval->getRVal()); |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
1982 onstack = true; |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
1983 } |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1984 } |
1 | 1985 } |
209
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
1986 if (!onstack) { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1987 LLValue* rval = dval->getRVal(); |
209
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
1988 DtoDeleteClass(rval); |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
1989 } |
210 | 1990 if (!dval->isThis() && dval->isVar() && dval->isVar()->lval) { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1991 LLValue* lval = dval->getLVal(); |
209
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
1992 DtoStore(llvm::Constant::getNullValue(lval->getType()->getContainedType(0)), lval); |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
1993 } |
1 | 1994 } |
209
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
1995 // dyn array |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
1996 else if (et->ty == Tarray) |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
1997 { |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
1998 DtoDeleteArray(dval); |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
1999 if (!dval->isSlice()) |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
2000 DtoSetArrayToNull(dval->getRVal()); |
1 | 2001 } |
209
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
2002 // unknown/invalid |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
2003 else |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
2004 { |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
2005 assert(0 && "invalid delete"); |
1 | 2006 } |
2007 | |
209
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
2008 // no value to return |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
207
diff
changeset
|
2009 return NULL; |
1 | 2010 } |
2011 | |
2012 ////////////////////////////////////////////////////////////////////////////////////////// | |
2013 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2014 DValue* ArrayLengthExp::toElem(IRState* p) |
1 | 2015 { |
2016 Logger::print("ArrayLengthExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2017 LOG_SCOPE; | |
2018 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2019 DValue* u = e1->toElem(p); |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
2020 Logger::println("e1 = %s", e1->type->toChars()); |
1 | 2021 |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
2022 if (p->topexp() && p->topexp()->e1 == this) |
34 | 2023 { |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
2024 return new DArrayLenValue(e1->type, u->getLVal()); |
34 | 2025 } |
2026 else | |
2027 { | |
207
e0b6040585b4
[svn r223] Fixed: assert with message could be broken.
lindquist
parents:
205
diff
changeset
|
2028 return new DImValue(type, DtoArrayLen(u)); |
34 | 2029 } |
1 | 2030 } |
2031 | |
2032 ////////////////////////////////////////////////////////////////////////////////////////// | |
2033 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2034 DValue* AssertExp::toElem(IRState* p) |
1 | 2035 { |
2036 Logger::print("AssertExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2037 LOG_SCOPE; | |
2038 | |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2039 // condition |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2040 DValue* cond = e1->toElem(p); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2041 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2042 // create basic blocks |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2043 llvm::BasicBlock* oldend = p->scopeend(); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
2044 llvm::BasicBlock* assertbb = llvm::BasicBlock::Create("assert", p->topfunc(), oldend); |
212
4c2689d57ba4
[svn r228] Fixed: when new'ing basic types, the storage was not default initialized.
lindquist
parents:
210
diff
changeset
|
2045 llvm::BasicBlock* endbb = llvm::BasicBlock::Create("noassert", p->topfunc(), oldend); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2046 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2047 // test condition |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2048 LLValue* condval = cond->getRVal(); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2049 condval = DtoBoolean(condval); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2050 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2051 // branch |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
2052 llvm::BranchInst::Create(endbb, assertbb, condval, p->scopebb()); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2053 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2054 // call assert runtime functions |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2055 p->scope() = IRScope(assertbb,endbb); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2056 DtoAssert(&loc, msg ? msg->toElem(p) : NULL); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2057 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2058 if (!gIR->scopereturned()) |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
2059 llvm::BranchInst::Create(endbb, p->scopebb()); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2060 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2061 // rewrite the scope |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2062 p->scope() = IRScope(endbb,oldend); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2063 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2064 // no meaningful return value |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2065 return NULL; |
1 | 2066 } |
2067 | |
2068 ////////////////////////////////////////////////////////////////////////////////////////// | |
2069 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2070 DValue* NotExp::toElem(IRState* p) |
1 | 2071 { |
2072 Logger::print("NotExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2073 LOG_SCOPE; | |
2074 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2075 DValue* u = e1->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2076 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2077 LLValue* b = DtoBoolean(u->getRVal()); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2078 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
2079 LLConstant* zero = llvm::ConstantInt::get(LLType::Int1Ty, 0, true); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2080 b = p->ir->CreateICmpEQ(b,zero); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2081 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2082 return new DImValue(type, b); |
1 | 2083 } |
2084 | |
2085 ////////////////////////////////////////////////////////////////////////////////////////// | |
2086 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2087 DValue* AndAndExp::toElem(IRState* p) |
1 | 2088 { |
2089 Logger::print("AndAndExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2090 LOG_SCOPE; | |
2091 | |
2092 // allocate a temporary for the final result. failed to come up with a better way :/ | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2093 LLValue* resval = 0; |
1 | 2094 llvm::BasicBlock* entryblock = &p->topfunc()->front(); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
2095 resval = new llvm::AllocaInst(LLType::Int1Ty,"andandtmp",p->topallocapoint()); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2096 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2097 DValue* u = e1->toElem(p); |
1 | 2098 |
2099 llvm::BasicBlock* oldend = p->scopeend(); | |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
2100 llvm::BasicBlock* andand = llvm::BasicBlock::Create("andand", gIR->topfunc(), oldend); |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
2101 llvm::BasicBlock* andandend = llvm::BasicBlock::Create("andandend", gIR->topfunc(), oldend); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2102 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2103 LLValue* ubool = DtoBoolean(u->getRVal()); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
2104 DtoStore(ubool,resval); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
2105 llvm::BranchInst::Create(andand,andandend,ubool,p->scopebb()); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2106 |
1 | 2107 p->scope() = IRScope(andand, andandend); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2108 DValue* v = e2->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2109 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2110 LLValue* vbool = DtoBoolean(v->getRVal()); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2111 LLValue* uandvbool = llvm::BinaryOperator::create(llvm::BinaryOperator::And, ubool, vbool,"tmp",p->scopebb()); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
2112 DtoStore(uandvbool,resval); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
2113 llvm::BranchInst::Create(andandend,p->scopebb()); |
1 | 2114 |
2115 p->scope() = IRScope(andandend, oldend); | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2116 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
2117 resval = DtoLoad(resval); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2118 return new DImValue(type, resval); |
1 | 2119 } |
2120 | |
2121 ////////////////////////////////////////////////////////////////////////////////////////// | |
2122 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2123 DValue* OrOrExp::toElem(IRState* p) |
1 | 2124 { |
2125 Logger::print("OrOrExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2126 LOG_SCOPE; | |
2127 | |
2128 // allocate a temporary for the final result. failed to come up with a better way :/ | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2129 LLValue* resval = 0; |
1 | 2130 llvm::BasicBlock* entryblock = &p->topfunc()->front(); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
2131 resval = new llvm::AllocaInst(LLType::Int1Ty,"orortmp",p->topallocapoint()); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2132 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2133 DValue* u = e1->toElem(p); |
1 | 2134 |
2135 llvm::BasicBlock* oldend = p->scopeend(); | |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
2136 llvm::BasicBlock* oror = llvm::BasicBlock::Create("oror", gIR->topfunc(), oldend); |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
2137 llvm::BasicBlock* ororend = llvm::BasicBlock::Create("ororend", gIR->topfunc(), oldend); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2138 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2139 LLValue* ubool = DtoBoolean(u->getRVal()); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
2140 DtoStore(ubool,resval); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
2141 llvm::BranchInst::Create(ororend,oror,ubool,p->scopebb()); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2142 |
1 | 2143 p->scope() = IRScope(oror, ororend); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2144 DValue* v = e2->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2145 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2146 LLValue* vbool = DtoBoolean(v->getRVal()); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
2147 DtoStore(vbool,resval); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
2148 llvm::BranchInst::Create(ororend,p->scopebb()); |
1 | 2149 |
2150 p->scope() = IRScope(ororend, oldend); | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2151 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2152 resval = new llvm::LoadInst(resval,"tmp",p->scopebb()); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2153 return new DImValue(type, resval); |
1 | 2154 } |
2155 | |
2156 ////////////////////////////////////////////////////////////////////////////////////////// | |
2157 | |
2158 #define BinBitExp(X,Y) \ | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2159 DValue* X##Exp::toElem(IRState* p) \ |
1 | 2160 { \ |
2161 Logger::print("%sExp::toElem: %s | %s\n", #X, toChars(), type->toChars()); \ | |
2162 LOG_SCOPE; \ | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2163 DValue* u = e1->toElem(p); \ |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2164 DValue* v = e2->toElem(p); \ |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2165 LLValue* x = llvm::BinaryOperator::create(llvm::Instruction::Y, u->getRVal(), v->getRVal(), "tmp", p->scopebb()); \ |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2166 return new DImValue(type, x); \ |
1 | 2167 } \ |
2168 \ | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2169 DValue* X##AssignExp::toElem(IRState* p) \ |
1 | 2170 { \ |
2171 Logger::print("%sAssignExp::toElem: %s | %s\n", #X, toChars(), type->toChars()); \ | |
2172 LOG_SCOPE; \ | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2173 p->exps.push_back(IRExp(e1,e2,NULL)); \ |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2174 DValue* u = e1->toElem(p); \ |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2175 p->topexp()->v = u; \ |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2176 DValue* v = e2->toElem(p); \ |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2177 p->exps.pop_back(); \ |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2178 LLValue* uval = u->getRVal(); \ |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2179 LLValue* vval = v->getRVal(); \ |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2180 LLValue* tmp = llvm::BinaryOperator::create(llvm::Instruction::Y, uval, vval, "tmp", p->scopebb()); \ |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
2181 DtoStore(DtoPointedType(u->getLVal(), tmp), u->getLVal()); \ |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2182 return u; \ |
1 | 2183 } |
2184 | |
2185 BinBitExp(And,And); | |
2186 BinBitExp(Or,Or); | |
2187 BinBitExp(Xor,Xor); | |
2188 BinBitExp(Shl,Shl); | |
2189 BinBitExp(Shr,AShr); | |
2190 BinBitExp(Ushr,LShr); | |
2191 | |
2192 ////////////////////////////////////////////////////////////////////////////////////////// | |
2193 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2194 DValue* HaltExp::toElem(IRState* p) |
1 | 2195 { |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
259
diff
changeset
|
2196 Logger::print("HaltExp::toElem: %s\n", toChars()); |
1 | 2197 LOG_SCOPE; |
2198 | |
258
8dbddae09152
[svn r276] Fixed debug info for 'this' arg seemed to be broken.
lindquist
parents:
245
diff
changeset
|
2199 #if 0 |
8dbddae09152
[svn r276] Fixed debug info for 'this' arg seemed to be broken.
lindquist
parents:
245
diff
changeset
|
2200 DtoAssert(&loc, NULL); |
8dbddae09152
[svn r276] Fixed debug info for 'this' arg seemed to be broken.
lindquist
parents:
245
diff
changeset
|
2201 #else |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
2202 // call the new (?) trap intrinsic |
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
2203 p->ir->CreateCall(GET_INTRINSIC_DECL(trap),""); |
258
8dbddae09152
[svn r276] Fixed debug info for 'this' arg seemed to be broken.
lindquist
parents:
245
diff
changeset
|
2204 #endif |
36
c0967c4b2a74
[svn r40] Cleaned up some of the array routines to use gep/load/store instead of memcpy/memset.
lindquist
parents:
34
diff
changeset
|
2205 |
40 | 2206 new llvm::UnreachableInst(p->scopebb()); |
1 | 2207 return 0; |
2208 } | |
2209 | |
2210 ////////////////////////////////////////////////////////////////////////////////////////// | |
2211 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2212 DValue* DelegateExp::toElem(IRState* p) |
1 | 2213 { |
2214 Logger::print("DelegateExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2215 LOG_SCOPE; | |
2216 | |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
2217 const LLPointerType* int8ptrty = getPtrToType(LLType::Int8Ty); |
1 | 2218 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2219 LLValue* lval; |
143
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2220 bool inplace = false; |
118
d580b95cce2b
[svn r122] Fixed temporary delegates can now alloca their own storage.
lindquist
parents:
116
diff
changeset
|
2221 if (p->topexp() && p->topexp()->e2 == this) { |
d580b95cce2b
[svn r122] Fixed temporary delegates can now alloca their own storage.
lindquist
parents:
116
diff
changeset
|
2222 assert(p->topexp()->v); |
d580b95cce2b
[svn r122] Fixed temporary delegates can now alloca their own storage.
lindquist
parents:
116
diff
changeset
|
2223 lval = p->topexp()->v->getLVal(); |
143
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2224 inplace = true; |
118
d580b95cce2b
[svn r122] Fixed temporary delegates can now alloca their own storage.
lindquist
parents:
116
diff
changeset
|
2225 } |
d580b95cce2b
[svn r122] Fixed temporary delegates can now alloca their own storage.
lindquist
parents:
116
diff
changeset
|
2226 else { |
d580b95cce2b
[svn r122] Fixed temporary delegates can now alloca their own storage.
lindquist
parents:
116
diff
changeset
|
2227 lval = new llvm::AllocaInst(DtoType(type), "tmpdelegate", p->topallocapoint()); |
d580b95cce2b
[svn r122] Fixed temporary delegates can now alloca their own storage.
lindquist
parents:
116
diff
changeset
|
2228 } |
1 | 2229 |
143
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2230 DValue* u = e1->toElem(p); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2231 LLValue* uval; |
119
79c9ac745fbc
[svn r123] Fixed some typeinfo module name mismatches.
lindquist
parents:
118
diff
changeset
|
2232 if (DFuncValue* f = u->isFunc()) { |
259
2e652b8ad1fd
[svn r277] Fixed a nasty bug in delegate expressions. Context pointers to nested functions of the parent, from inside a nested function were
lindquist
parents:
258
diff
changeset
|
2233 assert(f->func); |
2e652b8ad1fd
[svn r277] Fixed a nasty bug in delegate expressions. Context pointers to nested functions of the parent, from inside a nested function were
lindquist
parents:
258
diff
changeset
|
2234 LLValue* contextptr = DtoNestedContext(f->func->toParent2()->isFuncDeclaration()); |
2e652b8ad1fd
[svn r277] Fixed a nasty bug in delegate expressions. Context pointers to nested functions of the parent, from inside a nested function were
lindquist
parents:
258
diff
changeset
|
2235 if (!contextptr) |
2e652b8ad1fd
[svn r277] Fixed a nasty bug in delegate expressions. Context pointers to nested functions of the parent, from inside a nested function were
lindquist
parents:
258
diff
changeset
|
2236 uval = LLConstant::getNullValue(getVoidPtrType()); |
119
79c9ac745fbc
[svn r123] Fixed some typeinfo module name mismatches.
lindquist
parents:
118
diff
changeset
|
2237 else |
259
2e652b8ad1fd
[svn r277] Fixed a nasty bug in delegate expressions. Context pointers to nested functions of the parent, from inside a nested function were
lindquist
parents:
258
diff
changeset
|
2238 uval = DtoBitCast(contextptr, getVoidPtrType()); |
119
79c9ac745fbc
[svn r123] Fixed some typeinfo module name mismatches.
lindquist
parents:
118
diff
changeset
|
2239 } |
79c9ac745fbc
[svn r123] Fixed some typeinfo module name mismatches.
lindquist
parents:
118
diff
changeset
|
2240 else { |
143
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2241 DValue* src = u; |
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2242 if (ClassDeclaration* cd = u->getType()->isClassHandle()) |
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2243 { |
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2244 Logger::println("context type is class handle"); |
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2245 if (cd->isInterfaceDeclaration()) |
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2246 { |
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2247 Logger::println("context type is interface"); |
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2248 src = DtoCastInterfaceToObject(u, ClassDeclaration::object->type); |
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2249 } |
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2250 } |
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2251 uval = src->getRVal(); |
119
79c9ac745fbc
[svn r123] Fixed some typeinfo module name mismatches.
lindquist
parents:
118
diff
changeset
|
2252 } |
79c9ac745fbc
[svn r123] Fixed some typeinfo module name mismatches.
lindquist
parents:
118
diff
changeset
|
2253 |
143
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2254 Logger::cout() << "context = " << *uval << '\n'; |
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2255 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
2256 LLValue* context = DtoGEPi(lval,0,0); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2257 LLValue* castcontext = DtoBitCast(uval, int8ptrty); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2258 DtoStore(castcontext, context); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2259 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
2260 LLValue* fptr = DtoGEPi(lval,0,1); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2261 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2262 Logger::println("func: '%s'", func->toPrettyChars()); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2263 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2264 LLValue* castfptr; |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2265 if (func->isVirtual()) |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2266 castfptr = DtoVirtualFunctionPointer(u, func); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2267 else if (func->isAbstract()) |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2268 assert(0 && "TODO delegate to abstract method"); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2269 else if (func->toParent()->isInterfaceDeclaration()) |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2270 assert(0 && "TODO delegate to interface method"); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2271 else |
150
2c336566ffed
[svn r156] added a testcase for the most annoying bug ever
lindquist
parents:
144
diff
changeset
|
2272 { |
2c336566ffed
[svn r156] added a testcase for the most annoying bug ever
lindquist
parents:
144
diff
changeset
|
2273 DtoForceDeclareDsymbol(func); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
2274 castfptr = func->ir.irFunc->func; |
150
2c336566ffed
[svn r156] added a testcase for the most annoying bug ever
lindquist
parents:
144
diff
changeset
|
2275 } |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2276 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2277 castfptr = DtoBitCast(castfptr, fptr->getType()->getContainedType(0)); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2278 DtoStore(castfptr, fptr); |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
2279 |
143
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2280 return new DImValue(type, lval, inplace); |
1 | 2281 } |
2282 | |
2283 ////////////////////////////////////////////////////////////////////////////////////////// | |
2284 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2285 DValue* IdentityExp::toElem(IRState* p) |
1 | 2286 { |
2287 Logger::print("IdentityExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2288 LOG_SCOPE; | |
2289 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2290 DValue* u = e1->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2291 DValue* v = e2->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2292 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2293 LLValue* l = u->getRVal(); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2294 LLValue* r = v->getRVal(); |
1 | 2295 |
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:
78
diff
changeset
|
2296 Type* t1 = DtoDType(e1->type); |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
2297 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2298 LLValue* eval = 0; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2299 |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
2300 if (t1->ty == Tarray) { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2301 if (v->isNull()) { |
69
2b5a2eaa88be
[svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents:
68
diff
changeset
|
2302 r = NULL; |
2b5a2eaa88be
[svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents:
68
diff
changeset
|
2303 } |
2b5a2eaa88be
[svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents:
68
diff
changeset
|
2304 else { |
2b5a2eaa88be
[svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents:
68
diff
changeset
|
2305 assert(l->getType() == r->getType()); |
2b5a2eaa88be
[svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents:
68
diff
changeset
|
2306 } |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2307 eval = DtoDynArrayIs(op,l,r); |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
2308 } |
162
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
156
diff
changeset
|
2309 else if (t1->ty == Tdelegate) { |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
156
diff
changeset
|
2310 if (v->isNull()) { |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
156
diff
changeset
|
2311 r = NULL; |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
156
diff
changeset
|
2312 } |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
156
diff
changeset
|
2313 else { |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
156
diff
changeset
|
2314 assert(l->getType() == r->getType()); |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
156
diff
changeset
|
2315 } |
177
cea8dcfa76df
[svn r193] Fixed: abstract classes implementing interfaces now output proper Interface info arrays. (null vtables).
lindquist
parents:
176
diff
changeset
|
2316 eval = DtoDelegateCompare(op,l,r); |
162
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
156
diff
changeset
|
2317 } |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
2318 else if (t1->isfloating()) |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
2319 { |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
2320 llvm::FCmpInst::Predicate pred = (op == TOKidentity) ? llvm::FCmpInst::FCMP_OEQ : llvm::FCmpInst::FCMP_ONE; |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
2321 eval = new llvm::FCmpInst(pred, l, r, "tmp", p->scopebb()); |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
2322 } |
167
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
2323 else if (t1->ty == Tpointer) |
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
2324 { |
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
2325 if (l->getType() != r->getType()) { |
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
2326 if (v->isNull()) |
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
2327 r = llvm::ConstantPointerNull::get(isaPointer(l->getType())); |
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
2328 else |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
2329 r = DtoBitCast(r, l->getType()); |
167
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
2330 } |
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
2331 llvm::ICmpInst::Predicate pred = (op == TOKidentity) ? llvm::ICmpInst::ICMP_EQ : llvm::ICmpInst::ICMP_NE; |
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
2332 eval = new llvm::ICmpInst(pred, l, r, "tmp", p->scopebb()); |
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
2333 } |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
2334 else { |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
2335 llvm::ICmpInst::Predicate pred = (op == TOKidentity) ? llvm::ICmpInst::ICMP_EQ : llvm::ICmpInst::ICMP_NE; |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2336 //Logger::cout() << "l = " << *l << " r = " << *r << '\n'; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2337 eval = new llvm::ICmpInst(pred, l, r, "tmp", p->scopebb()); |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
2338 } |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2339 return new DImValue(type, eval); |
1 | 2340 } |
2341 | |
2342 ////////////////////////////////////////////////////////////////////////////////////////// | |
2343 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2344 DValue* CommaExp::toElem(IRState* p) |
1 | 2345 { |
2346 Logger::print("CommaExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2347 LOG_SCOPE; | |
2348 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2349 DValue* u = e1->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2350 DValue* v = e2->toElem(p); |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
2351 assert(e2->type == type); |
1 | 2352 return v; |
2353 } | |
2354 | |
2355 ////////////////////////////////////////////////////////////////////////////////////////// | |
2356 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2357 DValue* CondExp::toElem(IRState* p) |
1 | 2358 { |
2359 Logger::print("CondExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2360 LOG_SCOPE; | |
2361 | |
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:
78
diff
changeset
|
2362 Type* dtype = DtoDType(type); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2363 const LLType* resty = DtoType(dtype); |
1 | 2364 |
2365 // allocate a temporary for the final result. failed to come up with a better way :/ | |
2366 llvm::BasicBlock* entryblock = &p->topfunc()->front(); | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2367 LLValue* resval = new llvm::AllocaInst(resty,"condtmp",p->topallocapoint()); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2368 DVarValue* dvv = new DVarValue(type, resval, true); |
1 | 2369 |
2370 llvm::BasicBlock* oldend = p->scopeend(); | |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
2371 llvm::BasicBlock* condtrue = llvm::BasicBlock::Create("condtrue", gIR->topfunc(), oldend); |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
2372 llvm::BasicBlock* condfalse = llvm::BasicBlock::Create("condfalse", gIR->topfunc(), oldend); |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
2373 llvm::BasicBlock* condend = llvm::BasicBlock::Create("condend", gIR->topfunc(), oldend); |
1 | 2374 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2375 DValue* c = econd->toElem(p); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2376 LLValue* cond_val = DtoBoolean(c->getRVal()); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
2377 llvm::BranchInst::Create(condtrue,condfalse,cond_val,p->scopebb()); |
1 | 2378 |
2379 p->scope() = IRScope(condtrue, condfalse); | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2380 DValue* u = e1->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2381 DtoAssign(dvv, u); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
2382 llvm::BranchInst::Create(condend,p->scopebb()); |
1 | 2383 |
2384 p->scope() = IRScope(condfalse, condend); | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2385 DValue* v = e2->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2386 DtoAssign(dvv, v); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
2387 llvm::BranchInst::Create(condend,p->scopebb()); |
1 | 2388 |
2389 p->scope() = IRScope(condend, oldend); | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2390 return dvv; |
1 | 2391 } |
2392 | |
2393 ////////////////////////////////////////////////////////////////////////////////////////// | |
2394 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2395 DValue* ComExp::toElem(IRState* p) |
1 | 2396 { |
2397 Logger::print("ComExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2398 LOG_SCOPE; | |
2399 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2400 DValue* u = e1->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2401 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2402 LLValue* value = u->getRVal(); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2403 LLValue* minusone = llvm::ConstantInt::get(value->getType(), -1, true); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2404 value = llvm::BinaryOperator::create(llvm::Instruction::Xor, value, minusone, "tmp", p->scopebb()); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2405 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2406 return new DImValue(type, value); |
1 | 2407 } |
2408 | |
2409 ////////////////////////////////////////////////////////////////////////////////////////// | |
2410 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2411 DValue* NegExp::toElem(IRState* p) |
23 | 2412 { |
2413 Logger::print("NegExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2414 LOG_SCOPE; | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2415 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2416 DValue* l = e1->toElem(p); |
164
a64becf2a702
[svn r180] Fixed complex negation, and tango.math.Math now compiles.
lindquist
parents:
163
diff
changeset
|
2417 |
a64becf2a702
[svn r180] Fixed complex negation, and tango.math.Math now compiles.
lindquist
parents:
163
diff
changeset
|
2418 if (type->iscomplex()) { |
a64becf2a702
[svn r180] Fixed complex negation, and tango.math.Math now compiles.
lindquist
parents:
163
diff
changeset
|
2419 return DtoComplexNeg(type, l); |
a64becf2a702
[svn r180] Fixed complex negation, and tango.math.Math now compiles.
lindquist
parents:
163
diff
changeset
|
2420 } |
a64becf2a702
[svn r180] Fixed complex negation, and tango.math.Math now compiles.
lindquist
parents:
163
diff
changeset
|
2421 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2422 LLValue* val = l->getRVal(); |
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:
78
diff
changeset
|
2423 Type* t = DtoDType(type); |
40 | 2424 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2425 LLValue* zero = 0; |
40 | 2426 if (t->isintegral()) |
23 | 2427 zero = llvm::ConstantInt::get(val->getType(), 0, true); |
40 | 2428 else if (t->isfloating()) { |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
2429 zero = DtoConstFP(type, 0.0); |
23 | 2430 } |
2431 else | |
2432 assert(0); | |
2433 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2434 val = llvm::BinaryOperator::createSub(zero,val,"tmp",p->scopebb()); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2435 return new DImValue(type, val); |
23 | 2436 } |
2437 | |
2438 ////////////////////////////////////////////////////////////////////////////////////////// | |
2439 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2440 DValue* CatExp::toElem(IRState* p) |
36
c0967c4b2a74
[svn r40] Cleaned up some of the array routines to use gep/load/store instead of memcpy/memset.
lindquist
parents:
34
diff
changeset
|
2441 { |
c0967c4b2a74
[svn r40] Cleaned up some of the array routines to use gep/load/store instead of memcpy/memset.
lindquist
parents:
34
diff
changeset
|
2442 Logger::print("CatExp::toElem: %s | %s\n", toChars(), type->toChars()); |
c0967c4b2a74
[svn r40] Cleaned up some of the array routines to use gep/load/store instead of memcpy/memset.
lindquist
parents:
34
diff
changeset
|
2443 LOG_SCOPE; |
c0967c4b2a74
[svn r40] Cleaned up some of the array routines to use gep/load/store instead of memcpy/memset.
lindquist
parents:
34
diff
changeset
|
2444 |
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:
78
diff
changeset
|
2445 Type* t = DtoDType(type); |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
2446 |
132 | 2447 bool arrNarr = DtoDType(e1->type) == DtoDType(e2->type); |
2448 | |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
2449 // array ~ array |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
2450 if (arrNarr) |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
2451 { |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
2452 return DtoCatArrays(type, e1, e2); |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
2453 } |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
2454 // array ~ element |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
2455 // element ~ array |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
2456 else |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
2457 { |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
2458 return DtoCatArrayElement(type, e1, e2); |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
2459 } |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
2460 |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
2461 /* |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
2462 IRExp* ex = p->topexp(); |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
2463 if (ex && ex->e2 == this) { |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
2464 assert(ex->v); |
132 | 2465 if (arrNarr) |
2466 DtoCatArrays(ex->v->getLVal(),e1,e2); | |
2467 else | |
2468 DtoCatArrayElement(ex->v->getLVal(),e1,e2); | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2469 return new DImValue(type, ex->v->getLVal(), true); |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
2470 } |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
2471 else { |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
2472 assert(t->ty == Tarray); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2473 const LLType* arrty = DtoType(t); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2474 LLValue* dst = new llvm::AllocaInst(arrty, "tmpmem", p->topallocapoint()); |
132 | 2475 if (arrNarr) |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
2476 DtoCatAr |
132 | 2477 DtoCatArrays(dst,e1,e2); |
2478 else | |
2479 DtoCatArrayElement(dst,e1,e2); | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2480 return new DVarValue(type, dst, true); |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
2481 } |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
2482 */ |
36
c0967c4b2a74
[svn r40] Cleaned up some of the array routines to use gep/load/store instead of memcpy/memset.
lindquist
parents:
34
diff
changeset
|
2483 } |
c0967c4b2a74
[svn r40] Cleaned up some of the array routines to use gep/load/store instead of memcpy/memset.
lindquist
parents:
34
diff
changeset
|
2484 |
c0967c4b2a74
[svn r40] Cleaned up some of the array routines to use gep/load/store instead of memcpy/memset.
lindquist
parents:
34
diff
changeset
|
2485 ////////////////////////////////////////////////////////////////////////////////////////// |
c0967c4b2a74
[svn r40] Cleaned up some of the array routines to use gep/load/store instead of memcpy/memset.
lindquist
parents:
34
diff
changeset
|
2486 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2487 DValue* CatAssignExp::toElem(IRState* p) |
40 | 2488 { |
2489 Logger::print("CatAssignExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2490 LOG_SCOPE; | |
2491 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2492 DValue* l = e1->toElem(p); |
40 | 2493 |
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:
78
diff
changeset
|
2494 Type* e1type = DtoDType(e1->type); |
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:
78
diff
changeset
|
2495 Type* elemtype = DtoDType(e1type->next); |
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:
78
diff
changeset
|
2496 Type* e2type = DtoDType(e2->type); |
40 | 2497 |
2498 if (e2type == elemtype) { | |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
2499 DSliceValue* slice = DtoCatAssignElement(l,e2); |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
2500 DtoAssign(l, slice); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2501 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2502 else if (e1type == e2type) { |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
2503 DSliceValue* slice = DtoCatAssignArray(l,e2); |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
2504 DtoAssign(l, slice); |
40 | 2505 } |
2506 else | |
2507 assert(0 && "only one element at a time right now"); | |
2508 | |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
2509 return l; |
40 | 2510 } |
2511 | |
2512 ////////////////////////////////////////////////////////////////////////////////////////// | |
2513 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2514 DValue* FuncExp::toElem(IRState* p) |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2515 { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2516 Logger::print("FuncExp::toElem: %s | %s\n", toChars(), type->toChars()); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2517 LOG_SCOPE; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2518 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2519 assert(fd); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2520 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2521 if (fd->isNested()) Logger::println("nested"); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2522 Logger::println("kind = %s\n", fd->kind()); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2523 |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
2524 DtoForceDefineDsymbol(fd); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2525 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
2526 bool temp = false; |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2527 LLValue* lval = NULL; |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
2528 if (p->topexp() && p->topexp()->e2 == this) { |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
2529 assert(p->topexp()->v); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
2530 lval = p->topexp()->v->getLVal(); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
2531 } |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
2532 else { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2533 const LLType* dgty = DtoType(type); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2534 Logger::cout() << "delegate without explicit storage:" << '\n' << *dgty << '\n'; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2535 lval = new llvm::AllocaInst(dgty,"dgstorage",p->topallocapoint()); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
2536 temp = true; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2537 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2538 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
2539 LLValue* context = DtoGEPi(lval,0,0); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
2540 const LLPointerType* pty = isaPointer(context->getType()->getContainedType(0)); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2541 LLValue* llvmNested = p->func()->decl->ir.irFunc->nestedVar; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2542 if (llvmNested == NULL) { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2543 LLValue* nullcontext = llvm::ConstantPointerNull::get(pty); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
2544 DtoStore(nullcontext, context); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2545 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2546 else { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
2547 LLValue* nestedcontext = DtoBitCast(llvmNested, pty); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
2548 DtoStore(nestedcontext, context); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2549 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2550 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2551 LLValue* fptr = DtoGEPi(lval,0,1,"tmp",p->scopebb()); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2552 |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
2553 assert(fd->ir.irFunc->func); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
2554 LLValue* castfptr = DtoBitCast(fd->ir.irFunc->func, fptr->getType()->getContainedType(0)); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
2555 DtoStore(castfptr, fptr); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2556 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
2557 if (temp) |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
2558 return new DVarValue(type, lval, true); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
2559 else |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
2560 return new DImValue(type, lval, true); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2561 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2562 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2563 ////////////////////////////////////////////////////////////////////////////////////////// |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2564 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2565 DValue* ArrayLiteralExp::toElem(IRState* p) |
40 | 2566 { |
2567 Logger::print("ArrayLiteralExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2568 LOG_SCOPE; | |
2569 | |
175
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2570 // D types |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2571 Type* arrayType = type->toBasetype(); |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2572 Type* elemType = arrayType->nextOf()->toBasetype(); |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2573 |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2574 // is dynamic ? |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2575 bool dyn = (arrayType->ty == Tarray); |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2576 // length |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2577 size_t len = elements->dim; |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2578 // store into slice? |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2579 bool sliceInPlace = false; |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2580 |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2581 // llvm target type |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2582 const LLType* llType = DtoType(arrayType); |
175
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2583 Logger::cout() << (dyn?"dynamic":"static") << " array literal with length " << len << " of D type: '" << arrayType->toChars() << "' has llvm type: '" << *llType << "'\n"; |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2584 |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2585 // llvm storage type |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
2586 const LLType* llStoType = LLArrayType::get(DtoType(elemType), len); |
175
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2587 Logger::cout() << "llvm storage type: '" << *llStoType << "'\n"; |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2588 |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2589 // dst pointer |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2590 LLValue* dstMem = 0; |
175
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2591 |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2592 // rvalue of assignment |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2593 if (p->topexp() && p->topexp()->e2 == this) |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2594 { |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2595 DValue* topval = p->topexp()->v; |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2596 // slice assignment (copy) |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2597 if (DSliceValue* s = topval->isSlice()) |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2598 { |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2599 dstMem = s->ptr; |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2600 sliceInPlace = true; |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2601 assert(s->len == NULL); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2602 } |
175
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2603 // static array assignment |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2604 else if (topval->getType()->toBasetype()->ty == Tsarray) |
40 | 2605 { |
175
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2606 dstMem = topval->getLVal(); |
40 | 2607 } |
175
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2608 // otherwise we still need to alloca storage |
40 | 2609 } |
175
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2610 |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2611 // alloca storage if not found already |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2612 if (!dstMem) |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2613 { |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2614 dstMem = new llvm::AllocaInst(llStoType, "arrayliteral", p->topallocapoint()); |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2615 } |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2616 Logger::cout() << "using dest mem: " << *dstMem << '\n'; |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2617 |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2618 // store elements |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2619 for (size_t i=0; i<len; ++i) |
40 | 2620 { |
2621 Expression* expr = (Expression*)elements->data[i]; | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2622 LLValue* elemAddr = DtoGEPi(dstMem,0,i,"tmp",p->scopebb()); |
175
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2623 |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2624 // emulate assignment |
98
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
97
diff
changeset
|
2625 DVarValue* vv = new DVarValue(expr->type, elemAddr, true); |
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
97
diff
changeset
|
2626 p->exps.push_back(IRExp(NULL, expr, vv)); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2627 DValue* e = expr->toElem(p); |
98
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
97
diff
changeset
|
2628 p->exps.pop_back(); |
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
97
diff
changeset
|
2629 DImValue* im = e->isIm(); |
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
97
diff
changeset
|
2630 if (!im || !im->inPlace()) { |
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
97
diff
changeset
|
2631 DtoAssign(vv, e); |
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
97
diff
changeset
|
2632 } |
40 | 2633 } |
2634 | |
175
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2635 // return storage directly ? |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2636 if (!dyn || (dyn && sliceInPlace)) |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2637 return new DImValue(type, dstMem, true); |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2638 // wrap in a slice |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2639 return new DSliceValue(type, DtoConstSize_t(len), DtoGEPi(dstMem,0,0,"tmp")); |
40 | 2640 } |
2641 | |
2642 ////////////////////////////////////////////////////////////////////////////////////////// | |
2643 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2644 LLConstant* ArrayLiteralExp::toConstElem(IRState* p) |
40 | 2645 { |
2646 Logger::print("ArrayLiteralExp::toConstElem: %s | %s\n", toChars(), type->toChars()); | |
2647 LOG_SCOPE; | |
2648 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2649 const LLType* t = DtoType(type); |
40 | 2650 Logger::cout() << "array literal has llvm type: " << *t << '\n'; |
96 | 2651 assert(isaArray(t)); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
2652 const LLArrayType* arrtype = isaArray(t); |
40 | 2653 |
2654 assert(arrtype->getNumElements() == elements->dim); | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2655 std::vector<LLConstant*> vals(elements->dim, NULL); |
40 | 2656 for (unsigned i=0; i<elements->dim; ++i) |
2657 { | |
2658 Expression* expr = (Expression*)elements->data[i]; | |
2659 vals[i] = expr->toConstElem(p); | |
2660 } | |
2661 | |
2662 return llvm::ConstantArray::get(arrtype, vals); | |
2663 } | |
2664 | |
2665 ////////////////////////////////////////////////////////////////////////////////////////// | |
2666 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2667 DValue* StructLiteralExp::toElem(IRState* p) |
49
e5c4bece7fa1
[svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents:
48
diff
changeset
|
2668 { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2669 Logger::print("StructLiteralExp::toElem: %s | %s\n", toChars(), type->toChars()); |
49
e5c4bece7fa1
[svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents:
48
diff
changeset
|
2670 LOG_SCOPE; |
e5c4bece7fa1
[svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents:
48
diff
changeset
|
2671 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2672 LLValue* sptr; |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2673 const LLType* llt = DtoType(type); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2674 |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2675 LLValue* mem = 0; |
215
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
2676 bool isinplace = true; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2677 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2678 // temporary struct literal |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2679 if (!p->topexp() || p->topexp()->e2 != this) |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2680 { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2681 sptr = new llvm::AllocaInst(llt,"tmpstructliteral",p->topallocapoint()); |
215
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
2682 isinplace = false; |
50
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
2683 } |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2684 // already has memory |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
2685 else |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2686 { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2687 assert(p->topexp()->e2 == this); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2688 sptr = p->topexp()->v->getLVal(); |
50
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
2689 } |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2690 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2691 // num elements in literal |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2692 unsigned n = elements->dim; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2693 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2694 // unions might have different types for each literal |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
2695 if (sd->ir.irStruct->hasUnions) { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2696 // build the type of the literal |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2697 std::vector<const LLType*> tys; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2698 for (unsigned i=0; i<n; ++i) { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2699 Expression* vx = (Expression*)elements->data[i]; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2700 if (!vx) continue; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2701 tys.push_back(DtoType(vx->type)); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2702 } |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
2703 const LLStructType* t = LLStructType::get(tys); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2704 if (t != llt) { |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2705 if (getABITypeSize(t) != getABITypeSize(llt)) { |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2706 Logger::cout() << "got size " << getABITypeSize(t) << ", expected " << getABITypeSize(llt) << '\n'; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2707 assert(0 && "type size mismatch"); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2708 } |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2709 sptr = DtoBitCast(sptr, getPtrToType(t)); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2710 Logger::cout() << "sptr type is now: " << *t << '\n'; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2711 } |
50
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
2712 } |
49
e5c4bece7fa1
[svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents:
48
diff
changeset
|
2713 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2714 // build |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2715 unsigned j = 0; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2716 for (unsigned i=0; i<n; ++i) |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2717 { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2718 Expression* vx = (Expression*)elements->data[i]; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2719 if (!vx) continue; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2720 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2721 Logger::cout() << "getting index " << j << " of " << *sptr << '\n'; |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
2722 LLValue* arrptr = DtoGEPi(sptr,0,j); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2723 DValue* darrptr = new DVarValue(vx->type, arrptr, true); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2724 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2725 p->exps.push_back(IRExp(NULL,vx,darrptr)); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2726 DValue* ve = vx->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2727 p->exps.pop_back(); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2728 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2729 if (!ve->inPlace()) |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2730 DtoAssign(darrptr, ve); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2731 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2732 j++; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2733 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2734 |
215
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
2735 return new DImValue(type, sptr, isinplace); |
49
e5c4bece7fa1
[svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents:
48
diff
changeset
|
2736 } |
e5c4bece7fa1
[svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents:
48
diff
changeset
|
2737 |
e5c4bece7fa1
[svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents:
48
diff
changeset
|
2738 ////////////////////////////////////////////////////////////////////////////////////////// |
e5c4bece7fa1
[svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents:
48
diff
changeset
|
2739 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2740 LLConstant* StructLiteralExp::toConstElem(IRState* p) |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2741 { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2742 Logger::print("StructLiteralExp::toConstElem: %s | %s\n", toChars(), type->toChars()); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2743 LOG_SCOPE; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2744 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2745 unsigned n = elements->dim; |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2746 std::vector<LLConstant*> vals(n, NULL); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2747 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2748 for (unsigned i=0; i<n; ++i) |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2749 { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2750 Expression* vx = (Expression*)elements->data[i]; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2751 vals[i] = vx->toConstElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2752 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2753 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2754 assert(DtoDType(type)->ty == Tstruct); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2755 const LLType* t = DtoType(type); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
2756 const LLStructType* st = isaStruct(t); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2757 return llvm::ConstantStruct::get(st,vals); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2758 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2759 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2760 ////////////////////////////////////////////////////////////////////////////////////////// |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2761 |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2762 DValue* InExp::toElem(IRState* p) |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2763 { |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2764 Logger::print("InExp::toElem: %s | %s\n", toChars(), type->toChars()); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2765 LOG_SCOPE; |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2766 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2767 DValue* key = e1->toElem(p); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2768 DValue* aa = e2->toElem(p); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2769 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2770 return DtoAAIn(type, aa, key); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2771 } |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2772 |
127 | 2773 DValue* RemoveExp::toElem(IRState* p) |
2774 { | |
2775 Logger::print("RemoveExp::toElem: %s\n", toChars()); | |
2776 LOG_SCOPE; | |
2777 | |
2778 DValue* aa = e1->toElem(p); | |
2779 DValue* key = e2->toElem(p); | |
2780 | |
2781 DtoAARemove(aa, key); | |
2782 | |
2783 return NULL; // does not produce anything useful | |
2784 } | |
2785 | |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2786 ////////////////////////////////////////////////////////////////////////////////////////// |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2787 |
125 | 2788 DValue* AssocArrayLiteralExp::toElem(IRState* p) |
2789 { | |
2790 Logger::print("AssocArrayLiteralExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2791 LOG_SCOPE; | |
2792 | |
2793 assert(keys); | |
2794 assert(values); | |
2795 assert(keys->dim == values->dim); | |
2796 | |
127 | 2797 Type* aatype = DtoDType(type); |
2798 Type* vtype = aatype->next; | |
2799 | |
2800 DValue* aa; | |
2801 if (p->topexp() && p->topexp()->e2 == this) | |
2802 { | |
2803 aa = p->topexp()->v; | |
2804 } | |
2805 else | |
2806 { | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2807 LLValue* tmp = new llvm::AllocaInst(DtoType(type),"aaliteral",p->topallocapoint()); |
127 | 2808 aa = new DVarValue(type, tmp, true); |
2809 } | |
2810 | |
125 | 2811 const size_t n = keys->dim; |
2812 for (size_t i=0; i<n; ++i) | |
2813 { | |
2814 Expression* ekey = (Expression*)keys->data[i]; | |
2815 Expression* eval = (Expression*)values->data[i]; | |
2816 | |
2817 Logger::println("(%u) aa[%s] = %s", i, ekey->toChars(), eval->toChars()); | |
127 | 2818 |
2819 // index | |
2820 DValue* key = ekey->toElem(p); | |
2821 DValue* mem = DtoAAIndex(vtype, aa, key); | |
2822 | |
2823 // store | |
2824 DValue* val = eval->toElem(p); | |
2825 DtoAssign(mem, val); | |
125 | 2826 } |
2827 | |
127 | 2828 return aa; |
125 | 2829 } |
2830 | |
2831 ////////////////////////////////////////////////////////////////////////////////////////// | |
2832 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2833 #define STUB(x) DValue *x::toElem(IRState * p) {error("Exp type "#x" not implemented: %s", toChars()); fatal(); return 0; } |
1 | 2834 //STUB(IdentityExp); |
2835 //STUB(CondExp); | |
2836 //STUB(EqualExp); | |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2837 //STUB(InExp); |
1 | 2838 //STUB(CmpExp); |
2839 //STUB(AndAndExp); | |
2840 //STUB(OrOrExp); | |
2841 //STUB(AndExp); | |
2842 //STUB(AndAssignExp); | |
2843 //STUB(OrExp); | |
2844 //STUB(OrAssignExp); | |
2845 //STUB(XorExp); | |
2846 //STUB(XorAssignExp); | |
2847 //STUB(ShrExp); | |
2848 //STUB(ShrAssignExp); | |
2849 //STUB(ShlExp); | |
2850 //STUB(ShlAssignExp); | |
2851 //STUB(UshrExp); | |
2852 //STUB(UshrAssignExp); | |
2853 //STUB(DivExp); | |
2854 //STUB(DivAssignExp); | |
2855 //STUB(MulExp); | |
2856 //STUB(MulAssignExp); | |
2857 //STUB(ModExp); | |
2858 //STUB(ModAssignExp); | |
36
c0967c4b2a74
[svn r40] Cleaned up some of the array routines to use gep/load/store instead of memcpy/memset.
lindquist
parents:
34
diff
changeset
|
2859 //STUB(CatExp); |
40 | 2860 //STUB(CatAssignExp); |
1 | 2861 //STUB(AddExp); |
2862 //STUB(AddAssignExp); | |
2863 STUB(Expression); | |
2864 //STUB(MinExp); | |
2865 //STUB(MinAssignExp); | |
2866 //STUB(PostExp); | |
2867 //STUB(NullExp); | |
2868 //STUB(ThisExp); | |
2869 //STUB(CallExp); | |
2870 STUB(DotTypeExp); | |
2871 STUB(TypeDotIdExp); | |
2872 //STUB(DotVarExp); | |
2873 //STUB(AssertExp); | |
49
e5c4bece7fa1
[svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents:
48
diff
changeset
|
2874 //STUB(FuncExp); |
1 | 2875 //STUB(DelegateExp); |
2876 //STUB(VarExp); | |
2877 //STUB(DeclarationExp); | |
2878 //STUB(NewExp); | |
2879 //STUB(SymOffExp); | |
2880 STUB(ScopeExp); | |
2881 //STUB(AssignExp); | |
2882 | |
2883 STUB(TypeExp); | |
2884 //STUB(RealExp); | |
90 | 2885 //STUB(ComplexExp); |
1 | 2886 //STUB(StringExp); |
2887 //STUB(IntegerExp); | |
2888 STUB(BoolExp); | |
2889 | |
2890 //STUB(NotExp); | |
2891 //STUB(ComExp); | |
23 | 2892 //STUB(NegExp); |
1 | 2893 //STUB(PtrExp); |
2894 //STUB(AddrExp); | |
2895 //STUB(SliceExp); | |
2896 //STUB(CastExp); | |
2897 //STUB(DeleteExp); | |
2898 //STUB(IndexExp); | |
2899 //STUB(CommaExp); | |
2900 //STUB(ArrayLengthExp); | |
2901 //STUB(HaltExp); | |
127 | 2902 //STUB(RemoveExp); |
40 | 2903 //STUB(ArrayLiteralExp); |
125 | 2904 //STUB(AssocArrayLiteralExp); |
1 | 2905 //STUB(StructLiteralExp); |
92 | 2906 STUB(TupleExp); |
1 | 2907 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2908 #define CONSTSTUB(x) LLConstant* x::toConstElem(IRState * p) {error("const Exp type "#x" not implemented: '%s' type: '%s'", toChars(), type->toChars()); fatal(); return NULL; } |
40 | 2909 CONSTSTUB(Expression); |
2910 //CONSTSTUB(IntegerExp); | |
2911 //CONSTSTUB(RealExp); | |
2912 //CONSTSTUB(NullExp); | |
90 | 2913 //CONSTSTUB(ComplexExp); |
40 | 2914 //CONSTSTUB(StringExp); |
2915 //CONSTSTUB(VarExp); | |
2916 //CONSTSTUB(ArrayLiteralExp); | |
2917 CONSTSTUB(AssocArrayLiteralExp); | |
2918 //CONSTSTUB(StructLiteralExp); | |
2919 | |
1 | 2920 unsigned Type::totym() { return 0; } |
2921 | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2922 type * Type::toCtype() |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2923 { |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2924 assert(0); |
1 | 2925 return 0; |
2926 } | |
2927 | |
2928 type * Type::toCParamtype() | |
2929 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2930 assert(0); |
1 | 2931 return 0; |
2932 } | |
2933 Symbol * Type::toSymbol() | |
2934 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2935 assert(0); |
1 | 2936 return 0; |
2937 } | |
2938 | |
2939 type * | |
2940 TypeTypedef::toCtype() | |
2941 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2942 assert(0); |
1 | 2943 return 0; |
2944 } | |
2945 | |
2946 type * | |
2947 TypeTypedef::toCParamtype() | |
2948 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2949 assert(0); |
1 | 2950 return 0; |
2951 } | |
2952 | |
2953 void | |
2954 TypedefDeclaration::toDebug() | |
2955 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2956 assert(0); |
1 | 2957 } |
2958 | |
2959 | |
2960 type * | |
2961 TypeEnum::toCtype() | |
2962 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2963 assert(0); |
1 | 2964 return 0; |
2965 } | |
2966 | |
2967 type * | |
2968 TypeStruct::toCtype() | |
2969 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2970 assert(0); |
1 | 2971 return 0; |
2972 } | |
2973 | |
2974 void | |
2975 StructDeclaration::toDebug() | |
2976 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2977 assert(0); |
1 | 2978 } |
2979 | |
2980 Symbol * TypeClass::toSymbol() | |
2981 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2982 assert(0); |
1 | 2983 return 0; |
2984 } | |
2985 | |
2986 unsigned TypeFunction::totym() | |
2987 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2988 assert(0); |
1 | 2989 return 0; |
2990 } | |
2991 | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2992 type * TypeFunction::toCtype() |
1 | 2993 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2994 assert(0); |
1 | 2995 return 0; |
2996 } | |
2997 | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2998 type * TypeSArray::toCtype() |
1 | 2999 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3000 assert(0); |
1 | 3001 return 0; |
3002 } | |
3003 | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3004 type *TypeSArray::toCParamtype() |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3005 { |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3006 assert(0); |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3007 return 0; |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3008 } |
1 | 3009 |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3010 type * TypeDArray::toCtype() |
1 | 3011 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3012 assert(0); |
1 | 3013 return 0; |
3014 } | |
3015 | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3016 type * TypeAArray::toCtype() |
1 | 3017 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3018 assert(0); |
1 | 3019 return 0; |
3020 } | |
3021 | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3022 type * TypePointer::toCtype() |
1 | 3023 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3024 assert(0); |
1 | 3025 return 0; |
3026 } | |
3027 | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3028 type * TypeDelegate::toCtype() |
1 | 3029 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3030 assert(0); |
1 | 3031 return 0; |
3032 } | |
3033 | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3034 type * TypeClass::toCtype() |
1 | 3035 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3036 assert(0); |
1 | 3037 return 0; |
3038 } | |
3039 | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3040 void ClassDeclaration::toDebug() |
1 | 3041 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3042 assert(0); |
1 | 3043 } |
3044 | |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
11
diff
changeset
|
3045 ////////////////////////////////////////////////////////////////////////////// |
1 | 3046 |
3047 void | |
3048 EnumDeclaration::toDebug() | |
3049 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3050 assert(0); |
1 | 3051 } |
3052 | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3053 int Dsymbol::cvMember(unsigned char*) |
1 | 3054 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3055 assert(0); |
1 | 3056 return 0; |
3057 } | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3058 int EnumDeclaration::cvMember(unsigned char*) |
1 | 3059 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3060 assert(0); |
1 | 3061 return 0; |
3062 } | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3063 int FuncDeclaration::cvMember(unsigned char*) |
1 | 3064 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3065 assert(0); |
1 | 3066 return 0; |
3067 } | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3068 int VarDeclaration::cvMember(unsigned char*) |
1 | 3069 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3070 assert(0); |
1 | 3071 return 0; |
3072 } | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3073 int TypedefDeclaration::cvMember(unsigned char*) |
1 | 3074 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3075 assert(0); |
1 | 3076 return 0; |
3077 } | |
3078 | |
3079 void obj_includelib(char*){} | |
3080 | |
3081 void | |
3082 backend_init() | |
3083 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3084 // now lazily loaded |
1 | 3085 //LLVM_D_InitRuntime(); |
3086 } | |
3087 | |
3088 void | |
3089 backend_term() | |
3090 { | |
3091 LLVM_D_FreeRuntime(); | |
3092 } |