annotate gen/toir.cpp @ 399:0e6b4d65d3f8

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