Mercurial > projects > ldc
annotate gen/toir.cpp @ 637:29dc68c949b0
Applied the FreeBSD patch from Ralith, closes ticket #95 , slightly changed but basically the same. Thanx Ralith :)
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Thu, 02 Oct 2008 03:25:46 +0200 |
parents | 0084d2c76b74 |
children | 2a0bcf7f7b3d |
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" | |
321 | 21 #include "template.h" |
1 | 22 #include "hdrgen.h" |
23 #include "port.h" | |
594
e096a1502428
Fix #88 : pragma(lib, "str") is now converted to -lstr in the linker command line.
Christian Kamm <kamm incasoftware de>
parents:
592
diff
changeset
|
24 #include "mem.h" |
4
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
25 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
26 #include "gen/irstate.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
27 #include "gen/logger.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
28 #include "gen/tollvm.h" |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
29 #include "gen/llvmhelpers.h" |
4
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
30 #include "gen/runtime.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
31 #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
|
32 #include "gen/structs.h" |
100 | 33 #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
|
34 #include "gen/typeinf.h" |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
35 #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
|
36 #include "gen/dvalue.h" |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
37 #include "gen/aa.h" |
131 | 38 #include "gen/functions.h" |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
39 #include "gen/todebug.h" |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
40 |
1 | 41 ////////////////////////////////////////////////////////////////////////////////////////// |
42 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
43 DValue* DeclarationExp::toElem(IRState* p) |
1 | 44 { |
45 Logger::print("DeclarationExp::toElem: %s | T=%s\n", toChars(), type->toChars()); | |
46 LOG_SCOPE; | |
47 | |
433
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
426
diff
changeset
|
48 return DtoDeclarationExp(declaration); |
1 | 49 } |
50 | |
51 ////////////////////////////////////////////////////////////////////////////////////////// | |
52 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
53 DValue* VarExp::toElem(IRState* p) |
1 | 54 { |
55 Logger::print("VarExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
56 LOG_SCOPE; | |
57 | |
58 assert(var); | |
59 if (VarDeclaration* vd = var->isVarDeclaration()) | |
60 { | |
57
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
55
diff
changeset
|
61 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
|
62 |
57
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
55
diff
changeset
|
63 // _arguments |
464
e381e082d5cb
Fixed problem with using the variable names _arguments and _argptr in non D-style vararg functions.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
460
diff
changeset
|
64 if (vd->ident == Id::_arguments && p->func()->_arguments) |
57
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
55
diff
changeset
|
65 { |
72 | 66 Logger::println("Id::_arguments"); |
363 | 67 LLValue* v = p->func()->_arguments; |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
68 return new DVarValue(type, vd, v); |
57
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
55
diff
changeset
|
69 } |
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
55
diff
changeset
|
70 // _argptr |
464
e381e082d5cb
Fixed problem with using the variable names _arguments and _argptr in non D-style vararg functions.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
460
diff
changeset
|
71 else if (vd->ident == Id::_argptr && p->func()->_argptr) |
57
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
55
diff
changeset
|
72 { |
72 | 73 Logger::println("Id::_argptr"); |
363 | 74 LLValue* v = p->func()->_argptr; |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
75 return new DVarValue(type, vd, v); |
57
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
55
diff
changeset
|
76 } |
67
f918f3e2e99e
[svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents:
66
diff
changeset
|
77 // _dollar |
f918f3e2e99e
[svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents:
66
diff
changeset
|
78 else if (vd->ident == Id::dollar) |
f918f3e2e99e
[svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents:
66
diff
changeset
|
79 { |
72 | 80 Logger::println("Id::dollar"); |
67
f918f3e2e99e
[svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents:
66
diff
changeset
|
81 assert(!p->arrays.empty()); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
82 LLValue* tmp = DtoArrayLen(p->arrays.back()); |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
83 return new DImValue(type, tmp); |
67
f918f3e2e99e
[svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents:
66
diff
changeset
|
84 } |
f918f3e2e99e
[svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents:
66
diff
changeset
|
85 // typeinfo |
f918f3e2e99e
[svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents:
66
diff
changeset
|
86 else if (TypeInfoDeclaration* tid = vd->isTypeInfoDeclaration()) |
1 | 87 { |
88 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
|
89 DtoForceDeclareDsymbol(tid); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
90 assert(tid->ir.getIrValue()); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
91 const LLType* vartype = DtoType(type); |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
92 LLValue* m = tid->ir.getIrValue(); |
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
93 if (m->getType() != getPtrToType(vartype)) |
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
94 m = p->ir->CreateBitCast(m, vartype, "tmp"); |
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
95 return new DImValue(type, m); |
1 | 96 } |
100 | 97 // classinfo |
98 else if (ClassInfoDeclaration* cid = vd->isClassInfoDeclaration()) | |
99 { | |
100 Logger::println("ClassInfoDeclaration: %s", cid->cd->toChars()); | |
367
519adb3128b1
[svn r388] ClassInfo declaration could fail if base classdecl hadn't been resolved.
ChristianK
parents:
365
diff
changeset
|
101 DtoForceDeclareDsymbol(cid->cd); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
102 assert(cid->cd->ir.irStruct->classInfo); |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
103 return new DVarValue(type, vd, cid->cd->ir.irStruct->classInfo); |
100 | 104 } |
67
f918f3e2e99e
[svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents:
66
diff
changeset
|
105 // nested variable |
f918f3e2e99e
[svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents:
66
diff
changeset
|
106 else if (vd->nestedref) { |
72 | 107 Logger::println("nested variable"); |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
108 return DtoNestedVariable(loc, type, vd); |
1 | 109 } |
110 // function parameter | |
67
f918f3e2e99e
[svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents:
66
diff
changeset
|
111 else if (vd->isParameter()) { |
1 | 112 Logger::println("function param"); |
339
385a18242485
[svn r360] Another mostly rewrite of DtoArrayInit. Should be much more robust now, and probably faster code generated for the most common cases too!
lindquist
parents:
336
diff
changeset
|
113 FuncDeclaration* fd = vd->toParent2()->isFuncDeclaration(); |
385a18242485
[svn r360] Another mostly rewrite of DtoArrayInit. Should be much more robust now, and probably faster code generated for the most common cases too!
lindquist
parents:
336
diff
changeset
|
114 if (fd && fd != p->func()->decl) { |
385a18242485
[svn r360] Another mostly rewrite of DtoArrayInit. Should be much more robust now, and probably faster code generated for the most common cases too!
lindquist
parents:
336
diff
changeset
|
115 Logger::println("nested parameter"); |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
116 return DtoNestedVariable(loc, type, vd); |
339
385a18242485
[svn r360] Another mostly rewrite of DtoArrayInit. Should be much more robust now, and probably faster code generated for the most common cases too!
lindquist
parents:
336
diff
changeset
|
117 } |
385a18242485
[svn r360] Another mostly rewrite of DtoArrayInit. Should be much more robust now, and probably faster code generated for the most common cases too!
lindquist
parents:
336
diff
changeset
|
118 else if (vd->isRef() || vd->isOut() || DtoIsPassedByRef(vd->type) || llvm::isa<llvm::AllocaInst>(vd->ir.getIrValue())) { |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
119 return new DVarValue(type, vd, vd->ir.getIrValue()); |
1 | 120 } |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
121 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
|
122 return new DImValue(type, vd->ir.getIrValue()); |
1 | 123 } |
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
|
124 else assert(0); |
1 | 125 } |
126 else { | |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
127 Logger::println("a normal variable"); |
67
f918f3e2e99e
[svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents:
66
diff
changeset
|
128 // take care of forward references of global variables |
100 | 129 if (vd->isDataseg() || (vd->storage_class & STCextern)) { |
336 | 130 vd->toObjFile(0); // TODO: multiobj |
100 | 131 } |
553
d19e29194c13
Do not assert on non-existing supposed globals. (see nocompile/union_12,14)
Christian Kamm <kamm incasoftware de>
parents:
530
diff
changeset
|
132 if (!vd->ir.isSet() || !vd->ir.getIrValue() || DtoType(vd->type)->isAbstract()) { |
397
9ec89aad9dbc
Make an unresolved global into an error instead of an assert.
Christian Kamm <kamm incasoftware de>
parents:
384
diff
changeset
|
133 error("global variable %s not resolved", vd->toChars()); |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
619
diff
changeset
|
134 if (Logger::enabled()) |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
619
diff
changeset
|
135 Logger::cout() << "unresolved global had type: " << *DtoType(vd->type) << '\n'; |
397
9ec89aad9dbc
Make an unresolved global into an error instead of an assert.
Christian Kamm <kamm incasoftware de>
parents:
384
diff
changeset
|
136 fatal(); |
88
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
137 } |
628
e3c46bcce65f
Detect a missing global before trying to const init it.
Christian Kamm <kamm incasoftware de>
parents:
624
diff
changeset
|
138 if (vd->isDataseg() || (vd->storage_class & STCextern)) { |
e3c46bcce65f
Detect a missing global before trying to const init it.
Christian Kamm <kamm incasoftware de>
parents:
624
diff
changeset
|
139 DtoConstInitGlobal(vd); |
e3c46bcce65f
Detect a missing global before trying to const init it.
Christian Kamm <kamm incasoftware de>
parents:
624
diff
changeset
|
140 } |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
141 return new DVarValue(type, vd, vd->ir.getIrValue()); |
1 | 142 } |
143 } | |
144 else if (FuncDeclaration* fdecl = var->isFuncDeclaration()) | |
145 { | |
146 Logger::println("FuncDeclaration"); | |
384
3f98d46e05a4
Fixed segfault when using va_arg.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
379
diff
changeset
|
147 LLValue* func = 0; |
3f98d46e05a4
Fixed segfault when using va_arg.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
379
diff
changeset
|
148 if (fdecl->llvmInternal != LLVMva_arg) { |
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
|
149 DtoForceDeclareDsymbol(fdecl); |
384
3f98d46e05a4
Fixed segfault when using va_arg.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
379
diff
changeset
|
150 func = fdecl->ir.irFunc->func; |
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
|
151 } |
384
3f98d46e05a4
Fixed segfault when using va_arg.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
379
diff
changeset
|
152 return new DFuncValue(fdecl, func); |
1 | 153 } |
154 else if (SymbolDeclaration* sdecl = var->isSymbolDeclaration()) | |
155 { | |
156 // this seems to be the static initialiser for structs | |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
157 Type* sdecltype = sdecl->type->toBasetype(); |
40 | 158 Logger::print("Sym: type=%s\n", sdecltype->toChars()); |
159 assert(sdecltype->ty == Tstruct); | |
160 TypeStruct* ts = (TypeStruct*)sdecltype; | |
121
9c79b61fb638
[svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents:
120
diff
changeset
|
161 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
|
162 DtoForceConstInitDsymbol(ts->sym); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
163 assert(ts->sym->ir.irStruct->init); |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
164 return new DVarValue(type, ts->sym->ir.irStruct->init); |
1 | 165 } |
166 else | |
167 { | |
168 assert(0 && "Unimplemented VarExp type"); | |
169 } | |
170 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
171 return 0; |
1 | 172 } |
173 | |
174 ////////////////////////////////////////////////////////////////////////////////////////// | |
175 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
176 LLConstant* VarExp::toConstElem(IRState* p) |
40 | 177 { |
178 Logger::print("VarExp::toConstElem: %s | %s\n", toChars(), type->toChars()); | |
179 LOG_SCOPE; | |
180 if (SymbolDeclaration* sdecl = var->isSymbolDeclaration()) | |
181 { | |
182 // this seems to be the static initialiser for structs | |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
183 Type* sdecltype = sdecl->type->toBasetype(); |
40 | 184 Logger::print("Sym: type=%s\n", sdecltype->toChars()); |
185 assert(sdecltype->ty == Tstruct); | |
186 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
|
187 DtoForceConstInitDsymbol(ts->sym); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
188 assert(ts->sym->ir.irStruct->constInit); |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
189 return ts->sym->ir.irStruct->constInit; |
40 | 190 } |
132 | 191 else if (TypeInfoDeclaration* ti = var->isTypeInfoDeclaration()) |
192 { | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
193 const LLType* vartype = DtoType(type); |
275
665b81613475
[svn r296] Removed: the 'suite' dir, it never took off!
lindquist
parents:
268
diff
changeset
|
194 LLConstant* m = DtoTypeInfoOf(ti->tinfo, false); |
665b81613475
[svn r296] Removed: the 'suite' dir, it never took off!
lindquist
parents:
268
diff
changeset
|
195 if (m->getType() != getPtrToType(vartype)) |
132 | 196 m = llvm::ConstantExpr::getBitCast(m, vartype); |
197 return m; | |
198 } | |
199 assert(0 && "Unsupported const VarExp kind"); | |
40 | 200 return NULL; |
201 } | |
202 | |
203 ////////////////////////////////////////////////////////////////////////////////////////// | |
204 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
205 DValue* IntegerExp::toElem(IRState* p) |
1 | 206 { |
207 Logger::print("IntegerExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
208 LOG_SCOPE; | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
209 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
|
210 return new DConstValue(type, c); |
40 | 211 } |
212 | |
213 ////////////////////////////////////////////////////////////////////////////////////////// | |
214 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
215 LLConstant* IntegerExp::toConstElem(IRState* p) |
40 | 216 { |
217 Logger::print("IntegerExp::toConstElem: %s | %s\n", toChars(), type->toChars()); | |
218 LOG_SCOPE; | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
219 const LLType* t = DtoType(type); |
96 | 220 if (isaPointer(t)) { |
88
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
221 Logger::println("pointer"); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
222 LLConstant* i = llvm::ConstantInt::get(DtoSize_t(),(uint64_t)value,false); |
40 | 223 return llvm::ConstantExpr::getIntToPtr(i, t); |
1 | 224 } |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
225 assert(llvm::isa<LLIntegerType>(t)); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
226 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
|
227 assert(c); |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
619
diff
changeset
|
228 if (Logger::enabled()) |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
619
diff
changeset
|
229 Logger::cout() << "value = " << *c << '\n'; |
88
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
230 return c; |
1 | 231 } |
232 | |
233 ////////////////////////////////////////////////////////////////////////////////////////// | |
234 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
235 DValue* RealExp::toElem(IRState* p) |
1 | 236 { |
237 Logger::print("RealExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
238 LOG_SCOPE; | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
239 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
|
240 return new DConstValue(type, c); |
40 | 241 } |
242 | |
243 ////////////////////////////////////////////////////////////////////////////////////////// | |
244 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
245 LLConstant* RealExp::toConstElem(IRState* p) |
40 | 246 { |
247 Logger::print("RealExp::toConstElem: %s | %s\n", toChars(), type->toChars()); | |
248 LOG_SCOPE; | |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
249 Type* t = type->toBasetype(); |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
250 return DtoConstFP(t, value); |
1 | 251 } |
252 | |
253 ////////////////////////////////////////////////////////////////////////////////////////// | |
254 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
255 DValue* NullExp::toElem(IRState* p) |
1 | 256 { |
257 Logger::print("NullExp::toElem(type=%s): %s\n", type->toChars(),toChars()); | |
258 LOG_SCOPE; | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
259 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
|
260 return new DNullValue(type, c); |
40 | 261 } |
262 | |
263 ////////////////////////////////////////////////////////////////////////////////////////// | |
264 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
265 LLConstant* NullExp::toConstElem(IRState* p) |
40 | 266 { |
267 Logger::print("NullExp::toConstElem(type=%s): %s\n", type->toChars(),toChars()); | |
268 LOG_SCOPE; | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
269 const LLType* t = DtoType(type); |
28
1c80c18f3c82
[svn r32] * Fixed problems with arrays members of aggregates
lindquist
parents:
27
diff
changeset
|
270 if (type->ty == Tarray) { |
96 | 271 assert(isaStruct(t)); |
40 | 272 return llvm::ConstantAggregateZero::get(t); |
28
1c80c18f3c82
[svn r32] * Fixed problems with arrays members of aggregates
lindquist
parents:
27
diff
changeset
|
273 } |
40 | 274 else { |
275 return llvm::Constant::getNullValue(t); | |
276 } | |
277 assert(0); | |
278 return NULL; | |
1 | 279 } |
280 | |
281 ////////////////////////////////////////////////////////////////////////////////////////// | |
282 | |
90 | 283 DValue* ComplexExp::toElem(IRState* p) |
284 { | |
285 Logger::print("ComplexExp::toElem(): %s | %s\n", toChars(), type->toChars()); | |
286 LOG_SCOPE; | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
287 LLConstant* c = toConstElem(p); |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
288 LLValue* res; |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
289 |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
290 if (c->isNullValue()) { |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
291 Type* t = type->toBasetype(); |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
292 if (t->ty == Tcomplex32) |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
293 c = DtoConstFP(Type::tfloat32, 0); |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
294 else if (t->ty == Tcomplex64) |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
295 c = DtoConstFP(Type::tfloat64, 0); |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
296 else if (t->ty == Tcomplex80) |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
297 c = DtoConstFP(Type::tfloat80, 0); |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
298 else |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
299 assert(0); |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
300 res = DtoAggrPair(DtoType(type), c, c); |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
301 } |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
302 else { |
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
303 res = DtoAggrPair(DtoType(type), c->getOperand(0), c->getOperand(1)); |
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
304 } |
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
305 |
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
306 return new DImValue(type, res); |
90 | 307 } |
308 | |
309 ////////////////////////////////////////////////////////////////////////////////////////// | |
310 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
311 LLConstant* ComplexExp::toConstElem(IRState* p) |
90 | 312 { |
313 Logger::print("ComplexExp::toConstElem(): %s | %s\n", toChars(), type->toChars()); | |
314 LOG_SCOPE; | |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
315 return DtoConstComplex(type, value.re, value.im); |
90 | 316 } |
317 | |
318 ////////////////////////////////////////////////////////////////////////////////////////// | |
319 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
320 DValue* StringExp::toElem(IRState* p) |
1 | 321 { |
52 | 322 Logger::print("StringExp::toElem: %s | %s\n", toChars(), type->toChars()); |
1 | 323 LOG_SCOPE; |
324 | |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
325 Type* dtype = type->toBasetype(); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
326 Type* cty = dtype->next->toBasetype(); |
1 | 327 |
328
7086a84ab3d6
[svn r349] Fixed problems with static arrays of void as well as a static arrays with zero length.
lindquist
parents:
321
diff
changeset
|
328 const LLType* ct = DtoTypeNotVoid(cty); |
1 | 329 //printf("ct = %s\n", type->next->toChars()); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
330 const LLArrayType* at = LLArrayType::get(ct,len+1); |
1 | 331 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
332 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
|
333 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
|
334 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
|
335 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
|
336 _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
|
337 } |
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
|
338 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
|
339 uint16_t* str = (uint16_t*)string; |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
340 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
|
341 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
|
342 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
|
343 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
344 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
|
345 _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
|
346 } |
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
|
347 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
|
348 uint32_t* str = (uint32_t*)string; |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
349 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
|
350 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
|
351 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
|
352 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
353 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
|
354 _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
|
355 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
356 else |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
357 assert(0); |
1 | 358 |
359 llvm::GlobalValue::LinkageTypes _linkage = llvm::GlobalValue::InternalLinkage;//WeakLinkage; | |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
619
diff
changeset
|
360 if (Logger::enabled()) |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
619
diff
changeset
|
361 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
|
362 llvm::GlobalVariable* gvar = new llvm::GlobalVariable(at,true,_linkage,_init,".stringliteral",gIR->module); |
1 | 363 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
364 llvm::ConstantInt* zero = llvm::ConstantInt::get(LLType::Int32Ty, 0, false); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
365 LLConstant* idxs[2] = { zero, zero }; |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
366 LLConstant* arrptr = llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2); |
1 | 367 |
40 | 368 if (dtype->ty == Tarray) { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
369 LLConstant* clen = llvm::ConstantInt::get(DtoSize_t(),len,false); |
479
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
469
diff
changeset
|
370 LLValue* tmpmem = DtoAlloca(DtoType(dtype),"tempstring"); |
334 | 371 DtoSetArray(tmpmem, clen, arrptr); |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
372 return new DVarValue(type, tmpmem); |
1 | 373 } |
40 | 374 else if (dtype->ty == Tsarray) { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
375 const LLType* dstType = getPtrToType(LLArrayType::get(ct, len)); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
376 LLValue* emem = (gvar->getType() == dstType) ? gvar : DtoBitCast(gvar, dstType); |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
377 return new DVarValue(type, emem); |
21
8d45266bbabe
[svn r25] * Fixed a lot of problems with string literals
lindquist
parents:
18
diff
changeset
|
378 } |
40 | 379 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
|
380 return new DImValue(type, arrptr); |
1 | 381 } |
382 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
383 assert(0); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
384 return 0; |
1 | 385 } |
386 | |
387 ////////////////////////////////////////////////////////////////////////////////////////// | |
388 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
389 LLConstant* StringExp::toConstElem(IRState* p) |
40 | 390 { |
391 Logger::print("StringExp::toConstElem: %s | %s\n", toChars(), type->toChars()); | |
392 LOG_SCOPE; | |
393 | |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
394 Type* t = type->toBasetype(); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
395 Type* cty = t->next->toBasetype(); |
176
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
396 |
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
397 bool nullterm = (t->ty != Tsarray); |
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
398 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
|
399 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
400 const LLType* ct = DtoType(cty); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
401 const LLArrayType* at = LLArrayType::get(ct,endlen); |
176
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
402 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
403 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
|
404 if (cty->size() == 1) { |
176
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
405 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
|
406 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
|
407 _init = llvm::ConstantArray::get(cont, nullterm); |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
408 } |
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
|
409 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
|
410 uint16_t* str = (uint16_t*)string; |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
411 std::vector<LLConstant*> vals; |
176
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
412 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
|
413 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
|
414 } |
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
415 if (nullterm) |
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
416 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
|
417 _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
|
418 } |
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 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
|
420 uint32_t* str = (uint32_t*)string; |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
421 std::vector<LLConstant*> vals; |
176
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
422 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
|
423 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
|
424 } |
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
425 if (nullterm) |
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
426 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
|
427 _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
|
428 } |
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
429 else |
a074a5ff709c
[svn r192] Fixed: String literals as constant expression was broken for utf16/32.
lindquist
parents:
175
diff
changeset
|
430 assert(0); |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
431 |
178
8873b7f1457e
[svn r194] Fixed: string literal constant expressions with static array type was broken.
lindquist
parents:
177
diff
changeset
|
432 if (t->ty == Tsarray) |
8873b7f1457e
[svn r194] Fixed: string literal constant expressions with static array type was broken.
lindquist
parents:
177
diff
changeset
|
433 { |
8873b7f1457e
[svn r194] Fixed: string literal constant expressions with static array type was broken.
lindquist
parents:
177
diff
changeset
|
434 return _init; |
8873b7f1457e
[svn r194] Fixed: string literal constant expressions with static array type was broken.
lindquist
parents:
177
diff
changeset
|
435 } |
8873b7f1457e
[svn r194] Fixed: string literal constant expressions with static array type was broken.
lindquist
parents:
177
diff
changeset
|
436 |
40 | 437 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
|
438 llvm::GlobalVariable* gvar = new llvm::GlobalVariable(_init->getType(),true,_linkage,_init,".stringliteral",gIR->module); |
40 | 439 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
440 llvm::ConstantInt* zero = llvm::ConstantInt::get(LLType::Int32Ty, 0, false); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
441 LLConstant* idxs[2] = { zero, zero }; |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
442 LLConstant* arrptr = llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2); |
40 | 443 |
444 if (t->ty == Tpointer) { | |
445 return arrptr; | |
446 } | |
178
8873b7f1457e
[svn r194] Fixed: string literal constant expressions with static array type was broken.
lindquist
parents:
177
diff
changeset
|
447 else if (t->ty == Tarray) { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
448 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
|
449 return DtoConstSlice(clen, arrptr); |
40 | 450 } |
451 | |
452 assert(0); | |
453 return NULL; | |
454 } | |
455 | |
456 ////////////////////////////////////////////////////////////////////////////////////////// | |
457 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
458 DValue* AssignExp::toElem(IRState* p) |
1 | 459 { |
467
261b05cf4d1c
Fixed problem in AssignExp where the result value might be uninitialized. see mini/assign1.d
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
464
diff
changeset
|
460 Logger::print("AssignExp::toElem: %s | (%s)(%s = %s)\n", toChars(), type->toChars(), e1->type->toChars(), e2->type ? e2->type->toChars() : 0); |
1 | 461 LOG_SCOPE; |
462 | |
335
17b844102023
[svn r356] Fixed problem with array length assignment introduced in [355]
lindquist
parents:
334
diff
changeset
|
463 if (e1->op == TOKarraylength) |
17b844102023
[svn r356] Fixed problem with array length assignment introduced in [355]
lindquist
parents:
334
diff
changeset
|
464 { |
17b844102023
[svn r356] Fixed problem with array length assignment introduced in [355]
lindquist
parents:
334
diff
changeset
|
465 Logger::println("performing array.length assignment"); |
17b844102023
[svn r356] Fixed problem with array length assignment introduced in [355]
lindquist
parents:
334
diff
changeset
|
466 ArrayLengthExp *ale = (ArrayLengthExp *)e1; |
17b844102023
[svn r356] Fixed problem with array length assignment introduced in [355]
lindquist
parents:
334
diff
changeset
|
467 DValue* arr = ale->e1->toElem(p); |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
468 DVarValue arrval(ale->e1->type, arr->getLVal()); |
335
17b844102023
[svn r356] Fixed problem with array length assignment introduced in [355]
lindquist
parents:
334
diff
changeset
|
469 DValue* newlen = e2->toElem(p); |
17b844102023
[svn r356] Fixed problem with array length assignment introduced in [355]
lindquist
parents:
334
diff
changeset
|
470 DSliceValue* slice = DtoResizeDynArray(arrval.getType(), &arrval, newlen); |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
471 DtoAssign(loc, &arrval, slice); |
335
17b844102023
[svn r356] Fixed problem with array length assignment introduced in [355]
lindquist
parents:
334
diff
changeset
|
472 return newlen; |
17b844102023
[svn r356] Fixed problem with array length assignment introduced in [355]
lindquist
parents:
334
diff
changeset
|
473 } |
17b844102023
[svn r356] Fixed problem with array length assignment introduced in [355]
lindquist
parents:
334
diff
changeset
|
474 |
17b844102023
[svn r356] Fixed problem with array length assignment introduced in [355]
lindquist
parents:
334
diff
changeset
|
475 Logger::println("performing normal assignment"); |
17b844102023
[svn r356] Fixed problem with array length assignment introduced in [355]
lindquist
parents:
334
diff
changeset
|
476 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
477 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
|
478 DValue* r = e2->toElem(p); |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
479 DtoAssign(loc, l, r); |
92 | 480 |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
481 if (l->isSlice()) |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
482 return l; |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
483 |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
484 #if 0 |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
485 if (type->toBasetype()->ty == Tstruct && e2->type->isintegral()) |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
486 { |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
487 // handle struct = 0; |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
488 return l; |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
489 } |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
490 else |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
491 { |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
492 return r; |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
493 } |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
494 #else |
468
45a67b6f1310
Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
467
diff
changeset
|
495 return r; |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
496 #endif |
1 | 497 } |
498 | |
499 ////////////////////////////////////////////////////////////////////////////////////////// | |
500 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
501 DValue* AddExp::toElem(IRState* p) |
1 | 502 { |
23 | 503 Logger::print("AddExp::toElem: %s | %s\n", toChars(), type->toChars()); |
1 | 504 LOG_SCOPE; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
505 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
506 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
|
507 DValue* r = e2->toElem(p); |
1 | 508 |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
509 Type* t = type->toBasetype(); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
510 Type* e1type = e1->type->toBasetype(); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
511 Type* e1next = e1type->next ? e1type->next->toBasetype() : NULL; |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
512 Type* e2type = e2->type->toBasetype(); |
40 | 513 |
514 if (e1type != e2type) { | |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
515 /*if (llvmFieldIndex) { |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
516 assert(e1type->ty == Tpointer && e1next && e1next->ty == Tstruct); |
92 | 517 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
|
518 assert(r->isConst()); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
519 llvm::ConstantInt* cofs = llvm::cast<llvm::ConstantInt>(r->isConst()->c); |
1 | 520 |
92 | 521 TypeStruct* ts = (TypeStruct*)e1next; |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
522 DStructIndexVector offsets; |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
523 LLValue* v = DtoIndexStruct(l->getRVal(), ts->sym, t->next, cofs->getZExtValue(), offsets); |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
524 return new DFieldValue(type, v); |
1 | 525 } |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
526 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
|
527 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
|
528 if (r->isConst()) { |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
529 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
|
530 if (cofs->isZero()) { |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
531 Logger::println("is zero"); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
532 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
|
533 } |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
534 } |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
535 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
|
536 return new DImValue(type, v); |
1 | 537 } |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
538 else if (t->iscomplex()) { |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
539 return DtoComplexAdd(loc, type, l, r); |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
540 } |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
541 assert(0); |
1 | 542 } |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
543 else if (t->iscomplex()) { |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
544 return DtoComplexAdd(loc, type, l, r); |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
545 } |
1 | 546 else { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
547 return DtoBinAdd(l,r); |
1 | 548 } |
549 } | |
550 | |
551 ////////////////////////////////////////////////////////////////////////////////////////// | |
552 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
553 DValue* AddAssignExp::toElem(IRState* p) |
1 | 554 { |
555 Logger::print("AddAssignExp::toElem: %s\n", toChars()); | |
556 LOG_SCOPE; | |
557 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
558 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
|
559 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
|
560 |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
561 Type* t = type->toBasetype(); |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
562 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
563 DValue* res; |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
564 if (e1->type->toBasetype()->ty == Tpointer) { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
565 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
|
566 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
|
567 } |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
568 else if (t->iscomplex()) { |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
569 res = DtoComplexAdd(loc, e1->type, l, r); |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
570 } |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
571 else { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
572 res = DtoBinAdd(l,r); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
573 } |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
574 DtoAssign(loc, l, res); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
575 |
334 | 576 return res; |
1 | 577 } |
578 | |
579 ////////////////////////////////////////////////////////////////////////////////////////// | |
580 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
581 DValue* MinExp::toElem(IRState* p) |
1 | 582 { |
583 Logger::print("MinExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
584 LOG_SCOPE; | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
585 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
586 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
|
587 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
|
588 |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
589 Type* t = type->toBasetype(); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
590 Type* t1 = e1->type->toBasetype(); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
591 Type* t2 = e2->type->toBasetype(); |
167
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
592 |
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
593 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
|
594 LLValue* lv = l->getRVal(); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
595 LLValue* rv = r->getRVal(); |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
619
diff
changeset
|
596 if (Logger::enabled()) |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
619
diff
changeset
|
597 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
|
598 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
|
599 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
|
600 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
|
601 if (diff->getType() != DtoType(type)) |
167
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
602 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
|
603 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
|
604 } |
167
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
605 else if (t1->ty == Tpointer) { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
606 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
|
607 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
|
608 return new DImValue(type, v); |
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
609 } |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
610 else if (t->iscomplex()) { |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
611 return DtoComplexSub(loc, type, l, r); |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
612 } |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
613 else { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
614 return DtoBinSub(l,r); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
615 } |
1 | 616 } |
617 | |
618 ////////////////////////////////////////////////////////////////////////////////////////// | |
619 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
620 DValue* MinAssignExp::toElem(IRState* p) |
1 | 621 { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
622 Logger::print("MinAssignExp::toElem: %s | %s\n", toChars(), type->toChars()); |
1 | 623 LOG_SCOPE; |
624 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
625 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
|
626 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
|
627 |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
628 Type* t = type->toBasetype(); |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
629 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
630 DValue* res; |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
631 if (e1->type->toBasetype()->ty == Tpointer) { |
131 | 632 Logger::println("ptr"); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
633 LLValue* tmp = r->getRVal(); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
634 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
|
635 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
|
636 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
|
637 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
|
638 } |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
639 else if (t->iscomplex()) { |
131 | 640 Logger::println("complex"); |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
641 res = DtoComplexSub(loc, type, l, r); |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
642 } |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
643 else { |
131 | 644 Logger::println("basic"); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
645 res = DtoBinSub(l,r); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
646 } |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
647 DtoAssign(loc, l, res); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
648 |
364
8014dbd24605
[svn r385] Fix lvalue cast problems with -= and friends.
ChristianK
parents:
363
diff
changeset
|
649 return res; |
1 | 650 } |
651 | |
652 ////////////////////////////////////////////////////////////////////////////////////////// | |
653 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
654 DValue* MulExp::toElem(IRState* p) |
1 | 655 { |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
656 Logger::print("MulExp::toElem: %s | %s\n", toChars(), type->toChars()); |
1 | 657 LOG_SCOPE; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
658 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
659 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
|
660 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
|
661 |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
662 if (type->iscomplex()) { |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
663 return DtoComplexMul(loc, type, l, r); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
664 } |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
665 |
524
ca2dfe98036c
Binary ops had the wrong result type for real op imaginary.
Christian Kamm <kamm incasoftware de>
parents:
521
diff
changeset
|
666 return DtoBinMul(type, l, r); |
1 | 667 } |
668 | |
669 ////////////////////////////////////////////////////////////////////////////////////////// | |
670 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
671 DValue* MulAssignExp::toElem(IRState* p) |
1 | 672 { |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
673 Logger::print("MulAssignExp::toElem: %s | %s\n", toChars(), type->toChars()); |
1 | 674 LOG_SCOPE; |
675 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
676 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
|
677 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
|
678 |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
679 DValue* res; |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
680 if (type->iscomplex()) { |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
681 res = DtoComplexMul(loc, type, l, r); |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
682 } |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
683 else { |
525
b18b6135e54b
Fix binops change for OpAssign.
Christian Kamm <kamm incasoftware de>
parents:
524
diff
changeset
|
684 res = DtoBinMul(l->getType(), l, r); |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
685 } |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
686 DtoAssign(loc, l, res); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
687 |
364
8014dbd24605
[svn r385] Fix lvalue cast problems with -= and friends.
ChristianK
parents:
363
diff
changeset
|
688 return res; |
1 | 689 } |
690 | |
691 ////////////////////////////////////////////////////////////////////////////////////////// | |
692 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
693 DValue* DivExp::toElem(IRState* p) |
1 | 694 { |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
695 Logger::print("DivExp::toElem: %s | %s\n", toChars(), type->toChars()); |
1 | 696 LOG_SCOPE; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
697 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
698 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
|
699 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
|
700 |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
701 if (type->iscomplex()) { |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
702 return DtoComplexDiv(loc, type, l, r); |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
703 } |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
704 |
524
ca2dfe98036c
Binary ops had the wrong result type for real op imaginary.
Christian Kamm <kamm incasoftware de>
parents:
521
diff
changeset
|
705 return DtoBinDiv(type, l, r); |
1 | 706 } |
707 | |
708 ////////////////////////////////////////////////////////////////////////////////////////// | |
709 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
710 DValue* DivAssignExp::toElem(IRState* p) |
1 | 711 { |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
712 Logger::print("DivAssignExp::toElem: %s | %s\n", toChars(), type->toChars()); |
1 | 713 LOG_SCOPE; |
714 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
715 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
|
716 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
|
717 |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
718 DValue* res; |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
719 if (type->iscomplex()) { |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
720 res = DtoComplexDiv(loc, type, l, r); |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
721 } |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
722 else { |
525
b18b6135e54b
Fix binops change for OpAssign.
Christian Kamm <kamm incasoftware de>
parents:
524
diff
changeset
|
723 res = DtoBinDiv(l->getType(), l, r); |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
724 } |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
725 DtoAssign(loc, l, res); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
726 |
364
8014dbd24605
[svn r385] Fix lvalue cast problems with -= and friends.
ChristianK
parents:
363
diff
changeset
|
727 return res; |
1 | 728 } |
729 | |
730 ////////////////////////////////////////////////////////////////////////////////////////// | |
731 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
732 DValue* ModExp::toElem(IRState* p) |
1 | 733 { |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
734 Logger::print("ModExp::toElem: %s | %s\n", toChars(), type->toChars()); |
1 | 735 LOG_SCOPE; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
736 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
737 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
|
738 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
|
739 |
524
ca2dfe98036c
Binary ops had the wrong result type for real op imaginary.
Christian Kamm <kamm incasoftware de>
parents:
521
diff
changeset
|
740 return DtoBinRem(type, l, r); |
1 | 741 } |
742 | |
743 ////////////////////////////////////////////////////////////////////////////////////////// | |
744 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
745 DValue* ModAssignExp::toElem(IRState* p) |
1 | 746 { |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
747 Logger::print("ModAssignExp::toElem: %s | %s\n", toChars(), type->toChars()); |
1 | 748 LOG_SCOPE; |
749 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
750 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
|
751 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
|
752 |
525
b18b6135e54b
Fix binops change for OpAssign.
Christian Kamm <kamm incasoftware de>
parents:
524
diff
changeset
|
753 DValue* res = DtoBinRem(l->getType(), l, r); |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
754 DtoAssign(loc, l, res); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
755 |
364
8014dbd24605
[svn r385] Fix lvalue cast problems with -= and friends.
ChristianK
parents:
363
diff
changeset
|
756 return res; |
1 | 757 } |
758 | |
759 ////////////////////////////////////////////////////////////////////////////////////////// | |
760 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
761 DValue* CallExp::toElem(IRState* p) |
1 | 762 { |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
763 Logger::print("CallExp::toElem: %s | %s\n", toChars(), type->toChars()); |
1 | 764 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
|
765 |
414
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
766 // get the callee value |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
767 DValue* fnval = e1->toElem(p); |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
768 |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
769 // get func value if any |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
770 DFuncValue* dfnval = fnval->isFunc(); |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
771 |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
772 // handle magic intrinsics (mapping to instructions) |
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
|
773 bool va_intrinsic = false; |
414
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
774 if (dfnval && dfnval->func) |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
775 { |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
776 FuncDeclaration* fndecl = dfnval->func; |
215
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
777 // va_start instruction |
414
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
778 if (fndecl->llvmInternal == LLVMva_start) { |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
440
diff
changeset
|
779 // llvm doesn't need the second param hence the override |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
440
diff
changeset
|
780 Expression* exp = (Expression*)arguments->data[0]; |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
440
diff
changeset
|
781 DValue* expv = exp->toElem(p); |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
440
diff
changeset
|
782 LLValue* arg = DtoBitCast(expv->getLVal(), getVoidPtrType()); |
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
440
diff
changeset
|
783 return new DImValue(type, gIR->ir->CreateCall(GET_INTRINSIC_DECL(vastart), arg, "")); |
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
|
784 } |
215
a58d8f4b84df
[svn r231] Changed: warnings are no longer treated as an error.
lindquist
parents:
213
diff
changeset
|
785 // va_arg instruction |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
786 else if (fndecl->llvmInternal == LLVMva_arg) { |
414
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
787 return DtoVaArg(loc, type, (Expression*)arguments->data[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
|
788 } |
414
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
789 // C alloca |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
790 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
|
791 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
|
792 DValue* expv = exp->toElem(p); |
132 | 793 if (expv->getType()->toBasetype()->ty != Tint32) |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
794 expv = DtoCast(loc, expv, Type::tint32); |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
795 return new DImValue(type, p->ir->CreateAlloca(LLType::Int8Ty, expv->getRVal(), ".alloca")); |
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
|
796 } |
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
|
797 } |
414
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
798 |
422
fa91b03d9cd7
Error message for calling a function with a missing 'this' arg.
Christian Kamm <kamm incasoftware de>
parents:
414
diff
changeset
|
799 return DtoCallFunction(loc, type, fnval, arguments); |
1 | 800 } |
801 | |
802 ////////////////////////////////////////////////////////////////////////////////////////// | |
803 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
804 DValue* CastExp::toElem(IRState* p) |
1 | 805 { |
53
06ccc817acd4
[svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents:
52
diff
changeset
|
806 Logger::print("CastExp::toElem: %s | %s\n", toChars(), type->toChars()); |
1 | 807 LOG_SCOPE; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
808 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
809 DValue* u = e1->toElem(p); |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
810 DValue* v = DtoCast(loc, u, to); |
361
932229a851a4
[svn r382] In CastExp, after the cast to CastExp.to force the type to be CastExp.type.
ChristianK
parents:
359
diff
changeset
|
811 // force d type to this->type |
932229a851a4
[svn r382] In CastExp, after the cast to CastExp.to force the type to be CastExp.type.
ChristianK
parents:
359
diff
changeset
|
812 v->getType() = type; |
97
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
813 |
107
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
104
diff
changeset
|
814 if (v->isSlice()) { |
334 | 815 // only valid as rvalue! |
97
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
816 return v; |
1 | 817 } |
97
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
818 |
334 | 819 else if(u->isLVal()) |
359 | 820 return new DLRValue(u, v); |
107
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
104
diff
changeset
|
821 |
334 | 822 else |
823 return v; | |
1 | 824 } |
825 | |
826 ////////////////////////////////////////////////////////////////////////////////////////// | |
827 | |
619
722630261d62
Implemented constant pointer casts (like casting function pointer to void* as a constant global initializer)
tomas@myhost
parents:
616
diff
changeset
|
828 LLConstant* CastExp::toConstElem(IRState* p) |
722630261d62
Implemented constant pointer casts (like casting function pointer to void* as a constant global initializer)
tomas@myhost
parents:
616
diff
changeset
|
829 { |
722630261d62
Implemented constant pointer casts (like casting function pointer to void* as a constant global initializer)
tomas@myhost
parents:
616
diff
changeset
|
830 Logger::print("CastExp::toConstElem: %s | %s\n", toChars(), type->toChars()); |
722630261d62
Implemented constant pointer casts (like casting function pointer to void* as a constant global initializer)
tomas@myhost
parents:
616
diff
changeset
|
831 LOG_SCOPE; |
722630261d62
Implemented constant pointer casts (like casting function pointer to void* as a constant global initializer)
tomas@myhost
parents:
616
diff
changeset
|
832 |
722630261d62
Implemented constant pointer casts (like casting function pointer to void* as a constant global initializer)
tomas@myhost
parents:
616
diff
changeset
|
833 LLConstant* c = e1->toConstElem(p); |
722630261d62
Implemented constant pointer casts (like casting function pointer to void* as a constant global initializer)
tomas@myhost
parents:
616
diff
changeset
|
834 const LLType* lltype = DtoType(type); |
624
eb444ed4a2d3
Make invalid compile time casts an error instead of asserting.
Christian Kamm <kamm incasoftware de>
parents:
622
diff
changeset
|
835 |
eb444ed4a2d3
Make invalid compile time casts an error instead of asserting.
Christian Kamm <kamm incasoftware de>
parents:
622
diff
changeset
|
836 if(!isaPointer(c->getType()) || !isaPointer(lltype)) { |
eb444ed4a2d3
Make invalid compile time casts an error instead of asserting.
Christian Kamm <kamm incasoftware de>
parents:
622
diff
changeset
|
837 error("can only cast pointers to pointers at compile time, not %s to %s", type->toChars(), e1->type->toChars()); |
eb444ed4a2d3
Make invalid compile time casts an error instead of asserting.
Christian Kamm <kamm incasoftware de>
parents:
622
diff
changeset
|
838 fatal(); |
eb444ed4a2d3
Make invalid compile time casts an error instead of asserting.
Christian Kamm <kamm incasoftware de>
parents:
622
diff
changeset
|
839 } |
619
722630261d62
Implemented constant pointer casts (like casting function pointer to void* as a constant global initializer)
tomas@myhost
parents:
616
diff
changeset
|
840 |
722630261d62
Implemented constant pointer casts (like casting function pointer to void* as a constant global initializer)
tomas@myhost
parents:
616
diff
changeset
|
841 return llvm::ConstantExpr::getBitCast(c, lltype); |
722630261d62
Implemented constant pointer casts (like casting function pointer to void* as a constant global initializer)
tomas@myhost
parents:
616
diff
changeset
|
842 } |
722630261d62
Implemented constant pointer casts (like casting function pointer to void* as a constant global initializer)
tomas@myhost
parents:
616
diff
changeset
|
843 |
722630261d62
Implemented constant pointer casts (like casting function pointer to void* as a constant global initializer)
tomas@myhost
parents:
616
diff
changeset
|
844 ////////////////////////////////////////////////////////////////////////////////////////// |
722630261d62
Implemented constant pointer casts (like casting function pointer to void* as a constant global initializer)
tomas@myhost
parents:
616
diff
changeset
|
845 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
846 DValue* SymOffExp::toElem(IRState* p) |
1 | 847 { |
848 Logger::print("SymOffExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
849 LOG_SCOPE; | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
850 |
98
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
97
diff
changeset
|
851 assert(0 && "SymOffExp::toElem should no longer be called :/"); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
852 return 0; |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
853 } |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
854 |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
855 ////////////////////////////////////////////////////////////////////////////////////////// |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
856 |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
857 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
|
858 { |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
859 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
|
860 LOG_SCOPE; |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
861 DValue* v = e1->toElem(p); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
862 if (v->isField()) { |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
863 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
|
864 return v; |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
865 } |
100 | 866 else if (DFuncValue* fv = v->isFunc()) { |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
867 Logger::println("is func"); |
100 | 868 //Logger::println("FuncDeclaration"); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
869 FuncDeclaration* fd = fv->func; |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
92
diff
changeset
|
870 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
|
871 DtoForceDeclareDsymbol(fd); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
872 return new DFuncValue(fd, fd->ir.irFunc->func); |
1 | 873 } |
101
169fda3a77d4
[svn r105] -inline does nothing for now, the -On setting can already be used to trigger it.
lindquist
parents:
100
diff
changeset
|
874 else if (DImValue* im = v->isIm()) { |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
875 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
|
876 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
|
877 } |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
878 Logger::println("is nothing special"); |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
879 LLValue* lval = v->getLVal(); |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
619
diff
changeset
|
880 if (Logger::enabled()) |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
619
diff
changeset
|
881 Logger::cout() << "lval: " << *lval << '\n'; |
600
311f16f26297
Fixed AddrExp might silently change the type of its value, but we weren't casting to compensate ... why doesn't DMD insert a cast?
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
599
diff
changeset
|
882 return new DImValue(type, DtoBitCast(v->getLVal(), DtoType(type))); |
1 | 883 } |
884 | |
459
9db9099583ca
Implement a rough AddrExp::toConstElem()
Christian Kamm <kamm incasoftware de>
parents:
452
diff
changeset
|
885 LLConstant* AddrExp::toConstElem(IRState* p) |
9db9099583ca
Implement a rough AddrExp::toConstElem()
Christian Kamm <kamm incasoftware de>
parents:
452
diff
changeset
|
886 { |
9db9099583ca
Implement a rough AddrExp::toConstElem()
Christian Kamm <kamm incasoftware de>
parents:
452
diff
changeset
|
887 assert(e1->op == TOKvar); |
9db9099583ca
Implement a rough AddrExp::toConstElem()
Christian Kamm <kamm incasoftware de>
parents:
452
diff
changeset
|
888 VarExp* vexp = (VarExp*)e1; |
469
d0dad1fe0f45
Fixed constant expression taking address of function.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
468
diff
changeset
|
889 |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
890 if (vexp->var->needThis()) |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
891 { |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
892 error("need 'this' to access %s", vexp->var->toChars()); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
893 fatal(); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
894 } |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
895 |
469
d0dad1fe0f45
Fixed constant expression taking address of function.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
468
diff
changeset
|
896 // global variable |
d0dad1fe0f45
Fixed constant expression taking address of function.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
468
diff
changeset
|
897 if (VarDeclaration* vd = vexp->var->isVarDeclaration()) |
d0dad1fe0f45
Fixed constant expression taking address of function.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
468
diff
changeset
|
898 { |
d0dad1fe0f45
Fixed constant expression taking address of function.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
468
diff
changeset
|
899 LLConstant* llc = llvm::dyn_cast<LLConstant>(vd->ir.getIrValue()); |
d0dad1fe0f45
Fixed constant expression taking address of function.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
468
diff
changeset
|
900 assert(llc); |
d0dad1fe0f45
Fixed constant expression taking address of function.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
468
diff
changeset
|
901 return llc; |
d0dad1fe0f45
Fixed constant expression taking address of function.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
468
diff
changeset
|
902 } |
d0dad1fe0f45
Fixed constant expression taking address of function.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
468
diff
changeset
|
903 // static function |
d0dad1fe0f45
Fixed constant expression taking address of function.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
468
diff
changeset
|
904 else if (FuncDeclaration* fd = vexp->var->isFuncDeclaration()) |
d0dad1fe0f45
Fixed constant expression taking address of function.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
468
diff
changeset
|
905 { |
d0dad1fe0f45
Fixed constant expression taking address of function.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
468
diff
changeset
|
906 IrFunction* irfunc = fd->ir.irFunc; |
d0dad1fe0f45
Fixed constant expression taking address of function.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
468
diff
changeset
|
907 assert(irfunc); |
d0dad1fe0f45
Fixed constant expression taking address of function.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
468
diff
changeset
|
908 return irfunc->func; |
d0dad1fe0f45
Fixed constant expression taking address of function.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
468
diff
changeset
|
909 } |
d0dad1fe0f45
Fixed constant expression taking address of function.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
468
diff
changeset
|
910 // not yet supported |
d0dad1fe0f45
Fixed constant expression taking address of function.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
468
diff
changeset
|
911 else |
d0dad1fe0f45
Fixed constant expression taking address of function.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
468
diff
changeset
|
912 { |
d0dad1fe0f45
Fixed constant expression taking address of function.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
468
diff
changeset
|
913 error("constant expression '%s' not yet implemented", toChars()); |
d0dad1fe0f45
Fixed constant expression taking address of function.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
468
diff
changeset
|
914 fatal(); |
d0dad1fe0f45
Fixed constant expression taking address of function.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
468
diff
changeset
|
915 } |
459
9db9099583ca
Implement a rough AddrExp::toConstElem()
Christian Kamm <kamm incasoftware de>
parents:
452
diff
changeset
|
916 } |
9db9099583ca
Implement a rough AddrExp::toConstElem()
Christian Kamm <kamm incasoftware de>
parents:
452
diff
changeset
|
917 |
1 | 918 ////////////////////////////////////////////////////////////////////////////////////////// |
919 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
920 DValue* PtrExp::toElem(IRState* p) |
1 | 921 { |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
922 Logger::println("PtrExp::toElem: %s | %s", toChars(), type->toChars()); |
1 | 923 LOG_SCOPE; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
924 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
925 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
|
926 |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
927 // this is *so* ugly.. I'd really like to figure out some way to avoid this badness... |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
928 LLValue* lv = a->getRVal(); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
929 LLValue* v = lv; |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
930 |
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
931 Type* bt = type->toBasetype(); |
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
932 |
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
933 // we can't load function pointers, but they aren't passed by reference either |
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
934 // FIXME: maybe a MayLoad function isn't a bad idea after all ... |
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
935 if (!DtoIsPassedByRef(bt) && bt->ty != Tfunction) |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
936 v = DtoLoad(v); |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
937 |
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
938 return new DLRValue(new DVarValue(type, lv), new DImValue(type, v)); |
1 | 939 } |
940 | |
941 ////////////////////////////////////////////////////////////////////////////////////////// | |
942 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
943 DValue* DotVarExp::toElem(IRState* p) |
1 | 944 { |
945 Logger::print("DotVarExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
946 LOG_SCOPE; | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
947 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
948 DValue* l = e1->toElem(p); |
1 | 949 |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
950 Type* t = type->toBasetype(); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
951 Type* e1type = e1->type->toBasetype(); |
40 | 952 |
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
|
953 //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
|
954 //Logger::cout() << *DtoType(e1type) << '\n'; |
1 | 955 |
956 if (VarDeclaration* vd = var->isVarDeclaration()) { | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
957 LLValue* arrptr; |
40 | 958 if (e1type->ty == Tpointer) { |
959 assert(e1type->next->ty == Tstruct); | |
960 TypeStruct* ts = (TypeStruct*)e1type->next; | |
8
5e69b77a5c51
[svn r12] fixed accessing aggregate fields of aggregates
lindquist
parents:
6
diff
changeset
|
961 Logger::println("Struct member offset:%d", vd->offset); |
132 | 962 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
963 LLValue* src = l->getRVal(); |
132 | 964 |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
965 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
|
966 arrptr = DtoIndexStruct(src, ts->sym, vd->type, vd->offset, vdoffsets); |
1 | 967 } |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
968 // happens for tuples |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
969 else if (e1type->ty == Tstruct) { |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
970 TypeStruct* ts = (TypeStruct*)e1type; |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
971 Logger::println("Struct member offset:%d", vd->offset); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
972 |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
973 LLValue* src = l->getRVal(); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
974 |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
975 DStructIndexVector vdoffsets; |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
976 arrptr = DtoIndexStruct(src, ts->sym, vd->type, vd->offset, vdoffsets); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
977 } |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
978 else if (e1type->ty == Tclass) { |
40 | 979 TypeClass* tc = (TypeClass*)e1type; |
1 | 980 Logger::println("Class member offset: %d", vd->offset); |
132 | 981 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
982 LLValue* src = l->getRVal(); |
132 | 983 |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
984 DStructIndexVector vdoffsets; |
132 | 985 arrptr = DtoIndexClass(src, tc->sym, vd->type, vd->offset, vdoffsets); |
1 | 986 } |
77
714057ff2dbb
[svn r81] Fixed: Union support was very buggy. Should be fairly solid now.
lindquist
parents:
76
diff
changeset
|
987 else |
714057ff2dbb
[svn r81] Fixed: Union support was very buggy. Should be fairly solid now.
lindquist
parents:
76
diff
changeset
|
988 assert(0); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
989 |
123
7f9a0a58394b
[svn r127] Updated the lphobos build scripts a little. Created a new rebuild profile.
lindquist
parents:
122
diff
changeset
|
990 //Logger::cout() << "mem: " << *arrptr << '\n'; |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
991 return new DVarValue(type, vd, arrptr); |
1 | 992 } |
993 else if (FuncDeclaration* fdecl = var->isFuncDeclaration()) | |
994 { | |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
995 DtoResolveDsymbol(fdecl); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
996 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
997 LLValue* funcval; |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
998 LLValue* vthis2 = 0; |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
999 if (e1type->ty == Tclass) { |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1000 TypeClass* tc = (TypeClass*)e1type; |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1001 if (tc->sym->isInterfaceDeclaration()) { |
114 | 1002 vthis2 = DtoCastInterfaceToObject(l, NULL)->getRVal(); |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1003 } |
1 | 1004 } |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1005 LLValue* vthis = l->getRVal(); |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1006 if (!vthis2) vthis2 = vthis; |
1 | 1007 |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1008 // super call |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1009 if (e1->op == TOKsuper) { |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1010 DtoForceDeclareDsymbol(fdecl); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
1011 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
|
1012 assert(funcval); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1013 } |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1014 // normal virtual call |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1015 else if (fdecl->isAbstract() || (!fdecl->isFinal() && fdecl->isVirtual())) { |
1 | 1016 assert(fdecl->vtblIndex > 0); |
40 | 1017 assert(e1type->ty == Tclass); |
1 | 1018 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1019 LLValue* zero = llvm::ConstantInt::get(LLType::Int32Ty, 0, false); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1020 LLValue* vtblidx = llvm::ConstantInt::get(LLType::Int32Ty, (size_t)fdecl->vtblIndex, false); |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
619
diff
changeset
|
1021 if (Logger::enabled()) |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
619
diff
changeset
|
1022 Logger::cout() << "vthis: " << *vthis << '\n'; |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1023 funcval = DtoGEP(vthis, zero, zero); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1024 funcval = DtoLoad(funcval); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1025 funcval = DtoGEP(funcval, zero, vtblidx, toChars()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1026 funcval = DtoLoad(funcval); |
193
aca17e55b7a5
[svn r209] Fixed: exotic array to pointer casts were broken.
lindquist
parents:
183
diff
changeset
|
1027 #if OPAQUE_VTBLS |
aca17e55b7a5
[svn r209] Fixed: exotic array to pointer casts were broken.
lindquist
parents:
183
diff
changeset
|
1028 funcval = DtoBitCast(funcval, getPtrToType(DtoType(fdecl->type))); |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
619
diff
changeset
|
1029 if (Logger::enabled()) |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
619
diff
changeset
|
1030 Logger::cout() << "funcval casted: " << *funcval << '\n'; |
193
aca17e55b7a5
[svn r209] Fixed: exotic array to pointer casts were broken.
lindquist
parents:
183
diff
changeset
|
1031 #endif |
1 | 1032 } |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1033 // static call |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1034 else { |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1035 DtoForceDeclareDsymbol(fdecl); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
1036 funcval = fdecl->ir.irFunc->func; |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1037 assert(funcval); |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1038 } |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1039 return new DFuncValue(fdecl, funcval, vthis2); |
1 | 1040 } |
1041 else { | |
123
7f9a0a58394b
[svn r127] Updated the lphobos build scripts a little. Created a new rebuild profile.
lindquist
parents:
122
diff
changeset
|
1042 printf("unsupported dotvarexp: %s\n", var->toChars()); |
1 | 1043 } |
1044 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1045 assert(0); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1046 return 0; |
1 | 1047 } |
1048 | |
1049 ////////////////////////////////////////////////////////////////////////////////////////// | |
1050 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1051 DValue* ThisExp::toElem(IRState* p) |
1 | 1052 { |
1053 Logger::print("ThisExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1054 LOG_SCOPE; | |
1055 | |
328
7086a84ab3d6
[svn r349] Fixed problems with static arrays of void as well as a static arrays with zero length.
lindquist
parents:
321
diff
changeset
|
1056 // this seems to happen for dmd generated assert statements like: |
7086a84ab3d6
[svn r349] Fixed problems with static arrays of void as well as a static arrays with zero length.
lindquist
parents:
321
diff
changeset
|
1057 // assert(this, "null this"); |
452
30ef3c7bddca
Fixed problems with nested 'this'. Fixes #39 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
445
diff
changeset
|
1058 // FIXME: check for TOKthis in AssertExp instead |
328
7086a84ab3d6
[svn r349] Fixed problems with static arrays of void as well as a static arrays with zero length.
lindquist
parents:
321
diff
changeset
|
1059 if (!var) |
7086a84ab3d6
[svn r349] Fixed problems with static arrays of void as well as a static arrays with zero length.
lindquist
parents:
321
diff
changeset
|
1060 { |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
1061 LLValue* v = p->func()->thisArg; |
328
7086a84ab3d6
[svn r349] Fixed problems with static arrays of void as well as a static arrays with zero length.
lindquist
parents:
321
diff
changeset
|
1062 assert(v); |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
1063 return new DVarValue(type, v); |
328
7086a84ab3d6
[svn r349] Fixed problems with static arrays of void as well as a static arrays with zero length.
lindquist
parents:
321
diff
changeset
|
1064 } |
7086a84ab3d6
[svn r349] Fixed problems with static arrays of void as well as a static arrays with zero length.
lindquist
parents:
321
diff
changeset
|
1065 // regular this expr |
7086a84ab3d6
[svn r349] Fixed problems with static arrays of void as well as a static arrays with zero length.
lindquist
parents:
321
diff
changeset
|
1066 else if (VarDeclaration* vd = var->isVarDeclaration()) { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1067 LLValue* v; |
452
30ef3c7bddca
Fixed problems with nested 'this'. Fixes #39 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
445
diff
changeset
|
1068 if (vd->toParent2() != p->func()->decl) { |
30ef3c7bddca
Fixed problems with nested 'this'. Fixes #39 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
445
diff
changeset
|
1069 Logger::println("nested this exp"); |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
1070 return DtoNestedVariable(loc, type, vd); |
452
30ef3c7bddca
Fixed problems with nested 'this'. Fixes #39 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
445
diff
changeset
|
1071 } |
30ef3c7bddca
Fixed problems with nested 'this'. Fixes #39 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
445
diff
changeset
|
1072 else { |
30ef3c7bddca
Fixed problems with nested 'this'. Fixes #39 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
445
diff
changeset
|
1073 Logger::println("normal this exp"); |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
1074 v = p->func()->thisArg; |
452
30ef3c7bddca
Fixed problems with nested 'this'. Fixes #39 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
445
diff
changeset
|
1075 } |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
1076 return new DVarValue(type, vd, v); |
1 | 1077 } |
1078 | |
328
7086a84ab3d6
[svn r349] Fixed problems with static arrays of void as well as a static arrays with zero length.
lindquist
parents:
321
diff
changeset
|
1079 // anything we're not yet handling ? |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1080 assert(0); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1081 return 0; |
1 | 1082 } |
1083 | |
1084 ////////////////////////////////////////////////////////////////////////////////////////// | |
1085 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1086 DValue* IndexExp::toElem(IRState* p) |
1 | 1087 { |
1088 Logger::print("IndexExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1089 LOG_SCOPE; | |
1090 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1091 DValue* l = e1->toElem(p); |
1 | 1092 |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
1093 Type* e1type = e1->type->toBasetype(); |
40 | 1094 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1095 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
|
1096 DValue* r = e2->toElem(p); |
1 | 1097 p->arrays.pop_back(); |
1098 | |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1099 LLValue* zero = DtoConstUint(0); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1100 LLValue* one = DtoConstUint(1); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1101 |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1102 LLValue* arrptr = 0; |
40 | 1103 if (e1type->ty == Tpointer) { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1104 arrptr = DtoGEP1(l->getRVal(),r->getRVal()); |
1 | 1105 } |
40 | 1106 else if (e1type->ty == Tsarray) { |
439
47b64d06eb9f
Enable array bounds check and emit them in IndexExp.
Christian Kamm <kamm incasoftware de>
parents:
435
diff
changeset
|
1107 if(global.params.useArrayBounds) |
440
d8dc221d3db7
Insert array bound checks for slices.
Christian Kamm <kamm incasoftware de>
parents:
439
diff
changeset
|
1108 DtoArrayBoundsCheck(loc, l, r, false); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1109 arrptr = DtoGEP(l->getRVal(), zero, r->getRVal()); |
1 | 1110 } |
40 | 1111 else if (e1type->ty == Tarray) { |
439
47b64d06eb9f
Enable array bounds check and emit them in IndexExp.
Christian Kamm <kamm incasoftware de>
parents:
435
diff
changeset
|
1112 if(global.params.useArrayBounds) |
440
d8dc221d3db7
Insert array bound checks for slices.
Christian Kamm <kamm incasoftware de>
parents:
439
diff
changeset
|
1113 DtoArrayBoundsCheck(loc, l, r, false); |
275
665b81613475
[svn r296] Removed: the 'suite' dir, it never took off!
lindquist
parents:
268
diff
changeset
|
1114 arrptr = DtoArrayPtr(l); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1115 arrptr = DtoGEP1(arrptr,r->getRVal()); |
1 | 1116 } |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1117 else if (e1type->ty == Taarray) { |
458
121624c14053
Fixed AA Rvalue-only access (like indexing an AA return value immediately).
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
452
diff
changeset
|
1118 return DtoAAIndex(loc, type, l, r, modifiable); |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1119 } |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1120 else { |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1121 Logger::println("invalid index exp! e1type: %s", e1type->toChars()); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1122 assert(0); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1123 } |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
1124 return new DVarValue(type, arrptr); |
1 | 1125 } |
1126 | |
1127 ////////////////////////////////////////////////////////////////////////////////////////// | |
1128 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1129 DValue* SliceExp::toElem(IRState* p) |
1 | 1130 { |
1131 Logger::print("SliceExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1132 LOG_SCOPE; | |
1133 | |
308
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1134 // this is the new slicing code, it's different in that a full slice will no longer retain the original pointer. |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1135 // but this was broken if there *was* no original pointer, ie. a slice of a slice... |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1136 // now all slices have *both* the 'len' and 'ptr' fields set to != null. |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1137 |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1138 // value being sliced |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1139 LLValue* elen; |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1140 LLValue* eptr; |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1141 DValue* e = e1->toElem(p); |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1142 |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1143 // handle pointer slicing |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1144 Type* etype = e1->type->toBasetype(); |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1145 if (etype->ty == Tpointer) |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1146 { |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1147 assert(lwr); |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1148 eptr = e->getRVal(); |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1149 } |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1150 // array slice |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1151 else |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1152 { |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1153 eptr = DtoArrayPtr(e); |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1154 } |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1155 |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1156 // has lower bound, pointer needs adjustment |
1 | 1157 if (lwr) |
1158 { | |
308
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1159 // must have upper bound too then |
1 | 1160 assert(upr); |
308
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1161 |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1162 // get bounds (make sure $ works) |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1163 p->arrays.push_back(e); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1164 DValue* lo = lwr->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1165 DValue* up = upr->toElem(p); |
1 | 1166 p->arrays.pop_back(); |
308
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1167 LLValue* vlo = lo->getRVal(); |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1168 LLValue* vup = up->getRVal(); |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1169 |
440
d8dc221d3db7
Insert array bound checks for slices.
Christian Kamm <kamm incasoftware de>
parents:
439
diff
changeset
|
1170 if(global.params.useArrayBounds && (etype->ty == Tsarray || etype->ty == Tarray)) |
d8dc221d3db7
Insert array bound checks for slices.
Christian Kamm <kamm incasoftware de>
parents:
439
diff
changeset
|
1171 DtoArrayBoundsCheck(loc, e, up, true); |
d8dc221d3db7
Insert array bound checks for slices.
Christian Kamm <kamm incasoftware de>
parents:
439
diff
changeset
|
1172 |
308
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1173 // offset by lower |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1174 eptr = DtoGEP1(eptr, vlo); |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1175 |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1176 // adjust length |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1177 elen = p->ir->CreateSub(vup, vlo, "tmp"); |
1 | 1178 } |
308
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1179 // no bounds or full slice -> just convert to slice |
1 | 1180 else |
1181 { | |
308
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1182 assert(e1->type->toBasetype()->ty != Tpointer); |
339
385a18242485
[svn r360] Another mostly rewrite of DtoArrayInit. Should be much more robust now, and probably faster code generated for the most common cases too!
lindquist
parents:
336
diff
changeset
|
1183 // if the sliceee is a static array, we use the length of that as DMD seems |
385a18242485
[svn r360] Another mostly rewrite of DtoArrayInit. Should be much more robust now, and probably faster code generated for the most common cases too!
lindquist
parents:
336
diff
changeset
|
1184 // to give contrary inconsistent sizesin some multidimensional static array cases. |
385a18242485
[svn r360] Another mostly rewrite of DtoArrayInit. Should be much more robust now, and probably faster code generated for the most common cases too!
lindquist
parents:
336
diff
changeset
|
1185 // (namely default initialization, int[16][16] arr; -> int[256] arr = 0;) |
385a18242485
[svn r360] Another mostly rewrite of DtoArrayInit. Should be much more robust now, and probably faster code generated for the most common cases too!
lindquist
parents:
336
diff
changeset
|
1186 if (etype->ty == Tsarray) |
385a18242485
[svn r360] Another mostly rewrite of DtoArrayInit. Should be much more robust now, and probably faster code generated for the most common cases too!
lindquist
parents:
336
diff
changeset
|
1187 { |
385a18242485
[svn r360] Another mostly rewrite of DtoArrayInit. Should be much more robust now, and probably faster code generated for the most common cases too!
lindquist
parents:
336
diff
changeset
|
1188 TypeSArray* tsa = (TypeSArray*)etype; |
385a18242485
[svn r360] Another mostly rewrite of DtoArrayInit. Should be much more robust now, and probably faster code generated for the most common cases too!
lindquist
parents:
336
diff
changeset
|
1189 elen = DtoConstSize_t(tsa->dim->toUInteger()); |
385a18242485
[svn r360] Another mostly rewrite of DtoArrayInit. Should be much more robust now, and probably faster code generated for the most common cases too!
lindquist
parents:
336
diff
changeset
|
1190 } |
385a18242485
[svn r360] Another mostly rewrite of DtoArrayInit. Should be much more robust now, and probably faster code generated for the most common cases too!
lindquist
parents:
336
diff
changeset
|
1191 // for normal code the actual array length is what we want! |
385a18242485
[svn r360] Another mostly rewrite of DtoArrayInit. Should be much more robust now, and probably faster code generated for the most common cases too!
lindquist
parents:
336
diff
changeset
|
1192 else |
385a18242485
[svn r360] Another mostly rewrite of DtoArrayInit. Should be much more robust now, and probably faster code generated for the most common cases too!
lindquist
parents:
336
diff
changeset
|
1193 { |
385a18242485
[svn r360] Another mostly rewrite of DtoArrayInit. Should be much more robust now, and probably faster code generated for the most common cases too!
lindquist
parents:
336
diff
changeset
|
1194 elen = DtoArrayLen(e); |
385a18242485
[svn r360] Another mostly rewrite of DtoArrayInit. Should be much more robust now, and probably faster code generated for the most common cases too!
lindquist
parents:
336
diff
changeset
|
1195 } |
1 | 1196 } |
1197 | |
308
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1198 return new DSliceValue(type, elen, eptr); |
1 | 1199 } |
1200 | |
1201 ////////////////////////////////////////////////////////////////////////////////////////// | |
1202 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1203 DValue* CmpExp::toElem(IRState* p) |
1 | 1204 { |
1205 Logger::print("CmpExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1206 LOG_SCOPE; | |
1207 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1208 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
|
1209 DValue* r = e2->toElem(p); |
1 | 1210 |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
1211 Type* t = e1->type->toBasetype(); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
1212 Type* e2t = e2->type->toBasetype(); |
1 | 1213 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1214 LLValue* eval = 0; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1215 |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1216 if (t->isintegral() || t->ty == Tpointer) |
1 | 1217 { |
1218 llvm::ICmpInst::Predicate cmpop; | |
40 | 1219 bool skip = false; |
575
f0c20d50d4b3
Pointer comparisons were being treated as signed integers. Now they are handled as unsigned integers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
574
diff
changeset
|
1220 // pointers don't report as being unsigned |
f0c20d50d4b3
Pointer comparisons were being treated as signed integers. Now they are handled as unsigned integers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
574
diff
changeset
|
1221 bool uns = (t->isunsigned() || t->ty == Tpointer); |
1 | 1222 switch(op) |
1223 { | |
1224 case TOKlt: | |
40 | 1225 case TOKul: |
575
f0c20d50d4b3
Pointer comparisons were being treated as signed integers. Now they are handled as unsigned integers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
574
diff
changeset
|
1226 cmpop = uns ? llvm::ICmpInst::ICMP_ULT : llvm::ICmpInst::ICMP_SLT; |
1 | 1227 break; |
1228 case TOKle: | |
40 | 1229 case TOKule: |
575
f0c20d50d4b3
Pointer comparisons were being treated as signed integers. Now they are handled as unsigned integers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
574
diff
changeset
|
1230 cmpop = uns ? llvm::ICmpInst::ICMP_ULE : llvm::ICmpInst::ICMP_SLE; |
1 | 1231 break; |
1232 case TOKgt: | |
40 | 1233 case TOKug: |
575
f0c20d50d4b3
Pointer comparisons were being treated as signed integers. Now they are handled as unsigned integers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
574
diff
changeset
|
1234 cmpop = uns ? llvm::ICmpInst::ICMP_UGT : llvm::ICmpInst::ICMP_SGT; |
1 | 1235 break; |
1236 case TOKge: | |
40 | 1237 case TOKuge: |
575
f0c20d50d4b3
Pointer comparisons were being treated as signed integers. Now they are handled as unsigned integers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
574
diff
changeset
|
1238 cmpop = uns ? llvm::ICmpInst::ICMP_UGE : llvm::ICmpInst::ICMP_SGE; |
1 | 1239 break; |
40 | 1240 case TOKue: |
1241 cmpop = llvm::ICmpInst::ICMP_EQ; | |
1242 break; | |
1243 case TOKlg: | |
1244 cmpop = llvm::ICmpInst::ICMP_NE; | |
1245 break; | |
1246 case TOKleg: | |
1247 skip = true; | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1248 eval = llvm::ConstantInt::getTrue(); |
40 | 1249 break; |
1250 case TOKunord: | |
1251 skip = true; | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1252 eval = llvm::ConstantInt::getFalse(); |
40 | 1253 break; |
1254 | |
1 | 1255 default: |
1256 assert(0); | |
1257 } | |
40 | 1258 if (!skip) |
1259 { | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1260 LLValue* a = l->getRVal(); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1261 LLValue* b = r->getRVal(); |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
619
diff
changeset
|
1262 if (Logger::enabled()) |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
619
diff
changeset
|
1263 { |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
619
diff
changeset
|
1264 Logger::cout() << "type 1: " << *a << '\n'; |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
619
diff
changeset
|
1265 Logger::cout() << "type 2: " << *b << '\n'; |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
619
diff
changeset
|
1266 } |
574
aee6217b4084
Fixed pointer comparisons with differing types.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
554
diff
changeset
|
1267 if (a->getType() != b->getType()) |
aee6217b4084
Fixed pointer comparisons with differing types.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
554
diff
changeset
|
1268 b = DtoBitCast(b, a->getType()); |
365 | 1269 eval = p->ir->CreateICmp(cmpop, a, b, "tmp"); |
40 | 1270 } |
1 | 1271 } |
1272 else if (t->isfloating()) | |
1273 { | |
1274 llvm::FCmpInst::Predicate cmpop; | |
1275 switch(op) | |
1276 { | |
1277 case TOKlt: | |
1278 cmpop = llvm::FCmpInst::FCMP_OLT;break; | |
1279 case TOKle: | |
1280 cmpop = llvm::FCmpInst::FCMP_OLE;break; | |
1281 case TOKgt: | |
1282 cmpop = llvm::FCmpInst::FCMP_OGT;break; | |
1283 case TOKge: | |
1284 cmpop = llvm::FCmpInst::FCMP_OGE;break; | |
1285 case TOKunord: | |
1286 cmpop = llvm::FCmpInst::FCMP_UNO;break; | |
1287 case TOKule: | |
1288 cmpop = llvm::FCmpInst::FCMP_ULE;break; | |
1289 case TOKul: | |
1290 cmpop = llvm::FCmpInst::FCMP_ULT;break; | |
1291 case TOKuge: | |
1292 cmpop = llvm::FCmpInst::FCMP_UGE;break; | |
1293 case TOKug: | |
1294 cmpop = llvm::FCmpInst::FCMP_UGT;break; | |
1295 case TOKue: | |
1296 cmpop = llvm::FCmpInst::FCMP_UEQ;break; | |
1297 case TOKlg: | |
1298 cmpop = llvm::FCmpInst::FCMP_ONE;break; | |
1299 case TOKleg: | |
1300 cmpop = llvm::FCmpInst::FCMP_ORD;break; | |
1301 | |
1302 default: | |
1303 assert(0); | |
1304 } | |
365 | 1305 eval = p->ir->CreateFCmp(cmpop, l->getRVal(), r->getRVal(), "tmp"); |
1 | 1306 } |
99
a676a7743642
[svn r103] Array comparisons are now fully implemented, that is - to the extent that TypeInfo is.
lindquist
parents:
98
diff
changeset
|
1307 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
|
1308 { |
a676a7743642
[svn r103] Array comparisons are now fully implemented, that is - to the extent that TypeInfo is.
lindquist
parents:
98
diff
changeset
|
1309 Logger::println("static or dynamic array"); |
424
c8d98ccad0cc
Error if static array is cast to an array such that oldarraysize % newelemsize != 0.
Christian Kamm <kamm incasoftware de>
parents:
422
diff
changeset
|
1310 eval = DtoArrayCompare(loc,op,l,r); |
99
a676a7743642
[svn r103] Array comparisons are now fully implemented, that is - to the extent that TypeInfo is.
lindquist
parents:
98
diff
changeset
|
1311 } |
1 | 1312 else |
1313 { | |
1314 assert(0 && "Unsupported CmpExp type"); | |
1315 } | |
1316 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1317 return new DImValue(type, eval); |
1 | 1318 } |
1319 | |
1320 ////////////////////////////////////////////////////////////////////////////////////////// | |
1321 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1322 DValue* EqualExp::toElem(IRState* p) |
1 | 1323 { |
1324 Logger::print("EqualExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1325 LOG_SCOPE; | |
1326 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1327 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
|
1328 DValue* r = e2->toElem(p); |
1 | 1329 |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
1330 Type* t = e1->type->toBasetype(); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
1331 Type* e2t = e2->type->toBasetype(); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
1332 //assert(t == e2t); |
1 | 1333 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1334 LLValue* eval = 0; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1335 |
512
0d286cd9fd08
Add interface comparison to EqualExp: just do pointer comparison.
Christian Kamm <kamm incasoftware de>
parents:
487
diff
changeset
|
1336 // the Tclass catches interface comparisons, regular |
0d286cd9fd08
Add interface comparison to EqualExp: just do pointer comparison.
Christian Kamm <kamm incasoftware de>
parents:
487
diff
changeset
|
1337 // class equality should be rewritten as a.opEquals(b) by this time |
0d286cd9fd08
Add interface comparison to EqualExp: just do pointer comparison.
Christian Kamm <kamm incasoftware de>
parents:
487
diff
changeset
|
1338 if (t->isintegral() || t->ty == Tpointer || t->ty == Tclass) |
1 | 1339 { |
512
0d286cd9fd08
Add interface comparison to EqualExp: just do pointer comparison.
Christian Kamm <kamm incasoftware de>
parents:
487
diff
changeset
|
1340 Logger::println("integral or pointer or interface"); |
1 | 1341 llvm::ICmpInst::Predicate cmpop; |
1342 switch(op) | |
1343 { | |
1344 case TOKequal: | |
1345 cmpop = llvm::ICmpInst::ICMP_EQ; | |
1346 break; | |
1347 case TOKnotequal: | |
1348 cmpop = llvm::ICmpInst::ICMP_NE; | |
1349 break; | |
1350 default: | |
1351 assert(0); | |
1352 } | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1353 LLValue* lv = l->getRVal(); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1354 LLValue* rv = r->getRVal(); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
1355 if (rv->getType() != lv->getType()) { |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
1356 rv = DtoBitCast(rv, lv->getType()); |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
1357 } |
365 | 1358 eval = p->ir->CreateICmp(cmpop, lv, rv, "tmp"); |
1 | 1359 } |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
1360 else if (t->iscomplex()) |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
1361 { |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
1362 Logger::println("complex"); |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
1363 eval = DtoComplexEquals(loc, op, l, r); |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
102
diff
changeset
|
1364 } |
1 | 1365 else if (t->isfloating()) |
1366 { | |
64
b688ad419f8c
[svn r68] Added support for multi-dimensional static arrays.
lindquist
parents:
62
diff
changeset
|
1367 Logger::println("floating"); |
1 | 1368 llvm::FCmpInst::Predicate cmpop; |
1369 switch(op) | |
1370 { | |
1371 case TOKequal: | |
1372 cmpop = llvm::FCmpInst::FCMP_OEQ; | |
1373 break; | |
1374 case TOKnotequal: | |
1375 cmpop = llvm::FCmpInst::FCMP_UNE; | |
1376 break; | |
1377 default: | |
1378 assert(0); | |
1379 } | |
365 | 1380 eval = p->ir->CreateFCmp(cmpop, l->getRVal(), r->getRVal(), "tmp"); |
1 | 1381 } |
98
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
97
diff
changeset
|
1382 else if (t->ty == Tsarray || t->ty == Tarray) |
40 | 1383 { |
98
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
97
diff
changeset
|
1384 Logger::println("static or dynamic array"); |
424
c8d98ccad0cc
Error if static array is cast to an array such that oldarraysize % newelemsize != 0.
Christian Kamm <kamm incasoftware de>
parents:
422
diff
changeset
|
1385 eval = DtoArrayEquals(loc,op,l,r); |
1 | 1386 } |
53
06ccc817acd4
[svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents:
52
diff
changeset
|
1387 else if (t->ty == Tdelegate) |
06ccc817acd4
[svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents:
52
diff
changeset
|
1388 { |
64
b688ad419f8c
[svn r68] Added support for multi-dimensional static arrays.
lindquist
parents:
62
diff
changeset
|
1389 Logger::println("delegate"); |
344
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
340
diff
changeset
|
1390 eval = DtoDelegateEquals(op,l->getRVal(),r->getRVal()); |
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
340
diff
changeset
|
1391 } |
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
340
diff
changeset
|
1392 else if (t->ty == Tstruct) |
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
340
diff
changeset
|
1393 { |
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
340
diff
changeset
|
1394 Logger::println("struct"); |
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
340
diff
changeset
|
1395 // when this is reached it means there is no opEquals overload. |
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
340
diff
changeset
|
1396 eval = DtoStructEquals(op,l,r); |
53
06ccc817acd4
[svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents:
52
diff
changeset
|
1397 } |
1 | 1398 else |
1399 { | |
1400 assert(0 && "Unsupported EqualExp type"); | |
1401 } | |
1402 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1403 return new DImValue(type, eval); |
1 | 1404 } |
1405 | |
1406 ////////////////////////////////////////////////////////////////////////////////////////// | |
1407 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1408 DValue* PostExp::toElem(IRState* p) |
1 | 1409 { |
1410 Logger::print("PostExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1411 LOG_SCOPE; | |
1412 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1413 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
|
1414 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
|
1415 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1416 LLValue* val = l->getRVal(); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1417 LLValue* post = 0; |
1 | 1418 |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
1419 Type* e1type = e1->type->toBasetype(); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
1420 Type* e2type = e2->type->toBasetype(); |
40 | 1421 |
1422 if (e1type->isintegral()) | |
1 | 1423 { |
40 | 1424 assert(e2type->isintegral()); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1425 LLValue* one = llvm::ConstantInt::get(val->getType(), 1, !e2type->isunsigned()); |
1 | 1426 if (op == TOKplusplus) { |
1427 post = llvm::BinaryOperator::createAdd(val,one,"tmp",p->scopebb()); | |
1428 } | |
1429 else if (op == TOKminusminus) { | |
1430 post = llvm::BinaryOperator::createSub(val,one,"tmp",p->scopebb()); | |
1431 } | |
1432 } | |
40 | 1433 else if (e1type->ty == Tpointer) |
1 | 1434 { |
40 | 1435 assert(e2type->isintegral()); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1436 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
|
1437 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
|
1438 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
|
1439 post = llvm::GetElementPtrInst::Create(val, whichone, "tmp", p->scopebb()); |
1 | 1440 } |
40 | 1441 else if (e1type->isfloating()) |
1 | 1442 { |
40 | 1443 assert(e2type->isfloating()); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1444 LLValue* one = DtoConstFP(e1type, 1.0); |
1 | 1445 if (op == TOKplusplus) { |
1446 post = llvm::BinaryOperator::createAdd(val,one,"tmp",p->scopebb()); | |
1447 } | |
1448 else if (op == TOKminusminus) { | |
1449 post = llvm::BinaryOperator::createSub(val,one,"tmp",p->scopebb()); | |
1450 } | |
1451 } | |
1452 else | |
1453 assert(post); | |
1454 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1455 DtoStore(post,l->getLVal()); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1456 |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
1457 return new DImValue(type,val); |
1 | 1458 } |
1459 | |
1460 ////////////////////////////////////////////////////////////////////////////////////////// | |
1461 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1462 DValue* NewExp::toElem(IRState* p) |
1 | 1463 { |
1464 Logger::print("NewExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1465 LOG_SCOPE; | |
1466 | |
1467 assert(newtype); | |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
1468 Type* ntype = newtype->toBasetype(); |
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
|
1469 |
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
|
1470 // new class |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1471 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
|
1472 Logger::println("new class"); |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
1473 return DtoNewClass(loc, (TypeClass*)ntype, this); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1474 } |
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
|
1475 // 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
|
1476 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
|
1477 { |
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
|
1478 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
|
1479 // 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
|
1480 assert(arguments); |
286
a3b7c19c866c
[svn r307] Fixed: multidimensional new expressions now work. Eg.:
lindquist
parents:
284
diff
changeset
|
1481 assert(arguments->dim >= 1); |
a3b7c19c866c
[svn r307] Fixed: multidimensional new expressions now work. Eg.:
lindquist
parents:
284
diff
changeset
|
1482 if (arguments->dim == 1) |
a3b7c19c866c
[svn r307] Fixed: multidimensional new expressions now work. Eg.:
lindquist
parents:
284
diff
changeset
|
1483 { |
a3b7c19c866c
[svn r307] Fixed: multidimensional new expressions now work. Eg.:
lindquist
parents:
284
diff
changeset
|
1484 DValue* sz = ((Expression*)arguments->data[0])->toElem(p); |
a3b7c19c866c
[svn r307] Fixed: multidimensional new expressions now work. Eg.:
lindquist
parents:
284
diff
changeset
|
1485 // allocate & init |
591
e6bcc4d9e5ff
Add _d_newarrayvT and _d_newarraymvT to create arrays without initialization.
Christian Kamm <kamm incasoftware de>
parents:
587
diff
changeset
|
1486 return DtoNewDynArray(loc, newtype, sz, true); |
286
a3b7c19c866c
[svn r307] Fixed: multidimensional new expressions now work. Eg.:
lindquist
parents:
284
diff
changeset
|
1487 } |
a3b7c19c866c
[svn r307] Fixed: multidimensional new expressions now work. Eg.:
lindquist
parents:
284
diff
changeset
|
1488 else |
a3b7c19c866c
[svn r307] Fixed: multidimensional new expressions now work. Eg.:
lindquist
parents:
284
diff
changeset
|
1489 { |
a3b7c19c866c
[svn r307] Fixed: multidimensional new expressions now work. Eg.:
lindquist
parents:
284
diff
changeset
|
1490 size_t ndims = arguments->dim; |
a3b7c19c866c
[svn r307] Fixed: multidimensional new expressions now work. Eg.:
lindquist
parents:
284
diff
changeset
|
1491 std::vector<DValue*> dims(ndims); |
a3b7c19c866c
[svn r307] Fixed: multidimensional new expressions now work. Eg.:
lindquist
parents:
284
diff
changeset
|
1492 for (size_t i=0; i<ndims; ++i) |
a3b7c19c866c
[svn r307] Fixed: multidimensional new expressions now work. Eg.:
lindquist
parents:
284
diff
changeset
|
1493 dims[i] = ((Expression*)arguments->data[i])->toElem(p); |
591
e6bcc4d9e5ff
Add _d_newarrayvT and _d_newarraymvT to create arrays without initialization.
Christian Kamm <kamm incasoftware de>
parents:
587
diff
changeset
|
1494 return DtoNewMulDimDynArray(loc, newtype, &dims[0], ndims, true); |
286
a3b7c19c866c
[svn r307] Fixed: multidimensional new expressions now work. Eg.:
lindquist
parents:
284
diff
changeset
|
1495 } |
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
|
1496 } |
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
|
1497 // 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
|
1498 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
|
1499 { |
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
|
1500 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
|
1501 } |
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
|
1502 // 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
|
1503 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
|
1504 { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1505 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
|
1506 // allocate |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1507 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
|
1508 // 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
|
1509 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
|
1510 if (ts->isZeroInit()) { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1511 DtoAggrZeroInit(mem); |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1512 } |
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
|
1513 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
|
1514 assert(ts->sym); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1515 DtoAggrCopy(mem,ts->sym->ir.irStruct->init); |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1516 } |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
1517 return new DImValue(type, mem); |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1518 } |
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
|
1519 // 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
|
1520 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
|
1521 { |
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
|
1522 // allocate |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1523 LLValue* mem = DtoNew(newtype); |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
1524 DVarValue tmpvar(newtype, mem); |
212
4c2689d57ba4
[svn r228] Fixed: when new'ing basic types, the storage was not default initialized.
lindquist
parents:
210
diff
changeset
|
1525 |
4c2689d57ba4
[svn r228] Fixed: when new'ing basic types, the storage was not default initialized.
lindquist
parents:
210
diff
changeset
|
1526 // default initialize |
4c2689d57ba4
[svn r228] Fixed: when new'ing basic types, the storage was not default initialized.
lindquist
parents:
210
diff
changeset
|
1527 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
|
1528 DValue* iv = exp->toElem(gIR); |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
1529 DtoAssign(loc, &tmpvar, iv); |
212
4c2689d57ba4
[svn r228] Fixed: when new'ing basic types, the storage was not default initialized.
lindquist
parents:
210
diff
changeset
|
1530 |
4c2689d57ba4
[svn r228] Fixed: when new'ing basic types, the storage was not default initialized.
lindquist
parents:
210
diff
changeset
|
1531 // return as pointer-to |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
1532 return new DImValue(type, mem); |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
1533 } |
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
|
1534 |
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
|
1535 assert(0); |
1 | 1536 } |
1537 | |
1538 ////////////////////////////////////////////////////////////////////////////////////////// | |
1539 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1540 DValue* DeleteExp::toElem(IRState* p) |
1 | 1541 { |
1542 Logger::print("DeleteExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1543 LOG_SCOPE; | |
1544 | |
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
|
1545 DValue* dval = e1->toElem(p); |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
1546 Type* et = e1->type->toBasetype(); |
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
|
1547 |
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
|
1548 // 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
|
1549 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
|
1550 { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1551 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
|
1552 DtoDeleteMemory(rval); |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
1553 if (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
|
1554 DtoStore(llvm::Constant::getNullValue(rval->getType()), dval->getLVal()); |
1 | 1555 } |
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
|
1556 // 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
|
1557 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
|
1558 { |
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
|
1559 bool onstack = false; |
210 | 1560 TypeClass* tc = (TypeClass*)et; |
1561 if (tc->sym->isInterfaceDeclaration()) | |
1562 { | |
1563 DtoDeleteInterface(dval->getRVal()); | |
1564 onstack = true; | |
1565 } | |
1566 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
|
1567 if (vv->var && vv->var->onstack) { |
554
1b702422451c
Always call finalizer for stack classes. Checking for the number of
Christian Kamm <kamm incasoftware de>
parents:
553
diff
changeset
|
1568 DtoFinalizeClass(dval->getRVal()); |
275
665b81613475
[svn r296] Removed: the 'suite' dir, it never took off!
lindquist
parents:
268
diff
changeset
|
1569 onstack = true; |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
1570 } |
1 | 1571 } |
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
|
1572 if (!onstack) { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1573 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
|
1574 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
|
1575 } |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
1576 if (dval->isVar()) { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1577 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
|
1578 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
|
1579 } |
1 | 1580 } |
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
|
1581 // 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
|
1582 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
|
1583 { |
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
|
1584 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
|
1585 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
|
1586 DtoSetArrayToNull(dval->getRVal()); |
1 | 1587 } |
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
|
1588 // 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
|
1589 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
|
1590 { |
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
|
1591 assert(0 && "invalid delete"); |
1 | 1592 } |
1593 | |
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
|
1594 // 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
|
1595 return NULL; |
1 | 1596 } |
1597 | |
1598 ////////////////////////////////////////////////////////////////////////////////////////// | |
1599 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1600 DValue* ArrayLengthExp::toElem(IRState* p) |
1 | 1601 { |
1602 Logger::print("ArrayLengthExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1603 LOG_SCOPE; | |
1604 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1605 DValue* u = e1->toElem(p); |
335
17b844102023
[svn r356] Fixed problem with array length assignment introduced in [355]
lindquist
parents:
334
diff
changeset
|
1606 return new DImValue(type, DtoArrayLen(u)); |
1 | 1607 } |
1608 | |
1609 ////////////////////////////////////////////////////////////////////////////////////////// | |
1610 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1611 DValue* AssertExp::toElem(IRState* p) |
1 | 1612 { |
328
7086a84ab3d6
[svn r349] Fixed problems with static arrays of void as well as a static arrays with zero length.
lindquist
parents:
321
diff
changeset
|
1613 Logger::print("AssertExp::toElem: %s\n", toChars()); |
1 | 1614 LOG_SCOPE; |
1615 | |
530
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1616 if(!global.params.useAssert) |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1617 return NULL; |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1618 |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1619 // condition |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1620 DValue* cond = e1->toElem(p); |
530
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1621 Type* condty = e1->type->toBasetype(); |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1622 |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1623 InvariantDeclaration* invdecl; |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1624 |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1625 // class invariants |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1626 if( |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1627 global.params.useInvariants && |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1628 condty->ty == Tclass && |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1629 !((TypeClass*)condty)->sym->isInterfaceDeclaration()) |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1630 { |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1631 Logger::print("calling class invariant"); |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1632 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_invariant"); |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1633 LLValue* arg = DtoBitCast(cond->getRVal(), fn->getFunctionType()->getParamType(0)); |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1634 gIR->CreateCallOrInvoke(fn, arg); |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1635 } |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1636 // struct invariants |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1637 else if( |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1638 global.params.useInvariants && |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1639 condty->ty == Tpointer && condty->next->ty == Tstruct && |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1640 (invdecl = ((TypeStruct*)condty->next)->sym->inv) != NULL) |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1641 { |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1642 Logger::print("calling struct invariant"); |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1643 DFuncValue invfunc(invdecl, invdecl->ir.irFunc->func, cond->getRVal()); |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1644 DtoCallFunction(loc, NULL, &invfunc, NULL); |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1645 } |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1646 else |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1647 { |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1648 // create basic blocks |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1649 llvm::BasicBlock* oldend = p->scopeend(); |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1650 llvm::BasicBlock* assertbb = llvm::BasicBlock::Create("assert", p->topfunc(), oldend); |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1651 llvm::BasicBlock* endbb = llvm::BasicBlock::Create("noassert", p->topfunc(), oldend); |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1652 |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1653 // test condition |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1654 LLValue* condval = DtoBoolean(loc, cond); |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1655 |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1656 // branch |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1657 llvm::BranchInst::Create(endbb, assertbb, condval, p->scopebb()); |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1658 |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1659 // call assert runtime functions |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1660 p->scope() = IRScope(assertbb,endbb); |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1661 DtoAssert(&loc, msg ? msg->toElem(p) : NULL); |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1662 |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1663 // rewrite the scope |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1664 p->scope() = IRScope(endbb,oldend); |
d30c40f1128d
Make class invariants work.
Christian Kamm <kamm incasoftware de>
parents:
525
diff
changeset
|
1665 } |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1666 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1667 // no meaningful return value |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1668 return NULL; |
1 | 1669 } |
1670 | |
1671 ////////////////////////////////////////////////////////////////////////////////////////// | |
1672 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1673 DValue* NotExp::toElem(IRState* p) |
1 | 1674 { |
1675 Logger::print("NotExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1676 LOG_SCOPE; | |
1677 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1678 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
|
1679 |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
1680 LLValue* b = DtoBoolean(loc, u); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1681 |
611
83ca663ecc20
Backed out changeset 1b62222581fb
Christian Kamm <kamm incasoftware de>
parents:
610
diff
changeset
|
1682 LLConstant* zero = DtoConstBool(false); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1683 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
|
1684 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1685 return new DImValue(type, b); |
1 | 1686 } |
1687 | |
1688 ////////////////////////////////////////////////////////////////////////////////////////// | |
1689 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1690 DValue* AndAndExp::toElem(IRState* p) |
1 | 1691 { |
1692 Logger::print("AndAndExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1693 LOG_SCOPE; | |
1694 | |
1695 // 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
|
1696 LLValue* resval = 0; |
1 | 1697 llvm::BasicBlock* entryblock = &p->topfunc()->front(); |
479
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
469
diff
changeset
|
1698 resval = DtoAlloca(LLType::Int1Ty,"andandtmp"); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1699 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1700 DValue* u = e1->toElem(p); |
1 | 1701 |
1702 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
|
1703 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
|
1704 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
|
1705 |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
1706 LLValue* ubool = DtoBoolean(loc, u); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1707 DtoStore(ubool,resval); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
1708 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
|
1709 |
1 | 1710 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
|
1711 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
|
1712 |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
1713 LLValue* vbool = DtoBoolean(loc, v); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1714 LLValue* uandvbool = llvm::BinaryOperator::create(llvm::BinaryOperator::And, ubool, vbool,"tmp",p->scopebb()); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1715 DtoStore(uandvbool,resval); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
1716 llvm::BranchInst::Create(andandend,p->scopebb()); |
1 | 1717 |
1718 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
|
1719 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1720 resval = DtoLoad(resval); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1721 return new DImValue(type, resval); |
1 | 1722 } |
1723 | |
1724 ////////////////////////////////////////////////////////////////////////////////////////// | |
1725 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1726 DValue* OrOrExp::toElem(IRState* p) |
1 | 1727 { |
1728 Logger::print("OrOrExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1729 LOG_SCOPE; | |
1730 | |
1731 // 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
|
1732 LLValue* resval = 0; |
1 | 1733 llvm::BasicBlock* entryblock = &p->topfunc()->front(); |
479
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
469
diff
changeset
|
1734 resval = DtoAlloca(LLType::Int1Ty,"orortmp"); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1735 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1736 DValue* u = e1->toElem(p); |
1 | 1737 |
1738 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
|
1739 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
|
1740 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
|
1741 |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
1742 LLValue* ubool = DtoBoolean(loc, u); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1743 DtoStore(ubool,resval); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
1744 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
|
1745 |
1 | 1746 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
|
1747 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
|
1748 |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
1749 LLValue* vbool = DtoBoolean(loc, v); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1750 DtoStore(vbool,resval); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
1751 llvm::BranchInst::Create(ororend,p->scopebb()); |
1 | 1752 |
1753 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
|
1754 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1755 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
|
1756 return new DImValue(type, resval); |
1 | 1757 } |
1758 | |
1759 ////////////////////////////////////////////////////////////////////////////////////////// | |
1760 | |
1761 #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
|
1762 DValue* X##Exp::toElem(IRState* p) \ |
1 | 1763 { \ |
1764 Logger::print("%sExp::toElem: %s | %s\n", #X, toChars(), type->toChars()); \ | |
1765 LOG_SCOPE; \ | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1766 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
|
1767 DValue* v = e2->toElem(p); \ |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1768 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
|
1769 return new DImValue(type, x); \ |
1 | 1770 } \ |
1771 \ | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1772 DValue* X##AssignExp::toElem(IRState* p) \ |
1 | 1773 { \ |
1774 Logger::print("%sAssignExp::toElem: %s | %s\n", #X, toChars(), type->toChars()); \ | |
1775 LOG_SCOPE; \ | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1776 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
|
1777 DValue* v = e2->toElem(p); \ |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1778 LLValue* uval = u->getRVal(); \ |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1779 LLValue* vval = v->getRVal(); \ |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1780 LLValue* tmp = llvm::BinaryOperator::create(llvm::Instruction::Y, uval, vval, "tmp", p->scopebb()); \ |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1781 DtoStore(DtoPointedType(u->getLVal(), tmp), u->getLVal()); \ |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1782 return u; \ |
1 | 1783 } |
1784 | |
1785 BinBitExp(And,And); | |
1786 BinBitExp(Or,Or); | |
1787 BinBitExp(Xor,Xor); | |
1788 BinBitExp(Shl,Shl); | |
1789 BinBitExp(Ushr,LShr); | |
1790 | |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
264
diff
changeset
|
1791 DValue* ShrExp::toElem(IRState* p) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
264
diff
changeset
|
1792 { |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
264
diff
changeset
|
1793 Logger::print("ShrExp::toElem: %s | %s\n", toChars(), type->toChars()); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
264
diff
changeset
|
1794 LOG_SCOPE; |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
264
diff
changeset
|
1795 DValue* u = e1->toElem(p); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
264
diff
changeset
|
1796 DValue* v = e2->toElem(p); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
264
diff
changeset
|
1797 LLValue* x; |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
264
diff
changeset
|
1798 if (e1->type->isunsigned()) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
264
diff
changeset
|
1799 x = p->ir->CreateLShr(u->getRVal(), v->getRVal(), "tmp"); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
264
diff
changeset
|
1800 else |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
264
diff
changeset
|
1801 x = p->ir->CreateAShr(u->getRVal(), v->getRVal(), "tmp"); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
264
diff
changeset
|
1802 return new DImValue(type, x); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
264
diff
changeset
|
1803 } |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
264
diff
changeset
|
1804 |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
264
diff
changeset
|
1805 DValue* ShrAssignExp::toElem(IRState* p) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
264
diff
changeset
|
1806 { |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
264
diff
changeset
|
1807 Logger::print("ShrAssignExp::toElem: %s | %s\n", toChars(), type->toChars()); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
264
diff
changeset
|
1808 LOG_SCOPE; |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
264
diff
changeset
|
1809 DValue* u = e1->toElem(p); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
264
diff
changeset
|
1810 DValue* v = e2->toElem(p); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
264
diff
changeset
|
1811 LLValue* uval = u->getRVal(); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
264
diff
changeset
|
1812 LLValue* vval = v->getRVal(); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
264
diff
changeset
|
1813 LLValue* tmp; |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
264
diff
changeset
|
1814 if (e1->type->isunsigned()) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
264
diff
changeset
|
1815 tmp = p->ir->CreateLShr(uval, vval, "tmp"); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
264
diff
changeset
|
1816 else |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
264
diff
changeset
|
1817 tmp = p->ir->CreateAShr(uval, vval, "tmp"); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
264
diff
changeset
|
1818 DtoStore(DtoPointedType(u->getLVal(), tmp), u->getLVal()); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
264
diff
changeset
|
1819 return u; |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
264
diff
changeset
|
1820 } |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
264
diff
changeset
|
1821 |
1 | 1822 ////////////////////////////////////////////////////////////////////////////////////////// |
1823 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1824 DValue* HaltExp::toElem(IRState* p) |
1 | 1825 { |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
259
diff
changeset
|
1826 Logger::print("HaltExp::toElem: %s\n", toChars()); |
1 | 1827 LOG_SCOPE; |
1828 | |
363 | 1829 // FIXME: DMD inserts a trap here... we probably should as well !?! |
1830 | |
281
f5f97ca47b33
[svn r302] Make HaltExps and assert(0) generate an assert message again instead of using llvm's trap intrinsic.
ChristianK
parents:
275
diff
changeset
|
1831 #if 1 |
258
8dbddae09152
[svn r276] Fixed debug info for 'this' arg seemed to be broken.
lindquist
parents:
245
diff
changeset
|
1832 DtoAssert(&loc, NULL); |
8dbddae09152
[svn r276] Fixed debug info for 'this' arg seemed to be broken.
lindquist
parents:
245
diff
changeset
|
1833 #else |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
1834 // call the new (?) trap intrinsic |
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
1835 p->ir->CreateCall(GET_INTRINSIC_DECL(trap),""); |
291
068cb3c60afb
[svn r312] Changed assert codegen to insert an unreachable terminator after the call to the assert function, which currently calls abort().
lindquist
parents:
286
diff
changeset
|
1836 new llvm::UnreachableInst(p->scopebb()); |
258
8dbddae09152
[svn r276] Fixed debug info for 'this' arg seemed to be broken.
lindquist
parents:
245
diff
changeset
|
1837 #endif |
36
c0967c4b2a74
[svn r40] Cleaned up some of the array routines to use gep/load/store instead of memcpy/memset.
lindquist
parents:
34
diff
changeset
|
1838 |
282
74348f162225
[svn r303] Start a new basicblock behind a HaltExp to prevent compiler errors.
ChristianK
parents:
281
diff
changeset
|
1839 // this terminated the basicblock, start a new one |
74348f162225
[svn r303] Start a new basicblock behind a HaltExp to prevent compiler errors.
ChristianK
parents:
281
diff
changeset
|
1840 // this is sensible, since someone might goto behind the assert |
74348f162225
[svn r303] Start a new basicblock behind a HaltExp to prevent compiler errors.
ChristianK
parents:
281
diff
changeset
|
1841 // and prevents compiler errors if a terminator follows the assert |
74348f162225
[svn r303] Start a new basicblock behind a HaltExp to prevent compiler errors.
ChristianK
parents:
281
diff
changeset
|
1842 llvm::BasicBlock* oldend = gIR->scopeend(); |
74348f162225
[svn r303] Start a new basicblock behind a HaltExp to prevent compiler errors.
ChristianK
parents:
281
diff
changeset
|
1843 llvm::BasicBlock* bb = llvm::BasicBlock::Create("afterhalt", p->topfunc(), oldend); |
74348f162225
[svn r303] Start a new basicblock behind a HaltExp to prevent compiler errors.
ChristianK
parents:
281
diff
changeset
|
1844 p->scope() = IRScope(bb,oldend); |
74348f162225
[svn r303] Start a new basicblock behind a HaltExp to prevent compiler errors.
ChristianK
parents:
281
diff
changeset
|
1845 |
1 | 1846 return 0; |
1847 } | |
1848 | |
1849 ////////////////////////////////////////////////////////////////////////////////////////// | |
1850 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1851 DValue* DelegateExp::toElem(IRState* p) |
1 | 1852 { |
1853 Logger::print("DelegateExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1854 LOG_SCOPE; | |
1855 | |
426
e763821ab244
Disallow delegates to static functions.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
1856 if(func->isStatic()) |
e763821ab244
Disallow delegates to static functions.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
1857 error("can't take delegate of static function %s, it does not require a context ptr", func->toChars()); |
e763821ab244
Disallow delegates to static functions.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
1858 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1859 const LLPointerType* int8ptrty = getPtrToType(LLType::Int8Ty); |
1 | 1860 |
479
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
469
diff
changeset
|
1861 LLValue* lval = DtoAlloca(DtoType(type), "tmpdelegate"); |
1 | 1862 |
143
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
1863 DValue* u = e1->toElem(p); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1864 LLValue* uval; |
119
79c9ac745fbc
[svn r123] Fixed some typeinfo module name mismatches.
lindquist
parents:
118
diff
changeset
|
1865 if (DFuncValue* f = u->isFunc()) { |
634
0084d2c76b74
Fixed problem with taking the delegate of a nested function of the current function.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
629
diff
changeset
|
1866 assert(f->func); |
0084d2c76b74
Fixed problem with taking the delegate of a nested function of the current function.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
629
diff
changeset
|
1867 LLValue* contextptr = DtoNestedContext(loc, f->func); |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
1868 uval = DtoBitCast(contextptr, getVoidPtrType()); |
119
79c9ac745fbc
[svn r123] Fixed some typeinfo module name mismatches.
lindquist
parents:
118
diff
changeset
|
1869 } |
79c9ac745fbc
[svn r123] Fixed some typeinfo module name mismatches.
lindquist
parents:
118
diff
changeset
|
1870 else { |
143
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
1871 DValue* src = u; |
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
1872 if (ClassDeclaration* cd = u->getType()->isClassHandle()) |
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
1873 { |
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
1874 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
|
1875 if (cd->isInterfaceDeclaration()) |
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
1876 { |
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
1877 Logger::println("context type is interface"); |
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
1878 src = DtoCastInterfaceToObject(u, ClassDeclaration::object->type); |
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
1879 } |
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
1880 } |
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
1881 uval = src->getRVal(); |
119
79c9ac745fbc
[svn r123] Fixed some typeinfo module name mismatches.
lindquist
parents:
118
diff
changeset
|
1882 } |
79c9ac745fbc
[svn r123] Fixed some typeinfo module name mismatches.
lindquist
parents:
118
diff
changeset
|
1883 |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
619
diff
changeset
|
1884 if (Logger::enabled()) |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
619
diff
changeset
|
1885 Logger::cout() << "context = " << *uval << '\n'; |
143
336ec4f4bbb3
[svn r147] tango.io.Console is now working. True this time :) Yay!
lindquist
parents:
137
diff
changeset
|
1886 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1887 LLValue* context = DtoGEPi(lval,0,0); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1888 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
|
1889 DtoStore(castcontext, context); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1890 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1891 LLValue* fptr = DtoGEPi(lval,0,1); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1892 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1893 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
|
1894 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1895 LLValue* castfptr; |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1896 if (func->isVirtual()) |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1897 castfptr = DtoVirtualFunctionPointer(u, func); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1898 else if (func->isAbstract()) |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1899 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
|
1900 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
|
1901 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
|
1902 else |
150
2c336566ffed
[svn r156] added a testcase for the most annoying bug ever
lindquist
parents:
144
diff
changeset
|
1903 { |
2c336566ffed
[svn r156] added a testcase for the most annoying bug ever
lindquist
parents:
144
diff
changeset
|
1904 DtoForceDeclareDsymbol(func); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
172
diff
changeset
|
1905 castfptr = func->ir.irFunc->func; |
150
2c336566ffed
[svn r156] added a testcase for the most annoying bug ever
lindquist
parents:
144
diff
changeset
|
1906 } |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1907 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1908 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
|
1909 DtoStore(castfptr, fptr); |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
1910 |
334 | 1911 return new DImValue(type, lval); |
1 | 1912 } |
1913 | |
1914 ////////////////////////////////////////////////////////////////////////////////////////// | |
1915 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1916 DValue* IdentityExp::toElem(IRState* p) |
1 | 1917 { |
1918 Logger::print("IdentityExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1919 LOG_SCOPE; | |
1920 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1921 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
|
1922 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
|
1923 |
308
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1924 Type* t1 = e1->type->toBasetype(); |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1925 |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1926 // handle dynarray specially |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1927 if (t1->ty == Tarray) |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1928 return new DImValue(type, DtoDynArrayIs(op,u,v)); |
345
5320fe65a65d
[svn r366] Fixed identity exprs for structs was comparing addresses, not content!
lindquist
parents:
344
diff
changeset
|
1929 // also structs |
5320fe65a65d
[svn r366] Fixed identity exprs for structs was comparing addresses, not content!
lindquist
parents:
344
diff
changeset
|
1930 else if (t1->ty == Tstruct) |
5320fe65a65d
[svn r366] Fixed identity exprs for structs was comparing addresses, not content!
lindquist
parents:
344
diff
changeset
|
1931 return new DImValue(type, DtoStructEquals(op,u,v)); |
5320fe65a65d
[svn r366] Fixed identity exprs for structs was comparing addresses, not content!
lindquist
parents:
344
diff
changeset
|
1932 |
5320fe65a65d
[svn r366] Fixed identity exprs for structs was comparing addresses, not content!
lindquist
parents:
344
diff
changeset
|
1933 // FIXME this stuff isn't pretty |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1934 LLValue* l = u->getRVal(); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1935 LLValue* r = v->getRVal(); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1936 LLValue* eval = 0; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1937 |
308
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
295
diff
changeset
|
1938 if (t1->ty == Tdelegate) { |
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
|
1939 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
|
1940 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
|
1941 } |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
156
diff
changeset
|
1942 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
|
1943 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
|
1944 } |
344
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
340
diff
changeset
|
1945 eval = DtoDelegateEquals(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
|
1946 } |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
1947 else if (t1->isfloating()) |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
1948 { |
365 | 1949 eval = (op == TOKidentity) |
1950 ? p->ir->CreateFCmpOEQ(l,r,"tmp") | |
1951 : p->ir->CreateFCmpONE(l,r,"tmp"); | |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
1952 } |
629
607b6b5819a7
Fixed issue with IsExpression and potential type mismatch for classes.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
628
diff
changeset
|
1953 else if (t1->ty == Tpointer || t1->ty == Tclass) |
167
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
1954 { |
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
1955 if (l->getType() != r->getType()) { |
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
1956 if (v->isNull()) |
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
1957 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
|
1958 else |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
1959 r = DtoBitCast(r, l->getType()); |
167
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
1960 } |
365 | 1961 eval = (op == TOKidentity) |
1962 ? p->ir->CreateICmpEQ(l,r,"tmp") | |
1963 : p->ir->CreateICmpNE(l,r,"tmp"); | |
167
adca7f32fb6d
[svn r183] Fixed broken identity expressions with two pointers of different types.
lindquist
parents:
164
diff
changeset
|
1964 } |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
1965 else { |
629
607b6b5819a7
Fixed issue with IsExpression and potential type mismatch for classes.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
628
diff
changeset
|
1966 assert(l->getType() == r->getType()); |
365 | 1967 eval = (op == TOKidentity) |
1968 ? p->ir->CreateICmpEQ(l,r,"tmp") | |
1969 : p->ir->CreateICmpNE(l,r,"tmp"); | |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
1970 } |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1971 return new DImValue(type, eval); |
1 | 1972 } |
1973 | |
1974 ////////////////////////////////////////////////////////////////////////////////////////// | |
1975 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1976 DValue* CommaExp::toElem(IRState* p) |
1 | 1977 { |
1978 Logger::print("CommaExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1979 LOG_SCOPE; | |
1980 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1981 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
|
1982 DValue* v = e2->toElem(p); |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
143
diff
changeset
|
1983 assert(e2->type == type); |
1 | 1984 return v; |
1985 } | |
1986 | |
1987 ////////////////////////////////////////////////////////////////////////////////////////// | |
1988 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1989 DValue* CondExp::toElem(IRState* p) |
1 | 1990 { |
1991 Logger::print("CondExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
1992 LOG_SCOPE; | |
1993 | |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
1994 Type* dtype = type->toBasetype(); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
1995 const LLType* resty = DtoType(dtype); |
1 | 1996 |
1997 // allocate a temporary for the final result. failed to come up with a better way :/ | |
1998 llvm::BasicBlock* entryblock = &p->topfunc()->front(); | |
479
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
469
diff
changeset
|
1999 LLValue* resval = DtoAlloca(resty,"condtmp"); |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
2000 DVarValue* dvv = new DVarValue(type, resval); |
1 | 2001 |
2002 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
|
2003 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
|
2004 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
|
2005 llvm::BasicBlock* condend = llvm::BasicBlock::Create("condend", gIR->topfunc(), oldend); |
1 | 2006 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2007 DValue* c = econd->toElem(p); |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
2008 LLValue* cond_val = DtoBoolean(loc, c); |
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
|
2009 llvm::BranchInst::Create(condtrue,condfalse,cond_val,p->scopebb()); |
1 | 2010 |
2011 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
|
2012 DValue* u = e1->toElem(p); |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
2013 DtoAssign(loc, 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
|
2014 llvm::BranchInst::Create(condend,p->scopebb()); |
1 | 2015 |
2016 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
|
2017 DValue* v = e2->toElem(p); |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
2018 DtoAssign(loc, 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
|
2019 llvm::BranchInst::Create(condend,p->scopebb()); |
1 | 2020 |
2021 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
|
2022 return dvv; |
1 | 2023 } |
2024 | |
2025 ////////////////////////////////////////////////////////////////////////////////////////// | |
2026 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2027 DValue* ComExp::toElem(IRState* p) |
1 | 2028 { |
2029 Logger::print("ComExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2030 LOG_SCOPE; | |
2031 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2032 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
|
2033 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2034 LLValue* value = u->getRVal(); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2035 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
|
2036 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
|
2037 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2038 return new DImValue(type, value); |
1 | 2039 } |
2040 | |
2041 ////////////////////////////////////////////////////////////////////////////////////////// | |
2042 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2043 DValue* NegExp::toElem(IRState* p) |
23 | 2044 { |
2045 Logger::print("NegExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2046 LOG_SCOPE; | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2047 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2048 DValue* l = e1->toElem(p); |
164
a64becf2a702
[svn r180] Fixed complex negation, and tango.math.Math now compiles.
lindquist
parents:
163
diff
changeset
|
2049 |
a64becf2a702
[svn r180] Fixed complex negation, and tango.math.Math now compiles.
lindquist
parents:
163
diff
changeset
|
2050 if (type->iscomplex()) { |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
2051 return DtoComplexNeg(loc, type, l); |
164
a64becf2a702
[svn r180] Fixed complex negation, and tango.math.Math now compiles.
lindquist
parents:
163
diff
changeset
|
2052 } |
a64becf2a702
[svn r180] Fixed complex negation, and tango.math.Math now compiles.
lindquist
parents:
163
diff
changeset
|
2053 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2054 LLValue* val = l->getRVal(); |
616
5ced42a55aa9
Fix NegExp not to use substraction.
Christian Kamm <kamm incasoftware de>
parents:
611
diff
changeset
|
2055 |
5ced42a55aa9
Fix NegExp not to use substraction.
Christian Kamm <kamm incasoftware de>
parents:
611
diff
changeset
|
2056 val = gIR->ir->CreateNeg(val,"negval"); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2057 return new DImValue(type, val); |
23 | 2058 } |
2059 | |
2060 ////////////////////////////////////////////////////////////////////////////////////////// | |
2061 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2062 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
|
2063 { |
c0967c4b2a74
[svn r40] Cleaned up some of the array routines to use gep/load/store instead of memcpy/memset.
lindquist
parents:
34
diff
changeset
|
2064 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
|
2065 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
|
2066 |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
2067 Type* t = type->toBasetype(); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
2068 |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
2069 bool arrNarr = e1->type->toBasetype() == e2->type->toBasetype(); |
132 | 2070 |
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
|
2071 // 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
|
2072 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
|
2073 { |
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
|
2074 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
|
2075 } |
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
|
2076 // 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
|
2077 // 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
|
2078 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
|
2079 { |
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
|
2080 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
|
2081 } |
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
|
2082 } |
c0967c4b2a74
[svn r40] Cleaned up some of the array routines to use gep/load/store instead of memcpy/memset.
lindquist
parents:
34
diff
changeset
|
2083 |
c0967c4b2a74
[svn r40] Cleaned up some of the array routines to use gep/load/store instead of memcpy/memset.
lindquist
parents:
34
diff
changeset
|
2084 ////////////////////////////////////////////////////////////////////////////////////////// |
c0967c4b2a74
[svn r40] Cleaned up some of the array routines to use gep/load/store instead of memcpy/memset.
lindquist
parents:
34
diff
changeset
|
2085 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2086 DValue* CatAssignExp::toElem(IRState* p) |
40 | 2087 { |
2088 Logger::print("CatAssignExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2089 LOG_SCOPE; | |
2090 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2091 DValue* l = e1->toElem(p); |
40 | 2092 |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
2093 Type* e1type = e1->type->toBasetype(); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
2094 Type* elemtype = e1type->next->toBasetype(); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
2095 Type* e2type = e2->type->toBasetype(); |
40 | 2096 |
2097 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
|
2098 DSliceValue* slice = DtoCatAssignElement(l,e2); |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
2099 DtoAssign(loc, l, slice); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2100 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2101 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
|
2102 DSliceValue* slice = DtoCatAssignArray(l,e2); |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
2103 DtoAssign(loc, l, slice); |
40 | 2104 } |
2105 else | |
2106 assert(0 && "only one element at a time right now"); | |
2107 | |
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
|
2108 return l; |
40 | 2109 } |
2110 | |
2111 ////////////////////////////////////////////////////////////////////////////////////////// | |
2112 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2113 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
|
2114 { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2115 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
|
2116 LOG_SCOPE; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2117 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2118 assert(fd); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2119 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2120 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
|
2121 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
|
2122 |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
2123 DtoForceDefineDsymbol(fd); |
521
99e95dae90d5
Do not need to allocate temporary for function literal.
Christian Kamm <kamm incasoftware de>
parents:
520
diff
changeset
|
2124 assert(fd->ir.irFunc->func); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2125 |
520
73e41129b7f3
Fix function literals. They never carry a context.
Christian Kamm <kamm incasoftware de>
parents:
512
diff
changeset
|
2126 LLValue *lval, *fptr; |
73e41129b7f3
Fix function literals. They never carry a context.
Christian Kamm <kamm incasoftware de>
parents:
512
diff
changeset
|
2127 if(fd->tok == TOKdelegate) { |
73e41129b7f3
Fix function literals. They never carry a context.
Christian Kamm <kamm incasoftware de>
parents:
512
diff
changeset
|
2128 const LLType* dgty = DtoType(type); |
73e41129b7f3
Fix function literals. They never carry a context.
Christian Kamm <kamm incasoftware de>
parents:
512
diff
changeset
|
2129 lval = DtoAlloca(dgty,"dgstorage"); |
73e41129b7f3
Fix function literals. They never carry a context.
Christian Kamm <kamm incasoftware de>
parents:
512
diff
changeset
|
2130 |
73e41129b7f3
Fix function literals. They never carry a context.
Christian Kamm <kamm incasoftware de>
parents:
512
diff
changeset
|
2131 LLValue* context = DtoGEPi(lval,0,0); |
73e41129b7f3
Fix function literals. They never carry a context.
Christian Kamm <kamm incasoftware de>
parents:
512
diff
changeset
|
2132 LLValue* cval; |
73e41129b7f3
Fix function literals. They never carry a context.
Christian Kamm <kamm incasoftware de>
parents:
512
diff
changeset
|
2133 IrFunction* irfn = p->func(); |
73e41129b7f3
Fix function literals. They never carry a context.
Christian Kamm <kamm incasoftware de>
parents:
512
diff
changeset
|
2134 if (irfn->nestedVar) |
73e41129b7f3
Fix function literals. They never carry a context.
Christian Kamm <kamm incasoftware de>
parents:
512
diff
changeset
|
2135 cval = irfn->nestedVar; |
73e41129b7f3
Fix function literals. They never carry a context.
Christian Kamm <kamm incasoftware de>
parents:
512
diff
changeset
|
2136 else if (irfn->nestArg) |
73e41129b7f3
Fix function literals. They never carry a context.
Christian Kamm <kamm incasoftware de>
parents:
512
diff
changeset
|
2137 cval = irfn->nestArg; |
73e41129b7f3
Fix function literals. They never carry a context.
Christian Kamm <kamm incasoftware de>
parents:
512
diff
changeset
|
2138 else |
73e41129b7f3
Fix function literals. They never carry a context.
Christian Kamm <kamm incasoftware de>
parents:
512
diff
changeset
|
2139 cval = getNullPtr(getVoidPtrType()); |
73e41129b7f3
Fix function literals. They never carry a context.
Christian Kamm <kamm incasoftware de>
parents:
512
diff
changeset
|
2140 cval = DtoBitCast(cval, context->getType()->getContainedType(0)); |
73e41129b7f3
Fix function literals. They never carry a context.
Christian Kamm <kamm incasoftware de>
parents:
512
diff
changeset
|
2141 DtoStore(cval, context); |
73e41129b7f3
Fix function literals. They never carry a context.
Christian Kamm <kamm incasoftware de>
parents:
512
diff
changeset
|
2142 |
73e41129b7f3
Fix function literals. They never carry a context.
Christian Kamm <kamm incasoftware de>
parents:
512
diff
changeset
|
2143 fptr = DtoGEPi(lval,0,1,"tmp",p->scopebb()); |
521
99e95dae90d5
Do not need to allocate temporary for function literal.
Christian Kamm <kamm incasoftware de>
parents:
520
diff
changeset
|
2144 |
99e95dae90d5
Do not need to allocate temporary for function literal.
Christian Kamm <kamm incasoftware de>
parents:
520
diff
changeset
|
2145 LLValue* castfptr = DtoBitCast(fd->ir.irFunc->func, fptr->getType()->getContainedType(0)); |
99e95dae90d5
Do not need to allocate temporary for function literal.
Christian Kamm <kamm incasoftware de>
parents:
520
diff
changeset
|
2146 DtoStore(castfptr, fptr); |
99e95dae90d5
Do not need to allocate temporary for function literal.
Christian Kamm <kamm incasoftware de>
parents:
520
diff
changeset
|
2147 |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
2148 return new DVarValue(type, lval); |
521
99e95dae90d5
Do not need to allocate temporary for function literal.
Christian Kamm <kamm incasoftware de>
parents:
520
diff
changeset
|
2149 |
520
73e41129b7f3
Fix function literals. They never carry a context.
Christian Kamm <kamm incasoftware de>
parents:
512
diff
changeset
|
2150 } else if(fd->tok == TOKfunction) { |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
2151 return new DImValue(type, fd->ir.irFunc->func); |
520
73e41129b7f3
Fix function literals. They never carry a context.
Christian Kamm <kamm incasoftware de>
parents:
512
diff
changeset
|
2152 } |
521
99e95dae90d5
Do not need to allocate temporary for function literal.
Christian Kamm <kamm incasoftware de>
parents:
520
diff
changeset
|
2153 |
99e95dae90d5
Do not need to allocate temporary for function literal.
Christian Kamm <kamm incasoftware de>
parents:
520
diff
changeset
|
2154 assert(0 && "fd->tok must be TOKfunction or TOKdelegate"); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2155 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2156 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2157 ////////////////////////////////////////////////////////////////////////////////////////// |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2158 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2159 DValue* ArrayLiteralExp::toElem(IRState* p) |
40 | 2160 { |
2161 Logger::print("ArrayLiteralExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2162 LOG_SCOPE; | |
2163 | |
175
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2164 // D types |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2165 Type* arrayType = type->toBasetype(); |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2166 Type* elemType = arrayType->nextOf()->toBasetype(); |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2167 |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2168 // is dynamic ? |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2169 bool dyn = (arrayType->ty == Tarray); |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2170 // length |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2171 size_t len = elements->dim; |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2172 |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2173 // llvm target type |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2174 const LLType* llType = DtoType(arrayType); |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
619
diff
changeset
|
2175 if (Logger::enabled()) |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
619
diff
changeset
|
2176 Logger::cout() << (dyn?"dynamic":"static") << " array literal with length " << len << " of D type: '" << arrayType->toChars() << "' has llvm type: '" << *llType << "'\n"; |
175
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2177 |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2178 // llvm storage type |
587
23538d0f0d5b
Fixed a few mini tests issues.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
585
diff
changeset
|
2179 const LLType* llElemType = DtoTypeNotVoid(elemType); |
23538d0f0d5b
Fixed a few mini tests issues.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
585
diff
changeset
|
2180 const LLType* llStoType = LLArrayType::get(llElemType, len); |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
619
diff
changeset
|
2181 if (Logger::enabled()) |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
619
diff
changeset
|
2182 Logger::cout() << "llvm storage type: '" << *llStoType << "'\n"; |
175
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2183 |
587
23538d0f0d5b
Fixed a few mini tests issues.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
585
diff
changeset
|
2184 // don't allocate storage for zero length dynamic array literals |
23538d0f0d5b
Fixed a few mini tests issues.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
585
diff
changeset
|
2185 if (dyn && len == 0) |
23538d0f0d5b
Fixed a few mini tests issues.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
585
diff
changeset
|
2186 { |
23538d0f0d5b
Fixed a few mini tests issues.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
585
diff
changeset
|
2187 // dmd seems to just make them null... |
23538d0f0d5b
Fixed a few mini tests issues.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
585
diff
changeset
|
2188 return new DSliceValue(type, DtoConstSize_t(0), getNullPtr(getPtrToType(llElemType))); |
23538d0f0d5b
Fixed a few mini tests issues.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
585
diff
changeset
|
2189 } |
23538d0f0d5b
Fixed a few mini tests issues.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
585
diff
changeset
|
2190 |
175
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2191 // dst pointer |
592
5fb7ed0ac580
Allocate dynamic array literals on the heap.
Christian Kamm <kamm incasoftware de>
parents:
591
diff
changeset
|
2192 LLValue* dstMem; |
5fb7ed0ac580
Allocate dynamic array literals on the heap.
Christian Kamm <kamm incasoftware de>
parents:
591
diff
changeset
|
2193 DSliceValue* dynSlice = NULL; |
5fb7ed0ac580
Allocate dynamic array literals on the heap.
Christian Kamm <kamm incasoftware de>
parents:
591
diff
changeset
|
2194 if(dyn) |
5fb7ed0ac580
Allocate dynamic array literals on the heap.
Christian Kamm <kamm incasoftware de>
parents:
591
diff
changeset
|
2195 { |
5fb7ed0ac580
Allocate dynamic array literals on the heap.
Christian Kamm <kamm incasoftware de>
parents:
591
diff
changeset
|
2196 dynSlice = DtoNewDynArray(loc, arrayType, new DConstValue(Type::tsize_t, DtoConstSize_t(len)), false); |
5fb7ed0ac580
Allocate dynamic array literals on the heap.
Christian Kamm <kamm incasoftware de>
parents:
591
diff
changeset
|
2197 dstMem = dynSlice->ptr; |
5fb7ed0ac580
Allocate dynamic array literals on the heap.
Christian Kamm <kamm incasoftware de>
parents:
591
diff
changeset
|
2198 } |
5fb7ed0ac580
Allocate dynamic array literals on the heap.
Christian Kamm <kamm incasoftware de>
parents:
591
diff
changeset
|
2199 else |
5fb7ed0ac580
Allocate dynamic array literals on the heap.
Christian Kamm <kamm incasoftware de>
parents:
591
diff
changeset
|
2200 dstMem = DtoAlloca(llStoType, "arrayliteral"); |
175
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2201 |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2202 // store elements |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2203 for (size_t i=0; i<len; ++i) |
40 | 2204 { |
2205 Expression* expr = (Expression*)elements->data[i]; | |
592
5fb7ed0ac580
Allocate dynamic array literals on the heap.
Christian Kamm <kamm incasoftware de>
parents:
591
diff
changeset
|
2206 LLValue* elemAddr; |
5fb7ed0ac580
Allocate dynamic array literals on the heap.
Christian Kamm <kamm incasoftware de>
parents:
591
diff
changeset
|
2207 if(dyn) |
5fb7ed0ac580
Allocate dynamic array literals on the heap.
Christian Kamm <kamm incasoftware de>
parents:
591
diff
changeset
|
2208 elemAddr = DtoGEPi1(dstMem, i, "tmp", p->scopebb()); |
5fb7ed0ac580
Allocate dynamic array literals on the heap.
Christian Kamm <kamm incasoftware de>
parents:
591
diff
changeset
|
2209 else |
5fb7ed0ac580
Allocate dynamic array literals on the heap.
Christian Kamm <kamm incasoftware de>
parents:
591
diff
changeset
|
2210 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
|
2211 |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2212 // emulate assignment |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
2213 DVarValue* vv = new DVarValue(expr->type, elemAddr); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2214 DValue* e = expr->toElem(p); |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
2215 DtoAssign(loc, vv, e); |
40 | 2216 } |
2217 | |
175
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
2218 // return storage directly ? |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
2219 if (!dyn) |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
2220 return new DImValue(type, dstMem); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
2221 |
592
5fb7ed0ac580
Allocate dynamic array literals on the heap.
Christian Kamm <kamm incasoftware de>
parents:
591
diff
changeset
|
2222 // return slice |
5fb7ed0ac580
Allocate dynamic array literals on the heap.
Christian Kamm <kamm incasoftware de>
parents:
591
diff
changeset
|
2223 return dynSlice; |
40 | 2224 } |
2225 | |
2226 ////////////////////////////////////////////////////////////////////////////////////////// | |
2227 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2228 LLConstant* ArrayLiteralExp::toConstElem(IRState* p) |
40 | 2229 { |
2230 Logger::print("ArrayLiteralExp::toConstElem: %s | %s\n", toChars(), type->toChars()); | |
2231 LOG_SCOPE; | |
2232 | |
602
48f079b4fe0f
Fixed ArrayLiteralExp::toConstElem for dynamic arrays, tango-user library should now be possible to build. It seems to be related to DMD bug 2356, which must have been introduced recently, as we already handled this fine for ArrayInitializers, just not ArrayLiterals... Kinda annoying to have to do this work due to DMD bugs ...
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
600
diff
changeset
|
2233 // extract D types |
48f079b4fe0f
Fixed ArrayLiteralExp::toConstElem for dynamic arrays, tango-user library should now be possible to build. It seems to be related to DMD bug 2356, which must have been introduced recently, as we already handled this fine for ArrayInitializers, just not ArrayLiterals... Kinda annoying to have to do this work due to DMD bugs ...
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
600
diff
changeset
|
2234 Type* bt = type->toBasetype(); |
48f079b4fe0f
Fixed ArrayLiteralExp::toConstElem for dynamic arrays, tango-user library should now be possible to build. It seems to be related to DMD bug 2356, which must have been introduced recently, as we already handled this fine for ArrayInitializers, just not ArrayLiterals... Kinda annoying to have to do this work due to DMD bugs ...
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
600
diff
changeset
|
2235 Type* elemt = bt->next; |
48f079b4fe0f
Fixed ArrayLiteralExp::toConstElem for dynamic arrays, tango-user library should now be possible to build. It seems to be related to DMD bug 2356, which must have been introduced recently, as we already handled this fine for ArrayInitializers, just not ArrayLiterals... Kinda annoying to have to do this work due to DMD bugs ...
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
600
diff
changeset
|
2236 |
48f079b4fe0f
Fixed ArrayLiteralExp::toConstElem for dynamic arrays, tango-user library should now be possible to build. It seems to be related to DMD bug 2356, which must have been introduced recently, as we already handled this fine for ArrayInitializers, just not ArrayLiterals... Kinda annoying to have to do this work due to DMD bugs ...
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
600
diff
changeset
|
2237 // build llvm array type |
48f079b4fe0f
Fixed ArrayLiteralExp::toConstElem for dynamic arrays, tango-user library should now be possible to build. It seems to be related to DMD bug 2356, which must have been introduced recently, as we already handled this fine for ArrayInitializers, just not ArrayLiterals... Kinda annoying to have to do this work due to DMD bugs ...
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
600
diff
changeset
|
2238 const LLArrayType* arrtype = LLArrayType::get(DtoType(elemt), elements->dim); |
48f079b4fe0f
Fixed ArrayLiteralExp::toConstElem for dynamic arrays, tango-user library should now be possible to build. It seems to be related to DMD bug 2356, which must have been introduced recently, as we already handled this fine for ArrayInitializers, just not ArrayLiterals... Kinda annoying to have to do this work due to DMD bugs ...
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
600
diff
changeset
|
2239 |
48f079b4fe0f
Fixed ArrayLiteralExp::toConstElem for dynamic arrays, tango-user library should now be possible to build. It seems to be related to DMD bug 2356, which must have been introduced recently, as we already handled this fine for ArrayInitializers, just not ArrayLiterals... Kinda annoying to have to do this work due to DMD bugs ...
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
600
diff
changeset
|
2240 // dynamic arrays can occur here as well ... |
603
10bc9eb9e262
Fix typo in ArrayLiteralExp::toConstElem.
Christian Kamm <kamm incasoftware de>
parents:
602
diff
changeset
|
2241 bool dyn = (bt->ty == Tarray); |
602
48f079b4fe0f
Fixed ArrayLiteralExp::toConstElem for dynamic arrays, tango-user library should now be possible to build. It seems to be related to DMD bug 2356, which must have been introduced recently, as we already handled this fine for ArrayInitializers, just not ArrayLiterals... Kinda annoying to have to do this work due to DMD bugs ...
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
600
diff
changeset
|
2242 |
48f079b4fe0f
Fixed ArrayLiteralExp::toConstElem for dynamic arrays, tango-user library should now be possible to build. It seems to be related to DMD bug 2356, which must have been introduced recently, as we already handled this fine for ArrayInitializers, just not ArrayLiterals... Kinda annoying to have to do this work due to DMD bugs ...
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
600
diff
changeset
|
2243 // build the initializer |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2244 std::vector<LLConstant*> vals(elements->dim, NULL); |
40 | 2245 for (unsigned i=0; i<elements->dim; ++i) |
2246 { | |
2247 Expression* expr = (Expression*)elements->data[i]; | |
2248 vals[i] = expr->toConstElem(p); | |
2249 } | |
2250 | |
602
48f079b4fe0f
Fixed ArrayLiteralExp::toConstElem for dynamic arrays, tango-user library should now be possible to build. It seems to be related to DMD bug 2356, which must have been introduced recently, as we already handled this fine for ArrayInitializers, just not ArrayLiterals... Kinda annoying to have to do this work due to DMD bugs ...
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
600
diff
changeset
|
2251 // build the constant array initializer |
48f079b4fe0f
Fixed ArrayLiteralExp::toConstElem for dynamic arrays, tango-user library should now be possible to build. It seems to be related to DMD bug 2356, which must have been introduced recently, as we already handled this fine for ArrayInitializers, just not ArrayLiterals... Kinda annoying to have to do this work due to DMD bugs ...
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
600
diff
changeset
|
2252 LLConstant* initval = llvm::ConstantArray::get(arrtype, vals); |
48f079b4fe0f
Fixed ArrayLiteralExp::toConstElem for dynamic arrays, tango-user library should now be possible to build. It seems to be related to DMD bug 2356, which must have been introduced recently, as we already handled this fine for ArrayInitializers, just not ArrayLiterals... Kinda annoying to have to do this work due to DMD bugs ...
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
600
diff
changeset
|
2253 |
48f079b4fe0f
Fixed ArrayLiteralExp::toConstElem for dynamic arrays, tango-user library should now be possible to build. It seems to be related to DMD bug 2356, which must have been introduced recently, as we already handled this fine for ArrayInitializers, just not ArrayLiterals... Kinda annoying to have to do this work due to DMD bugs ...
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
600
diff
changeset
|
2254 // if static array, we're done |
48f079b4fe0f
Fixed ArrayLiteralExp::toConstElem for dynamic arrays, tango-user library should now be possible to build. It seems to be related to DMD bug 2356, which must have been introduced recently, as we already handled this fine for ArrayInitializers, just not ArrayLiterals... Kinda annoying to have to do this work due to DMD bugs ...
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
600
diff
changeset
|
2255 if (!dyn) |
48f079b4fe0f
Fixed ArrayLiteralExp::toConstElem for dynamic arrays, tango-user library should now be possible to build. It seems to be related to DMD bug 2356, which must have been introduced recently, as we already handled this fine for ArrayInitializers, just not ArrayLiterals... Kinda annoying to have to do this work due to DMD bugs ...
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
600
diff
changeset
|
2256 return initval; |
48f079b4fe0f
Fixed ArrayLiteralExp::toConstElem for dynamic arrays, tango-user library should now be possible to build. It seems to be related to DMD bug 2356, which must have been introduced recently, as we already handled this fine for ArrayInitializers, just not ArrayLiterals... Kinda annoying to have to do this work due to DMD bugs ...
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
600
diff
changeset
|
2257 |
48f079b4fe0f
Fixed ArrayLiteralExp::toConstElem for dynamic arrays, tango-user library should now be possible to build. It seems to be related to DMD bug 2356, which must have been introduced recently, as we already handled this fine for ArrayInitializers, just not ArrayLiterals... Kinda annoying to have to do this work due to DMD bugs ...
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
600
diff
changeset
|
2258 // for dynamic arrays we need to put the initializer in a global, and build a constant dynamic array reference with the .ptr field pointing into this global |
48f079b4fe0f
Fixed ArrayLiteralExp::toConstElem for dynamic arrays, tango-user library should now be possible to build. It seems to be related to DMD bug 2356, which must have been introduced recently, as we already handled this fine for ArrayInitializers, just not ArrayLiterals... Kinda annoying to have to do this work due to DMD bugs ...
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
600
diff
changeset
|
2259 LLConstant* globalstore = new LLGlobalVariable(arrtype, true, LLGlobalValue::InternalLinkage, initval, ".dynarrayStorage", p->module); |
48f079b4fe0f
Fixed ArrayLiteralExp::toConstElem for dynamic arrays, tango-user library should now be possible to build. It seems to be related to DMD bug 2356, which must have been introduced recently, as we already handled this fine for ArrayInitializers, just not ArrayLiterals... Kinda annoying to have to do this work due to DMD bugs ...
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
600
diff
changeset
|
2260 LLConstant* idxs[2] = { DtoConstUint(0), DtoConstUint(0) }; |
48f079b4fe0f
Fixed ArrayLiteralExp::toConstElem for dynamic arrays, tango-user library should now be possible to build. It seems to be related to DMD bug 2356, which must have been introduced recently, as we already handled this fine for ArrayInitializers, just not ArrayLiterals... Kinda annoying to have to do this work due to DMD bugs ...
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
600
diff
changeset
|
2261 LLConstant* globalstorePtr = llvm::ConstantExpr::getGetElementPtr(globalstore, idxs, 2); |
48f079b4fe0f
Fixed ArrayLiteralExp::toConstElem for dynamic arrays, tango-user library should now be possible to build. It seems to be related to DMD bug 2356, which must have been introduced recently, as we already handled this fine for ArrayInitializers, just not ArrayLiterals... Kinda annoying to have to do this work due to DMD bugs ...
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
600
diff
changeset
|
2262 |
48f079b4fe0f
Fixed ArrayLiteralExp::toConstElem for dynamic arrays, tango-user library should now be possible to build. It seems to be related to DMD bug 2356, which must have been introduced recently, as we already handled this fine for ArrayInitializers, just not ArrayLiterals... Kinda annoying to have to do this work due to DMD bugs ...
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
600
diff
changeset
|
2263 return DtoConstSlice(DtoConstSize_t(elements->dim), globalstorePtr); |
40 | 2264 } |
2265 | |
2266 ////////////////////////////////////////////////////////////////////////////////////////// | |
2267 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2268 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
|
2269 { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2270 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
|
2271 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
|
2272 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2273 const LLType* llt = DtoType(type); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2274 |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2275 LLValue* mem = 0; |
334 | 2276 |
479
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
469
diff
changeset
|
2277 LLValue* sptr = DtoAlloca(llt,"tmpstructliteral"); |
295
895e1b50cf2a
[svn r316] Fixed array slice assignments like: int[] arr = ...; arr[] = 42;
lindquist
parents:
291
diff
changeset
|
2278 |
485
50f6e2337a6b
Default initialize temporary struct generated from struct literal.
Christian Kamm <kamm incasoftware de>
parents:
479
diff
changeset
|
2279 // default init the struct to take care of padding |
50f6e2337a6b
Default initialize temporary struct generated from struct literal.
Christian Kamm <kamm incasoftware de>
parents:
479
diff
changeset
|
2280 // and unspecified members |
487
d7b2e8777e2b
Make struct literals work with typedefs.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
2281 TypeStruct* ts = (TypeStruct*)type->toBasetype(); |
485
50f6e2337a6b
Default initialize temporary struct generated from struct literal.
Christian Kamm <kamm incasoftware de>
parents:
479
diff
changeset
|
2282 assert(ts->sym); |
50f6e2337a6b
Default initialize temporary struct generated from struct literal.
Christian Kamm <kamm incasoftware de>
parents:
479
diff
changeset
|
2283 DtoForceConstInitDsymbol(ts->sym); |
50f6e2337a6b
Default initialize temporary struct generated from struct literal.
Christian Kamm <kamm incasoftware de>
parents:
479
diff
changeset
|
2284 assert(ts->sym->ir.irStruct->init); |
50f6e2337a6b
Default initialize temporary struct generated from struct literal.
Christian Kamm <kamm incasoftware de>
parents:
479
diff
changeset
|
2285 DtoAggrCopy(sptr, ts->sym->ir.irStruct->init); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2286 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2287 // num elements in literal |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2288 unsigned n = elements->dim; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2289 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2290 // 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
|
2291 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
|
2292 // build the type of the literal |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2293 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
|
2294 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
|
2295 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
|
2296 if (!vx) continue; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2297 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
|
2298 } |
435
74101be2a553
Added type param to DVarValue as DMD sometimes overrides the type of the VarDeclaration.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
433
diff
changeset
|
2299 const LLStructType* t = LLStructType::get(tys, sd->ir.irStruct->packed); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2300 if (t != llt) { |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2301 if (getABITypeSize(t) != getABITypeSize(llt)) { |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
619
diff
changeset
|
2302 if (Logger::enabled()) |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
619
diff
changeset
|
2303 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
|
2304 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
|
2305 } |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
2306 sptr = DtoBitCast(sptr, getPtrToType(t)); |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
619
diff
changeset
|
2307 if (Logger::enabled()) |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
619
diff
changeset
|
2308 Logger::cout() << "sptr type is now: " << *t << '\n'; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2309 } |
50
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
2310 } |
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
|
2311 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2312 // build |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2313 unsigned j = 0; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2314 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
|
2315 { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2316 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
|
2317 if (!vx) continue; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2318 |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
619
diff
changeset
|
2319 if (Logger::enabled()) |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
619
diff
changeset
|
2320 Logger::cout() << "getting index " << j << " of " << *sptr << '\n'; |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
2321 LLValue* arrptr = DtoGEPi(sptr,0,j); |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
2322 DValue* darrptr = new DVarValue(vx->type, arrptr); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2323 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2324 DValue* ve = vx->toElem(p); |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
2325 DtoAssign(loc, darrptr, ve); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2326 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2327 j++; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2328 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2329 |
334 | 2330 return new DImValue(type, sptr); |
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
|
2331 } |
e5c4bece7fa1
[svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents:
48
diff
changeset
|
2332 |
e5c4bece7fa1
[svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents:
48
diff
changeset
|
2333 ////////////////////////////////////////////////////////////////////////////////////////// |
e5c4bece7fa1
[svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents:
48
diff
changeset
|
2334 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2335 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
|
2336 { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2337 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
|
2338 LOG_SCOPE; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2339 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2340 unsigned n = elements->dim; |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2341 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
|
2342 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2343 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
|
2344 { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2345 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
|
2346 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
|
2347 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2348 |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
2349 assert(type->toBasetype()->ty == Tstruct); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2350 const LLType* t = DtoType(type); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
243
diff
changeset
|
2351 const LLStructType* st = isaStruct(t); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2352 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
|
2353 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2354 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2355 ////////////////////////////////////////////////////////////////////////////////////////// |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2356 |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2357 DValue* InExp::toElem(IRState* p) |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2358 { |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2359 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
|
2360 LOG_SCOPE; |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2361 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2362 DValue* key = e1->toElem(p); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2363 DValue* aa = e2->toElem(p); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2364 |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
2365 return DtoAAIn(loc, type, aa, key); |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2366 } |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2367 |
127 | 2368 DValue* RemoveExp::toElem(IRState* p) |
2369 { | |
2370 Logger::print("RemoveExp::toElem: %s\n", toChars()); | |
2371 LOG_SCOPE; | |
2372 | |
2373 DValue* aa = e1->toElem(p); | |
2374 DValue* key = e2->toElem(p); | |
2375 | |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
2376 DtoAARemove(loc, aa, key); |
127 | 2377 |
2378 return NULL; // does not produce anything useful | |
2379 } | |
2380 | |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2381 ////////////////////////////////////////////////////////////////////////////////////////// |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
2382 |
125 | 2383 DValue* AssocArrayLiteralExp::toElem(IRState* p) |
2384 { | |
2385 Logger::print("AssocArrayLiteralExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2386 LOG_SCOPE; | |
2387 | |
2388 assert(keys); | |
2389 assert(values); | |
2390 assert(keys->dim == values->dim); | |
2391 | |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
485
diff
changeset
|
2392 Type* aatype = type->toBasetype(); |
127 | 2393 Type* vtype = aatype->next; |
283
9bb48fb57a7d
[svn r304] Fix associative array literals by always reserving a zero inited temporary for them.
ChristianK
parents:
282
diff
changeset
|
2394 const LLType* aalltype = DtoType(type); |
9bb48fb57a7d
[svn r304] Fix associative array literals by always reserving a zero inited temporary for them.
ChristianK
parents:
282
diff
changeset
|
2395 |
9bb48fb57a7d
[svn r304] Fix associative array literals by always reserving a zero inited temporary for them.
ChristianK
parents:
282
diff
changeset
|
2396 // it should be possible to avoid the temporary in some cases |
479
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
469
diff
changeset
|
2397 LLValue* tmp = DtoAlloca(aalltype,"aaliteral"); |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
575
diff
changeset
|
2398 DValue* aa = new DVarValue(type, tmp); |
283
9bb48fb57a7d
[svn r304] Fix associative array literals by always reserving a zero inited temporary for them.
ChristianK
parents:
282
diff
changeset
|
2399 DtoStore(LLConstant::getNullValue(aalltype), tmp); |
127 | 2400 |
125 | 2401 const size_t n = keys->dim; |
2402 for (size_t i=0; i<n; ++i) | |
2403 { | |
2404 Expression* ekey = (Expression*)keys->data[i]; | |
2405 Expression* eval = (Expression*)values->data[i]; | |
2406 | |
2407 Logger::println("(%u) aa[%s] = %s", i, ekey->toChars(), eval->toChars()); | |
127 | 2408 |
2409 // index | |
2410 DValue* key = ekey->toElem(p); | |
458
121624c14053
Fixed AA Rvalue-only access (like indexing an AA return value immediately).
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
452
diff
changeset
|
2411 DValue* mem = DtoAAIndex(loc, vtype, aa, key, true); |
127 | 2412 |
2413 // store | |
2414 DValue* val = eval->toElem(p); | |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
397
diff
changeset
|
2415 DtoAssign(loc, mem, val); |
125 | 2416 } |
2417 | |
127 | 2418 return aa; |
125 | 2419 } |
2420 | |
2421 ////////////////////////////////////////////////////////////////////////////////////////// | |
2422 | |
599
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
594
diff
changeset
|
2423 DValue* GEPExp::toElem(IRState* p) |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
594
diff
changeset
|
2424 { |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
594
diff
changeset
|
2425 // this should be good enough for now! |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
594
diff
changeset
|
2426 DValue* val = e1->toElem(p); |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
594
diff
changeset
|
2427 assert(val->isLVal()); |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
594
diff
changeset
|
2428 LLValue* v = DtoGEPi(val->getLVal(), 0, index); |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
594
diff
changeset
|
2429 return new DVarValue(type, DtoBitCast(v, getPtrToType(DtoType(type)))); |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
594
diff
changeset
|
2430 } |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
594
diff
changeset
|
2431 |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
594
diff
changeset
|
2432 ////////////////////////////////////////////////////////////////////////////////////////// |
4435f57956e7
Fixed .funcptr property of delegates, no longer uses the infamous DMD rewrites to pointer arithmetic, instead a GEPExp has been introduced.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
594
diff
changeset
|
2433 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
2434 #define STUB(x) DValue *x::toElem(IRState * p) {error("Exp type "#x" not implemented: %s", toChars()); fatal(); return 0; } |
1 | 2435 STUB(Expression); |
2436 STUB(DotTypeExp); | |
2437 STUB(TypeDotIdExp); | |
2438 STUB(ScopeExp); | |
2439 STUB(TypeExp); | |
2440 STUB(BoolExp); | |
92 | 2441 STUB(TupleExp); |
1 | 2442 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
212
diff
changeset
|
2443 #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 | 2444 CONSTSTUB(Expression); |
2445 CONSTSTUB(AssocArrayLiteralExp); | |
2446 | |
1 | 2447 unsigned Type::totym() { return 0; } |
2448 | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2449 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
|
2450 { |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2451 assert(0); |
1 | 2452 return 0; |
2453 } | |
2454 | |
2455 type * Type::toCParamtype() | |
2456 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2457 assert(0); |
1 | 2458 return 0; |
2459 } | |
2460 Symbol * Type::toSymbol() | |
2461 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2462 assert(0); |
1 | 2463 return 0; |
2464 } | |
2465 | |
2466 type * | |
2467 TypeTypedef::toCtype() | |
2468 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2469 assert(0); |
1 | 2470 return 0; |
2471 } | |
2472 | |
2473 type * | |
2474 TypeTypedef::toCParamtype() | |
2475 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2476 assert(0); |
1 | 2477 return 0; |
2478 } | |
2479 | |
2480 void | |
2481 TypedefDeclaration::toDebug() | |
2482 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2483 assert(0); |
1 | 2484 } |
2485 | |
2486 | |
2487 type * | |
2488 TypeEnum::toCtype() | |
2489 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2490 assert(0); |
1 | 2491 return 0; |
2492 } | |
2493 | |
2494 type * | |
2495 TypeStruct::toCtype() | |
2496 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2497 assert(0); |
1 | 2498 return 0; |
2499 } | |
2500 | |
2501 void | |
2502 StructDeclaration::toDebug() | |
2503 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2504 assert(0); |
1 | 2505 } |
2506 | |
2507 Symbol * TypeClass::toSymbol() | |
2508 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2509 assert(0); |
1 | 2510 return 0; |
2511 } | |
2512 | |
2513 unsigned TypeFunction::totym() | |
2514 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2515 assert(0); |
1 | 2516 return 0; |
2517 } | |
2518 | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2519 type * TypeFunction::toCtype() |
1 | 2520 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2521 assert(0); |
1 | 2522 return 0; |
2523 } | |
2524 | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2525 type * TypeSArray::toCtype() |
1 | 2526 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2527 assert(0); |
1 | 2528 return 0; |
2529 } | |
2530 | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2531 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
|
2532 { |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2533 assert(0); |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2534 return 0; |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2535 } |
1 | 2536 |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2537 type * TypeDArray::toCtype() |
1 | 2538 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2539 assert(0); |
1 | 2540 return 0; |
2541 } | |
2542 | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2543 type * TypeAArray::toCtype() |
1 | 2544 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2545 assert(0); |
1 | 2546 return 0; |
2547 } | |
2548 | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2549 type * TypePointer::toCtype() |
1 | 2550 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2551 assert(0); |
1 | 2552 return 0; |
2553 } | |
2554 | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2555 type * TypeDelegate::toCtype() |
1 | 2556 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2557 assert(0); |
1 | 2558 return 0; |
2559 } | |
2560 | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2561 type * TypeClass::toCtype() |
1 | 2562 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2563 assert(0); |
1 | 2564 return 0; |
2565 } | |
2566 | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2567 void ClassDeclaration::toDebug() |
1 | 2568 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2569 assert(0); |
1 | 2570 } |
2571 | |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
11
diff
changeset
|
2572 ////////////////////////////////////////////////////////////////////////////// |
1 | 2573 |
2574 void | |
2575 EnumDeclaration::toDebug() | |
2576 { | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2577 assert(0); |
1 | 2578 } |
2579 | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2580 int Dsymbol::cvMember(unsigned char*) |
1 | 2581 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2582 assert(0); |
1 | 2583 return 0; |
2584 } | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2585 int EnumDeclaration::cvMember(unsigned char*) |
1 | 2586 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2587 assert(0); |
1 | 2588 return 0; |
2589 } | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2590 int FuncDeclaration::cvMember(unsigned char*) |
1 | 2591 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2592 assert(0); |
1 | 2593 return 0; |
2594 } | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2595 int VarDeclaration::cvMember(unsigned char*) |
1 | 2596 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2597 assert(0); |
1 | 2598 return 0; |
2599 } | |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2600 int TypedefDeclaration::cvMember(unsigned char*) |
1 | 2601 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2602 assert(0); |
1 | 2603 return 0; |
2604 } | |
2605 | |
594
e096a1502428
Fix #88 : pragma(lib, "str") is now converted to -lstr in the linker command line.
Christian Kamm <kamm incasoftware de>
parents:
592
diff
changeset
|
2606 void obj_includelib(char* lib) |
340 | 2607 { |
594
e096a1502428
Fix #88 : pragma(lib, "str") is now converted to -lstr in the linker command line.
Christian Kamm <kamm incasoftware de>
parents:
592
diff
changeset
|
2608 char *arg = (char *)mem.malloc(64); |
e096a1502428
Fix #88 : pragma(lib, "str") is now converted to -lstr in the linker command line.
Christian Kamm <kamm incasoftware de>
parents:
592
diff
changeset
|
2609 strcpy(arg, "-l"); |
e096a1502428
Fix #88 : pragma(lib, "str") is now converted to -lstr in the linker command line.
Christian Kamm <kamm incasoftware de>
parents:
592
diff
changeset
|
2610 strncat(arg, lib, 64); |
e096a1502428
Fix #88 : pragma(lib, "str") is now converted to -lstr in the linker command line.
Christian Kamm <kamm incasoftware de>
parents:
592
diff
changeset
|
2611 global.params.linkswitches->push(arg); |
340 | 2612 } |
2613 | |
2614 void backend_init() | |
1 | 2615 { |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
36
diff
changeset
|
2616 // now lazily loaded |
1 | 2617 //LLVM_D_InitRuntime(); |
2618 } | |
2619 | |
340 | 2620 void backend_term() |
1 | 2621 { |
2622 LLVM_D_FreeRuntime(); | |
2623 } |