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