Mercurial > projects > ldc
annotate gen/toir.cpp @ 228:52d1e9d27dc6 trunk
[svn r244] added another asm test.
author | lindquist |
---|---|
date | Sat, 07 Jun 2008 19:20:15 +0200 |
parents | 761c8352f494 |
children | 0db62b770a49 |
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) { |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1203 if (llfnty->getParamType(j) != NULL) { |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1204 if (llargs[j]->getType() != llfnty->getParamType(j)) { |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1205 Logger::println("llvmRunTimeHack==true - force casting argument"); |
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
1206 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
|
1207 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
|
1208 } |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1209 } |
57
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
55
diff
changeset
|
1210 } |
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
|
1211 } |
1 | 1212 } |
1213 | |
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
|
1214 #if 0 |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
1215 Logger::println("%d params passed", n); |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
1216 for (int i=0; i<llargs.size(); ++i) { |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
1217 assert(llargs[i]); |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
1218 Logger::cout() << "arg["<<i<<"] = " << *llargs[i] << '\n'; |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
1219 } |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
1220 #endif |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
1221 |
1 | 1222 // void returns cannot not be named |
1223 const char* varname = ""; | |
1224 if (llfnty->getReturnType() != llvm::Type::VoidTy) | |
1225 varname = "tmp"; | |
1226 | |
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
|
1227 //Logger::cout() << "Calling: " << *funcval << '\n'; |
1 | 1228 |
1229 // 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
|
1230 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
|
1231 LLValue* retllval = (retinptr) ? llargs[0] : call; |
1 | 1232 |
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
|
1233 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
|
1234 const LLType* rettype = getPtrToType(DtoType(type)); |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1235 if (retllval->getType() != rettype) { |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1236 Logger::println("llvmRunTimeHack==true - force casting return value"); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1237 Logger::cout() << "from: " << *retllval->getType() << " to: " << *rettype << '\n'; |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1238 retllval = DtoBitCast(retllval, rettype); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1239 } |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1240 } |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1241 |
1 | 1242 // set calling convention |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1243 if (dfn && dfn->func) { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1244 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
|
1245 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
|
1246 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
|
1247 } |
0c5f410d973c
[svn r70] Fixed bug where correct calling convention was not set on calling aggregate methods
lindquist
parents:
64
diff
changeset
|
1248 } |
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
|
1249 /*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
|
1250 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
|
1251 }*/ |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1252 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
|
1253 call->setCallingConv(dfn->cc); |
67
f918f3e2e99e
[svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents:
66
diff
changeset
|
1254 } |
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
|
1255 else { |
100 | 1256 call->setCallingConv(DtoCallingConv(dlink)); |
1257 } | |
1 | 1258 |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
1259 // param attrs |
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
1260 call->setParamAttrs(palist); |
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
1261 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1262 return new DImValue(type, retllval, isInPlace); |
1 | 1263 } |
1264 | |
1265 ////////////////////////////////////////////////////////////////////////////////////////// | |
1266 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1267 DValue* CastExp::toElem(IRState* p) |
1 | 1268 { |
53
06ccc817acd4
[svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents:
52
diff
changeset
|
1269 Logger::print("CastExp::toElem: %s | %s\n", toChars(), type->toChars()); |
1 | 1270 LOG_SCOPE; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1271 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1272 DValue* u = e1->toElem(p); |
97
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1273 DValue* v = DtoCast(u, to); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1274 |
107
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
104
diff
changeset
|
1275 if (v->isSlice()) { |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
104
diff
changeset
|
1276 assert(!gIR->topexp() || gIR->topexp()->e1 != this); |
97
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1277 return v; |
1 | 1278 } |
97
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1279 |
201 | 1280 else if (DLRValue* lr = u->isLRValue()) |
1281 return new DLRValue(lr->getLType(), lr->getLVal(), to, v->getRVal()); | |
1282 | |
1283 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
|
1284 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
|
1285 |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
104
diff
changeset
|
1286 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
|
1287 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
|
1288 |
97
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1289 return v; |
1 | 1290 } |
1291 | |
1292 ////////////////////////////////////////////////////////////////////////////////////////// | |
1293 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1294 DValue* SymOffExp::toElem(IRState* p) |
1 | 1295 { |
1296 Logger::print("SymOffExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1297 LOG_SCOPE; | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1298 |
98
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
97
diff
changeset
|
1299 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
|
1300 |
1 | 1301 if (VarDeclaration* vd = var->isVarDeclaration()) |
1302 { | |
1303 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
|
1304 |
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
|
1305 // handle forward reference |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
1306 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
|
1307 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
|
1308 } |
52 | 1309 |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
1310 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
|
1311 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
|
1312 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
|
1313 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
|
1314 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1315 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
|
1316 LLValue* varmem = 0; |
50
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
1317 |
40 | 1318 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
|
1319 Logger::println("struct"); |
40 | 1320 TypeStruct* vdt = (TypeStruct*)vdtype; |
72 | 1321 assert(vdt->sym); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1322 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1323 const LLType* llt = DtoType(t); |
72 | 1324 if (offset == 0) { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1325 varmem = p->ir->CreateBitCast(llvalue, llt, "tmp"); |
72 | 1326 } |
1327 else { | |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
1328 DStructIndexVector dst; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1329 varmem = DtoIndexStruct(llvalue,vdt->sym, tnext, offset, dst); |
72 | 1330 } |
1 | 1331 } |
40 | 1332 else if (vdtype->ty == Tsarray) { |
78
2332006e1fa4
[svn r82] Fixed: Fall-through switch cases were broken.
lindquist
parents:
77
diff
changeset
|
1333 Logger::println("sarray"); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1334 |
64
b688ad419f8c
[svn r68] Added support for multi-dimensional static arrays.
lindquist
parents:
62
diff
changeset
|
1335 assert(llvalue); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1336 //e->arg = llvalue; // TODO |
64
b688ad419f8c
[svn r68] Added support for multi-dimensional static arrays.
lindquist
parents:
62
diff
changeset
|
1337 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1338 const LLType* llt = DtoType(t); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1339 LLValue* off = 0; |
64
b688ad419f8c
[svn r68] Added support for multi-dimensional static arrays.
lindquist
parents:
62
diff
changeset
|
1340 if (offset != 0) { |
b688ad419f8c
[svn r68] Added support for multi-dimensional static arrays.
lindquist
parents:
62
diff
changeset
|
1341 Logger::println("offset = %d\n", offset); |
b688ad419f8c
[svn r68] Added support for multi-dimensional static arrays.
lindquist
parents:
62
diff
changeset
|
1342 } |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
1343 if (offset == 0) { |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
1344 varmem = llvalue; |
64
b688ad419f8c
[svn r68] Added support for multi-dimensional static arrays.
lindquist
parents:
62
diff
changeset
|
1345 } |
b688ad419f8c
[svn r68] Added support for multi-dimensional static arrays.
lindquist
parents:
62
diff
changeset
|
1346 else { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1347 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
|
1348 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
|
1349 varmem = DtoGEPi(llvalue, 0, offset / elemsz, "tmp"); |
64
b688ad419f8c
[svn r68] Added support for multi-dimensional static arrays.
lindquist
parents:
62
diff
changeset
|
1350 } |
1 | 1351 } |
1352 else if (offset == 0) { | |
78
2332006e1fa4
[svn r82] Fixed: Fall-through switch cases were broken.
lindquist
parents:
77
diff
changeset
|
1353 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
|
1354 |
50
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
1355 assert(llvalue); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1356 varmem = llvalue; |
64
b688ad419f8c
[svn r68] Added support for multi-dimensional static arrays.
lindquist
parents:
62
diff
changeset
|
1357 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1358 const LLType* llt = DtoType(t); |
53
06ccc817acd4
[svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents:
52
diff
changeset
|
1359 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
|
1360 varmem = p->ir->CreateBitCast(varmem, llt, "tmp"); |
53
06ccc817acd4
[svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents:
52
diff
changeset
|
1361 } |
1 | 1362 } |
1363 else { | |
1364 assert(0); | |
1365 } | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1366 return new DFieldValue(type, varmem, true); |
1 | 1367 } |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
1368 |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
1369 assert(0); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
1370 return 0; |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
1371 } |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
1372 |
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 |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
1375 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
|
1376 { |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
1377 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
|
1378 LOG_SCOPE; |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
1379 DValue* v = e1->toElem(p); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
1380 if (v->isField()) { |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
1381 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
|
1382 return v; |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
1383 } |
100 | 1384 else if (DFuncValue* fv = v->isFunc()) { |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
1385 Logger::println("is func"); |
100 | 1386 //Logger::println("FuncDeclaration"); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
1387 FuncDeclaration* fd = fv->func; |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
1388 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
|
1389 DtoForceDeclareDsymbol(fd); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
1390 return new DFuncValue(fd, fd->ir.irFunc->func); |
1 | 1391 } |
101
169fda3a77d4
[svn r105] -inline does nothing for now, the -On setting can already be used to trigger it.
lindquist
parents:
100
diff
changeset
|
1392 else if (DImValue* im = v->isIm()) { |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
1393 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
|
1394 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
|
1395 } |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
1396 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
|
1397 return new DFieldValue(type, v->getLVal(), false); |
1 | 1398 } |
1399 | |
1400 ////////////////////////////////////////////////////////////////////////////////////////// | |
1401 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1402 DValue* PtrExp::toElem(IRState* p) |
1 | 1403 { |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
1404 Logger::println("PtrExp::toElem: %s | %s", toChars(), type->toChars()); |
1 | 1405 LOG_SCOPE; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1406 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1407 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
|
1408 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1409 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
|
1410 Logger::println("lval PtrExp"); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1411 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
|
1412 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1413 |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1414 // 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
|
1415 LLValue* lv = a->getRVal(); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1416 LLValue* v = lv; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1417 if (DtoCanLoad(v)) |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1418 v = DtoLoad(v); |
107
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
104
diff
changeset
|
1419 return new DLRValue(e1->type, lv, type, v); |
1 | 1420 } |
1421 | |
1422 ////////////////////////////////////////////////////////////////////////////////////////// | |
1423 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1424 DValue* DotVarExp::toElem(IRState* p) |
1 | 1425 { |
1426 Logger::print("DotVarExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1427 LOG_SCOPE; | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1428 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1429 DValue* l = e1->toElem(p); |
1 | 1430 |
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
|
1431 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
|
1432 Type* e1type = DtoDType(e1->type); |
40 | 1433 |
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
|
1434 //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
|
1435 //Logger::cout() << *DtoType(e1type) << '\n'; |
1 | 1436 |
1437 if (VarDeclaration* vd = var->isVarDeclaration()) { | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1438 LLValue* arrptr; |
40 | 1439 if (e1type->ty == Tpointer) { |
1440 assert(e1type->next->ty == Tstruct); | |
1441 TypeStruct* ts = (TypeStruct*)e1type->next; | |
8
5e69b77a5c51
[svn r12] fixed accessing aggregate fields of aggregates
lindquist
parents:
6
diff
changeset
|
1442 Logger::println("Struct member offset:%d", vd->offset); |
132 | 1443 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1444 LLValue* src = l->getRVal(); |
132 | 1445 |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
1446 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
|
1447 arrptr = DtoIndexStruct(src, ts->sym, vd->type, vd->offset, vdoffsets); |
1 | 1448 } |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1449 else if (e1type->ty == Tclass) { |
40 | 1450 TypeClass* tc = (TypeClass*)e1type; |
1 | 1451 Logger::println("Class member offset: %d", vd->offset); |
132 | 1452 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1453 LLValue* src = l->getRVal(); |
132 | 1454 |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
1455 DStructIndexVector vdoffsets; |
132 | 1456 arrptr = DtoIndexClass(src, tc->sym, vd->type, vd->offset, vdoffsets); |
1457 | |
1458 /*std::vector<unsigned> vdoffsets(1,0); | |
1459 tc->sym->offsetToIndex(vd->type, vd->offset, vdoffsets); | |
1460 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1461 LLValue* src = l->getRVal(); |
132 | 1462 |
1463 Logger::println("indices:"); | |
1464 for (size_t i=0; i<vdoffsets.size(); ++i) | |
1465 Logger::println("%d", vdoffsets[i]); | |
1466 | |
1467 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
|
1468 arrptr = DtoGEP(src,vdoffsets,"tmp",p->scopebb()); |
132 | 1469 Logger::cout() << "dst: " << *arrptr << '\n';*/ |
1 | 1470 } |
77
714057ff2dbb
[svn r81] Fixed: Union support was very buggy. Should be fairly solid now.
lindquist
parents:
76
diff
changeset
|
1471 else |
714057ff2dbb
[svn r81] Fixed: Union support was very buggy. Should be fairly solid now.
lindquist
parents:
76
diff
changeset
|
1472 assert(0); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1473 |
123
7f9a0a58394b
[svn r127] Updated the lphobos build scripts a little. Created a new rebuild profile.
lindquist
parents:
122
diff
changeset
|
1474 //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
|
1475 return new DVarValue(vd, arrptr, true); |
1 | 1476 } |
1477 else if (FuncDeclaration* fdecl = var->isFuncDeclaration()) | |
1478 { | |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1479 DtoResolveDsymbol(fdecl); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1480 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1481 LLValue* funcval; |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1482 LLValue* vthis2 = 0; |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1483 if (e1type->ty == Tclass) { |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1484 TypeClass* tc = (TypeClass*)e1type; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1485 if (tc->sym->isInterfaceDeclaration()) { |
114 | 1486 vthis2 = DtoCastInterfaceToObject(l, NULL)->getRVal(); |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1487 } |
1 | 1488 } |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1489 LLValue* vthis = l->getRVal(); |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1490 if (!vthis2) vthis2 = vthis; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1491 //unsigned cc = (unsigned)-1; |
1 | 1492 |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1493 // super call |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1494 if (e1->op == TOKsuper) { |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1495 DtoForceDeclareDsymbol(fdecl); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
1496 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
|
1497 assert(funcval); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1498 } |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1499 // normal virtual call |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1500 else if (fdecl->isAbstract() || (!fdecl->isFinal() && fdecl->isVirtual())) { |
1 | 1501 assert(fdecl->vtblIndex > 0); |
40 | 1502 assert(e1type->ty == Tclass); |
1 | 1503 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1504 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
|
1505 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
|
1506 //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
|
1507 funcval = DtoGEP(vthis, zero, zero, "tmp", p->scopebb()); |
1 | 1508 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
|
1509 funcval = DtoGEP(funcval, zero, vtblidx, toChars(), p->scopebb()); |
1 | 1510 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
|
1511 #if OPAQUE_VTBLS |
aca17e55b7a5
[svn r209] Fixed: exotic array to pointer casts were broken.
lindquist
parents:
183
diff
changeset
|
1512 funcval = DtoBitCast(funcval, getPtrToType(DtoType(fdecl->type))); |
aca17e55b7a5
[svn r209] Fixed: exotic array to pointer casts were broken.
lindquist
parents:
183
diff
changeset
|
1513 Logger::cout() << "funcval casted: " << *funcval << '\n'; |
aca17e55b7a5
[svn r209] Fixed: exotic array to pointer casts were broken.
lindquist
parents:
183
diff
changeset
|
1514 #endif |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1515 //assert(funcval->getType() == DtoType(fdecl->type)); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1516 //cc = DtoCallingConv(fdecl->linkage); |
1 | 1517 } |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1518 // static call |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1519 else { |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1520 DtoForceDeclareDsymbol(fdecl); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
1521 funcval = fdecl->ir.irFunc->func; |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1522 assert(funcval); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1523 //assert(funcval->getType() == DtoType(fdecl->type)); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1524 } |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1525 return new DFuncValue(fdecl, funcval, vthis2); |
1 | 1526 } |
1527 else { | |
123
7f9a0a58394b
[svn r127] Updated the lphobos build scripts a little. Created a new rebuild profile.
lindquist
parents:
122
diff
changeset
|
1528 printf("unsupported dotvarexp: %s\n", var->toChars()); |
1 | 1529 } |
1530 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1531 assert(0); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1532 return 0; |
1 | 1533 } |
1534 | |
1535 ////////////////////////////////////////////////////////////////////////////////////////// | |
1536 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1537 DValue* ThisExp::toElem(IRState* p) |
1 | 1538 { |
1539 Logger::print("ThisExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1540 LOG_SCOPE; | |
1541 | |
1542 if (VarDeclaration* vd = var->isVarDeclaration()) { | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1543 LLValue* v; |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
1544 v = p->func()->decl->ir.irFunc->thisVar; |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
1545 if (llvm::isa<llvm::AllocaInst>(v)) |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
1546 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
|
1547 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
|
1548 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
|
1549 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
|
1550 return new DThisValue(vd, v); |
1 | 1551 } |
1552 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1553 assert(0); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1554 return 0; |
1 | 1555 } |
1556 | |
1557 ////////////////////////////////////////////////////////////////////////////////////////// | |
1558 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1559 DValue* IndexExp::toElem(IRState* p) |
1 | 1560 { |
1561 Logger::print("IndexExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1562 LOG_SCOPE; | |
1563 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1564 DValue* l = e1->toElem(p); |
1 | 1565 |
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
|
1566 Type* e1type = DtoDType(e1->type); |
40 | 1567 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1568 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
|
1569 DValue* r = e2->toElem(p); |
1 | 1570 p->arrays.pop_back(); |
1571 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1572 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
|
1573 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
|
1574 |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1575 LLValue* arrptr = 0; |
40 | 1576 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
|
1577 arrptr = llvm::GetElementPtrInst::Create(l->getRVal(),r->getRVal(),"tmp",p->scopebb()); |
1 | 1578 } |
40 | 1579 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
|
1580 arrptr = DtoGEP(l->getRVal(), zero, r->getRVal(),"tmp",p->scopebb()); |
1 | 1581 } |
40 | 1582 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
|
1583 arrptr = DtoGEP(l->getRVal(),zero,one,"tmp",p->scopebb()); |
1 | 1584 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
|
1585 arrptr = llvm::GetElementPtrInst::Create(arrptr,r->getRVal(),"tmp",p->scopebb()); |
1 | 1586 } |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1587 else if (e1type->ty == Taarray) { |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1588 return DtoAAIndex(type, l, r); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1589 } |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1590 else { |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1591 Logger::println("invalid index exp! e1type: %s", e1type->toChars()); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1592 assert(0); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1593 } |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1594 return new DVarValue(type, arrptr, true); |
1 | 1595 } |
1596 | |
1597 ////////////////////////////////////////////////////////////////////////////////////////// | |
1598 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1599 DValue* SliceExp::toElem(IRState* p) |
1 | 1600 { |
1601 Logger::print("SliceExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1602 LOG_SCOPE; | |
1603 | |
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
|
1604 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
|
1605 Type* e1type = DtoDType(e1->type); |
1 | 1606 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1607 DValue* v = e1->toElem(p); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1608 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
|
1609 assert(vmem); |
1 | 1610 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1611 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
|
1612 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
|
1613 |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1614 LLValue* emem = 0; |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1615 LLValue* earg = 0; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1616 |
1 | 1617 // partial slice |
1618 if (lwr) | |
1619 { | |
1620 assert(upr); | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1621 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
|
1622 DValue* lo = lwr->toElem(p); |
1 | 1623 |
1624 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
|
1625 if (DConstValue* cv = lo->isConst()) |
1 | 1626 { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1627 assert(llvm::isa<llvm::ConstantInt>(cv->c)); |
1 | 1628 |
40 | 1629 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
|
1630 emem = v->getRVal(); |
1 | 1631 } |
40 | 1632 else if (e1type->ty == Tarray) { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1633 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
|
1634 emem = new llvm::LoadInst(tmp,"tmp",p->scopebb()); |
1 | 1635 } |
40 | 1636 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
|
1637 emem = DtoGEP(vmem,zero,zero,"tmp",p->scopebb()); |
40 | 1638 } |
1 | 1639 else |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1640 assert(emem); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1641 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1642 llvm::ConstantInt* c = llvm::cast<llvm::ConstantInt>(cv->c); |
1 | 1643 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
|
1644 emem = llvm::GetElementPtrInst::Create(emem,cv->c,"tmp",p->scopebb()); |
1 | 1645 } |
1646 } | |
1647 else | |
1648 { | |
40 | 1649 if (e1type->ty == Tarray) { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1650 LLValue* tmp = DtoGEP(vmem,zero,one,"tmp",p->scopebb()); |
40 | 1651 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
|
1652 emem = llvm::GetElementPtrInst::Create(tmp,lo->getRVal(),"tmp",p->scopebb()); |
40 | 1653 } |
1654 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
|
1655 emem = DtoGEP(vmem,zero,lo->getRVal(),"tmp",p->scopebb()); |
40 | 1656 } |
73 | 1657 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
|
1658 emem = llvm::GetElementPtrInst::Create(v->getRVal(),lo->getRVal(),"tmp",p->scopebb()); |
73 | 1659 } |
1660 else { | |
1661 Logger::println("type = %s", e1type->toChars()); | |
1662 assert(0); | |
1663 } | |
1 | 1664 } |
1665 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1666 DValue* up = upr->toElem(p); |
1 | 1667 p->arrays.pop_back(); |
1668 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1669 if (DConstValue* cv = up->isConst()) |
1 | 1670 { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1671 assert(llvm::isa<llvm::ConstantInt>(cv->c)); |
1 | 1672 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
|
1673 earg = cv->c; |
1 | 1674 } |
1675 else { | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1676 if (lo->isConst()) { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1677 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
|
1678 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
|
1679 earg = llvm::ConstantExpr::getSub(cup, clo); |
1 | 1680 } |
1681 else { | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1682 earg = llvm::BinaryOperator::createSub(cv->c, lo->getRVal(), "tmp", p->scopebb()); |
1 | 1683 } |
1684 } | |
1685 } | |
1686 else | |
1687 { | |
1688 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
|
1689 earg = up->getRVal(); |
1 | 1690 } |
1691 else { | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1692 earg = llvm::BinaryOperator::createSub(up->getRVal(), lo->getRVal(), "tmp", p->scopebb()); |
1 | 1693 } |
1694 } | |
1695 } | |
1696 // full slice | |
1697 else | |
1698 { | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1699 emem = vmem; |
1 | 1700 } |
1701 | |
116
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1702 if (earg) Logger::cout() << "slice exp result, length = " << *earg << '\n'; |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1703 Logger::cout() << "slice exp result, ptr = " << *emem << '\n'; |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1704 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1705 return new DSliceValue(type,earg,emem); |
1 | 1706 } |
1707 | |
1708 ////////////////////////////////////////////////////////////////////////////////////////// | |
1709 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1710 DValue* CmpExp::toElem(IRState* p) |
1 | 1711 { |
1712 Logger::print("CmpExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1713 LOG_SCOPE; | |
1714 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1715 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
|
1716 DValue* r = e2->toElem(p); |
1 | 1717 |
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
|
1718 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
|
1719 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
|
1720 assert(DtoType(t) == DtoType(e2t)); |
1 | 1721 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1722 LLValue* eval = 0; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1723 |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1724 if (t->isintegral() || t->ty == Tpointer) |
1 | 1725 { |
1726 llvm::ICmpInst::Predicate cmpop; | |
40 | 1727 bool skip = false; |
1 | 1728 switch(op) |
1729 { | |
1730 case TOKlt: | |
40 | 1731 case TOKul: |
1 | 1732 cmpop = t->isunsigned() ? llvm::ICmpInst::ICMP_ULT : llvm::ICmpInst::ICMP_SLT; |
1733 break; | |
1734 case TOKle: | |
40 | 1735 case TOKule: |
1 | 1736 cmpop = t->isunsigned() ? llvm::ICmpInst::ICMP_ULE : llvm::ICmpInst::ICMP_SLE; |
1737 break; | |
1738 case TOKgt: | |
40 | 1739 case TOKug: |
1 | 1740 cmpop = t->isunsigned() ? llvm::ICmpInst::ICMP_UGT : llvm::ICmpInst::ICMP_SGT; |
1741 break; | |
1742 case TOKge: | |
40 | 1743 case TOKuge: |
1 | 1744 cmpop = t->isunsigned() ? llvm::ICmpInst::ICMP_UGE : llvm::ICmpInst::ICMP_SGE; |
1745 break; | |
40 | 1746 case TOKue: |
1747 cmpop = llvm::ICmpInst::ICMP_EQ; | |
1748 break; | |
1749 case TOKlg: | |
1750 cmpop = llvm::ICmpInst::ICMP_NE; | |
1751 break; | |
1752 case TOKleg: | |
1753 skip = true; | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1754 eval = llvm::ConstantInt::getTrue(); |
40 | 1755 break; |
1756 case TOKunord: | |
1757 skip = true; | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1758 eval = llvm::ConstantInt::getFalse(); |
40 | 1759 break; |
1760 | |
1 | 1761 default: |
1762 assert(0); | |
1763 } | |
40 | 1764 if (!skip) |
1765 { | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1766 LLValue* a = l->getRVal(); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1767 LLValue* b = r->getRVal(); |
132 | 1768 Logger::cout() << "type 1: " << *a << '\n'; |
1769 Logger::cout() << "type 2: " << *b << '\n'; | |
1770 eval = new llvm::ICmpInst(cmpop, a, b, "tmp", p->scopebb()); | |
40 | 1771 } |
1 | 1772 } |
1773 else if (t->isfloating()) | |
1774 { | |
1775 llvm::FCmpInst::Predicate cmpop; | |
1776 switch(op) | |
1777 { | |
1778 case TOKlt: | |
1779 cmpop = llvm::FCmpInst::FCMP_OLT;break; | |
1780 case TOKle: | |
1781 cmpop = llvm::FCmpInst::FCMP_OLE;break; | |
1782 case TOKgt: | |
1783 cmpop = llvm::FCmpInst::FCMP_OGT;break; | |
1784 case TOKge: | |
1785 cmpop = llvm::FCmpInst::FCMP_OGE;break; | |
1786 case TOKunord: | |
1787 cmpop = llvm::FCmpInst::FCMP_UNO;break; | |
1788 case TOKule: | |
1789 cmpop = llvm::FCmpInst::FCMP_ULE;break; | |
1790 case TOKul: | |
1791 cmpop = llvm::FCmpInst::FCMP_ULT;break; | |
1792 case TOKuge: | |
1793 cmpop = llvm::FCmpInst::FCMP_UGE;break; | |
1794 case TOKug: | |
1795 cmpop = llvm::FCmpInst::FCMP_UGT;break; | |
1796 case TOKue: | |
1797 cmpop = llvm::FCmpInst::FCMP_UEQ;break; | |
1798 case TOKlg: | |
1799 cmpop = llvm::FCmpInst::FCMP_ONE;break; | |
1800 case TOKleg: | |
1801 cmpop = llvm::FCmpInst::FCMP_ORD;break; | |
1802 | |
1803 default: | |
1804 assert(0); | |
1805 } | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1806 eval = new llvm::FCmpInst(cmpop, l->getRVal(), r->getRVal(), "tmp", p->scopebb()); |
1 | 1807 } |
99
a676a7743642
[svn r103] Array comparisons are now fully implemented, that is - to the extent that TypeInfo is.
lindquist
parents:
98
diff
changeset
|
1808 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
|
1809 { |
a676a7743642
[svn r103] Array comparisons are now fully implemented, that is - to the extent that TypeInfo is.
lindquist
parents:
98
diff
changeset
|
1810 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
|
1811 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
|
1812 } |
1 | 1813 else |
1814 { | |
1815 assert(0 && "Unsupported CmpExp type"); | |
1816 } | |
1817 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1818 return new DImValue(type, eval); |
1 | 1819 } |
1820 | |
1821 ////////////////////////////////////////////////////////////////////////////////////////// | |
1822 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1823 DValue* EqualExp::toElem(IRState* p) |
1 | 1824 { |
1825 Logger::print("EqualExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1826 LOG_SCOPE; | |
1827 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1828 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
|
1829 DValue* r = e2->toElem(p); |
1 | 1830 |
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
|
1831 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
|
1832 Type* e2t = DtoDType(e2->type); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
1833 //assert(t == e2t); |
1 | 1834 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1835 LLValue* eval = 0; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1836 |
1 | 1837 if (t->isintegral() || t->ty == Tpointer) |
1838 { | |
64
b688ad419f8c
[svn r68] Added support for multi-dimensional static arrays.
lindquist
parents:
62
diff
changeset
|
1839 Logger::println("integral or pointer"); |
1 | 1840 llvm::ICmpInst::Predicate cmpop; |
1841 switch(op) | |
1842 { | |
1843 case TOKequal: | |
1844 cmpop = llvm::ICmpInst::ICMP_EQ; | |
1845 break; | |
1846 case TOKnotequal: | |
1847 cmpop = llvm::ICmpInst::ICMP_NE; | |
1848 break; | |
1849 default: | |
1850 assert(0); | |
1851 } | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1852 LLValue* lv = l->getRVal(); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1853 LLValue* rv = r->getRVal(); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
1854 if (rv->getType() != lv->getType()) { |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
1855 rv = DtoBitCast(rv, lv->getType()); |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
1856 } |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
1857 eval = new llvm::ICmpInst(cmpop, lv, rv, "tmp", p->scopebb()); |
1 | 1858 } |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
1859 else if (t->iscomplex()) |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
1860 { |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
1861 Logger::println("complex"); |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
1862 eval = DtoComplexEquals(op, l, r); |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
1863 } |
1 | 1864 else if (t->isfloating()) |
1865 { | |
64
b688ad419f8c
[svn r68] Added support for multi-dimensional static arrays.
lindquist
parents:
62
diff
changeset
|
1866 Logger::println("floating"); |
1 | 1867 llvm::FCmpInst::Predicate cmpop; |
1868 switch(op) | |
1869 { | |
1870 case TOKequal: | |
1871 cmpop = llvm::FCmpInst::FCMP_OEQ; | |
1872 break; | |
1873 case TOKnotequal: | |
1874 cmpop = llvm::FCmpInst::FCMP_UNE; | |
1875 break; | |
1876 default: | |
1877 assert(0); | |
1878 } | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1879 eval = new llvm::FCmpInst(cmpop, l->getRVal(), r->getRVal(), "tmp", p->scopebb()); |
1 | 1880 } |
98
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
97
diff
changeset
|
1881 else if (t->ty == Tsarray || t->ty == Tarray) |
40 | 1882 { |
98
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
97
diff
changeset
|
1883 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
|
1884 eval = DtoArrayEquals(op,l,r); |
1 | 1885 } |
53
06ccc817acd4
[svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents:
52
diff
changeset
|
1886 else if (t->ty == Tdelegate) |
06ccc817acd4
[svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents:
52
diff
changeset
|
1887 { |
64
b688ad419f8c
[svn r68] Added support for multi-dimensional static arrays.
lindquist
parents:
62
diff
changeset
|
1888 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
|
1889 eval = DtoDelegateCompare(op,l->getRVal(),r->getRVal()); |
53
06ccc817acd4
[svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents:
52
diff
changeset
|
1890 } |
1 | 1891 else |
1892 { | |
1893 assert(0 && "Unsupported EqualExp type"); | |
1894 } | |
1895 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1896 return new DImValue(type, eval); |
1 | 1897 } |
1898 | |
1899 ////////////////////////////////////////////////////////////////////////////////////////// | |
1900 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1901 DValue* PostExp::toElem(IRState* p) |
1 | 1902 { |
1903 Logger::print("PostExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1904 LOG_SCOPE; | |
1905 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1906 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
|
1907 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
|
1908 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1909 LLValue* val = l->getRVal(); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1910 LLValue* post = 0; |
1 | 1911 |
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
|
1912 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
|
1913 Type* e2type = DtoDType(e2->type); |
40 | 1914 |
1915 if (e1type->isintegral()) | |
1 | 1916 { |
40 | 1917 assert(e2type->isintegral()); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1918 LLValue* one = llvm::ConstantInt::get(val->getType(), 1, !e2type->isunsigned()); |
1 | 1919 if (op == TOKplusplus) { |
1920 post = llvm::BinaryOperator::createAdd(val,one,"tmp",p->scopebb()); | |
1921 } | |
1922 else if (op == TOKminusminus) { | |
1923 post = llvm::BinaryOperator::createSub(val,one,"tmp",p->scopebb()); | |
1924 } | |
1925 } | |
40 | 1926 else if (e1type->ty == Tpointer) |
1 | 1927 { |
40 | 1928 assert(e2type->isintegral()); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1929 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
|
1930 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
|
1931 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
|
1932 post = llvm::GetElementPtrInst::Create(val, whichone, "tmp", p->scopebb()); |
1 | 1933 } |
40 | 1934 else if (e1type->isfloating()) |
1 | 1935 { |
40 | 1936 assert(e2type->isfloating()); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1937 LLValue* one = DtoConstFP(e1type, 1.0); |
1 | 1938 if (op == TOKplusplus) { |
1939 post = llvm::BinaryOperator::createAdd(val,one,"tmp",p->scopebb()); | |
1940 } | |
1941 else if (op == TOKminusminus) { | |
1942 post = llvm::BinaryOperator::createSub(val,one,"tmp",p->scopebb()); | |
1943 } | |
1944 } | |
1945 else | |
1946 assert(post); | |
1947 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1948 DtoStore(post,l->getLVal()); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1949 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1950 return new DImValue(type,val,true); |
1 | 1951 } |
1952 | |
1953 ////////////////////////////////////////////////////////////////////////////////////////// | |
1954 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1955 DValue* NewExp::toElem(IRState* p) |
1 | 1956 { |
1957 Logger::print("NewExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1958 LOG_SCOPE; | |
1959 | |
123
7f9a0a58394b
[svn r127] Updated the lphobos build scripts a little. Created a new rebuild profile.
lindquist
parents:
122
diff
changeset
|
1960 assert(!newargs && "arguments to new not yet supported"); |
1 | 1961 assert(newtype); |
123
7f9a0a58394b
[svn r127] Updated the lphobos build scripts a little. Created a new rebuild profile.
lindquist
parents:
122
diff
changeset
|
1962 assert(!allocator && "custom allocators not yet supported"); |
1 | 1963 |
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
|
1964 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
|
1965 |
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
|
1966 // new class |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1967 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
|
1968 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
|
1969 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
|
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 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
|
1972 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
|
1973 { |
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
|
1974 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
|
1975 // 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
|
1976 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
|
1977 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
|
1978 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
|
1979 // 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
|
1980 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
|
1981 } |
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 // 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
|
1983 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
|
1984 { |
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 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
|
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 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
|
1988 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
|
1989 { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1990 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
|
1991 // allocate |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1992 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
|
1993 // 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
|
1994 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
|
1995 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
|
1996 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
|
1997 } |
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 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
|
1999 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
|
2000 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
|
2001 } |
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 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
|
2003 } |
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 // 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
|
2005 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
|
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 // allocate |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2008 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
|
2009 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
|
2010 |
4c2689d57ba4
[svn r228] Fixed: when new'ing basic types, the storage was not default initialized.
lindquist
parents:
210
diff
changeset
|
2011 // default initialize |
4c2689d57ba4
[svn r228] Fixed: when new'ing basic types, the storage was not default initialized.
lindquist
parents:
210
diff
changeset
|
2012 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
|
2013 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
|
2014 DtoAssign(&tmpvar, iv); |
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 // 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
|
2017 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
|
2018 } |
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
|
2019 |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
2020 assert(0); |
1 | 2021 } |
2022 | |
2023 ////////////////////////////////////////////////////////////////////////////////////////// | |
2024 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2025 DValue* DeleteExp::toElem(IRState* p) |
1 | 2026 { |
2027 Logger::print("DeleteExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2028 LOG_SCOPE; | |
2029 | |
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
|
2030 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
|
2031 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
|
2032 |
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
|
2033 // 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
|
2034 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
|
2035 { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2036 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
|
2037 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
|
2038 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
|
2039 DtoStore(llvm::Constant::getNullValue(rval->getType()), dval->getLVal()); |
1 | 2040 } |
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
|
2041 // 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
|
2042 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
|
2043 { |
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 bool onstack = false; |
210 | 2045 TypeClass* tc = (TypeClass*)et; |
2046 if (tc->sym->isInterfaceDeclaration()) | |
2047 { | |
2048 DtoDeleteInterface(dval->getRVal()); | |
2049 onstack = true; | |
2050 } | |
2051 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
|
2052 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
|
2053 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
|
2054 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
|
2055 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
|
2056 } |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
2057 } |
1 | 2058 } |
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
|
2059 if (!onstack) { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2060 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
|
2061 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
|
2062 } |
210 | 2063 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
|
2064 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
|
2065 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
|
2066 } |
1 | 2067 } |
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
|
2068 // 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
|
2069 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
|
2070 { |
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 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
|
2072 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
|
2073 DtoSetArrayToNull(dval->getRVal()); |
1 | 2074 } |
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
|
2075 // 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
|
2076 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
|
2077 { |
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 assert(0 && "invalid delete"); |
1 | 2079 } |
2080 | |
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
|
2081 // 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
|
2082 return NULL; |
1 | 2083 } |
2084 | |
2085 ////////////////////////////////////////////////////////////////////////////////////////// | |
2086 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2087 DValue* ArrayLengthExp::toElem(IRState* p) |
1 | 2088 { |
2089 Logger::print("ArrayLengthExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2090 LOG_SCOPE; | |
2091 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2092 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
|
2093 Logger::println("e1 = %s", e1->type->toChars()); |
1 | 2094 |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
2095 if (p->topexp() && p->topexp()->e1 == this) |
34 | 2096 { |
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
|
2097 return new DArrayLenValue(e1->type, u->getLVal()); |
34 | 2098 } |
2099 else | |
2100 { | |
207
e0b6040585b4
[svn r223] Fixed: assert with message could be broken.
lindquist
parents:
205
diff
changeset
|
2101 return new DImValue(type, DtoArrayLen(u)); |
34 | 2102 } |
1 | 2103 } |
2104 | |
2105 ////////////////////////////////////////////////////////////////////////////////////////// | |
2106 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2107 DValue* AssertExp::toElem(IRState* p) |
1 | 2108 { |
2109 Logger::print("AssertExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2110 LOG_SCOPE; | |
2111 | |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2112 // condition |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2113 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
|
2114 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2115 // create basic blocks |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2116 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
|
2117 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
|
2118 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
|
2119 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2120 // test condition |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2121 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
|
2122 condval = DtoBoolean(condval); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2123 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2124 // 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
|
2125 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
|
2126 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2127 // call assert runtime functions |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2128 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
|
2129 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
|
2130 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2131 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
|
2132 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
|
2133 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2134 // rewrite the scope |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2135 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
|
2136 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2137 // no meaningful return value |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2138 return NULL; |
1 | 2139 } |
2140 | |
2141 ////////////////////////////////////////////////////////////////////////////////////////// | |
2142 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2143 DValue* NotExp::toElem(IRState* p) |
1 | 2144 { |
2145 Logger::print("NotExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2146 LOG_SCOPE; | |
2147 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2148 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
|
2149 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2150 LLValue* b = DtoBoolean(u->getRVal()); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2151 |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2152 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
|
2153 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
|
2154 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2155 return new DImValue(type, b); |
1 | 2156 } |
2157 | |
2158 ////////////////////////////////////////////////////////////////////////////////////////// | |
2159 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2160 DValue* AndAndExp::toElem(IRState* p) |
1 | 2161 { |
2162 Logger::print("AndAndExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2163 LOG_SCOPE; | |
2164 | |
2165 // 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
|
2166 LLValue* resval = 0; |
1 | 2167 llvm::BasicBlock* entryblock = &p->topfunc()->front(); |
2168 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
|
2169 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2170 DValue* u = e1->toElem(p); |
1 | 2171 |
2172 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
|
2173 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
|
2174 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
|
2175 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2176 LLValue* ubool = DtoBoolean(u->getRVal()); |
1 | 2177 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
|
2178 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
|
2179 |
1 | 2180 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
|
2181 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
|
2182 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2183 LLValue* vbool = DtoBoolean(v->getRVal()); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2184 LLValue* uandvbool = llvm::BinaryOperator::create(llvm::BinaryOperator::And, ubool, vbool,"tmp",p->scopebb()); |
1 | 2185 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
|
2186 llvm::BranchInst::Create(andandend,p->scopebb()); |
1 | 2187 |
2188 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
|
2189 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2190 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
|
2191 return new DImValue(type, resval); |
1 | 2192 } |
2193 | |
2194 ////////////////////////////////////////////////////////////////////////////////////////// | |
2195 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2196 DValue* OrOrExp::toElem(IRState* p) |
1 | 2197 { |
2198 Logger::print("OrOrExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2199 LOG_SCOPE; | |
2200 | |
2201 // 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
|
2202 LLValue* resval = 0; |
1 | 2203 llvm::BasicBlock* entryblock = &p->topfunc()->front(); |
2204 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
|
2205 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2206 DValue* u = e1->toElem(p); |
1 | 2207 |
2208 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
|
2209 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
|
2210 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
|
2211 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2212 LLValue* ubool = DtoBoolean(u->getRVal()); |
1 | 2213 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
|
2214 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
|
2215 |
1 | 2216 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
|
2217 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
|
2218 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2219 LLValue* vbool = DtoBoolean(v->getRVal()); |
1 | 2220 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
|
2221 llvm::BranchInst::Create(ororend,p->scopebb()); |
1 | 2222 |
2223 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
|
2224 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2225 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
|
2226 return new DImValue(type, resval); |
1 | 2227 } |
2228 | |
2229 ////////////////////////////////////////////////////////////////////////////////////////// | |
2230 | |
2231 #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
|
2232 DValue* X##Exp::toElem(IRState* p) \ |
1 | 2233 { \ |
2234 Logger::print("%sExp::toElem: %s | %s\n", #X, toChars(), type->toChars()); \ | |
2235 LOG_SCOPE; \ | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2236 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
|
2237 DValue* v = e2->toElem(p); \ |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2238 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
|
2239 return new DImValue(type, x); \ |
1 | 2240 } \ |
2241 \ | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2242 DValue* X##AssignExp::toElem(IRState* p) \ |
1 | 2243 { \ |
2244 Logger::print("%sAssignExp::toElem: %s | %s\n", #X, toChars(), type->toChars()); \ | |
2245 LOG_SCOPE; \ | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2246 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
|
2247 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
|
2248 p->topexp()->v = u; \ |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2249 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
|
2250 p->exps.pop_back(); \ |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2251 LLValue* uval = u->getRVal(); \ |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2252 LLValue* vval = v->getRVal(); \ |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2253 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
|
2254 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
|
2255 return u; \ |
1 | 2256 } |
2257 | |
2258 BinBitExp(And,And); | |
2259 BinBitExp(Or,Or); | |
2260 BinBitExp(Xor,Xor); | |
2261 BinBitExp(Shl,Shl); | |
2262 BinBitExp(Shr,AShr); | |
2263 BinBitExp(Ushr,LShr); | |
2264 | |
2265 ////////////////////////////////////////////////////////////////////////////////////////// | |
2266 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2267 DValue* HaltExp::toElem(IRState* p) |
1 | 2268 { |
2269 Logger::print("HaltExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2270 LOG_SCOPE; | |
2271 | |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
2272 // call the new (?) trap intrinsic |
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
2273 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
|
2274 |
40 | 2275 new llvm::UnreachableInst(p->scopebb()); |
1 | 2276 return 0; |
2277 } | |
2278 | |
2279 ////////////////////////////////////////////////////////////////////////////////////////// | |
2280 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2281 DValue* DelegateExp::toElem(IRState* p) |
1 | 2282 { |
2283 Logger::print("DelegateExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2284 LOG_SCOPE; | |
2285 | |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2286 const llvm::PointerType* int8ptrty = getPtrToType(llvm::Type::Int8Ty); |
1 | 2287 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2288 LLValue* lval; |
143
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2289 bool inplace = false; |
118
d580b95cce2b
[svn r122] Fixed temporary delegates can now alloca their own storage.
lindquist
parents:
116
diff
changeset
|
2290 if (p->topexp() && p->topexp()->e2 == this) { |
d580b95cce2b
[svn r122] Fixed temporary delegates can now alloca their own storage.
lindquist
parents:
116
diff
changeset
|
2291 assert(p->topexp()->v); |
d580b95cce2b
[svn r122] Fixed temporary delegates can now alloca their own storage.
lindquist
parents:
116
diff
changeset
|
2292 lval = p->topexp()->v->getLVal(); |
143
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2293 inplace = true; |
118
d580b95cce2b
[svn r122] Fixed temporary delegates can now alloca their own storage.
lindquist
parents:
116
diff
changeset
|
2294 } |
d580b95cce2b
[svn r122] Fixed temporary delegates can now alloca their own storage.
lindquist
parents:
116
diff
changeset
|
2295 else { |
d580b95cce2b
[svn r122] Fixed temporary delegates can now alloca their own storage.
lindquist
parents:
116
diff
changeset
|
2296 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
|
2297 } |
1 | 2298 |
143
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2299 DValue* u = e1->toElem(p); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2300 LLValue* uval; |
119
79c9ac745fbc
[svn r123] Fixed some typeinfo module name mismatches.
lindquist
parents:
118
diff
changeset
|
2301 if (DFuncValue* f = u->isFunc()) { |
79c9ac745fbc
[svn r123] Fixed some typeinfo module name mismatches.
lindquist
parents:
118
diff
changeset
|
2302 //assert(f->vthis); |
79c9ac745fbc
[svn r123] Fixed some typeinfo module name mismatches.
lindquist
parents:
118
diff
changeset
|
2303 //uval = f->vthis; |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2304 LLValue* nestvar = p->func()->decl->ir.irFunc->nestedVar; |
119
79c9ac745fbc
[svn r123] Fixed some typeinfo module name mismatches.
lindquist
parents:
118
diff
changeset
|
2305 if (nestvar) |
79c9ac745fbc
[svn r123] Fixed some typeinfo module name mismatches.
lindquist
parents:
118
diff
changeset
|
2306 uval = nestvar; |
79c9ac745fbc
[svn r123] Fixed some typeinfo module name mismatches.
lindquist
parents:
118
diff
changeset
|
2307 else |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2308 uval = llvm::ConstantPointerNull::get(int8ptrty); |
119
79c9ac745fbc
[svn r123] Fixed some typeinfo module name mismatches.
lindquist
parents:
118
diff
changeset
|
2309 } |
79c9ac745fbc
[svn r123] Fixed some typeinfo module name mismatches.
lindquist
parents:
118
diff
changeset
|
2310 else { |
143
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2311 DValue* src = u; |
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2312 if (ClassDeclaration* cd = u->getType()->isClassHandle()) |
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2313 { |
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2314 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
|
2315 if (cd->isInterfaceDeclaration()) |
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2316 { |
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2317 Logger::println("context type is interface"); |
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2318 src = DtoCastInterfaceToObject(u, ClassDeclaration::object->type); |
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2319 } |
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2320 } |
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2321 uval = src->getRVal(); |
119
79c9ac745fbc
[svn r123] Fixed some typeinfo module name mismatches.
lindquist
parents:
118
diff
changeset
|
2322 } |
79c9ac745fbc
[svn r123] Fixed some typeinfo module name mismatches.
lindquist
parents:
118
diff
changeset
|
2323 |
143
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2324 Logger::cout() << "context = " << *uval << '\n'; |
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2325 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2326 LLValue* context = DtoGEPi(lval,0,0,"tmp"); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2327 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
|
2328 DtoStore(castcontext, context); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2329 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2330 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
|
2331 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2332 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
|
2333 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2334 LLValue* castfptr; |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2335 if (func->isVirtual()) |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2336 castfptr = DtoVirtualFunctionPointer(u, func); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2337 else if (func->isAbstract()) |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2338 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
|
2339 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
|
2340 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
|
2341 else |
150
2c336566ffed
[svn r156] added a testcase for the most annoying bug ever
lindquist
parents:
144
diff
changeset
|
2342 { |
2c336566ffed
[svn r156] added a testcase for the most annoying bug ever
lindquist
parents:
144
diff
changeset
|
2343 DtoForceDeclareDsymbol(func); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
2344 castfptr = func->ir.irFunc->func; |
150
2c336566ffed
[svn r156] added a testcase for the most annoying bug ever
lindquist
parents:
144
diff
changeset
|
2345 } |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2346 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2347 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
|
2348 DtoStore(castfptr, fptr); |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
2349 |
143
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
2350 return new DImValue(type, lval, inplace); |
1 | 2351 } |
2352 | |
2353 ////////////////////////////////////////////////////////////////////////////////////////// | |
2354 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2355 DValue* IdentityExp::toElem(IRState* p) |
1 | 2356 { |
2357 Logger::print("IdentityExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2358 LOG_SCOPE; | |
2359 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2360 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
|
2361 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
|
2362 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2363 LLValue* l = u->getRVal(); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2364 LLValue* r = v->getRVal(); |
1 | 2365 |
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
|
2366 Type* t1 = DtoDType(e1->type); |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
2367 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2368 LLValue* eval = 0; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2369 |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
2370 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
|
2371 if (v->isNull()) { |
69
2b5a2eaa88be
[svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents:
68
diff
changeset
|
2372 r = NULL; |
2b5a2eaa88be
[svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents:
68
diff
changeset
|
2373 } |
2b5a2eaa88be
[svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents:
68
diff
changeset
|
2374 else { |
2b5a2eaa88be
[svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents:
68
diff
changeset
|
2375 assert(l->getType() == r->getType()); |
2b5a2eaa88be
[svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents:
68
diff
changeset
|
2376 } |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2377 eval = DtoDynArrayIs(op,l,r); |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
2378 } |
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
|
2379 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
|
2380 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
|
2381 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
|
2382 } |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
156
diff
changeset
|
2383 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
|
2384 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
|
2385 } |
177
cea8dcfa76df
[svn r193] Fixed: abstract classes implementing interfaces now output proper Interface info arrays. (null vtables).
lindquist
parents:
176
diff
changeset
|
2386 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
|
2387 } |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
2388 else if (t1->isfloating()) |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
2389 { |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
2390 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
|
2391 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
|
2392 } |
167
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
2393 else if (t1->ty == Tpointer) |
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
2394 { |
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
2395 if (l->getType() != r->getType()) { |
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
2396 if (v->isNull()) |
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
2397 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
|
2398 else |
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
2399 r = DtoBitCast(r, l->getType(), "tmp"); |
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
2400 } |
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
2401 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
|
2402 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
|
2403 } |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
2404 else { |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
2405 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
|
2406 //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
|
2407 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
|
2408 } |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2409 return new DImValue(type, eval); |
1 | 2410 } |
2411 | |
2412 ////////////////////////////////////////////////////////////////////////////////////////// | |
2413 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2414 DValue* CommaExp::toElem(IRState* p) |
1 | 2415 { |
2416 Logger::print("CommaExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2417 LOG_SCOPE; | |
2418 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2419 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
|
2420 DValue* v = e2->toElem(p); |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
2421 assert(e2->type == type); |
1 | 2422 return v; |
2423 } | |
2424 | |
2425 ////////////////////////////////////////////////////////////////////////////////////////// | |
2426 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2427 DValue* CondExp::toElem(IRState* p) |
1 | 2428 { |
2429 Logger::print("CondExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2430 LOG_SCOPE; | |
2431 | |
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
|
2432 Type* dtype = DtoDType(type); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2433 const LLType* resty = DtoType(dtype); |
1 | 2434 |
2435 // allocate a temporary for the final result. failed to come up with a better way :/ | |
2436 llvm::BasicBlock* entryblock = &p->topfunc()->front(); | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2437 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
|
2438 DVarValue* dvv = new DVarValue(type, resval, true); |
1 | 2439 |
2440 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
|
2441 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
|
2442 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
|
2443 llvm::BasicBlock* condend = llvm::BasicBlock::Create("condend", gIR->topfunc(), oldend); |
1 | 2444 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2445 DValue* c = econd->toElem(p); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2446 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
|
2447 llvm::BranchInst::Create(condtrue,condfalse,cond_val,p->scopebb()); |
1 | 2448 |
2449 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
|
2450 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
|
2451 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
|
2452 llvm::BranchInst::Create(condend,p->scopebb()); |
1 | 2453 |
2454 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
|
2455 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
|
2456 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
|
2457 llvm::BranchInst::Create(condend,p->scopebb()); |
1 | 2458 |
2459 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
|
2460 return dvv; |
1 | 2461 } |
2462 | |
2463 ////////////////////////////////////////////////////////////////////////////////////////// | |
2464 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2465 DValue* ComExp::toElem(IRState* p) |
1 | 2466 { |
2467 Logger::print("ComExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2468 LOG_SCOPE; | |
2469 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2470 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
|
2471 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2472 LLValue* value = u->getRVal(); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2473 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
|
2474 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
|
2475 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2476 return new DImValue(type, value); |
1 | 2477 } |
2478 | |
2479 ////////////////////////////////////////////////////////////////////////////////////////// | |
2480 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2481 DValue* NegExp::toElem(IRState* p) |
23 | 2482 { |
2483 Logger::print("NegExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2484 LOG_SCOPE; | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2485 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2486 DValue* l = e1->toElem(p); |
164
a64becf2a702
[svn r180] Fixed complex negation, and tango.math.Math now compiles.
lindquist
parents:
163
diff
changeset
|
2487 |
a64becf2a702
[svn r180] Fixed complex negation, and tango.math.Math now compiles.
lindquist
parents:
163
diff
changeset
|
2488 if (type->iscomplex()) { |
a64becf2a702
[svn r180] Fixed complex negation, and tango.math.Math now compiles.
lindquist
parents:
163
diff
changeset
|
2489 return DtoComplexNeg(type, l); |
a64becf2a702
[svn r180] Fixed complex negation, and tango.math.Math now compiles.
lindquist
parents:
163
diff
changeset
|
2490 } |
a64becf2a702
[svn r180] Fixed complex negation, and tango.math.Math now compiles.
lindquist
parents:
163
diff
changeset
|
2491 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2492 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
|
2493 Type* t = DtoDType(type); |
40 | 2494 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2495 LLValue* zero = 0; |
40 | 2496 if (t->isintegral()) |
23 | 2497 zero = llvm::ConstantInt::get(val->getType(), 0, true); |
40 | 2498 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
|
2499 zero = DtoConstFP(type, 0.0); |
23 | 2500 } |
2501 else | |
2502 assert(0); | |
2503 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2504 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
|
2505 return new DImValue(type, val); |
23 | 2506 } |
2507 | |
2508 ////////////////////////////////////////////////////////////////////////////////////////// | |
2509 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2510 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
|
2511 { |
c0967c4b2a74
[svn r40] Cleaned up some of the array routines to use gep/load/store instead of memcpy/memset.
lindquist
parents:
34
diff
changeset
|
2512 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
|
2513 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
|
2514 |
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
|
2515 Type* t = DtoDType(type); |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
2516 |
132 | 2517 bool arrNarr = DtoDType(e1->type) == DtoDType(e2->type); |
2518 | |
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
|
2519 // 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
|
2520 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
|
2521 { |
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
|
2522 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
|
2523 } |
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 ~ 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
|
2525 // 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
|
2526 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
|
2527 { |
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 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
|
2529 } |
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 |
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 /* |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
2532 IRExp* ex = p->topexp(); |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
2533 if (ex && ex->e2 == this) { |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
2534 assert(ex->v); |
132 | 2535 if (arrNarr) |
2536 DtoCatArrays(ex->v->getLVal(),e1,e2); | |
2537 else | |
2538 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
|
2539 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
|
2540 } |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
2541 else { |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
2542 assert(t->ty == Tarray); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2543 const LLType* arrty = DtoType(t); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2544 LLValue* dst = new llvm::AllocaInst(arrty, "tmpmem", p->topallocapoint()); |
132 | 2545 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
|
2546 DtoCatAr |
132 | 2547 DtoCatArrays(dst,e1,e2); |
2548 else | |
2549 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
|
2550 return new DVarValue(type, dst, true); |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
2551 } |
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
|
2552 */ |
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
|
2553 } |
c0967c4b2a74
[svn r40] Cleaned up some of the array routines to use gep/load/store instead of memcpy/memset.
lindquist
parents:
34
diff
changeset
|
2554 |
c0967c4b2a74
[svn r40] Cleaned up some of the array routines to use gep/load/store instead of memcpy/memset.
lindquist
parents:
34
diff
changeset
|
2555 ////////////////////////////////////////////////////////////////////////////////////////// |
c0967c4b2a74
[svn r40] Cleaned up some of the array routines to use gep/load/store instead of memcpy/memset.
lindquist
parents:
34
diff
changeset
|
2556 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2557 DValue* CatAssignExp::toElem(IRState* p) |
40 | 2558 { |
2559 Logger::print("CatAssignExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2560 LOG_SCOPE; | |
2561 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2562 DValue* l = e1->toElem(p); |
40 | 2563 |
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
|
2564 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
|
2565 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
|
2566 Type* e2type = DtoDType(e2->type); |
40 | 2567 |
2568 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
|
2569 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
|
2570 DtoAssign(l, slice); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2571 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2572 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
|
2573 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
|
2574 DtoAssign(l, slice); |
40 | 2575 } |
2576 else | |
2577 assert(0 && "only one element at a time right now"); | |
2578 | |
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
|
2579 return l; |
40 | 2580 } |
2581 | |
2582 ////////////////////////////////////////////////////////////////////////////////////////// | |
2583 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2584 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
|
2585 { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2586 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
|
2587 LOG_SCOPE; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2588 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2589 assert(fd); |
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 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
|
2592 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
|
2593 |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
2594 DtoForceDefineDsymbol(fd); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2595 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
2596 bool temp = false; |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2597 LLValue* lval = NULL; |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
2598 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
|
2599 assert(p->topexp()->v); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
2600 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
|
2601 } |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
2602 else { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2603 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
|
2604 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
|
2605 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
|
2606 temp = true; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2607 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2608 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2609 LLValue* context = DtoGEPi(lval,0,0,"tmp",p->scopebb()); |
96 | 2610 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
|
2611 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
|
2612 if (llvmNested == NULL) { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2613 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
|
2614 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
|
2615 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2616 else { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2617 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
|
2618 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
|
2619 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2620 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2621 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
|
2622 |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
2623 assert(fd->ir.irFunc->func); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2624 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
|
2625 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
|
2626 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
2627 if (temp) |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
2628 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
|
2629 else |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
2630 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
|
2631 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2632 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2633 ////////////////////////////////////////////////////////////////////////////////////////// |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2634 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2635 DValue* ArrayLiteralExp::toElem(IRState* p) |
40 | 2636 { |
2637 Logger::print("ArrayLiteralExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2638 LOG_SCOPE; | |
2639 | |
175
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2640 // D types |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2641 Type* arrayType = type->toBasetype(); |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2642 Type* elemType = arrayType->nextOf()->toBasetype(); |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2643 |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2644 // is dynamic ? |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2645 bool dyn = (arrayType->ty == Tarray); |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2646 // length |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2647 size_t len = elements->dim; |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2648 // store into slice? |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2649 bool sliceInPlace = false; |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2650 |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2651 // llvm target type |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2652 const LLType* llType = DtoType(arrayType); |
175
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2653 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
|
2654 |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2655 // llvm storage type |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2656 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
|
2657 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
|
2658 |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2659 // dst pointer |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2660 LLValue* dstMem = 0; |
175
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2661 |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2662 // rvalue of assignment |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2663 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
|
2664 { |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2665 DValue* topval = p->topexp()->v; |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2666 // slice assignment (copy) |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2667 if (DSliceValue* s = topval->isSlice()) |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2668 { |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2669 dstMem = s->ptr; |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2670 sliceInPlace = true; |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2671 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
|
2672 } |
175
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2673 // static array assignment |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2674 else if (topval->getType()->toBasetype()->ty == Tsarray) |
40 | 2675 { |
175
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2676 dstMem = topval->getLVal(); |
40 | 2677 } |
175
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2678 // otherwise we still need to alloca storage |
40 | 2679 } |
175
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2680 |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2681 // alloca storage if not found already |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2682 if (!dstMem) |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2683 { |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2684 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
|
2685 } |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2686 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
|
2687 |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2688 // store elements |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2689 for (size_t i=0; i<len; ++i) |
40 | 2690 { |
2691 Expression* expr = (Expression*)elements->data[i]; | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2692 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
|
2693 |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2694 // emulate assignment |
98
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
97
diff
changeset
|
2695 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
|
2696 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
|
2697 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
|
2698 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
|
2699 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
|
2700 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
|
2701 DtoAssign(vv, e); |
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
97
diff
changeset
|
2702 } |
40 | 2703 } |
2704 | |
175
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2705 // return storage directly ? |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2706 if (!dyn || (dyn && sliceInPlace)) |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2707 return new DImValue(type, dstMem, true); |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2708 // wrap in a slice |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2709 return new DSliceValue(type, DtoConstSize_t(len), DtoGEPi(dstMem,0,0,"tmp")); |
40 | 2710 } |
2711 | |
2712 ////////////////////////////////////////////////////////////////////////////////////////// | |
2713 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2714 LLConstant* ArrayLiteralExp::toConstElem(IRState* p) |
40 | 2715 { |
2716 Logger::print("ArrayLiteralExp::toConstElem: %s | %s\n", toChars(), type->toChars()); | |
2717 LOG_SCOPE; | |
2718 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2719 const LLType* t = DtoType(type); |
40 | 2720 Logger::cout() << "array literal has llvm type: " << *t << '\n'; |
96 | 2721 assert(isaArray(t)); |
2722 const llvm::ArrayType* arrtype = isaArray(t); | |
40 | 2723 |
2724 assert(arrtype->getNumElements() == elements->dim); | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2725 std::vector<LLConstant*> vals(elements->dim, NULL); |
40 | 2726 for (unsigned i=0; i<elements->dim; ++i) |
2727 { | |
2728 Expression* expr = (Expression*)elements->data[i]; | |
2729 vals[i] = expr->toConstElem(p); | |
2730 } | |
2731 | |
2732 return llvm::ConstantArray::get(arrtype, vals); | |
2733 } | |
2734 | |
2735 ////////////////////////////////////////////////////////////////////////////////////////// | |
2736 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2737 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
|
2738 { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2739 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
|
2740 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
|
2741 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2742 LLValue* sptr; |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2743 const LLType* llt = DtoType(type); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2744 |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2745 LLValue* mem = 0; |
215
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
2746 bool isinplace = true; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2747 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2748 // temporary struct literal |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2749 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
|
2750 { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2751 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
|
2752 isinplace = false; |
50
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
2753 } |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2754 // already has memory |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
2755 else |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2756 { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2757 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
|
2758 sptr = p->topexp()->v->getLVal(); |
50
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
2759 } |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2760 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2761 // num elements in literal |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2762 unsigned n = elements->dim; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2763 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2764 // 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
|
2765 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
|
2766 // build the type of the literal |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2767 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
|
2768 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
|
2769 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
|
2770 if (!vx) continue; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2771 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
|
2772 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2773 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
|
2774 if (t != llt) { |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2775 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
|
2776 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
|
2777 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
|
2778 } |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2779 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
|
2780 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
|
2781 } |
50
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
2782 } |
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
|
2783 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2784 // build |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2785 unsigned j = 0; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2786 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
|
2787 { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2788 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
|
2789 if (!vx) continue; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2790 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2791 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
|
2792 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
|
2793 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
|
2794 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2795 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
|
2796 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
|
2797 p->exps.pop_back(); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2798 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2799 if (!ve->inPlace()) |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2800 DtoAssign(darrptr, ve); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2801 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2802 j++; |
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 |
215
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
2805 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
|
2806 } |
e5c4bece7fa1
[svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents:
48
diff
changeset
|
2807 |
e5c4bece7fa1
[svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents:
48
diff
changeset
|
2808 ////////////////////////////////////////////////////////////////////////////////////////// |
e5c4bece7fa1
[svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents:
48
diff
changeset
|
2809 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2810 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
|
2811 { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2812 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
|
2813 LOG_SCOPE; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2814 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2815 unsigned n = elements->dim; |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2816 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
|
2817 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2818 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
|
2819 { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2820 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
|
2821 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
|
2822 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2823 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2824 assert(DtoDType(type)->ty == Tstruct); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2825 const LLType* t = DtoType(type); |
96 | 2826 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
|
2827 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
|
2828 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2829 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2830 ////////////////////////////////////////////////////////////////////////////////////////// |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2831 |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2832 DValue* InExp::toElem(IRState* p) |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2833 { |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2834 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
|
2835 LOG_SCOPE; |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2836 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2837 DValue* key = e1->toElem(p); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2838 DValue* aa = e2->toElem(p); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2839 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2840 return DtoAAIn(type, aa, key); |
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 |
127 | 2843 DValue* RemoveExp::toElem(IRState* p) |
2844 { | |
2845 Logger::print("RemoveExp::toElem: %s\n", toChars()); | |
2846 LOG_SCOPE; | |
2847 | |
2848 DValue* aa = e1->toElem(p); | |
2849 DValue* key = e2->toElem(p); | |
2850 | |
2851 DtoAARemove(aa, key); | |
2852 | |
2853 return NULL; // does not produce anything useful | |
2854 } | |
2855 | |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2856 ////////////////////////////////////////////////////////////////////////////////////////// |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2857 |
125 | 2858 DValue* AssocArrayLiteralExp::toElem(IRState* p) |
2859 { | |
2860 Logger::print("AssocArrayLiteralExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2861 LOG_SCOPE; | |
2862 | |
2863 assert(keys); | |
2864 assert(values); | |
2865 assert(keys->dim == values->dim); | |
2866 | |
127 | 2867 Type* aatype = DtoDType(type); |
2868 Type* vtype = aatype->next; | |
2869 | |
2870 DValue* aa; | |
2871 if (p->topexp() && p->topexp()->e2 == this) | |
2872 { | |
2873 aa = p->topexp()->v; | |
2874 } | |
2875 else | |
2876 { | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2877 LLValue* tmp = new llvm::AllocaInst(DtoType(type),"aaliteral",p->topallocapoint()); |
127 | 2878 aa = new DVarValue(type, tmp, true); |
2879 } | |
2880 | |
125 | 2881 const size_t n = keys->dim; |
2882 for (size_t i=0; i<n; ++i) | |
2883 { | |
2884 Expression* ekey = (Expression*)keys->data[i]; | |
2885 Expression* eval = (Expression*)values->data[i]; | |
2886 | |
2887 Logger::println("(%u) aa[%s] = %s", i, ekey->toChars(), eval->toChars()); | |
127 | 2888 |
2889 // index | |
2890 DValue* key = ekey->toElem(p); | |
2891 DValue* mem = DtoAAIndex(vtype, aa, key); | |
2892 | |
2893 // store | |
2894 DValue* val = eval->toElem(p); | |
2895 DtoAssign(mem, val); | |
125 | 2896 } |
2897 | |
127 | 2898 return aa; |
125 | 2899 } |
2900 | |
2901 ////////////////////////////////////////////////////////////////////////////////////////// | |
2902 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2903 #define STUB(x) DValue *x::toElem(IRState * p) {error("Exp type "#x" not implemented: %s", toChars()); fatal(); return 0; } |
1 | 2904 //STUB(IdentityExp); |
2905 //STUB(CondExp); | |
2906 //STUB(EqualExp); | |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2907 //STUB(InExp); |
1 | 2908 //STUB(CmpExp); |
2909 //STUB(AndAndExp); | |
2910 //STUB(OrOrExp); | |
2911 //STUB(AndExp); | |
2912 //STUB(AndAssignExp); | |
2913 //STUB(OrExp); | |
2914 //STUB(OrAssignExp); | |
2915 //STUB(XorExp); | |
2916 //STUB(XorAssignExp); | |
2917 //STUB(ShrExp); | |
2918 //STUB(ShrAssignExp); | |
2919 //STUB(ShlExp); | |
2920 //STUB(ShlAssignExp); | |
2921 //STUB(UshrExp); | |
2922 //STUB(UshrAssignExp); | |
2923 //STUB(DivExp); | |
2924 //STUB(DivAssignExp); | |
2925 //STUB(MulExp); | |
2926 //STUB(MulAssignExp); | |
2927 //STUB(ModExp); | |
2928 //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
|
2929 //STUB(CatExp); |
40 | 2930 //STUB(CatAssignExp); |
1 | 2931 //STUB(AddExp); |
2932 //STUB(AddAssignExp); | |
2933 STUB(Expression); | |
2934 //STUB(MinExp); | |
2935 //STUB(MinAssignExp); | |
2936 //STUB(PostExp); | |
2937 //STUB(NullExp); | |
2938 //STUB(ThisExp); | |
2939 //STUB(CallExp); | |
2940 STUB(DotTypeExp); | |
2941 STUB(TypeDotIdExp); | |
2942 //STUB(DotVarExp); | |
2943 //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
|
2944 //STUB(FuncExp); |
1 | 2945 //STUB(DelegateExp); |
2946 //STUB(VarExp); | |
2947 //STUB(DeclarationExp); | |
2948 //STUB(NewExp); | |
2949 //STUB(SymOffExp); | |
2950 STUB(ScopeExp); | |
2951 //STUB(AssignExp); | |
2952 | |
2953 STUB(TypeExp); | |
2954 //STUB(RealExp); | |
90 | 2955 //STUB(ComplexExp); |
1 | 2956 //STUB(StringExp); |
2957 //STUB(IntegerExp); | |
2958 STUB(BoolExp); | |
2959 | |
2960 //STUB(NotExp); | |
2961 //STUB(ComExp); | |
23 | 2962 //STUB(NegExp); |
1 | 2963 //STUB(PtrExp); |
2964 //STUB(AddrExp); | |
2965 //STUB(SliceExp); | |
2966 //STUB(CastExp); | |
2967 //STUB(DeleteExp); | |
2968 //STUB(IndexExp); | |
2969 //STUB(CommaExp); | |
2970 //STUB(ArrayLengthExp); | |
2971 //STUB(HaltExp); | |
127 | 2972 //STUB(RemoveExp); |
40 | 2973 //STUB(ArrayLiteralExp); |
125 | 2974 //STUB(AssocArrayLiteralExp); |
1 | 2975 //STUB(StructLiteralExp); |
92 | 2976 STUB(TupleExp); |
1 | 2977 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2978 #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 | 2979 CONSTSTUB(Expression); |
2980 //CONSTSTUB(IntegerExp); | |
2981 //CONSTSTUB(RealExp); | |
2982 //CONSTSTUB(NullExp); | |
90 | 2983 //CONSTSTUB(ComplexExp); |
40 | 2984 //CONSTSTUB(StringExp); |
2985 //CONSTSTUB(VarExp); | |
2986 //CONSTSTUB(ArrayLiteralExp); | |
2987 CONSTSTUB(AssocArrayLiteralExp); | |
2988 //CONSTSTUB(StructLiteralExp); | |
2989 | |
1 | 2990 unsigned Type::totym() { return 0; } |
2991 | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2992 type * Type::toCtype() |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2993 { |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2994 assert(0); |
1 | 2995 return 0; |
2996 } | |
2997 | |
2998 type * Type::toCParamtype() | |
2999 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3000 assert(0); |
1 | 3001 return 0; |
3002 } | |
3003 Symbol * Type::toSymbol() | |
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 | |
3009 type * | |
3010 TypeTypedef::toCtype() | |
3011 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3012 assert(0); |
1 | 3013 return 0; |
3014 } | |
3015 | |
3016 type * | |
3017 TypeTypedef::toCParamtype() | |
3018 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3019 assert(0); |
1 | 3020 return 0; |
3021 } | |
3022 | |
3023 void | |
3024 TypedefDeclaration::toDebug() | |
3025 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3026 assert(0); |
1 | 3027 } |
3028 | |
3029 | |
3030 type * | |
3031 TypeEnum::toCtype() | |
3032 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3033 assert(0); |
1 | 3034 return 0; |
3035 } | |
3036 | |
3037 type * | |
3038 TypeStruct::toCtype() | |
3039 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3040 assert(0); |
1 | 3041 return 0; |
3042 } | |
3043 | |
3044 void | |
3045 StructDeclaration::toDebug() | |
3046 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3047 assert(0); |
1 | 3048 } |
3049 | |
3050 Symbol * TypeClass::toSymbol() | |
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 return 0; |
3054 } | |
3055 | |
3056 unsigned TypeFunction::totym() | |
3057 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3058 assert(0); |
1 | 3059 return 0; |
3060 } | |
3061 | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3062 type * TypeFunction::toCtype() |
1 | 3063 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3064 assert(0); |
1 | 3065 return 0; |
3066 } | |
3067 | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3068 type * TypeSArray::toCtype() |
1 | 3069 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3070 assert(0); |
1 | 3071 return 0; |
3072 } | |
3073 | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3074 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
|
3075 { |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3076 assert(0); |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3077 return 0; |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3078 } |
1 | 3079 |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3080 type * TypeDArray::toCtype() |
1 | 3081 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3082 assert(0); |
1 | 3083 return 0; |
3084 } | |
3085 | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3086 type * TypeAArray::toCtype() |
1 | 3087 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3088 assert(0); |
1 | 3089 return 0; |
3090 } | |
3091 | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3092 type * TypePointer::toCtype() |
1 | 3093 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3094 assert(0); |
1 | 3095 return 0; |
3096 } | |
3097 | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3098 type * TypeDelegate::toCtype() |
1 | 3099 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3100 assert(0); |
1 | 3101 return 0; |
3102 } | |
3103 | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3104 type * TypeClass::toCtype() |
1 | 3105 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3106 assert(0); |
1 | 3107 return 0; |
3108 } | |
3109 | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3110 void ClassDeclaration::toDebug() |
1 | 3111 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3112 assert(0); |
1 | 3113 } |
3114 | |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
11
diff
changeset
|
3115 ////////////////////////////////////////////////////////////////////////////// |
1 | 3116 |
3117 void | |
3118 EnumDeclaration::toDebug() | |
3119 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3120 assert(0); |
1 | 3121 } |
3122 | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3123 int Dsymbol::cvMember(unsigned char*) |
1 | 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 return 0; |
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 EnumDeclaration::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 FuncDeclaration::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 VarDeclaration::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 TypedefDeclaration::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 } | |
3148 | |
3149 void obj_includelib(char*){} | |
3150 | |
219
761c8352f494
[svn r235] rough port of GDC's inline assembler code, unfinished
ChristianK
parents:
218
diff
changeset
|
3151 /* this has moved to asmstmt.cpp |
1 | 3152 AsmStatement::AsmStatement(Loc loc, Token *tokens) : |
3153 Statement(loc) | |
3154 { | |
131 | 3155 this->tokens = tokens; |
1 | 3156 } |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3157 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
|
3158 { |
219
761c8352f494
[svn r235] rough port of GDC's inline assembler code, unfinished
ChristianK
parents:
218
diff
changeset
|
3159 //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
|
3160 //fatal(); |
761c8352f494
[svn r235] rough port of GDC's inline assembler code, unfinished
ChristianK
parents:
218
diff
changeset
|
3161 //assert(0); |
1 | 3162 return 0; |
3163 } | |
3164 | |
3165 Statement *AsmStatement::semantic(Scope *sc) | |
3166 { | |
3167 return Statement::semantic(sc); | |
3168 } | |
3169 | |
3170 | |
3171 void AsmStatement::toCBuffer(OutBuffer *buf, HdrGenState *hgs) | |
3172 { | |
3173 Statement::toCBuffer(buf, hgs); | |
3174 } | |
3175 | |
3176 int AsmStatement::comeFrom() | |
3177 { | |
219
761c8352f494
[svn r235] rough port of GDC's inline assembler code, unfinished
ChristianK
parents:
218
diff
changeset
|
3178 //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
|
3179 //fatal(); |
761c8352f494
[svn r235] rough port of GDC's inline assembler code, unfinished
ChristianK
parents:
218
diff
changeset
|
3180 //assert(0); |
96 | 3181 return 0; |
1 | 3182 } |
219
761c8352f494
[svn r235] rough port of GDC's inline assembler code, unfinished
ChristianK
parents:
218
diff
changeset
|
3183 */ |
1 | 3184 |
3185 void | |
3186 backend_init() | |
3187 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
3188 // now lazily loaded |
1 | 3189 //LLVM_D_InitRuntime(); |
3190 } | |
3191 | |
3192 void | |
3193 backend_term() | |
3194 { | |
3195 LLVM_D_FreeRuntime(); | |
3196 } |