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