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