annotate gen/toir.c @ 85:f869c636a113 trunk

[svn r89] Fixed a bunch of problems with template instance across multiple modules. Fixed initialization of function local static variables, with a non const initializer (now happens on first call using a global to make sure it only happens once.)
author lindquist
date Fri, 02 Nov 2007 06:32:32 +0100
parents 339422268de1
children
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
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
17 #include "total.h"
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
18 #include "init.h"
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
19 #include "symbol.h"
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
20 #include "mtype.h"
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
21 #include "hdrgen.h"
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
22 #include "port.h"
4
e116aa1488e6 [svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents: 1
diff changeset
23
e116aa1488e6 [svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents: 1
diff changeset
24 #include "gen/irstate.h"
e116aa1488e6 [svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents: 1
diff changeset
25 #include "gen/elem.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"
e116aa1488e6 [svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents: 1
diff changeset
28 #include "gen/runtime.h"
e116aa1488e6 [svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents: 1
diff changeset
29 #include "gen/arrays.h"
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
30
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
31 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
32
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
33 elem* DeclarationExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
34 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
35 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
36 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
37 elem* e = new elem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
38
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
39 // variable declaration
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
40 if (VarDeclaration* vd = declaration->isVarDeclaration())
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
41 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
42 Logger::println("VarDeclaration");
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
43
50
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
44 // static
26
99737f94abfb [svn r30] * Fixed static function-local variables.
lindquist
parents: 25
diff changeset
45 if (vd->isDataseg())
99737f94abfb [svn r30] * Fixed static function-local variables.
lindquist
parents: 25
diff changeset
46 {
99737f94abfb [svn r30] * Fixed static function-local variables.
lindquist
parents: 25
diff changeset
47 vd->toObjFile();
99737f94abfb [svn r30] * Fixed static function-local variables.
lindquist
parents: 25
diff changeset
48 }
99737f94abfb [svn r30] * Fixed static function-local variables.
lindquist
parents: 25
diff changeset
49 else
99737f94abfb [svn r30] * Fixed static function-local variables.
lindquist
parents: 25
diff changeset
50 {
99737f94abfb [svn r30] * Fixed static function-local variables.
lindquist
parents: 25
diff changeset
51 Logger::println("vdtype = %s", vd->type->toChars());
50
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
52 // referenced by nested delegate?
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
53 if (vd->nestedref) {
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
54 Logger::println("has nestedref set");
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
55 vd->llvmValue = p->func().decl->llvmNested;
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
56 assert(vd->llvmValue);
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
57 assert(vd->llvmNestedIndex >= 0);
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
58 }
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
59 // normal stack variable
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
60 else {
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
61 // allocate storage on the stack
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
62 const llvm::Type* lltype = DtoType(vd->type);
50
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
63 llvm::AllocaInst* allocainst = new llvm::AllocaInst(lltype, vd->toChars(), p->topallocapoint());
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
64 //allocainst->setAlignment(vd->type->alignsize()); // TODO
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
65 vd->llvmValue = allocainst;
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
66 }
85
f869c636a113 [svn r89] Fixed a bunch of problems with template instance across multiple modules.
lindquist
parents: 83
diff changeset
67 elem* ie = DtoInitializer(vd->init);
f869c636a113 [svn r89] Fixed a bunch of problems with template instance across multiple modules.
lindquist
parents: 83
diff changeset
68 delete ie;
26
99737f94abfb [svn r30] * Fixed static function-local variables.
lindquist
parents: 25
diff changeset
69 }
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
70 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
71 // struct declaration
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
72 else if (StructDeclaration* s = declaration->isStructDeclaration())
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
73 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
74 Logger::println("StructDeclaration");
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
75 s->toObjFile();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
76 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
77 // function declaration
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
78 else if (FuncDeclaration* f = declaration->isFuncDeclaration())
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
79 {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
80 Logger::println("FuncDeclaration");
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
81 f->toObjFile();
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
82 }
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
83 // alias declaration
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
84 else if (AliasDeclaration* a = declaration->isAliasDeclaration())
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
85 {
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
86 Logger::println("AliasDeclaration - no work");
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
87 // do nothing
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 51
diff changeset
88 }
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 51
diff changeset
89 else if (EnumDeclaration* e = declaration->isEnumDeclaration())
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 51
diff changeset
90 {
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
91 Logger::println("EnumDeclaration - no work");
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 51
diff changeset
92 // do nothing
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
93 }
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
94 // unsupported declaration
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
95 else
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
96 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
97 error("Only Var/Struct-Declaration is supported for DeclarationExp");
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 51
diff changeset
98 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
99 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
100 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
101 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
102
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
103 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
104
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
105 elem* VarExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
106 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
107 Logger::print("VarExp::toElem: %s | %s\n", toChars(), type->toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
108 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
109
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
110 elem* e = new elem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
111
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
112 assert(var);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
113 if (VarDeclaration* vd = var->isVarDeclaration())
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
114 {
57
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
115 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
116
57
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
117 // _arguments
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
118 if (vd->ident == Id::_arguments)
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
119 {
72
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 70
diff changeset
120 Logger::println("Id::_arguments");
57
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
121 vd->llvmValue = p->func().decl->llvmArguments;
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
122 assert(vd->llvmValue);
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
123 e->mem = vd->llvmValue;
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
124 e->type = elem::VAR;
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
125 }
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
126 // _argptr
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
127 else if (vd->ident == Id::_argptr)
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
128 {
72
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 70
diff changeset
129 Logger::println("Id::_argptr");
57
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
130 vd->llvmValue = p->func().decl->llvmArgPtr;
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
131 assert(vd->llvmValue);
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
132 e->mem = vd->llvmValue;
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
133 e->type = elem::VAR;
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
134 }
67
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
135 // _dollar
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
136 else if (vd->ident == Id::dollar)
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
137 {
72
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 70
diff changeset
138 Logger::println("Id::dollar");
67
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
139 assert(!p->arrays.empty());
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
140 llvm::Value* tmp = DtoGEPi(p->arrays.back(),0,0,"tmp",p->scopebb());
67
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
141 e->val = new llvm::LoadInst(tmp,"tmp",p->scopebb());
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
142 e->type = elem::VAL;
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
143 }
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
144 // typeinfo
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
145 else if (TypeInfoDeclaration* tid = vd->isTypeInfoDeclaration())
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
146 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
147 Logger::println("TypeInfoDeclaration");
67
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
148 tid->toObjFile();
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
149 assert(tid->llvmValue);
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
150 const llvm::Type* vartype = DtoType(type);
67
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
151 if (tid->llvmValue->getType() != llvm::PointerType::get(vartype))
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
152 e->mem = p->ir->CreateBitCast(tid->llvmValue, vartype, "tmp");
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
153 else
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
154 e->mem = tid->llvmValue;
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
155 e->type = elem::VAR;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
156 }
67
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
157 // nested variable
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
158 else if (vd->nestedref) {
72
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 70
diff changeset
159 Logger::println("nested variable");
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
160 e->mem = DtoNestedVariable(vd);
67
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
161 e->type = elem::VAR;
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
162 e->vardecl = vd;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
163 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
164 // function parameter
67
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
165 else if (vd->isParameter()) {
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
166 Logger::println("function param");
72
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 70
diff changeset
167 if (!vd->llvmValue) {
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 70
diff changeset
168 // TODO: determine this properly
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 70
diff changeset
169 // this happens when the DMD frontend generates by pointer wrappers for struct opEquals(S) and opCmp(S)
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 70
diff changeset
170 vd->llvmValue = &p->func().func->getArgumentList().back();
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 70
diff changeset
171 }
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
172 if (vd->isRef() || vd->isOut() || DtoIsPassedByRef(vd->type) || llvm::isa<llvm::AllocaInst>(vd->llvmValue)) {
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
173 e->mem = vd->llvmValue;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
174 e->type = elem::VAR;
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
175 e->vardecl = vd;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
176 }
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
177 else if (llvm::isa<llvm::Argument>(vd->llvmValue)) {
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
178 e->val = vd->llvmValue;
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
179 e->type = elem::VAL;
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
180 e->vardecl = vd;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
181 }
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
182 else assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
183 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
184 else {
67
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
185 // take care of forward references of global variables
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
186 if (!vd->llvmTouched && vd->isDataseg())
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
187 vd->toObjFile();
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
188 assert(vd->llvmValue);
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
189 e->mem = vd->llvmValue;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
190 e->vardecl = vd;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
191 e->type = elem::VAR;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
192 }
67
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
193
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
194 assert(e->mem || e->val);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
195 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
196 else if (FuncDeclaration* fdecl = var->isFuncDeclaration())
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
197 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
198 Logger::println("FuncDeclaration");
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
199 if (fdecl->llvmInternal != LLVMva_arg && fdecl->llvmValue == 0)
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
200 fdecl->toObjFile();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
201 e->val = fdecl->llvmValue;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
202 e->type = elem::FUNC;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
203 e->funcdecl = fdecl;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
204 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
205 else if (SymbolDeclaration* sdecl = var->isSymbolDeclaration())
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
206 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
207 // 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
208 Type* sdecltype = DtoDType(sdecl->type);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
209 Logger::print("Sym: type=%s\n", sdecltype->toChars());
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
210 assert(sdecltype->ty == Tstruct);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
211 TypeStruct* ts = (TypeStruct*)sdecltype;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
212 e->mem = ts->llvmInit;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
213 assert(e->mem);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
214 e->type = elem::VAR;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
215 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
216 else
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
217 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
218 assert(0 && "Unimplemented VarExp type");
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
219 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
220
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
221 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
222 }
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 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
225
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
226 llvm::Constant* VarExp::toConstElem(IRState* p)
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
227 {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
228 Logger::print("VarExp::toConstElem: %s | %s\n", toChars(), type->toChars());
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
229 LOG_SCOPE;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
230 if (SymbolDeclaration* sdecl = var->isSymbolDeclaration())
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
231 {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
232 // 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
233 Type* sdecltype = DtoDType(sdecl->type);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
234 Logger::print("Sym: type=%s\n", sdecltype->toChars());
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
235 assert(sdecltype->ty == Tstruct);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
236 TypeStruct* ts = (TypeStruct*)sdecltype;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
237 assert(ts->sym->llvmInitZ);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
238 return ts->sym->llvmInitZ;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
239 }
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
240 assert(0 && "Only support const var exp is SymbolDeclaration");
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
241 return NULL;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
242 }
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
243
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
244 //////////////////////////////////////////////////////////////////////////////////////////
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
245
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
246 elem* IntegerExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
247 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
248 Logger::print("IntegerExp::toElem: %s | %s\n", toChars(), type->toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
249 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
250 elem* e = new elem;
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
251 e->val = toConstElem(p);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
252 e->type = elem::CONST;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
253 return e;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
254 }
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
255
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
256 //////////////////////////////////////////////////////////////////////////////////////////
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
257
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
258 llvm::Constant* IntegerExp::toConstElem(IRState* p)
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
259 {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
260 Logger::print("IntegerExp::toConstElem: %s | %s\n", toChars(), type->toChars());
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
261 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
262 const llvm::Type* t = DtoType(type);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
263 if (llvm::isa<llvm::PointerType>(t)) {
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
264 llvm::Constant* i = llvm::ConstantInt::get(DtoSize_t(),(uint64_t)value,false);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
265 return llvm::ConstantExpr::getIntToPtr(i, t);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
266 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
267 else if (llvm::isa<llvm::IntegerType>(t)) {
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
268 return llvm::ConstantInt::get(t,(uint64_t)value,!type->isunsigned());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
269 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
270 assert(0);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
271 return NULL;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
272 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
273
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
274 //////////////////////////////////////////////////////////////////////////////////////////
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 elem* RealExp::toElem(IRState* p)
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 Logger::print("RealExp::toElem: %s | %s\n", toChars(), type->toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
279 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
280 elem* e = new elem;
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
281 e->val = toConstElem(p);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
282 e->type = elem::CONST;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
283 return e;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
284 }
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
285
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
286 //////////////////////////////////////////////////////////////////////////////////////////
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 llvm::Constant* RealExp::toConstElem(IRState* p)
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
289 {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
290 Logger::print("RealExp::toConstElem: %s | %s\n", toChars(), type->toChars());
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
291 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
292 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
293 const llvm::Type* fty = DtoType(t);
62
b86e00b938a5 [svn r66] Added support for imaginary floating point types
lindquist
parents: 58
diff changeset
294 if (t->ty == Tfloat32 || t->ty == Timaginary32)
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
295 return llvm::ConstantFP::get(fty,float(value));
62
b86e00b938a5 [svn r66] Added support for imaginary floating point types
lindquist
parents: 58
diff changeset
296 else if (t->ty == Tfloat64 || t->ty == Timaginary64 || t->ty == Tfloat80 || t->ty == Timaginary80)
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
297 return llvm::ConstantFP::get(fty,double(value));
6
35d93ce68cf4 [svn r10] Updated for LLVM rev. 20070913
lindquist
parents: 5
diff changeset
298 assert(0);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
299 return NULL;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
300 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
301
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
302 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
303
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
304 elem* NullExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
305 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
306 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
307 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
308 elem* e = new elem;
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
309 e->val = toConstElem(p);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
310 e->type = elem::NUL;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
311 //Logger::cout() << "null value is now " << *e->val << '\n';
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
312 return e;
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
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
315 //////////////////////////////////////////////////////////////////////////////////////////
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
316
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
317 llvm::Constant* NullExp::toConstElem(IRState* p)
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
318 {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
319 Logger::print("NullExp::toConstElem(type=%s): %s\n", type->toChars(),toChars());
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
320 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
321 const llvm::Type* t = DtoType(type);
28
1c80c18f3c82 [svn r32] * Fixed problems with arrays members of aggregates
lindquist
parents: 27
diff changeset
322 if (type->ty == Tarray) {
1c80c18f3c82 [svn r32] * Fixed problems with arrays members of aggregates
lindquist
parents: 27
diff changeset
323 assert(llvm::isa<llvm::StructType>(t));
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
324 return llvm::ConstantAggregateZero::get(t);
28
1c80c18f3c82 [svn r32] * Fixed problems with arrays members of aggregates
lindquist
parents: 27
diff changeset
325 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
326 else {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
327 return llvm::Constant::getNullValue(t);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
328 }
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
329 assert(0);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
330 return NULL;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
331 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
332
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
333 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
334
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
335 elem* StringExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
336 {
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 51
diff changeset
337 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
338 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
339
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
340 Type* dtype = DtoDType(type);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
341
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
342 assert(dtype->next->ty == Tchar && "Only char is supported");
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
343 assert(sz == 1);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
344
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
345 const llvm::Type* ct = DtoType(dtype->next);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
346 //printf("ct = %s\n", type->next->toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
347 const llvm::ArrayType* at = llvm::ArrayType::get(ct,len+1);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
348
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
349 uint8_t* str = (uint8_t*)string;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
350 std::string cont((char*)str, len);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
351
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
352 llvm::Constant* _init = llvm::ConstantArray::get(cont,true);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
353
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
354 llvm::GlobalValue::LinkageTypes _linkage = llvm::GlobalValue::InternalLinkage;//WeakLinkage;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
355 llvm::GlobalVariable* gvar = new llvm::GlobalVariable(at,true,_linkage,_init,"stringliteral",gIR->module);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
356
21
8d45266bbabe [svn r25] * Fixed a lot of problems with string literals
lindquist
parents: 18
diff changeset
357 llvm::ConstantInt* zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false);
8d45266bbabe [svn r25] * Fixed a lot of problems with string literals
lindquist
parents: 18
diff changeset
358 llvm::Constant* idxs[2] = { zero, zero };
8d45266bbabe [svn r25] * Fixed a lot of problems with string literals
lindquist
parents: 18
diff changeset
359 llvm::Constant* arrptr = llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2);
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 elem* e = new elem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
362
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
363 if (dtype->ty == Tarray) {
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
364 llvm::Constant* clen = llvm::ConstantInt::get(DtoSize_t(),len,false);
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
365 if (!p->topexp() || p->topexp()->e2 != this) {
83
339422268de1 [svn r87] Fixed some memory bloat when passing string literals as char[] params (double temporary before)
lindquist
parents: 82
diff changeset
366 llvm::Value* tmpmem = new llvm::AllocaInst(DtoType(dtype),"tempstring",p->topallocapoint());
81
3587401b6eeb [svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents: 78
diff changeset
367 DtoSetArray(tmpmem, clen, arrptr);
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 51
diff changeset
368 e->mem = tmpmem;
83
339422268de1 [svn r87] Fixed some memory bloat when passing string literals as char[] params (double temporary before)
lindquist
parents: 82
diff changeset
369 e->temp = true;
4
e116aa1488e6 [svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents: 1
diff changeset
370 }
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
371 else if (p->topexp()->e2 == this) {
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
372 llvm::Value* arr = p->topexp()->v;
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
373 assert(arr);
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
374 DtoSetArray(arr, clen, arrptr);
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
375 e->inplace = true;
4
e116aa1488e6 [svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents: 1
diff changeset
376 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
377 else
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
378 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
379 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
380 else if (dtype->ty == Tsarray) {
21
8d45266bbabe [svn r25] * Fixed a lot of problems with string literals
lindquist
parents: 18
diff changeset
381 const llvm::Type* dstType = llvm::PointerType::get(llvm::ArrayType::get(ct, len));
8d45266bbabe [svn r25] * Fixed a lot of problems with string literals
lindquist
parents: 18
diff changeset
382 e->mem = new llvm::BitCastInst(gvar, dstType, "tmp", gIR->scopebb());
8d45266bbabe [svn r25] * Fixed a lot of problems with string literals
lindquist
parents: 18
diff changeset
383 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
384 else if (dtype->ty == Tpointer) {
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
385 e->mem = arrptr;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
386 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
387 else {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
388 assert(0);
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 e->type = elem::VAL;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
392
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
393 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
394 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
395
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
396 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
397
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
398 llvm::Constant* StringExp::toConstElem(IRState* p)
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
399 {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
400 Logger::print("StringExp::toConstElem: %s | %s\n", toChars(), type->toChars());
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
401 LOG_SCOPE;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
402
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
403 uint8_t* str = (uint8_t*)string;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
404 std::string cont((char*)str, len);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
405
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
406 Type* t = DtoDType(type);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
407
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
408 if (t->ty == Tsarray) {
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
409 return llvm::ConstantArray::get(cont,false);
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
410 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
411 llvm::Constant* _init = llvm::ConstantArray::get(cont,true);
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
412
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
413 llvm::GlobalValue::LinkageTypes _linkage = llvm::GlobalValue::InternalLinkage;//WeakLinkage;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
414 llvm::GlobalVariable* gvar = new llvm::GlobalVariable(_init->getType(),true,_linkage,_init,"stringliteral",gIR->module);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
415
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
416 llvm::ConstantInt* zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
417 llvm::Constant* idxs[2] = { zero, zero };
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
418 llvm::Constant* arrptr = llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
419
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
420 if (t->ty == Tpointer) {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
421 return arrptr;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
422 }
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
423
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
424 if (t->ty == Tarray) {
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
425 llvm::Constant* clen = llvm::ConstantInt::get(DtoSize_t(),len,false);
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 return DtoConstSlice(clen, arrptr);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
427 }
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
428
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
429 assert(0);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
430 return NULL;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
431 }
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
432
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
433 //////////////////////////////////////////////////////////////////////////////////////////
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
434
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
435 elem* AssignExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
436 {
57
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
437 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
438 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
439
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
440 p->exps.push_back(IRExp(e1,e2,NULL));
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
441
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
442 elem* l = e1->toElem(p);
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
443 p->topexp()->v = l->mem;
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
444 elem* r = e2->toElem(p);
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
445
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
446 p->exps.pop_back();
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
447
34
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 32
diff changeset
448 if (l->type == elem::ARRAYLEN)
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 32
diff changeset
449 {
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
450 DtoResizeDynArray(l->mem, r->getValue());
34
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 32
diff changeset
451 delete r;
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 32
diff changeset
452 delete l;
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 32
diff changeset
453 return 0;
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 32
diff changeset
454 }
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 32
diff changeset
455
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
456 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
457 Type* e2type = DtoDType(e2->type);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
458 TY e1ty = e1type->ty;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
459 TY e2ty = e2type->ty;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
460
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
461 elem* e = new elem;
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
462 e->type = elem::VAR;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
463
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
464 // struct
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
465 if (e1ty == Tstruct) {
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
466 e->mem = l->mem;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
467 // struct + struct
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
468 if (e2ty == Tstruct) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
469 // struct literals do the assignment themselvs (in place)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
470 if (!r->inplace) {
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
471 DtoStructCopy(l->mem,r->getValue());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
472 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
473 else {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
474 e->inplace = true;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
475 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
476 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
477 // struct + const int
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
478 else if (e2type->isintegral()){
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
479 IntegerExp* iexp = (IntegerExp*)e2;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
480 assert(iexp->value == 0 && "Only integral struct initializer allowed is zero");
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
481 DtoStructZeroInit(l->mem);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
482 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
483 // :x
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
484 else
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
485 assert(0 && "struct = unknown");
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 else if (e1ty == Tsarray) {
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
488 assert(0 && "static array not supported");
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
489 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
490 else if (e1ty == Tarray) {
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
491 if (e2type->isscalar() || e2type->ty == Tclass){
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
492 DtoArrayInit(l->mem, r->getValue());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
493 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
494 else if (e2ty == Tarray) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
495 //new llvm::StoreInst(r->val,l->val,p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
496 if (r->type == elem::NUL) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
497 llvm::Constant* c = llvm::cast<llvm::Constant>(r->val);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
498 assert(c->isNullValue());
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
499 DtoNullArray(l->mem);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
500 e->mem = l->mem;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
501 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
502 else if (r->type == elem::SLICE) {
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
503 if (l->type == elem::SLICE) {
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
504 DtoArrayCopy(l,r);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
505 e->type = elem::SLICE;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
506 e->mem = l->mem;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
507 e->arg = l->arg;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
508 }
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
509 else {
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
510 DtoSetArray(l->mem,r->arg,r->mem);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
511 e->mem = l->mem;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
512 }
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
513 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
514 else {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
515 // new expressions write directly to the array reference
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
516 // so do string literals
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
517 e->mem = l->mem;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
518 if (!r->inplace) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
519 assert(r->mem);
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
520 DtoArrayAssign(l->mem, r->mem);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
521 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
522 else {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
523 e->inplace = true;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
524 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
525 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
526 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
527 else
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
528 assert(0);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
529 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
530 else if (e1ty == Tpointer) {
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
531 e->mem = l->mem;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
532 if (e2ty == Tpointer) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
533 llvm::Value* v = r->field ? r->mem : r->getValue();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
534 Logger::cout() << "*=*: " << *v << ", " << *l->mem << '\n';
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
535 new llvm::StoreInst(v, l->mem, p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
536 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
537 else
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
538 assert(0);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
539 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
540 else if (e1ty == Tclass) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
541 if (e2ty == Tclass) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
542 llvm::Value* tmp = r->getValue();
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
543 Logger::cout() << "tmp: " << *tmp << " ||| " << *l->mem << '\n';
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
544 // assignment to this in constructor special case
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
545 if (l->isthis) {
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
546 FuncDeclaration* fdecl = p->func().decl;
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
547 // respecify the this param
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
548 if (!llvm::isa<llvm::AllocaInst>(fdecl->llvmThisVar))
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
549 fdecl->llvmThisVar = new llvm::AllocaInst(tmp->getType(), "newthis", p->topallocapoint());
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
550 new llvm::StoreInst(tmp, fdecl->llvmThisVar, p->scopebb());
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
551 e->mem = fdecl->llvmThisVar;
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
552 }
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
553 // regular class ref -> class ref assignment
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
554 else {
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
555 new llvm::StoreInst(tmp, l->mem, p->scopebb());
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
556 e->mem = l->mem;
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
557 }
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
558 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
559 else
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
560 assert(0);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
561 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
562 else if (e1ty == Tdelegate) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
563 Logger::println("Assigning to delegate");
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
564 if (e2ty == Tdelegate) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
565 if (r->type == elem::NUL) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
566 llvm::Constant* c = llvm::cast<llvm::Constant>(r->val);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
567 if (c->isNullValue()) {
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
568 DtoNullDelegate(l->mem);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
569 e->mem = l->mem;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
570 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
571 else
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
572 assert(0);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
573 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
574 else if (r->inplace) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
575 // do nothing
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
576 e->inplace = true;
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
577 e->mem = l->mem;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
578 }
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
579 else {
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
580 DtoDelegateCopy(l->mem, r->getValue());
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
581 e->mem = l->mem;
e5c4bece7fa1 [svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents: 48
diff changeset
582 }
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
583 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
584 else
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
585 assert(0);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
586 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
587 // !struct && !array && !pointer && !class
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
588 else {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
589 Logger::cout() << *l->mem << '\n';
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
590 new llvm::StoreInst(r->getValue(),l->mem,p->scopebb());
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
591 e->mem = l->mem;
1
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 delete r;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
595 delete l;
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
596
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
597 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
598 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
599
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
600 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
601
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
602 elem* AddExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
603 {
23
77e3d1ddae3f [svn r27] * Fixed bug in aggregate field lookup.
lindquist
parents: 21
diff changeset
604 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
605 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
606 elem* e = new elem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
607 elem* l = e1->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
608 elem* r = e2->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
609
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
610 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
611 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
612 Type* e2type = DtoDType(e2->type);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
613
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
614 if (e1type != e2type) {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
615 if (e1type->ty == Tpointer && e1type->next->ty == Tstruct) {
8
5e69b77a5c51 [svn r12] fixed accessing aggregate fields of aggregates
lindquist
parents: 6
diff changeset
616 //assert(l->field);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
617 assert(r->type == elem::CONST);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
618 llvm::ConstantInt* cofs = llvm::cast<llvm::ConstantInt>(r->val);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
619
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
620 TypeStruct* ts = (TypeStruct*)e1type->next;
77
714057ff2dbb [svn r81] Fixed: Union support was very buggy. Should be fairly solid now.
lindquist
parents: 76
diff changeset
621 std::vector<unsigned> offsets;
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
622 e->mem = DtoIndexStruct(l->getValue(), ts->sym, t->next, cofs->getZExtValue(), offsets);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
623 e->type = elem::VAR;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
624 e->field = true;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
625 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
626 else if (e1->type->ty == Tpointer) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
627 e->val = new llvm::GetElementPtrInst(l->getValue(), r->getValue(), "tmp", p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
628 e->type = elem::VAR;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
629 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
630 else {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
631 assert(0);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
632 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
633 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
634 else {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
635 e->val = llvm::BinaryOperator::createAdd(l->getValue(), r->getValue(), "tmp", p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
636 e->type = elem::VAL;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
637 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
638 delete l;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
639 delete r;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
640 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
641 }
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 elem* AddAssignExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
646 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
647 Logger::print("AddAssignExp::toElem: %s\n", toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
648 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
649
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
650 elem* l = e1->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
651 elem* r = e2->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
652
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
653 Type* e1type = DtoDType(e1->type);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
654
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
655 elem* e = new elem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
656 llvm::Value* val = 0;
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
657 if (e1type->ty == Tpointer) {
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
658 val = e->mem = new llvm::GetElementPtrInst(l->getValue(),r->getValue(),"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
659 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
660 else {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
661 val = e->val = llvm::BinaryOperator::createAdd(l->getValue(),r->getValue(),"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
662 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
663
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
664 /*llvm::Value* storeVal = l->storeVal ? l->storeVal : l->val;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
665 if (llvm::isa<llvm::PointerType>(storeVal->getType()) && storeVal->getType()->getContainedType(0) != tmp->getType())
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
666 {
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
667 tmp = DtoPointedType(storeVal, tmp);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
668 }*/
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
669
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
670 assert(l->mem);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
671 new llvm::StoreInst(val,l->mem,p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
672 e->type = elem::VAR;
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 delete l;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
675 delete r;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
676 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
677 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
678
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
679 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
680
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
681 elem* MinExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
682 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
683 Logger::print("MinExp::toElem: %s | %s\n", toChars(), type->toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
684 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
685 elem* e = new elem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
686 elem* l = e1->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
687 elem* r = e2->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
688
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
689 llvm::Value* left = l->getValue();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
690 if (llvm::isa<llvm::PointerType>(left->getType()))
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
691 left = new llvm::PtrToIntInst(left,DtoSize_t(),"tmp",p->scopebb());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
692
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
693 llvm::Value* right = r->getValue();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
694 if (llvm::isa<llvm::PointerType>(right->getType()))
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
695 right = new llvm::PtrToIntInst(right,DtoSize_t(),"tmp",p->scopebb());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
696
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
697 e->val = llvm::BinaryOperator::createSub(left,right,"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
698 e->type = elem::VAL;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
699
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
700 const llvm::Type* totype = DtoType(type);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
701 if (e->val->getType() != totype) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
702 assert(0);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
703 assert(llvm::isa<llvm::PointerType>(e->val->getType()));
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
704 assert(llvm::isa<llvm::IntegerType>(totype));
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
705 e->val = new llvm::IntToPtrInst(e->val,totype,"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
706 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
707
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
708 delete l;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
709 delete r;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
710 return e;
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
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
713 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
714
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
715 elem* MinAssignExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
716 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
717 Logger::print("MinAssignExp::toElem: %s\n", toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
718 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
719
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
720 elem* l = e1->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
721 elem* r = e2->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
722
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
723 Type* e1type = DtoDType(e1->type);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
724
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
725 llvm::Value* tmp = 0;
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
726 if (e1type->ty == Tpointer) {
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
727 tmp = r->getValue();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
728 llvm::Value* zero = llvm::ConstantInt::get(tmp->getType(),0,false);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
729 tmp = llvm::BinaryOperator::createSub(zero,tmp,"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
730 tmp = new llvm::GetElementPtrInst(l->getValue(),tmp,"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
731 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
732 else {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
733 tmp = llvm::BinaryOperator::createSub(l->getValue(),r->getValue(),"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
734 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
735
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
736 /*llvm::Value* storeVal = l->storeVal ? l->storeVal : l->val;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
737 if (storeVal->getType()->getContainedType(0) != tmp->getType())
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
738 {
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
739 tmp = DtoPointedType(storeVal, tmp);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
740 }*/
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
741
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
742 assert(l->mem);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
743 new llvm::StoreInst(tmp, l->mem, p->scopebb());
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 delete l;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
746 delete r;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
747
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
748 elem* e = new elem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
749 e->val = tmp;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
750 e->type = elem::VAR;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
751 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
752 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
753
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
754 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
755
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
756 elem* MulExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
757 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
758 Logger::print("MulExp::toElem: %s\n", toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
759 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
760 elem* e = new elem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
761 elem* l = e1->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
762 elem* r = e2->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
763 llvm::Value* vl = l->getValue();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
764 llvm::Value* vr = r->getValue();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
765 Logger::cout() << "mul: " << *vl << ", " << *vr << '\n';
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
766 e->val = llvm::BinaryOperator::createMul(vl,vr,"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
767 e->type = elem::VAL;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
768 delete l;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
769 delete r;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
770 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
771 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
772
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
773 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
774
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
775 elem* MulAssignExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
776 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
777 Logger::print("MulAssignExp::toElem: %s\n", toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
778 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
779
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
780 elem* l = e1->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
781 elem* r = e2->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
782 llvm::Value* vl = l->getValue();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
783 llvm::Value* vr = r->getValue();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
784 Logger::cout() << "mulassign: " << *vl << ", " << *vr << '\n';
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
785 llvm::Value* tmp = llvm::BinaryOperator::createMul(vl,vr,"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
786
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
787 /*llvm::Value* storeVal = l->storeVal ? l->storeVal : l->val;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
788 if (storeVal->getType()->getContainedType(0) != tmp->getType())
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
789 {
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
790 tmp = DtoPointedType(storeVal, tmp);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
791 }*/
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
792
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
793 assert(l->mem);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
794 new llvm::StoreInst(tmp,l->mem,p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
795
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
796 delete l;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
797 delete r;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
798
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
799 elem* e = new elem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
800 e->val = tmp;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
801 e->type = elem::VAR;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
802 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
803 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
804
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
805 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
806
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
807 elem* DivExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
808 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
809 Logger::print("DivExp::toElem: %s\n", toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
810 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
811 elem* e = new elem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
812 elem* l = e1->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
813 elem* r = e2->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
814
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
815 Type* t = DtoDType(type);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
816
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
817 if (t->isunsigned())
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
818 e->val = llvm::BinaryOperator::createUDiv(l->getValue(),r->getValue(),"tmp",p->scopebb());
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
819 else if (t->isintegral())
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
820 e->val = llvm::BinaryOperator::createSDiv(l->getValue(),r->getValue(),"tmp",p->scopebb());
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
821 else if (t->isfloating())
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
822 e->val = llvm::BinaryOperator::createFDiv(l->getValue(),r->getValue(),"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
823 else
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
824 assert(0);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
825 e->type = elem::VAL;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
826 delete l;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
827 delete r;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
828 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
829 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
830
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
831 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
832
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
833 elem* DivAssignExp::toElem(IRState* p)
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 Logger::print("DivAssignExp::toElem: %s\n", toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
836 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
837
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
838 elem* l = e1->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
839 elem* r = e2->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
840
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
841 Type* t = DtoDType(type);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
842
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
843 llvm::Value* tmp;
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
844 if (t->isunsigned())
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
845 tmp = llvm::BinaryOperator::createUDiv(l->getValue(),r->getValue(),"tmp",p->scopebb());
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
846 else if (t->isintegral())
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
847 tmp = llvm::BinaryOperator::createSDiv(l->getValue(),r->getValue(),"tmp",p->scopebb());
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
848 else if (t->isfloating())
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
849 tmp = llvm::BinaryOperator::createFDiv(l->getValue(),r->getValue(),"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
850 else
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
851 assert(0);
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 /*llvm::Value* storeVal = l->storeVal ? l->storeVal : l->val;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
854 if (storeVal->getType()->getContainedType(0) != tmp->getType())
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
855 {
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
856 tmp = DtoPointedType(storeVal, tmp);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
857 }*/
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
858
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
859 assert(l->mem);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
860 new llvm::StoreInst(tmp,l->mem,p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
861
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
862 delete l;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
863 delete r;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
864
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
865 elem* e = new elem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
866 e->val = tmp;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
867 e->type = elem::VAR;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
868 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
869 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
870
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
871 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
872
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
873 elem* ModExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
874 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
875 Logger::print("ModExp::toElem: %s\n", toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
876 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
877 elem* e = new elem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
878 elem* l = e1->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
879 elem* r = e2->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
880
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
881 Type* t = DtoDType(type);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
882
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
883 if (t->isunsigned())
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
884 e->val = llvm::BinaryOperator::createURem(l->getValue(),r->getValue(),"tmp",p->scopebb());
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
885 else if (t->isintegral())
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
886 e->val = llvm::BinaryOperator::createSRem(l->getValue(),r->getValue(),"tmp",p->scopebb());
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
887 else if (t->isfloating())
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
888 e->val = llvm::BinaryOperator::createFRem(l->getValue(),r->getValue(),"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
889 else
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
890 assert(0);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
891 e->type = elem::VAL;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
892 delete l;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
893 delete r;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
894 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
895 }
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 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
898
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
899 elem* ModAssignExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
900 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
901 Logger::print("ModAssignExp::toElem: %s\n", toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
902 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
903
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
904 elem* l = e1->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
905 elem* r = e2->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
906
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
907 Type* t = DtoDType(type);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
908
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
909 llvm::Value* tmp;
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
910 if (t->isunsigned())
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
911 tmp = llvm::BinaryOperator::createURem(l->getValue(),r->getValue(),"tmp",p->scopebb());
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
912 else if (t->isintegral())
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
913 tmp = llvm::BinaryOperator::createSRem(l->getValue(),r->getValue(),"tmp",p->scopebb());
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
914 else if (t->isfloating())
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
915 tmp = llvm::BinaryOperator::createFRem(l->getValue(),r->getValue(),"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
916 else
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
917 assert(0);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
918
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
919 /*llvm::Value* storeVal = l->storeVal ? l->storeVal : l->val;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
920 if (storeVal->getType()->getContainedType(0) != tmp->getType())
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
921 {
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
922 tmp = DtoPointedType(storeVal, tmp);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
923 }*/
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
924
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
925 assert(l->mem);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
926 new llvm::StoreInst(tmp,l->mem,p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
927
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
928 delete l;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
929 delete r;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
930
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
931 elem* e = new elem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
932 e->val = tmp;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
933 e->type = elem::VAR;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
934 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
935 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
936
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
937 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
938
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
939 elem* CallExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
940 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
941 Logger::print("CallExp::toElem: %s\n", toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
942 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
943
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
944 elem* e = new elem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
945 elem* 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
946
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 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
948 Type* e1type = DtoDType(e1->type);
18
c05ef76f1c20 [svn r22] * Forgot to add std.stdio
lindquist
parents: 15
diff changeset
949
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
950 bool delegateCall = false;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
951 llvm::Value* zero = llvm::ConstantInt::get(llvm::Type::Int32Ty,0,false);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
952 llvm::Value* one = llvm::ConstantInt::get(llvm::Type::Int32Ty,1,false);
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
953 LINK dlink = LINKdefault;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
954
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
955 // hidden struct return parameter handling
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
956 bool retinptr = false;
18
c05ef76f1c20 [svn r22] * Forgot to add std.stdio
lindquist
parents: 15
diff changeset
957
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
958 // regular functions
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
959 if (e1type->ty == Tfunction) {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
960 tf = (TypeFunction*)e1type;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
961 if (tf->llvmRetInPtr) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
962 retinptr = true;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
963 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
964 dlink = tf->linkage;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
965 }
18
c05ef76f1c20 [svn r22] * Forgot to add std.stdio
lindquist
parents: 15
diff changeset
966
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
967 // delegates
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
968 else if (e1type->ty == Tdelegate) {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
969 Logger::println("delegateTy = %s\n", e1type->toChars());
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
970 assert(e1type->next->ty == Tfunction);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
971 tf = (TypeFunction*)e1type->next;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
972 if (tf->llvmRetInPtr) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
973 retinptr = true;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
974 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
975 dlink = tf->linkage;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
976 delegateCall = true;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
977 }
18
c05ef76f1c20 [svn r22] * Forgot to add std.stdio
lindquist
parents: 15
diff changeset
978
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
979 // invalid
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
980 else {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
981 assert(tf);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
982 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
983
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
984 // va args
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
985 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
986 bool va_intrinsic = 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
987 if (fn->funcdecl) {
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
988 if (fn->funcdecl->llvmInternal == LLVMva_intrinsic) {
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
989 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
990 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
991 }
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
992 else if (fn->funcdecl->llvmInternal == LLVMva_start) {
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
993 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
994 }
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
995 else if (fn->funcdecl->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
996 //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
997 Expression* exp = (Expression*)arguments->data[0];
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
998 elem* expelem = exp->toElem(p);
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
999 assert(expelem->mem);
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
1000 elem* e = new elem;
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
1001 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
1002 const llvm::Type* llt = DtoType(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
1003 if (DtoIsPassedByRef(t))
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
1004 llt = llvm::PointerType::get(llt);
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
1005 e->type = elem::VAL;
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
1006 e->val = p->ir->CreateVAArg(expelem->mem,llt,"tmp");
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
1007 delete expelem;
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
1008 return e;
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
1009 }
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
1010 }
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
1011
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
1012 // args
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1013 size_t n = arguments->dim;
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
1014 if (fn->funcdecl && fn->funcdecl->llvmInternal == LLVMva_start)
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
1015 n = 1;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1016 if (fn->arg || delegateCall) n++;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1017 if (retinptr) n++;
57
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1018 if (tf->linkage == LINKd && tf->varargs == 1) n+=2;
68
c4b3f5d2cd9b [svn r72] Calling a nested function that is not a delegate was not working.
lindquist
parents: 67
diff changeset
1019 if (fn->funcdecl && fn->funcdecl->isNested()) n++;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1020
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1021 llvm::Value* funcval = fn->getValue();
18
c05ef76f1c20 [svn r22] * Forgot to add std.stdio
lindquist
parents: 15
diff changeset
1022 assert(funcval != 0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1023 std::vector<llvm::Value*> llargs(n, 0);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1024
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1025 const llvm::FunctionType* llfnty = 0;
18
c05ef76f1c20 [svn r22] * Forgot to add std.stdio
lindquist
parents: 15
diff changeset
1026
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1027 // normal function call
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1028 if (llvm::isa<llvm::FunctionType>(funcval->getType())) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1029 llfnty = llvm::cast<llvm::FunctionType>(funcval->getType());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1030 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1031 // pointer to something
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1032 else if (llvm::isa<llvm::PointerType>(funcval->getType())) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1033 // 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
1034 // seems like sometimes we get a func* other times a func**
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1035 if (llvm::isa<llvm::PointerType>(funcval->getType()->getContainedType(0))) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1036 funcval = new llvm::LoadInst(funcval,"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1037 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1038 // function pointer
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1039 if (llvm::isa<llvm::FunctionType>(funcval->getType()->getContainedType(0))) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1040 //Logger::cout() << "function pointer type:\n" << *funcval << '\n';
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1041 llfnty = llvm::cast<llvm::FunctionType>(funcval->getType()->getContainedType(0));
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1042 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1043 // struct pointer - delegate
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1044 else if (llvm::isa<llvm::StructType>(funcval->getType()->getContainedType(0))) {
81
3587401b6eeb [svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents: 78
diff changeset
1045 funcval = DtoGEP(funcval,zero,one,"tmp",p->scopebb());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1046 funcval = new llvm::LoadInst(funcval,"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1047 const llvm::Type* ty = funcval->getType()->getContainedType(0);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1048 llfnty = llvm::cast<llvm::FunctionType>(ty);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1049 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1050 // unknown
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1051 else {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1052 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
1053 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1054 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1055 else {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1056 Logger::cout() << "what are we calling? : " << *funcval << '\n';
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1057 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1058 assert(llfnty);
53
06ccc817acd4 [svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents: 52
diff changeset
1059 //Logger::cout() << "Function LLVM type: " << *llfnty << '\n';
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1060
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1061 // argument handling
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1062 llvm::FunctionType::param_iterator argiter = llfnty->param_begin();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1063 int j = 0;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1064
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
1065 IRExp* topexp = p->topexp();
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
1066
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1067 // hidden struct return arguments
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1068 if (retinptr) {
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
1069 if (topexp && topexp->e2 == this) {
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
1070 assert(topexp->v);
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
1071 assert(llvm::isa<llvm::StructType>(topexp->v->getType()->getContainedType(0)));
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
1072 llargs[j] = topexp->v;
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
1073 if (DtoIsPassedByRef(tf->next)) {
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1074 e->inplace = true;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1075 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1076 else
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1077 assert(0);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1078 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1079 else {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1080 llargs[j] = new llvm::AllocaInst(argiter->get()->getContainedType(0),"rettmp",p->topallocapoint());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1081 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1082 ++j;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1083 ++argiter;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1084 e->type = elem::VAR;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1085 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1086 else {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1087 e->type = elem::VAL;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1088 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1089
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1090 // this arguments
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1091 if (fn->arg) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1092 Logger::println("This Call");
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1093 if (fn->arg->getType() != argiter->get()) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1094 //Logger::cout() << *fn->thisparam << '|' << *argiter->get() << '\n';
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1095 llargs[j] = new llvm::BitCastInst(fn->arg, argiter->get(), "tmp", p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1096 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1097 else {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1098 llargs[j] = fn->arg;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1099 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1100 ++j;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1101 ++argiter;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1102 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1103 // delegate context arguments
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1104 else if (delegateCall) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1105 Logger::println("Delegate Call");
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
1106 llvm::Value* contextptr = DtoGEP(fn->mem,zero,zero,"tmp",p->scopebb());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1107 llargs[j] = new llvm::LoadInst(contextptr,"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1108 ++j;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1109 ++argiter;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1110 }
68
c4b3f5d2cd9b [svn r72] Calling a nested function that is not a delegate was not working.
lindquist
parents: 67
diff changeset
1111 // nested call
c4b3f5d2cd9b [svn r72] Calling a nested function that is not a delegate was not working.
lindquist
parents: 67
diff changeset
1112 else if (fn->funcdecl && fn->funcdecl->isNested()) {
c4b3f5d2cd9b [svn r72] Calling a nested function that is not a delegate was not working.
lindquist
parents: 67
diff changeset
1113 Logger::println("Nested Call");
c4b3f5d2cd9b [svn r72] Calling a nested function that is not a delegate was not working.
lindquist
parents: 67
diff changeset
1114 llvm::Value* contextptr = p->func().decl->llvmNested;
c4b3f5d2cd9b [svn r72] Calling a nested function that is not a delegate was not working.
lindquist
parents: 67
diff changeset
1115 assert(contextptr);
c4b3f5d2cd9b [svn r72] Calling a nested function that is not a delegate was not working.
lindquist
parents: 67
diff changeset
1116 llargs[j] = p->ir->CreateBitCast(contextptr, llvm::PointerType::get(llvm::Type::Int8Ty), "tmp");
c4b3f5d2cd9b [svn r72] Calling a nested function that is not a delegate was not working.
lindquist
parents: 67
diff changeset
1117 ++j;
c4b3f5d2cd9b [svn r72] Calling a nested function that is not a delegate was not working.
lindquist
parents: 67
diff changeset
1118 ++argiter;
c4b3f5d2cd9b [svn r72] Calling a nested function that is not a delegate was not working.
lindquist
parents: 67
diff changeset
1119 }
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1120
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
1121 // va arg function special argument passing
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
1122 if (va_magic) {
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
1123 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
1124 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
1125 {
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
1126 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
1127 Expression* exp = (Expression*)arguments->data[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
1128 elem* expelem = exp->toElem(p);
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
1129 assert(expelem->mem);
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
1130 llargs[j] = p->ir->CreateBitCast(expelem->mem, llvm::PointerType::get(llvm::Type::Int8Ty), "tmp");
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
1131 delete expelem;
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
1132 }
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
1133 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1134 // regular arguments
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
1135 else {
57
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1136 if (tf->linkage == LINKd && tf->varargs == 1)
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
1137 {
57
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1138 Logger::println("doing d-style variadic arguments");
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1139
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1140 std::vector<const llvm::Type*> vtypes;
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1141 std::vector<llvm::Value*> vvalues;
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1142 std::vector<llvm::Value*> vtypeinfos;
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1143
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1144 for (int i=0; i<arguments->dim; i++) {
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1145 Argument* fnarg = Argument::getNth(tf->parameters, i);
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1146 Expression* argexp = (Expression*)arguments->data[i];
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
1147 vvalues.push_back(DtoArgument(NULL, fnarg, argexp));
57
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1148 vtypes.push_back(vvalues.back()->getType());
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1149
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1150 TypeInfoDeclaration* tidecl = argexp->type->getTypeInfoDeclaration();
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1151 tidecl->toObjFile();
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1152 assert(tidecl->llvmValue);
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1153 vtypeinfos.push_back(tidecl->llvmValue);
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1154 }
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 const llvm::StructType* vtype = llvm::StructType::get(vtypes);
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1157 llvm::Value* mem = new llvm::AllocaInst(vtype,"_argptr_storage",p->topallocapoint());
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1158 for (unsigned i=0; i<vtype->getNumElements(); ++i)
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
1159 p->ir->CreateStore(vvalues[i], DtoGEPi(mem,0,i,"tmp"));
57
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1160
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1161 //llvm::Constant* typeinfoparam = llvm::ConstantPointerNull::get(llvm::cast<llvm::PointerType>(llfnty->getParamType(j)));
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1162 assert(Type::typeinfo->llvmInitZ);
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1163 const llvm::Type* typeinfotype = llvm::PointerType::get(Type::typeinfo->llvmInitZ->getType());
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1164 Logger::cout() << "typeinfo ptr type: " << *typeinfotype << '\n';
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1165 const llvm::ArrayType* typeinfoarraytype = llvm::ArrayType::get(typeinfotype,vtype->getNumElements());
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1166 llvm::Value* typeinfomem = new llvm::AllocaInst(typeinfoarraytype,"_arguments_storage",p->topallocapoint());
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1167 for (unsigned i=0; i<vtype->getNumElements(); ++i) {
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1168 llvm::Value* v = p->ir->CreateBitCast(vtypeinfos[i], typeinfotype, "tmp");
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
1169 p->ir->CreateStore(v, DtoGEPi(typeinfomem,0,i,"tmp"));
57
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1170 }
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1171
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1172 llvm::Value* typeinfoarrayparam = new llvm::AllocaInst(llfnty->getParamType(j)->getContainedType(0),"_arguments_array",p->topallocapoint());
81
3587401b6eeb [svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents: 78
diff changeset
1173 p->ir->CreateStore(DtoConstSize_t(vtype->getNumElements()), DtoGEPi(typeinfoarrayparam,0,0,"tmp"));
57
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1174 llvm::Value* casttypeinfomem = p->ir->CreateBitCast(typeinfomem, llvm::PointerType::get(typeinfotype), "tmp");
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
1175 p->ir->CreateStore(casttypeinfomem, DtoGEPi(typeinfoarrayparam,0,1,"tmp"));
57
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1176
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1177 llargs[j] = typeinfoarrayparam;;
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1178 j++;
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1179 llargs[j] = p->ir->CreateBitCast(mem, llvm::PointerType::get(llvm::Type::Int8Ty), "tmp");
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1180 j++;
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1181 llargs.resize(2);
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1182 }
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1183 else {
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1184 Logger::println("doing normal arguments");
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1185 for (int i=0; i<arguments->dim; i++,j++) {
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1186 Argument* fnarg = Argument::getNth(tf->parameters, i);
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
1187 llargs[j] = DtoArgument(llfnty->getParamType(j), fnarg, (Expression*)arguments->data[i]);
57
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1188 }
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1189 Logger::println("%d params passed", n);
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1190 for (int i=0; i<n; ++i) {
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1191 Logger::cout() << *llargs[i] << '\n';
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1192 }
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
1193 }
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1194 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1195
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1196 // void returns cannot not be named
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1197 const char* varname = "";
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1198 if (llfnty->getReturnType() != llvm::Type::VoidTy)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1199 varname = "tmp";
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1200
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
1201 Logger::cout() << "Calling: " << *funcval->getType() << '\n';
1
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 // call the function
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1204 llvm::CallInst* call = new llvm::CallInst(funcval, llargs.begin(), llargs.end(), varname, p->scopebb());
27
92408a3a2bac [svn r31] * Fixed returning through hidden pointer was unable to report back the return value
lindquist
parents: 26
diff changeset
1205 if (retinptr)
92408a3a2bac [svn r31] * Fixed returning through hidden pointer was unable to report back the return value
lindquist
parents: 26
diff changeset
1206 e->mem = llargs[0];
92408a3a2bac [svn r31] * Fixed returning through hidden pointer was unable to report back the return value
lindquist
parents: 26
diff changeset
1207 else
92408a3a2bac [svn r31] * Fixed returning through hidden pointer was unable to report back the return value
lindquist
parents: 26
diff changeset
1208 e->val = call;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1209
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1210 // set calling convention
66
0c5f410d973c [svn r70] Fixed bug where correct calling convention was not set on calling aggregate methods
lindquist
parents: 64
diff changeset
1211 if (fn->funcdecl) {
0c5f410d973c [svn r70] Fixed bug where correct calling convention was not set on calling aggregate methods
lindquist
parents: 64
diff changeset
1212 int li = fn->funcdecl->llvmInternal;
0c5f410d973c [svn r70] Fixed bug where correct calling convention was not set on calling aggregate methods
lindquist
parents: 64
diff changeset
1213 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
1214 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
1215 }
0c5f410d973c [svn r70] Fixed bug where correct calling convention was not set on calling aggregate methods
lindquist
parents: 64
diff changeset
1216 }
67
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
1217 else if (delegateCall) {
81
3587401b6eeb [svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents: 78
diff changeset
1218 call->setCallingConv(DtoCallingConv(dlink));
67
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
1219 }
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
1220 else if (fn->callconv != (unsigned)-1) {
11
d3ee9efe20e2 [svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents: 9
diff changeset
1221 call->setCallingConv(fn->callconv);
67
f918f3e2e99e [svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents: 66
diff changeset
1222 }
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1223
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1224 delete fn;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1225 return e;
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 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1229
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1230 elem* CastExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1231 {
53
06ccc817acd4 [svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents: 52
diff changeset
1232 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
1233 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1234 elem* e = new elem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1235 elem* u = e1->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
1236 const llvm::Type* tolltype = DtoType(to);
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
1237 Type* fromtype = 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
1238 Type* totype = DtoDType(to);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1239 int lsz = fromtype->size();
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1240 int rsz = totype->size();
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1241
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1242 // this makes sure the strange lvalue casts don't screw things up
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1243 e->mem = u->mem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1244
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1245 if (fromtype->isintegral()) {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1246 if (totype->isintegral()) {
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1247 if (lsz < rsz) {
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1248 Logger::cout() << *tolltype << '\n';
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1249 if (fromtype->isunsigned() || fromtype->ty == Tbool) {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1250 e->val = new llvm::ZExtInst(u->getValue(), tolltype, "tmp", p->scopebb());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1251 } else {
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1252 e->val = new llvm::SExtInst(u->getValue(), tolltype, "tmp", p->scopebb());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1253 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1254 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1255 else if (lsz > rsz) {
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1256 e->val = new llvm::TruncInst(u->getValue(), tolltype, "tmp", p->scopebb());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1257 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1258 else {
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1259 e->val = new llvm::BitCastInst(u->getValue(), tolltype, "tmp", p->scopebb());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1260 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1261 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1262 else if (totype->isfloating()) {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1263 if (fromtype->isunsigned()) {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1264 e->val = new llvm::UIToFPInst(u->getValue(), tolltype, "tmp", p->scopebb());
1
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 else {
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1267 e->val = new llvm::SIToFPInst(u->getValue(), tolltype, "tmp", p->scopebb());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1268 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1269 }
70
fb265a6efea1 [svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents: 69
diff changeset
1270 else if (totype->ty == Tpointer) {
fb265a6efea1 [svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents: 69
diff changeset
1271 e->val = p->ir->CreateIntToPtr(u->getValue(), tolltype, "tmp");
fb265a6efea1 [svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents: 69
diff changeset
1272 }
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1273 else {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1274 assert(0);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1275 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1276 //e->storeVal = u->storeVal ? u->storeVal : u->val;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1277 e->type = elem::VAL;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1278 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1279 else if (fromtype->isfloating()) {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1280 if (totype->isfloating()) {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1281 if ((fromtype->ty == Tfloat80 || fromtype->ty == Tfloat64) && (totype->ty == Tfloat80 || totype->ty == Tfloat64)) {
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1282 e->val = u->getValue();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1283 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1284 else if (lsz < rsz) {
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1285 e->val = new llvm::FPExtInst(u->getValue(), tolltype, "tmp", p->scopebb());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1286 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1287 else if (lsz > rsz) {
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1288 e->val = new llvm::FPTruncInst(u->getValue(), tolltype, "tmp", p->scopebb());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1289 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1290 else {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1291 assert(0);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1292 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1293 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1294 else if (totype->isintegral()) {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1295 if (totype->isunsigned()) {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1296 e->val = new llvm::FPToUIInst(u->getValue(), tolltype, "tmp", p->scopebb());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1297 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1298 else {
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1299 e->val = new llvm::FPToSIInst(u->getValue(), tolltype, "tmp", p->scopebb());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1300 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1301 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1302 else {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1303 assert(0);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1304 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1305 e->type = elem::VAL;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1306 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1307 else if (fromtype->ty == Tclass) {
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1308 //assert(to->ty == Tclass);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1309 e->val = new llvm::BitCastInst(u->getValue(), tolltype, "tmp", p->scopebb());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1310 e->type = elem::VAL;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1311 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1312 else if (fromtype->ty == Tarray || fromtype->ty == Tsarray) {
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1313 Logger::cout() << "from array or sarray" << '\n';
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1314 if (totype->ty == Tpointer) {
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1315 Logger::cout() << "to pointer" << '\n';
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
1316 assert(fromtype->next == totype->next || totype->next->ty == Tvoid);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1317 llvm::Value* zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1318 llvm::Value* one = llvm::ConstantInt::get(llvm::Type::Int32Ty, 1, 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
1319 llvm::Value* ptr = DtoGEP(u->getValue(),zero,one,"tmp",p->scopebb());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1320 e->val = new llvm::LoadInst(ptr, "tmp", p->scopebb());
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
1321 if (fromtype->next != totype->next)
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
1322 e->val = p->ir->CreateBitCast(e->val, llvm::PointerType::get(llvm::Type::Int8Ty), "tmp");
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1323 e->type = elem::VAL;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1324 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1325 else if (totype->ty == Tarray) {
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1326 Logger::cout() << "to array" << '\n';
81
3587401b6eeb [svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents: 78
diff changeset
1327 const llvm::Type* ptrty = DtoType(totype->next);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1328 if (ptrty == llvm::Type::VoidTy)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1329 ptrty = llvm::Type::Int8Ty;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1330 ptrty = llvm::PointerType::get(ptrty);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1331
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
1332 const llvm::Type* ety = DtoType(fromtype->next);
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 51
diff changeset
1333 if (ety == llvm::Type::VoidTy)
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 51
diff changeset
1334 ety = llvm::Type::Int8Ty;
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 51
diff changeset
1335
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1336 if (u->type == elem::SLICE) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1337 e->mem = new llvm::BitCastInst(u->mem, ptrty, "tmp", p->scopebb());
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 51
diff changeset
1338 if (fromtype->next->size() == totype->next->size())
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 51
diff changeset
1339 e->arg = u->arg;
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 51
diff changeset
1340 else
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
1341 e->arg = DtoArrayCastLength(u->arg, ety, ptrty->getContainedType(0));
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1342 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1343 else {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1344 llvm::Value* uval = u->getValue();
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1345 if (fromtype->ty == Tsarray) {
4
e116aa1488e6 [svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents: 1
diff changeset
1346 Logger::cout() << "uvalTy = " << *uval->getType() << '\n';
e116aa1488e6 [svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents: 1
diff changeset
1347 assert(llvm::isa<llvm::PointerType>(uval->getType()));
e116aa1488e6 [svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents: 1
diff changeset
1348 const llvm::ArrayType* arrty = llvm::cast<llvm::ArrayType>(uval->getType()->getContainedType(0));
81
3587401b6eeb [svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents: 78
diff changeset
1349 e->arg = llvm::ConstantInt::get(DtoSize_t(), arrty->getNumElements(), false);
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
1350 e->arg = DtoArrayCastLength(e->arg, ety, ptrty->getContainedType(0));
4
e116aa1488e6 [svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents: 1
diff changeset
1351 e->mem = new llvm::BitCastInst(uval, ptrty, "tmp", p->scopebb());
e116aa1488e6 [svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents: 1
diff changeset
1352 }
e116aa1488e6 [svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents: 1
diff changeset
1353 else {
e116aa1488e6 [svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents: 1
diff changeset
1354 llvm::Value* zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false);
e116aa1488e6 [svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents: 1
diff changeset
1355 llvm::Value* one = llvm::ConstantInt::get(llvm::Type::Int32Ty, 1, 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
1356 e->arg = DtoGEP(uval,zero,zero,"tmp",p->scopebb());
4
e116aa1488e6 [svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents: 1
diff changeset
1357 e->arg = new llvm::LoadInst(e->arg, "tmp", p->scopebb());
81
3587401b6eeb [svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents: 78
diff changeset
1358 e->arg = DtoArrayCastLength(e->arg, ety, ptrty->getContainedType(0));
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
1359
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
1360 e->mem = DtoGEP(uval,zero,one,"tmp",p->scopebb());
4
e116aa1488e6 [svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents: 1
diff changeset
1361 e->mem = new llvm::LoadInst(e->mem, "tmp", p->scopebb());
e116aa1488e6 [svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents: 1
diff changeset
1362 //Logger::cout() << *e->mem->getType() << '|' << *ptrty << '\n';
e116aa1488e6 [svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents: 1
diff changeset
1363 e->mem = new llvm::BitCastInst(e->mem, ptrty, "tmp", p->scopebb());
e116aa1488e6 [svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents: 1
diff changeset
1364 }
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1365 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1366 e->type = elem::SLICE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1367 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1368 else if (totype->ty == Tsarray) {
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1369 Logger::cout() << "to sarray" << '\n';
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1370 assert(0);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1371 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1372 else {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1373 assert(0);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1374 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1375 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1376 else if (fromtype->ty == Tpointer) {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1377 if (totype->ty == Tpointer || totype->ty == Tclass) {
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1378 llvm::Value* src = u->getValue();
57
a9d29e9f1fed [svn r61] Added support for D-style variadic functions :)
lindquist
parents: 55
diff changeset
1379 Logger::cout() << *src << '|' << *tolltype << '\n';
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1380 e->val = new llvm::BitCastInst(src, tolltype, "tmp", p->scopebb());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1381 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1382 else if (totype->isintegral()) {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1383 e->val = new llvm::PtrToIntInst(u->getValue(), tolltype, "tmp", p->scopebb());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1384 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1385 else
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1386 assert(0);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1387 e->type = elem::VAL;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1388 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1389 else {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1390 assert(0);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1391 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1392 delete u;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1393 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1394 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1395
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1396 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1397
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1398 elem* SymOffExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1399 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1400 Logger::print("SymOffExp::toElem: %s | %s\n", toChars(), type->toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1401 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1402 elem* e = 0;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1403 if (VarDeclaration* vd = var->isVarDeclaration())
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1404 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1405 Logger::println("VarDeclaration");
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 51
diff changeset
1406 if (!vd->llvmTouched && vd->isDataseg())
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 51
diff changeset
1407 vd->toObjFile();
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 51
diff changeset
1408
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 51
diff changeset
1409 if (vd->isTypedefDeclaration()) {
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 51
diff changeset
1410 e->istypeinfo = true;
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 51
diff changeset
1411 }
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 51
diff changeset
1412
23
77e3d1ddae3f [svn r27] * Fixed bug in aggregate field lookup.
lindquist
parents: 21
diff changeset
1413 assert(vd->llvmValue);
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
1414 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
1415 Type* tnext = DtoDType(t->next);
3587401b6eeb [svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents: 78
diff changeset
1416 Type* vdtype = DtoDType(vd->type);
3587401b6eeb [svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents: 78
diff changeset
1417
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
1418 llvm::Value* llvalue = vd->nestedref ? DtoNestedVariable(vd) : vd->llvmValue;
50
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
1419
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1420 if (vdtype->ty == Tstruct && !(t->ty == Tpointer && t->next == vdtype)) {
78
2332006e1fa4 [svn r82] Fixed: Fall-through switch cases were broken.
lindquist
parents: 77
diff changeset
1421 Logger::println("struct");
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1422 TypeStruct* vdt = (TypeStruct*)vdtype;
72
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 70
diff changeset
1423 assert(vdt->sym);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1424 e = new elem;
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
1425 const llvm::Type* llt = DtoType(t);
72
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 70
diff changeset
1426 if (offset == 0) {
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 70
diff changeset
1427 e->mem = p->ir->CreateBitCast(llvalue, llt, "tmp");
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 70
diff changeset
1428 }
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 70
diff changeset
1429 else {
77
714057ff2dbb [svn r81] Fixed: Union support was very buggy. Should be fairly solid now.
lindquist
parents: 76
diff changeset
1430 std::vector<unsigned> dst;
81
3587401b6eeb [svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents: 78
diff changeset
1431 e->mem = DtoIndexStruct(llvalue,vdt->sym, tnext, offset, dst);
72
d7e764e62462 [svn r76] Fixed: TypeInfo for structs.
lindquist
parents: 70
diff changeset
1432 }
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1433 e->type = elem::VAL;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1434 e->field = true;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1435 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1436 else if (vdtype->ty == Tsarray) {
78
2332006e1fa4 [svn r82] Fixed: Fall-through switch cases were broken.
lindquist
parents: 77
diff changeset
1437 Logger::println("sarray");
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1438 e = new elem;
64
b688ad419f8c [svn r68] Added support for multi-dimensional static arrays.
lindquist
parents: 62
diff changeset
1439 assert(llvalue);
50
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
1440 e->arg = llvalue;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1441 e->type = elem::VAL;
64
b688ad419f8c [svn r68] Added support for multi-dimensional static arrays.
lindquist
parents: 62
diff changeset
1442
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
1443 const llvm::Type* llt = DtoType(t);
64
b688ad419f8c [svn r68] Added support for multi-dimensional static arrays.
lindquist
parents: 62
diff changeset
1444 llvm::Value* off = 0;
b688ad419f8c [svn r68] Added support for multi-dimensional static arrays.
lindquist
parents: 62
diff changeset
1445 if (offset != 0) {
b688ad419f8c [svn r68] Added support for multi-dimensional static arrays.
lindquist
parents: 62
diff changeset
1446 Logger::println("offset = %d\n", offset);
b688ad419f8c [svn r68] Added support for multi-dimensional static arrays.
lindquist
parents: 62
diff changeset
1447 }
b688ad419f8c [svn r68] Added support for multi-dimensional static arrays.
lindquist
parents: 62
diff changeset
1448 if (llvalue->getType() != llt) {
b688ad419f8c [svn r68] Added support for multi-dimensional static arrays.
lindquist
parents: 62
diff changeset
1449 e->mem = p->ir->CreateBitCast(llvalue, llt, "tmp");
b688ad419f8c [svn r68] Added support for multi-dimensional static arrays.
lindquist
parents: 62
diff changeset
1450 if (offset != 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
1451 e->mem = DtoGEPi(e->mem, offset, "tmp");
64
b688ad419f8c [svn r68] Added support for multi-dimensional static arrays.
lindquist
parents: 62
diff changeset
1452 }
b688ad419f8c [svn r68] Added support for multi-dimensional static arrays.
lindquist
parents: 62
diff changeset
1453 else {
b688ad419f8c [svn r68] Added support for multi-dimensional static arrays.
lindquist
parents: 62
diff changeset
1454 assert(offset == 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
1455 e->mem = DtoGEPi(llvalue,0,0,"tmp");
64
b688ad419f8c [svn r68] Added support for multi-dimensional static arrays.
lindquist
parents: 62
diff changeset
1456 }
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1457 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1458 else if (offset == 0) {
78
2332006e1fa4 [svn r82] Fixed: Fall-through switch cases were broken.
lindquist
parents: 77
diff changeset
1459 Logger::println("normal symoff");
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1460 e = new elem;
64
b688ad419f8c [svn r68] Added support for multi-dimensional static arrays.
lindquist
parents: 62
diff changeset
1461 e->type = elem::VAL;
50
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
1462 assert(llvalue);
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
1463 e->mem = llvalue;
64
b688ad419f8c [svn r68] Added support for multi-dimensional static arrays.
lindquist
parents: 62
diff changeset
1464
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
1465 const llvm::Type* llt = DtoType(t);
53
06ccc817acd4 [svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents: 52
diff changeset
1466 if (llvalue->getType() != llt) {
06ccc817acd4 [svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents: 52
diff changeset
1467 e->mem = p->ir->CreateBitCast(e->mem, llt, "tmp");
06ccc817acd4 [svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents: 52
diff changeset
1468 }
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1469 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1470 else {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1471 assert(0);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1472 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1473 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1474 else if (FuncDeclaration* fd = var->isFuncDeclaration())
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1475 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1476 Logger::println("FuncDeclaration");
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1477 e = new elem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1478 if (fd->llvmValue == 0)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1479 fd->toObjFile();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1480 e->val = fd->llvmValue;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1481 e->type = elem::FUNC;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1482 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1483 assert(e != 0);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1484 assert(e->type != elem::NONE);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1485 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1486 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1487
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1488 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1489
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1490 elem* PtrExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1491 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1492 Logger::print("PtrExp::toElem: %s | %s\n", toChars(), type->toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1493 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1494 elem* e = new elem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1495 elem* a = e1->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1496
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1497 if (a->mem)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1498 Logger::cout() << "mem: " << *a->mem << '\n';
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1499 if (a->val)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1500 Logger::cout() << "val: " << *a->val << '\n';
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1501
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1502 if (a->field)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1503 e->mem = a->mem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1504 else
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1505 e->mem = a->getValue();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1506 e->type = elem::VAR;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1507
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1508 delete a;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1509 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1510 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1511
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1512 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1513
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1514 elem* DotVarExp::toElem(IRState* p)
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 Logger::print("DotVarExp::toElem: %s | %s\n", toChars(), type->toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1517 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1518 elem* e = new elem;
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 elem* l = e1->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1521
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
1522 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
1523 Type* e1type = DtoDType(e1->type);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1524
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1525 Logger::print("e1->type=%s\n", e1type->toChars());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1526
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1527 if (VarDeclaration* vd = var->isVarDeclaration()) {
77
714057ff2dbb [svn r81] Fixed: Union support was very buggy. Should be fairly solid now.
lindquist
parents: 76
diff changeset
1528 llvm::Value* arrptr;
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1529 if (e1type->ty == Tpointer) {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1530 assert(e1type->next->ty == Tstruct);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1531 TypeStruct* ts = (TypeStruct*)e1type->next;
8
5e69b77a5c51 [svn r12] fixed accessing aggregate fields of aggregates
lindquist
parents: 6
diff changeset
1532 Logger::println("Struct member offset:%d", vd->offset);
77
714057ff2dbb [svn r81] Fixed: Union support was very buggy. Should be fairly solid now.
lindquist
parents: 76
diff changeset
1533 llvm::Value* src = l->val ? l->val : l->mem;
714057ff2dbb [svn r81] Fixed: Union support was very buggy. Should be fairly solid now.
lindquist
parents: 76
diff changeset
1534 std::vector<unsigned> 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
1535 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
1536 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1537 else if (e1->type->ty == Tclass) {
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1538 TypeClass* tc = (TypeClass*)e1type;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1539 Logger::println("Class member offset: %d", vd->offset);
77
714057ff2dbb [svn r81] Fixed: Union support was very buggy. Should be fairly solid now.
lindquist
parents: 76
diff changeset
1540 std::vector<unsigned> vdoffsets(1,0);
24
25bb577878e8 [svn r28] * Fixed accessing aggregate fields. it was still not quite right. hopefully is now :)
lindquist
parents: 23
diff changeset
1541 tc->sym->offsetToIndex(vd->type, vd->offset, vdoffsets);
77
714057ff2dbb [svn r81] Fixed: Union support was very buggy. Should be fairly solid now.
lindquist
parents: 76
diff changeset
1542 llvm::Value* src = l->getValue();
714057ff2dbb [svn r81] Fixed: Union support was very buggy. Should be fairly solid now.
lindquist
parents: 76
diff changeset
1543 Logger::cout() << "src: " << *src << '\n';
81
3587401b6eeb [svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents: 78
diff changeset
1544 arrptr = DtoGEP(src,vdoffsets,"tmp",p->scopebb());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1545 }
77
714057ff2dbb [svn r81] Fixed: Union support was very buggy. Should be fairly solid now.
lindquist
parents: 76
diff changeset
1546 else
714057ff2dbb [svn r81] Fixed: Union support was very buggy. Should be fairly solid now.
lindquist
parents: 76
diff changeset
1547 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1548 e->mem = arrptr;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1549 Logger::cout() << "mem: " << *e->mem << '\n';
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1550 e->type = elem::VAR;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1551 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1552 else if (FuncDeclaration* fdecl = var->isFuncDeclaration())
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1553 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1554 if (fdecl->llvmValue == 0)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1555 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1556 fdecl->toObjFile();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1557 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1558
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1559 llvm::Value* funcval = fdecl->llvmValue;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1560 e->arg = l->getValue();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1561
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1562 // virtual call
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1563 if (fdecl->isVirtual()) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1564 assert(fdecl->vtblIndex > 0);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1565 assert(e1type->ty == Tclass);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1566
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1567 llvm::Value* zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1568 llvm::Value* vtblidx = llvm::ConstantInt::get(llvm::Type::Int32Ty, (size_t)fdecl->vtblIndex, 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
1569 funcval = DtoGEP(e->arg, zero, zero, "tmp", p->scopebb());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1570 funcval = new llvm::LoadInst(funcval,"tmp",p->scopebb());
81
3587401b6eeb [svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents: 78
diff changeset
1571 funcval = DtoGEP(funcval, zero, vtblidx, toChars(), p->scopebb());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1572 funcval = new llvm::LoadInst(funcval,"tmp",p->scopebb());
9
dafae18f9c08 [svn r13] * Updated for LLVM 2.1
lindquist
parents: 8
diff changeset
1573 assert(funcval->getType() == fdecl->llvmValue->getType());
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
1574 e->callconv = DtoCallingConv(fdecl->linkage);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1575 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1576 e->val = funcval;
66
0c5f410d973c [svn r70] Fixed bug where correct calling convention was not set on calling aggregate methods
lindquist
parents: 64
diff changeset
1577 e->type = elem::FUNC;
0c5f410d973c [svn r70] Fixed bug where correct calling convention was not set on calling aggregate methods
lindquist
parents: 64
diff changeset
1578 e->funcdecl = fdecl;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1579 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1580 else {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1581 printf("unknown: %s\n", var->toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1582 assert(0);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1583 }
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 delete l;
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 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1588 }
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 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1591
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1592 elem* ThisExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1593 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1594 Logger::print("ThisExp::toElem: %s | %s\n", toChars(), type->toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1595 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1596 elem* e = new elem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1597
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1598 if (VarDeclaration* vd = var->isVarDeclaration()) {
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1599 llvm::Value* v = p->func().decl->llvmThisVar;
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
1600 if (llvm::isa<llvm::AllocaInst>(v))
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
1601 v = new llvm::LoadInst(v, "tmp", p->scopebb());
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
1602 e->mem = v;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1603 e->type = elem::VAL;
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
1604 e->isthis = true;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1605 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1606 else {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1607 assert(0);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1608 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1609
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1610 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1611 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1612
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1613 //////////////////////////////////////////////////////////////////////////////////////////
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 elem* AddrExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1616 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1617 Logger::print("AddrExp::toElem: %s | %s\n", toChars(), type->toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1618 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1619 elem* e = e1->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1620 e->field = true;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1621 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1622 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1623
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1624 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1625
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1626 elem* StructLiteralExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1627 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1628 Logger::print("StructLiteralExp::toElem: %s | %s\n", toChars(), type->toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1629 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1630 elem* e = new elem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1631
76
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1632 llvm::Value* sptr;
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
1633 const llvm::Type* llt = DtoType(type);
76
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1634
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1635 // temporary struct literal
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
1636 if (!p->topexp() || p->topexp()->e2 != this)
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1637 {
76
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1638 sptr = new llvm::AllocaInst(llt,"tmpstructliteral",p->topallocapoint());
30
881158a93592 [svn r34] * Fixed passing a struct literal as function argument
lindquist
parents: 29
diff changeset
1639 e->mem = sptr;
881158a93592 [svn r34] * Fixed passing a struct literal as function argument
lindquist
parents: 29
diff changeset
1640 e->type = elem::VAR;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1641 }
30
881158a93592 [svn r34] * Fixed passing a struct literal as function argument
lindquist
parents: 29
diff changeset
1642 // already has memory
76
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1643 else
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1644 {
76
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1645 assert(p->topexp()->e2 == this);
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
1646 sptr = p->topexp()->v;
30
881158a93592 [svn r34] * Fixed passing a struct literal as function argument
lindquist
parents: 29
diff changeset
1647 }
76
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1648
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1649 // num elements in literal
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1650 unsigned n = elements->dim;
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1651
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1652 // unions might have different types for each literal
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1653 if (sd->llvmHasUnions) {
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1654 // build the type of the literal
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1655 std::vector<const llvm::Type*> tys;
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1656 for (unsigned i=0; i<n; ++i) {
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1657 Expression* vx = (Expression*)elements->data[i];
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1658 if (!vx) continue;
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
1659 tys.push_back(DtoType(vx->type));
76
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1660 }
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1661 const llvm::StructType* t = llvm::StructType::get(tys);
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1662 if (t != llt) {
77
714057ff2dbb [svn r81] Fixed: Union support was very buggy. Should be fairly solid now.
lindquist
parents: 76
diff changeset
1663 if (gTargetData->getTypeSize(t) != gTargetData->getTypeSize(llt)) {
714057ff2dbb [svn r81] Fixed: Union support was very buggy. Should be fairly solid now.
lindquist
parents: 76
diff changeset
1664 Logger::cout() << "got size " << gTargetData->getTypeSize(t) << ", expected " << gTargetData->getTypeSize(llt) << '\n';
714057ff2dbb [svn r81] Fixed: Union support was very buggy. Should be fairly solid now.
lindquist
parents: 76
diff changeset
1665 assert(0 && "type size mismatch");
714057ff2dbb [svn r81] Fixed: Union support was very buggy. Should be fairly solid now.
lindquist
parents: 76
diff changeset
1666 }
76
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1667 sptr = p->ir->CreateBitCast(sptr, llvm::PointerType::get(t), "tmp");
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1668 Logger::cout() << "sptr type is now: " << *t << '\n';
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1669 }
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1670 }
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1671
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1672 // build
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1673 unsigned j = 0;
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1674 for (unsigned i=0; i<n; ++i)
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1675 {
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1676 Expression* vx = (Expression*)elements->data[i];
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1677 if (!vx) continue;
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1678
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1679 Logger::cout() << "getting index " << j << " of " << *sptr << '\n';
81
3587401b6eeb [svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents: 78
diff changeset
1680 llvm::Value* arrptr = DtoGEPi(sptr,0,j,"tmp",p->scopebb());
73
b706170e24a9 [svn r77] Fixed foreach on slice.
lindquist
parents: 72
diff changeset
1681
b706170e24a9 [svn r77] Fixed foreach on slice.
lindquist
parents: 72
diff changeset
1682 p->exps.push_back(IRExp(NULL,vx,arrptr));
b706170e24a9 [svn r77] Fixed foreach on slice.
lindquist
parents: 72
diff changeset
1683 elem* ve = vx->toElem(p);
b706170e24a9 [svn r77] Fixed foreach on slice.
lindquist
parents: 72
diff changeset
1684 p->exps.pop_back();
b706170e24a9 [svn r77] Fixed foreach on slice.
lindquist
parents: 72
diff changeset
1685
b706170e24a9 [svn r77] Fixed foreach on slice.
lindquist
parents: 72
diff changeset
1686 if (!ve->inplace) {
b706170e24a9 [svn r77] Fixed foreach on slice.
lindquist
parents: 72
diff changeset
1687 llvm::Value* val = ve->getValue();
b706170e24a9 [svn r77] Fixed foreach on slice.
lindquist
parents: 72
diff changeset
1688 Logger::cout() << *val << " | " << *arrptr << '\n';
76
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1689
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
1690 Type* vxtype = DtoDType(vx->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
1691 DtoAssign(vxtype, arrptr, val);
73
b706170e24a9 [svn r77] Fixed foreach on slice.
lindquist
parents: 72
diff changeset
1692 }
b706170e24a9 [svn r77] Fixed foreach on slice.
lindquist
parents: 72
diff changeset
1693 delete ve;
76
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1694
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents: 73
diff changeset
1695 j++;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1696 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1697
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1698 e->inplace = true;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1699
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1700 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1701 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1702
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1703 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1704
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1705 llvm::Constant* StructLiteralExp::toConstElem(IRState* p)
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1706 {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1707 Logger::print("StructLiteralExp::toConstElem: %s | %s\n", toChars(), type->toChars());
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1708 LOG_SCOPE;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1709
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1710 unsigned n = elements->dim;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1711 std::vector<llvm::Constant*> vals(n, NULL);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1712
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1713 for (unsigned i=0; i<n; ++i)
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1714 {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1715 Expression* vx = (Expression*)elements->data[i];
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1716 vals[i] = vx->toConstElem(p);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1717 }
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1718
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
1719 assert(DtoDType(type)->ty == Tstruct);
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
1720 const llvm::Type* t = DtoType(type);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1721 const llvm::StructType* st = llvm::cast<llvm::StructType>(t);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1722 return llvm::ConstantStruct::get(st,vals);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1723 }
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1724
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1725 //////////////////////////////////////////////////////////////////////////////////////////
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1726
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1727 elem* IndexExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1728 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1729 Logger::print("IndexExp::toElem: %s | %s\n", toChars(), type->toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1730 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1731
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1732 elem* e = new elem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1733
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1734 elem* l = e1->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1735
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
1736 Type* e1type = DtoDType(e1->type);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1737
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1738 p->arrays.push_back(l->mem); // if $ is used it must be an array so this is fine.
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1739 elem* r = e2->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1740 p->arrays.pop_back();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1741
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1742 llvm::Value* zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1743 llvm::Value* one = llvm::ConstantInt::get(llvm::Type::Int32Ty, 1, false);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1744
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1745 llvm::Value* arrptr = 0;
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1746 if (e1type->ty == Tpointer) {
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1747 arrptr = new llvm::GetElementPtrInst(l->getValue(),r->getValue(),"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1748 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1749 else if (e1type->ty == Tsarray) {
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
1750 arrptr = DtoGEP(l->getValue(), zero, r->getValue(),"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->ty == Tarray) {
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
1753 arrptr = DtoGEP(l->mem,zero,one,"tmp",p->scopebb());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1754 arrptr = new llvm::LoadInst(arrptr,"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1755 arrptr = new llvm::GetElementPtrInst(arrptr,r->getValue(),"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1756 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1757 assert(arrptr);
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 e->mem = arrptr;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1760 e->type = elem::VAR;
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 delete l;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1763 delete r;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1764
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1765 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1766 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1767
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1768 //////////////////////////////////////////////////////////////////////////////////////////
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 elem* SliceExp::toElem(IRState* p)
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 Logger::print("SliceExp::toElem: %s | %s\n", toChars(), type->toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1773 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1774
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
1775 Type* t = DtoDType(type);
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 51
diff changeset
1776 assert(t->ty == Tarray);
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 51
diff changeset
1777
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1778 elem* v = e1->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
1779 Type* e1type = DtoDType(e1->type);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1780
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1781 elem* e = new elem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1782 assert(v->mem);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1783 e->type = elem::SLICE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1784
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1785 llvm::Value* zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1786 llvm::Value* one = llvm::ConstantInt::get(llvm::Type::Int32Ty, 1, false);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1787
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1788 // partial slice
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1789 if (lwr)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1790 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1791 assert(upr);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1792 p->arrays.push_back(v->mem);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1793 elem* lo = lwr->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1794
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1795 bool lwr_is_zero = false;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1796 if (lo->type == elem::CONST)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1797 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1798 assert(lo->val);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1799 assert(llvm::isa<llvm::ConstantInt>(lo->val));
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1800
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1801 if (e1type->ty == Tpointer) {
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1802 e->mem = v->getValue();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1803 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1804 else if (e1type->ty == Tarray) {
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
1805 llvm::Value* tmp = DtoGEP(v->mem,zero,one,"tmp",p->scopebb());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1806 e->mem = new llvm::LoadInst(tmp,"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1807 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1808 else if (e1type->ty == Tsarray) {
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
1809 e->mem = DtoGEP(v->mem,zero,zero,"tmp",p->scopebb());
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1810 }
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1811 else
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1812 assert(e->mem);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1813
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1814 llvm::ConstantInt* c = llvm::cast<llvm::ConstantInt>(lo->val);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1815 if (!(lwr_is_zero = c->isZero())) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1816 e->mem = new llvm::GetElementPtrInst(e->mem,lo->val,"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1817 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1818 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1819 else
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1820 {
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1821 if (e1type->ty == Tarray) {
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
1822 llvm::Value* tmp = DtoGEP(v->mem,zero,one,"tmp",p->scopebb());
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1823 tmp = new llvm::LoadInst(tmp,"tmp",p->scopebb());
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1824 e->mem = new llvm::GetElementPtrInst(tmp,lo->getValue(),"tmp",p->scopebb());
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1825 }
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1826 else if (e1type->ty == Tsarray) {
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
1827 e->mem = DtoGEP(v->mem,zero,lo->getValue(),"tmp",p->scopebb());
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1828 }
73
b706170e24a9 [svn r77] Fixed foreach on slice.
lindquist
parents: 72
diff changeset
1829 else if (e1type->ty == Tpointer) {
b706170e24a9 [svn r77] Fixed foreach on slice.
lindquist
parents: 72
diff changeset
1830 e->mem = new llvm::GetElementPtrInst(v->getValue(),lo->getValue(),"tmp",p->scopebb());
b706170e24a9 [svn r77] Fixed foreach on slice.
lindquist
parents: 72
diff changeset
1831 }
b706170e24a9 [svn r77] Fixed foreach on slice.
lindquist
parents: 72
diff changeset
1832 else {
b706170e24a9 [svn r77] Fixed foreach on slice.
lindquist
parents: 72
diff changeset
1833 Logger::println("type = %s", e1type->toChars());
b706170e24a9 [svn r77] Fixed foreach on slice.
lindquist
parents: 72
diff changeset
1834 assert(0);
b706170e24a9 [svn r77] Fixed foreach on slice.
lindquist
parents: 72
diff changeset
1835 }
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1836 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1837
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1838 elem* up = upr->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1839 p->arrays.pop_back();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1840
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1841 if (up->type == elem::CONST)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1842 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1843 assert(up->val);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1844 assert(llvm::isa<llvm::ConstantInt>(up->val));
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1845 if (lwr_is_zero) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1846 e->arg = up->val;
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 else {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1849 if (lo->type == elem::CONST) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1850 llvm::Constant* clo = llvm::cast<llvm::Constant>(lo->val);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1851 llvm::Constant* cup = llvm::cast<llvm::Constant>(up->val);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1852 e->arg = llvm::ConstantExpr::getSub(cup, clo);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1853 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1854 else {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1855 e->arg = llvm::BinaryOperator::createSub(up->val, lo->getValue(), "tmp", p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1856 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1857 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1858 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1859 else
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1860 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1861 if (lwr_is_zero) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1862 e->arg = up->getValue();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1863 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1864 else {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1865 e->arg = llvm::BinaryOperator::createSub(up->getValue(), lo->getValue(), "tmp", p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1866 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1867 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1868
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1869 delete lo;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1870 delete up;
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 51
diff changeset
1871
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 51
diff changeset
1872 /*
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
1873 llvm::Value* tmpmem = new llvm::AllocaInst(DtoType(t),"tmp",p->topallocapoint());
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
1874 llvm::Value* ptr = DtoGEPi(tmpmem,0,0,"tmp");
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 51
diff changeset
1875 p->ir->CreateStore(e->arg, ptr);
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
1876 ptr = DtoGEPi(tmpmem,0,1,"tmp");
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 51
diff changeset
1877 p->ir->CreateStore(e->mem, ptr);
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 51
diff changeset
1878 e->arg = NULL;
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 51
diff changeset
1879 e->mem = tmpmem;
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 51
diff changeset
1880 */
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1881 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1882 // full slice
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1883 else
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1884 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1885 e->mem = v->mem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1886 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1887
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1888 delete v;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1889
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1890 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1891 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1892
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1893 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1894
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1895 elem* CmpExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1896 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1897 Logger::print("CmpExp::toElem: %s | %s\n", toChars(), type->toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1898 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1899
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1900 elem* e = new elem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1901
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1902 elem* l = e1->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1903 elem* r = e2->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1904
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
1905 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
1906 Type* e2t = DtoDType(e2->type);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1907 assert(t == e2t);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1908
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
1909 if (t->isintegral() || t->ty == Tpointer)
1
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 llvm::ICmpInst::Predicate cmpop;
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1912 bool skip = false;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1913 switch(op)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1914 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1915 case TOKlt:
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1916 case TOKul:
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1917 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
1918 break;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1919 case TOKle:
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1920 case TOKule:
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1921 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
1922 break;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1923 case TOKgt:
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1924 case TOKug:
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1925 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
1926 break;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1927 case TOKge:
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1928 case TOKuge:
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1929 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
1930 break;
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1931 case TOKue:
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1932 cmpop = llvm::ICmpInst::ICMP_EQ;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1933 break;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1934 case TOKlg:
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1935 cmpop = llvm::ICmpInst::ICMP_NE;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1936 break;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1937 case TOKleg:
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1938 skip = true;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1939 e->val = llvm::ConstantInt::getTrue();
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1940 break;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1941 case TOKunord:
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1942 skip = true;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1943 e->val = llvm::ConstantInt::getFalse();
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1944 break;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1945
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1946 default:
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1947 assert(0);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1948 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1949 if (!skip)
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1950 {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1951 e->val = new llvm::ICmpInst(cmpop, l->getValue(), r->getValue(), "tmp", p->scopebb());
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1952 }
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1953 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1954 else if (t->isfloating())
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 llvm::FCmpInst::Predicate cmpop;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1957 switch(op)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1958 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1959 case TOKlt:
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1960 cmpop = llvm::FCmpInst::FCMP_OLT;break;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1961 case TOKle:
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1962 cmpop = llvm::FCmpInst::FCMP_OLE;break;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1963 case TOKgt:
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1964 cmpop = llvm::FCmpInst::FCMP_OGT;break;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1965 case TOKge:
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1966 cmpop = llvm::FCmpInst::FCMP_OGE;break;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1967 case TOKunord:
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1968 cmpop = llvm::FCmpInst::FCMP_UNO;break;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1969 case TOKule:
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1970 cmpop = llvm::FCmpInst::FCMP_ULE;break;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1971 case TOKul:
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1972 cmpop = llvm::FCmpInst::FCMP_ULT;break;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1973 case TOKuge:
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1974 cmpop = llvm::FCmpInst::FCMP_UGE;break;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1975 case TOKug:
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1976 cmpop = llvm::FCmpInst::FCMP_UGT;break;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1977 case TOKue:
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1978 cmpop = llvm::FCmpInst::FCMP_UEQ;break;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1979 case TOKlg:
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1980 cmpop = llvm::FCmpInst::FCMP_ONE;break;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1981 case TOKleg:
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1982 cmpop = llvm::FCmpInst::FCMP_ORD;break;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1983
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1984 default:
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1985 assert(0);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1986 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1987 e->val = new llvm::FCmpInst(cmpop, l->getValue(), r->getValue(), "tmp", p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1988 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1989 else
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1990 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1991 assert(0 && "Unsupported CmpExp type");
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1992 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1993
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1994 delete l;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1995 delete r;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1996
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1997 e->type = elem::VAL;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1998
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
1999 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2000 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2001
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2002 //////////////////////////////////////////////////////////////////////////////////////////
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 elem* EqualExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2005 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2006 Logger::print("EqualExp::toElem: %s | %s\n", toChars(), type->toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2007 LOG_SCOPE;
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 elem* e = new elem;
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 elem* l = e1->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2012 elem* r = e2->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2013
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
2014 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
2015 Type* e2t = DtoDType(e2->type);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2016 assert(t == e2t);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2017
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2018 if (t->isintegral() || t->ty == Tpointer)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2019 {
64
b688ad419f8c [svn r68] Added support for multi-dimensional static arrays.
lindquist
parents: 62
diff changeset
2020 Logger::println("integral or pointer");
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2021 llvm::ICmpInst::Predicate cmpop;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2022 switch(op)
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 case TOKequal:
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2025 cmpop = llvm::ICmpInst::ICMP_EQ;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2026 break;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2027 case TOKnotequal:
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2028 cmpop = llvm::ICmpInst::ICMP_NE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2029 break;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2030 default:
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2031 assert(0);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2032 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2033 e->val = new llvm::ICmpInst(cmpop, l->getValue(), r->getValue(), "tmp", p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2034 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2035 else if (t->isfloating())
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2036 {
64
b688ad419f8c [svn r68] Added support for multi-dimensional static arrays.
lindquist
parents: 62
diff changeset
2037 Logger::println("floating");
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2038 llvm::FCmpInst::Predicate cmpop;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2039 switch(op)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2040 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2041 case TOKequal:
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2042 cmpop = llvm::FCmpInst::FCMP_OEQ;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2043 break;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2044 case TOKnotequal:
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2045 cmpop = llvm::FCmpInst::FCMP_UNE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2046 break;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2047 default:
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2048 assert(0);
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 e->val = new llvm::FCmpInst(cmpop, l->getValue(), r->getValue(), "tmp", p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2051 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2052 else if (t->ty == Tsarray)
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2053 {
64
b688ad419f8c [svn r68] Added support for multi-dimensional static arrays.
lindquist
parents: 62
diff changeset
2054 Logger::println("static array");
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
2055 e->val = DtoStaticArrayCompare(op,l->mem,r->mem);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2056 }
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2057 else if (t->ty == Tarray)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2058 {
64
b688ad419f8c [svn r68] Added support for multi-dimensional static arrays.
lindquist
parents: 62
diff changeset
2059 Logger::println("dynamic array");
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
2060 e->val = DtoDynArrayCompare(op,l->mem,r->mem);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2061 }
53
06ccc817acd4 [svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents: 52
diff changeset
2062 else if (t->ty == Tdelegate)
06ccc817acd4 [svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents: 52
diff changeset
2063 {
64
b688ad419f8c [svn r68] Added support for multi-dimensional static arrays.
lindquist
parents: 62
diff changeset
2064 Logger::println("delegate");
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
2065 e->val = DtoCompareDelegate(op,l->mem,r->mem);
53
06ccc817acd4 [svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents: 52
diff changeset
2066 }
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2067 else
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2068 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2069 assert(0 && "Unsupported EqualExp type");
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
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2072 delete l;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2073 delete r;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2074
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2075 e->type = elem::VAL;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2076
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2077 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2078 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2079
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2080 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2081
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2082 elem* PostExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2083 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2084 Logger::print("PostExp::toElem: %s | %s\n", toChars(), type->toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2085 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2086
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2087 elem* l = e1->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2088 elem* r = e2->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2089
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2090 elem* e = new elem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2091 e->mem = l->mem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2092 e->val = l->getValue();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2093 e->type = elem::VAL;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2094
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2095 llvm::Value* val = e->val;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2096 llvm::Value* post = 0;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2097
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
2098 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
2099 Type* e2type = DtoDType(e2->type);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2100
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2101 if (e1type->isintegral())
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2102 {
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2103 assert(e2type->isintegral());
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2104 llvm::Value* one = llvm::ConstantInt::get(val->getType(), 1, !e2type->isunsigned());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2105 if (op == TOKplusplus) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2106 post = llvm::BinaryOperator::createAdd(val,one,"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2107 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2108 else if (op == TOKminusminus) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2109 post = llvm::BinaryOperator::createSub(val,one,"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2110 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2111 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2112 else if (e1type->ty == Tpointer)
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2113 {
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2114 assert(e2type->isintegral());
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
2115 llvm::Constant* minusone = llvm::ConstantInt::get(DtoSize_t(),(uint64_t)-1,true);
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
2116 llvm::Constant* plusone = llvm::ConstantInt::get(DtoSize_t(),(uint64_t)1,false);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2117 llvm::Constant* whichone = (op == TOKplusplus) ? plusone : minusone;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2118 post = new llvm::GetElementPtrInst(val, whichone, "tmp", p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2119 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2120 else if (e1type->isfloating())
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2121 {
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2122 assert(e2type->isfloating());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2123 llvm::Value* one = llvm::ConstantFP::get(val->getType(), 1.0f);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2124 if (op == TOKplusplus) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2125 post = llvm::BinaryOperator::createAdd(val,one,"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2126 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2127 else if (op == TOKminusminus) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2128 post = llvm::BinaryOperator::createSub(val,one,"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2129 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2130 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2131 else
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2132 assert(post);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2133
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
2134 assert(l->mem);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2135 new llvm::StoreInst(post,l->mem,p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2136
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2137 delete l;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2138 delete r;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2139
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2140 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2141 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2142
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2143 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2144
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2145 elem* NewExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2146 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2147 Logger::print("NewExp::toElem: %s | %s\n", toChars(), type->toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2148 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2149
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2150 assert(!thisexp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2151 assert(!newargs);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2152 assert(newtype);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2153 assert(!allocator);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2154
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2155 elem* e = new elem;
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2156 e->inplace = true;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2157
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
2158 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
2159
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
2160 const llvm::Type* t = DtoType(ntype);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2161
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2162 if (onstack) {
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2163 assert(ntype->ty == Tclass);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2164 e->mem = new llvm::AllocaInst(t->getContainedType(0),"tmp",p->topallocapoint());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2165 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2166 else {
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2167 if (ntype->ty == Tclass) {
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2168 e->mem = new llvm::MallocInst(t->getContainedType(0),"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2169 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2170 else if (ntype->ty == Tarray) {
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2171 assert(arguments);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2172 if (arguments->dim == 1) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2173 elem* sz = ((Expression*)arguments->data[0])->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2174 llvm::Value* dimval = sz->getValue();
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
2175 Type* nnt = DtoDType(ntype->next);
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2176 if (nnt->ty == Tvoid)
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2177 nnt = Type::tint8;
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2178 if (!p->topexp() || p->topexp()->e2 != this) {
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
2179 const llvm::Type* restype = DtoType(type);
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2180 Logger::cout() << "restype = " << *restype << '\n';
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2181 e->mem = new llvm::AllocaInst(restype,"tmp",p->topallocapoint());
81
3587401b6eeb [svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents: 78
diff changeset
2182 DtoNewDynArray(e->mem, dimval, nnt);
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2183 e->inplace = false;
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2184 }
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2185 else if (p->topexp() || p->topexp()->e2 != this) {
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2186 assert(p->topexp()->v);
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2187 e->mem = p->topexp()->v;
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
2188 DtoNewDynArray(e->mem, dimval, nnt);
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2189 }
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2190 else
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2191 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2192 delete sz;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2193 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2194 else {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2195 assert(0);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2196 }
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 else {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2199 e->mem = new llvm::MallocInst(t,"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2200 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2201 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2202
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2203 if (ntype->ty == Tclass) {
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2204 // first apply the static initializer
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2205 assert(e->mem);
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
2206 DtoInitClass((TypeClass*)ntype, e->mem);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2207
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2208 // then call constructor
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2209 if (arguments) {
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2210 assert(member);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2211 assert(member->llvmValue);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2212 llvm::Function* fn = llvm::cast<llvm::Function>(member->llvmValue);
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
2213 TypeFunction* tf = (TypeFunction*)DtoDType(member->type);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2214
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2215 std::vector<llvm::Value*> ctorargs;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2216 ctorargs.push_back(e->mem);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2217 for (size_t i=0; i<arguments->dim; ++i)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2218 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2219 Expression* ex = (Expression*)arguments->data[i];
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2220 Argument* fnarg = Argument::getNth(tf->parameters, i);
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
2221 llvm::Value* a = DtoArgument(fn->getFunctionType()->getParamType(i+1), fnarg, ex);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2222 ctorargs.push_back(a);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2223 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2224 e->mem = new llvm::CallInst(fn, ctorargs.begin(), ctorargs.end(), "tmp", p->scopebb());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2225 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2226 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2227 else if (ntype->ty == Tstruct) {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2228 TypeStruct* ts = (TypeStruct*)ntype;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2229 if (ts->isZeroInit()) {
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
2230 DtoStructZeroInit(e->mem);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2231 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2232 else {
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
2233 DtoStructCopy(e->mem,ts->llvmInit);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2234 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2235 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2236
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2237 e->type = elem::VAR;
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
2238
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2239 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2240 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2241
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2242 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2243
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2244 elem* DeleteExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2245 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2246 Logger::print("DeleteExp::toElem: %s | %s\n", toChars(), type->toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2247 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2248
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2249 //assert(e1->type->ty != Tclass);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2250
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2251 elem* v = e1->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2252 llvm::Value* val = v->getValue();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2253 llvm::Value* ldval = 0;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2254
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2255 const llvm::Type* t = val->getType();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2256 llvm::Constant* z = llvm::Constant::getNullValue(t);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2257
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
2258 Type* e1type = DtoDType(e1->type);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2259
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2260 if (e1type->ty == Tpointer) {
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2261 ldval = v->getValue();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2262 new llvm::FreeInst(ldval, p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2263
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2264 Logger::cout() << *z << '\n';
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2265 Logger::cout() << *val << '\n';
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2266 new llvm::StoreInst(z, v->mem, p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2267 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2268 else if (e1type->ty == Tclass) {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2269 TypeClass* tc = (TypeClass*)e1type;
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
2270 DtoCallClassDtors(tc, val);
1
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 if (v->vardecl && !v->vardecl->onstack) {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2273 new llvm::FreeInst(val, p->scopebb());
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 new llvm::StoreInst(z, v->mem, p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2276 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2277 else if (e1type->ty == Tarray) {
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2278 // must be on the heap (correct?)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2279 ldval = v->getValue();
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 llvm::Value* zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2282 llvm::Value* one = llvm::ConstantInt::get(llvm::Type::Int32Ty, 1, false);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2283
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
2284 llvm::Value* ptr = DtoGEP(ldval,zero,one,"tmp",p->scopebb());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2285 ptr = new llvm::LoadInst(ptr,"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2286 new llvm::FreeInst(ptr, p->scopebb());
81
3587401b6eeb [svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents: 78
diff changeset
2287 DtoNullArray(val);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2288 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2289 else {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2290 assert(0);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2291 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2292
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2293 delete v;
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 // this expression produces no useful data
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2296 return 0;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2297 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2298
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
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2301 elem* ArrayLengthExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2302 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2303 Logger::print("ArrayLengthExp::toElem: %s | %s\n", toChars(), type->toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2304 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2305
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2306 elem* e = new elem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2307 elem* u = e1->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2308
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
2309 if (p->topexp() && p->topexp()->e1 == this)
34
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 32
diff changeset
2310 {
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 32
diff changeset
2311 e->mem = u->mem;
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 32
diff changeset
2312 e->type = elem::ARRAYLEN;
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 32
diff changeset
2313 }
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 32
diff changeset
2314 else
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 32
diff changeset
2315 {
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 32
diff changeset
2316 llvm::Value* zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, 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
2317 llvm::Value* ptr = DtoGEP(u->mem,zero,zero,"tmp",p->scopebb());
34
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 32
diff changeset
2318 e->val = new llvm::LoadInst(ptr, "tmp", p->scopebb());
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 32
diff changeset
2319 e->type = elem::VAL;
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 32
diff changeset
2320 }
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2321 delete u;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2322
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2323 return e;
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 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2327
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2328 elem* AssertExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2329 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2330 Logger::print("AssertExp::toElem: %s | %s\n", toChars(), type->toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2331 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2332
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2333 elem* u = e1->toElem(p);
34
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 32
diff changeset
2334 elem* m = msg ? msg->toElem(p) : NULL;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2335
34
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 32
diff changeset
2336 llvm::Value* loca = llvm::ConstantInt::get(llvm::Type::Int32Ty, loc.linnum, 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
2337 DtoAssert(u->getValue(), loca, m ? m->val : NULL);
34
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 32
diff changeset
2338
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2339 delete m;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2340 delete u;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2341
34
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 32
diff changeset
2342 return new elem;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2343 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2344
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2345 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2346
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2347 elem* NotExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2348 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2349 Logger::print("NotExp::toElem: %s | %s\n", toChars(), type->toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2350 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2351
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2352 elem* e = new elem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2353 elem* u = e1->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2354
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
2355 llvm::Value* b = DtoBoolean(u->getValue());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2356
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2357 llvm::Value* zero = llvm::ConstantInt::get(llvm::Type::Int1Ty, 0, true);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2358 e->val = p->ir->CreateICmpEQ(b,zero);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2359 //e->val = new llvm::ICmpInst(llvm::ICmpInst::ICMP_EQ,b,zero,"tmp",p->scopebb());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2360 e->type = elem::VAL;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2361
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2362 delete u;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2363
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2364 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2365 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2366
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2367 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2368
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2369 elem* AndAndExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2370 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2371 Logger::print("AndAndExp::toElem: %s | %s\n", toChars(), type->toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2372 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2373
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2374 // 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
2375 llvm::Value* resval = 0;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2376 llvm::BasicBlock* entryblock = &p->topfunc()->front();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2377 resval = new llvm::AllocaInst(llvm::Type::Int1Ty,"andandtmp",p->topallocapoint());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2378
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2379 elem* e = new elem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2380 elem* u = e1->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2381
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2382 llvm::BasicBlock* oldend = p->scopeend();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2383 llvm::BasicBlock* andand = new llvm::BasicBlock("andand", gIR->topfunc(), oldend);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2384 llvm::BasicBlock* andandend = new llvm::BasicBlock("andandend", gIR->topfunc(), oldend);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2385
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
2386 llvm::Value* ubool = DtoBoolean(u->getValue());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2387 new llvm::StoreInst(ubool,resval,p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2388 new llvm::BranchInst(andand,andandend,ubool,p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2389
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2390 p->scope() = IRScope(andand, andandend);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2391 elem* v = e2->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2392
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
2393 llvm::Value* vbool = DtoBoolean(v->getValue());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2394 llvm::Value* uandvbool = llvm::BinaryOperator::create(llvm::BinaryOperator::And, ubool, vbool,"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2395 new llvm::StoreInst(uandvbool,resval,p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2396 new llvm::BranchInst(andandend,p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2397
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2398 delete u;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2399 delete v;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2400
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2401 p->scope() = IRScope(andandend, oldend);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2402
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2403 e->val = new llvm::LoadInst(resval,"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2404 e->type = elem::VAL;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2405
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2406 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2407 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2408
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2409 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2410
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2411 elem* OrOrExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2412 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2413 Logger::print("OrOrExp::toElem: %s | %s\n", toChars(), type->toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2414 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2415
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2416 // 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
2417 llvm::Value* resval = 0;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2418 llvm::BasicBlock* entryblock = &p->topfunc()->front();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2419 resval = new llvm::AllocaInst(llvm::Type::Int1Ty,"orortmp",p->topallocapoint());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2420
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2421 elem* e = new elem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2422 elem* u = e1->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2423
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2424 llvm::BasicBlock* oldend = p->scopeend();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2425 llvm::BasicBlock* oror = new llvm::BasicBlock("oror", gIR->topfunc(), oldend);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2426 llvm::BasicBlock* ororend = new llvm::BasicBlock("ororend", gIR->topfunc(), oldend);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2427
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
2428 llvm::Value* ubool = DtoBoolean(u->getValue());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2429 new llvm::StoreInst(ubool,resval,p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2430 new llvm::BranchInst(ororend,oror,ubool,p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2431
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2432 p->scope() = IRScope(oror, ororend);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2433 elem* v = e2->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2434
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
2435 llvm::Value* vbool = DtoBoolean(v->getValue());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2436 new llvm::StoreInst(vbool,resval,p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2437 new llvm::BranchInst(ororend,p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2438
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2439 delete u;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2440 delete v;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2441
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2442 p->scope() = IRScope(ororend, oldend);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2443
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2444 e->val = new llvm::LoadInst(resval,"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2445 e->type = elem::VAL;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2446
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2447 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2448 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2449
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2450 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2451
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2452 #define BinBitExp(X,Y) \
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2453 elem* X##Exp::toElem(IRState* p) \
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2454 { \
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2455 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
2456 LOG_SCOPE; \
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2457 elem* e = new elem; \
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2458 elem* u = e1->toElem(p); \
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2459 elem* v = e2->toElem(p); \
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2460 e->val = llvm::BinaryOperator::create(llvm::Instruction::Y, u->getValue(), v->getValue(), "tmp", p->scopebb()); \
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2461 e->type = elem::VAL; \
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2462 delete u; \
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2463 delete v; \
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2464 return e; \
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2465 } \
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2466 \
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2467 elem* X##AssignExp::toElem(IRState* p) \
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2468 { \
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2469 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
2470 LOG_SCOPE; \
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2471 elem* u = e1->toElem(p); \
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2472 elem* v = e2->toElem(p); \
42
0b9b286b67b6 [svn r46] fix for shift operations
lindquist
parents: 40
diff changeset
2473 llvm::Value* uval = u->getValue(); \
0b9b286b67b6 [svn r46] fix for shift operations
lindquist
parents: 40
diff changeset
2474 assert(uval); \
0b9b286b67b6 [svn r46] fix for shift operations
lindquist
parents: 40
diff changeset
2475 llvm::Value* vval = v->getValue(); \
0b9b286b67b6 [svn r46] fix for shift operations
lindquist
parents: 40
diff changeset
2476 assert(vval); \
0b9b286b67b6 [svn r46] fix for shift operations
lindquist
parents: 40
diff changeset
2477 llvm::Value* tmp = llvm::BinaryOperator::create(llvm::Instruction::Y, uval, vval, "tmp", p->scopebb()); \
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
2478 assert(u->mem); \
42
0b9b286b67b6 [svn r46] fix for shift operations
lindquist
parents: 40
diff changeset
2479 Logger::cout() << *tmp << '|' << *u->mem << '\n'; \
81
3587401b6eeb [svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents: 78
diff changeset
2480 new llvm::StoreInst(DtoPointedType(u->mem, tmp), u->mem, p->scopebb()); \
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2481 delete u; \
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2482 delete v; \
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2483 elem* e = new elem; \
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2484 e->mem = u->mem; \
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2485 e->type = elem::VAR; \
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2486 return e; \
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2487 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2488
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2489 BinBitExp(And,And);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2490 BinBitExp(Or,Or);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2491 BinBitExp(Xor,Xor);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2492 BinBitExp(Shl,Shl);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2493 BinBitExp(Shr,AShr);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2494 BinBitExp(Ushr,LShr);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2495
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2496 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2497
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2498 elem* HaltExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2499 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2500 Logger::print("HaltExp::toElem: %s | %s\n", toChars(), type->toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2501 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2502
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
2503 llvm::Value* loca = llvm::ConstantInt::get(llvm::Type::Int32Ty, loc.linnum, 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
2504 DtoAssert(llvm::ConstantInt::getFalse(), loca, NULL);
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
2505
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2506 new llvm::UnreachableInst(p->scopebb());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2507 return 0;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2508 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2509
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2510 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2511
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2512 elem* DelegateExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2513 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2514 Logger::print("DelegateExp::toElem: %s | %s\n", toChars(), type->toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2515 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2516
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2517 elem* e = new elem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2518 elem* u = e1->toElem(p);
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
2519
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2520 llvm::Value* zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2521 llvm::Value* one = llvm::ConstantInt::get(llvm::Type::Int32Ty, 1, false);
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
2522
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2523 const llvm::Type* int8ptrty = llvm::PointerType::get(llvm::Type::Int8Ty);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2524
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
2525 assert(p->topexp() && p->topexp()->e2 == this && p->topexp()->v);
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
2526 llvm::Value* lval = p->topexp()->v;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2527
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
2528 llvm::Value* context = DtoGEP(lval,zero,zero,"tmp",p->scopebb());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2529 llvm::Value* castcontext = new llvm::BitCastInst(u->getValue(),int8ptrty,"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2530 new llvm::StoreInst(castcontext, context, p->scopebb());
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
2531
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
2532 llvm::Value* fptr = DtoGEP(lval,zero,one,"tmp",p->scopebb());
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
2533
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2534 assert(func->llvmValue);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2535 llvm::Value* castfptr = new llvm::BitCastInst(func->llvmValue,fptr->getType()->getContainedType(0),"tmp",p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2536 new llvm::StoreInst(castfptr, fptr, p->scopebb());
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
2537
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2538 e->inplace = true;
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
2539
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2540 delete u;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2541 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2542 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2543
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2544 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2545
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2546 elem* IdentityExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2547 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2548 Logger::print("IdentityExp::toElem: %s | %s\n", toChars(), type->toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2549 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2550
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2551 elem* u = e1->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2552 elem* v = e2->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2553
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2554 elem* e = new elem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2555
73
b706170e24a9 [svn r77] Fixed foreach on slice.
lindquist
parents: 72
diff changeset
2556 llvm::Value* l = u->field ? u->mem : u->getValue();
b706170e24a9 [svn r77] Fixed foreach on slice.
lindquist
parents: 72
diff changeset
2557 llvm::Value* r = v->field ? v->mem : v->getValue();
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2558
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
2559 Type* t1 = DtoDType(e1->type);
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
2560
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
2561 if (t1->ty == Tarray) {
69
2b5a2eaa88be [svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents: 68
diff changeset
2562 if (v->type == elem::NUL) {
2b5a2eaa88be [svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents: 68
diff changeset
2563 r = NULL;
2b5a2eaa88be [svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents: 68
diff changeset
2564 }
2b5a2eaa88be [svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents: 68
diff changeset
2565 else {
2b5a2eaa88be [svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents: 68
diff changeset
2566 assert(l->getType() == r->getType());
2b5a2eaa88be [svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents: 68
diff changeset
2567 }
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
2568 e->val = DtoDynArrayIs(op,l,r);
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
2569 }
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
2570 else {
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
2571 llvm::ICmpInst::Predicate pred = (op == TOKidentity) ? llvm::ICmpInst::ICMP_EQ : llvm::ICmpInst::ICMP_NE;
69
2b5a2eaa88be [svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents: 68
diff changeset
2572 if (t1->ty == Tpointer && v->type == elem::NUL && l->getType() != r->getType()) {
2b5a2eaa88be [svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents: 68
diff changeset
2573 r = llvm::ConstantPointerNull::get(llvm::cast<llvm::PointerType>(l->getType()));
2b5a2eaa88be [svn r73] Identity expression for dynamic array and null was broken.
lindquist
parents: 68
diff changeset
2574 }
73
b706170e24a9 [svn r77] Fixed foreach on slice.
lindquist
parents: 72
diff changeset
2575 Logger::cout() << "l = " << *l << " r = " << *r << '\n';
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
2576 e->val = new llvm::ICmpInst(pred, l, r, "tmp", p->scopebb());
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
2577 }
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2578 e->type = elem::VAL;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2579
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2580 delete u;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2581 delete v;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2582
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2583 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2584 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2585
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2586 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2587
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2588 elem* CommaExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2589 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2590 Logger::print("CommaExp::toElem: %s | %s\n", toChars(), type->toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2591 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2592
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2593 elem* u = e1->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2594 elem* v = e2->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2595 delete u;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2596 return v;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2597 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2598
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2599 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2600
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2601 elem* CondExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2602 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2603 Logger::print("CondExp::toElem: %s | %s\n", toChars(), type->toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2604 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2605
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
2606 Type* dtype = 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
2607 const llvm::Type* resty = DtoType(dtype);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2608
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2609 // 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
2610 llvm::BasicBlock* entryblock = &p->topfunc()->front();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2611 llvm::Value* resval = new llvm::AllocaInst(resty,"condtmp",p->topallocapoint());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2612
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2613 llvm::BasicBlock* oldend = p->scopeend();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2614 llvm::BasicBlock* condtrue = new llvm::BasicBlock("condtrue", gIR->topfunc(), oldend);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2615 llvm::BasicBlock* condfalse = new llvm::BasicBlock("condfalse", gIR->topfunc(), oldend);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2616 llvm::BasicBlock* condend = new llvm::BasicBlock("condend", gIR->topfunc(), oldend);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2617
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2618 elem* c = econd->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
2619 llvm::Value* cond_val = DtoBoolean(c->getValue());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2620 delete c;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2621 new llvm::BranchInst(condtrue,condfalse,cond_val,p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2622
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2623 p->scope() = IRScope(condtrue, condfalse);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2624 elem* u = e1->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
2625 DtoAssign(dtype, resval, u->getValue());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2626 new llvm::BranchInst(condend,p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2627 delete u;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2628
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2629 p->scope() = IRScope(condfalse, condend);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2630 elem* v = e2->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
2631 DtoAssign(dtype, resval, v->getValue());
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2632 new llvm::BranchInst(condend,p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2633 delete v;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2634
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2635 p->scope() = IRScope(condend, oldend);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2636
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2637 elem* e = new elem;
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
2638 e->mem = resval;
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
2639 e->type = elem::VAR;
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2640 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2641 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2642
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2643 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2644
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2645 elem* ComExp::toElem(IRState* p)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2646 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2647 Logger::print("ComExp::toElem: %s | %s\n", toChars(), type->toChars());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2648 LOG_SCOPE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2649
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2650 elem* e = new elem;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2651 elem* u = e1->toElem(p);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2652
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2653 llvm::Value* value = u->getValue();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2654 llvm::Value* minusone = llvm::ConstantInt::get(value->getType(), -1, true);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2655 e->val = llvm::BinaryOperator::create(llvm::Instruction::Xor, value, minusone, "tmp", p->scopebb());
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2656
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2657 delete u;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2658
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2659 e->type = elem::VAL;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2660
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2661 return e;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2662 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2663
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2664 //////////////////////////////////////////////////////////////////////////////////////////
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2665
23
77e3d1ddae3f [svn r27] * Fixed bug in aggregate field lookup.
lindquist
parents: 21
diff changeset
2666 elem* NegExp::toElem(IRState* p)
77e3d1ddae3f [svn r27] * Fixed bug in aggregate field lookup.
lindquist
parents: 21
diff changeset
2667 {
77e3d1ddae3f [svn r27] * Fixed bug in aggregate field lookup.
lindquist
parents: 21
diff changeset
2668 Logger::print("NegExp::toElem: %s | %s\n", toChars(), type->toChars());
77e3d1ddae3f [svn r27] * Fixed bug in aggregate field lookup.
lindquist
parents: 21
diff changeset
2669 LOG_SCOPE;
77e3d1ddae3f [svn r27] * Fixed bug in aggregate field lookup.
lindquist
parents: 21
diff changeset
2670 elem* e = new elem;
77e3d1ddae3f [svn r27] * Fixed bug in aggregate field lookup.
lindquist
parents: 21
diff changeset
2671 elem* l = e1->toElem(p);
77e3d1ddae3f [svn r27] * Fixed bug in aggregate field lookup.
lindquist
parents: 21
diff changeset
2672 llvm::Value* val = l->getValue();
77e3d1ddae3f [svn r27] * Fixed bug in aggregate field lookup.
lindquist
parents: 21
diff changeset
2673 delete l;
77e3d1ddae3f [svn r27] * Fixed bug in aggregate field lookup.
lindquist
parents: 21
diff changeset
2674
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
2675 Type* t = DtoDType(type);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2676
23
77e3d1ddae3f [svn r27] * Fixed bug in aggregate field lookup.
lindquist
parents: 21
diff changeset
2677 llvm::Value* zero = 0;
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2678 if (t->isintegral())
23
77e3d1ddae3f [svn r27] * Fixed bug in aggregate field lookup.
lindquist
parents: 21
diff changeset
2679 zero = llvm::ConstantInt::get(val->getType(), 0, true);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2680 else if (t->isfloating()) {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2681 if (t->ty == Tfloat32)
23
77e3d1ddae3f [svn r27] * Fixed bug in aggregate field lookup.
lindquist
parents: 21
diff changeset
2682 zero = llvm::ConstantFP::get(val->getType(), float(0));
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2683 else if (t->ty == Tfloat64 || t->ty == Tfloat80)
23
77e3d1ddae3f [svn r27] * Fixed bug in aggregate field lookup.
lindquist
parents: 21
diff changeset
2684 zero = llvm::ConstantFP::get(val->getType(), double(0));
77e3d1ddae3f [svn r27] * Fixed bug in aggregate field lookup.
lindquist
parents: 21
diff changeset
2685 else
77e3d1ddae3f [svn r27] * Fixed bug in aggregate field lookup.
lindquist
parents: 21
diff changeset
2686 assert(0);
77e3d1ddae3f [svn r27] * Fixed bug in aggregate field lookup.
lindquist
parents: 21
diff changeset
2687 }
77e3d1ddae3f [svn r27] * Fixed bug in aggregate field lookup.
lindquist
parents: 21
diff changeset
2688 else
77e3d1ddae3f [svn r27] * Fixed bug in aggregate field lookup.
lindquist
parents: 21
diff changeset
2689 assert(0);
77e3d1ddae3f [svn r27] * Fixed bug in aggregate field lookup.
lindquist
parents: 21
diff changeset
2690
77e3d1ddae3f [svn r27] * Fixed bug in aggregate field lookup.
lindquist
parents: 21
diff changeset
2691 e->val = llvm::BinaryOperator::createSub(zero,val,"tmp",p->scopebb());
77e3d1ddae3f [svn r27] * Fixed bug in aggregate field lookup.
lindquist
parents: 21
diff changeset
2692 e->type = elem::VAL;
77e3d1ddae3f [svn r27] * Fixed bug in aggregate field lookup.
lindquist
parents: 21
diff changeset
2693
77e3d1ddae3f [svn r27] * Fixed bug in aggregate field lookup.
lindquist
parents: 21
diff changeset
2694 return e;
77e3d1ddae3f [svn r27] * Fixed bug in aggregate field lookup.
lindquist
parents: 21
diff changeset
2695 }
77e3d1ddae3f [svn r27] * Fixed bug in aggregate field lookup.
lindquist
parents: 21
diff changeset
2696
77e3d1ddae3f [svn r27] * Fixed bug in aggregate field lookup.
lindquist
parents: 21
diff changeset
2697 //////////////////////////////////////////////////////////////////////////////////////////
77e3d1ddae3f [svn r27] * Fixed bug in aggregate field lookup.
lindquist
parents: 21
diff changeset
2698
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
2699 elem* CatExp::toElem(IRState* p)
c0967c4b2a74 [svn r40] Cleaned up some of the array routines to use gep/load/store instead of memcpy/memset.
lindquist
parents: 34
diff changeset
2700 {
c0967c4b2a74 [svn r40] Cleaned up some of the array routines to use gep/load/store instead of memcpy/memset.
lindquist
parents: 34
diff changeset
2701 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
2702 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
2703
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
2704 Type* t = DtoDType(type);
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2705
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2706 bool inplace = false;
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2707 llvm::Value* dst = 0;
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2708 IRExp* ex = p->topexp();
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2709 if (ex && ex->e2 == this) {
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2710 assert(ex->v);
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2711 dst = ex->v;
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2712 inplace = true;
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2713 }
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2714 else {
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2715 assert(t->ty == Tarray);
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
2716 const llvm::Type* arrty = DtoType(t);
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2717 dst = new llvm::AllocaInst(arrty, "tmpmem", p->topallocapoint());
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2718 }
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2719
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
2720 DtoCatArrays(dst,e1,e2);
58
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2721
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2722 elem* e = new elem;
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2723 e->mem = dst;
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2724 e->type = elem::VAR;
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2725 e->inplace = inplace;
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2726
2c3cd3596187 [svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents: 57
diff changeset
2727 return e;
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
2728 }
c0967c4b2a74 [svn r40] Cleaned up some of the array routines to use gep/load/store instead of memcpy/memset.
lindquist
parents: 34
diff changeset
2729
c0967c4b2a74 [svn r40] Cleaned up some of the array routines to use gep/load/store instead of memcpy/memset.
lindquist
parents: 34
diff changeset
2730 //////////////////////////////////////////////////////////////////////////////////////////
c0967c4b2a74 [svn r40] Cleaned up some of the array routines to use gep/load/store instead of memcpy/memset.
lindquist
parents: 34
diff changeset
2731
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2732 elem* CatAssignExp::toElem(IRState* p)
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2733 {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2734 Logger::print("CatAssignExp::toElem: %s | %s\n", toChars(), type->toChars());
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2735 LOG_SCOPE;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2736
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2737 elem* l = e1->toElem(p);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2738 assert(l->mem);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2739
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
2740 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
2741 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
2742 Type* e2type = DtoDType(e2->type);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2743
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2744 if (e2type == elemtype) {
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
2745 DtoCatAssignElement(l->mem,e2);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2746 }
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2747 else
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2748 assert(0 && "only one element at a time right now");
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2749
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2750 return 0;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2751 }
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2752
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2753 //////////////////////////////////////////////////////////////////////////////////////////
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2754
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2755 elem* ArrayLiteralExp::toElem(IRState* p)
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2756 {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2757 Logger::print("ArrayLiteralExp::toElem: %s | %s\n", toChars(), type->toChars());
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2758 LOG_SCOPE;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2759
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
2760 const llvm::Type* t = DtoType(type);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2761 Logger::cout() << "array literal has llvm type: " << *t << '\n';
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2762
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2763 llvm::Value* mem = 0;
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
2764 if (!p->topexp() || p->topexp()->e2 != this) {
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
2765 assert(DtoDType(type)->ty == Tsarray);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2766 mem = new llvm::AllocaInst(t,"tmparrayliteral",p->topallocapoint());
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2767 }
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
2768 else if (p->topexp()->e2 == this) {
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
2769 mem = p->topexp()->v;
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
2770 assert(mem);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2771 if (!llvm::isa<llvm::PointerType>(mem->getType()) ||
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2772 !llvm::isa<llvm::ArrayType>(mem->getType()->getContainedType(0)))
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2773 {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2774 error("TODO array literals can currently only be used to initialise static arrays");
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2775 fatal();
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2776 }
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2777 }
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
2778 else
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
2779 assert(0);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2780
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2781 for (unsigned i=0; i<elements->dim; ++i)
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2782 {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2783 Expression* expr = (Expression*)elements->data[i];
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
2784 llvm::Value* elemAddr = DtoGEPi(mem,0,i,"tmp",p->scopebb());
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2785 elem* e = expr->toElem(p);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2786 new llvm::StoreInst(e->getValue(), elemAddr, p->scopebb());
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2787 }
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2788
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2789 elem* e = new elem;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2790 e->mem = mem;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2791 e->type = elem::VAL;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2792 e->inplace = true;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2793
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2794 return e;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2795 }
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2796
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2797 //////////////////////////////////////////////////////////////////////////////////////////
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2798
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2799 llvm::Constant* ArrayLiteralExp::toConstElem(IRState* p)
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2800 {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2801 Logger::print("ArrayLiteralExp::toConstElem: %s | %s\n", toChars(), type->toChars());
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2802 LOG_SCOPE;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2803
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
2804 const llvm::Type* t = DtoType(type);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2805 Logger::cout() << "array literal has llvm type: " << *t << '\n';
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2806 assert(llvm::isa<llvm::ArrayType>(t));
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2807 const llvm::ArrayType* arrtype = llvm::cast<llvm::ArrayType>(t);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2808
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2809 assert(arrtype->getNumElements() == elements->dim);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2810 std::vector<llvm::Constant*> vals(elements->dim, NULL);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2811 for (unsigned i=0; i<elements->dim; ++i)
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2812 {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2813 Expression* expr = (Expression*)elements->data[i];
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2814 vals[i] = expr->toConstElem(p);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2815 }
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2816
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2817 return llvm::ConstantArray::get(arrtype, vals);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2818 }
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2819
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2820 //////////////////////////////////////////////////////////////////////////////////////////
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2821
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
2822 elem* FuncExp::toElem(IRState* p)
e5c4bece7fa1 [svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents: 48
diff changeset
2823 {
e5c4bece7fa1 [svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents: 48
diff changeset
2824 Logger::print("FuncExp::toElem: %s | %s\n", toChars(), type->toChars());
e5c4bece7fa1 [svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents: 48
diff changeset
2825 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
2826
e5c4bece7fa1 [svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents: 48
diff changeset
2827 assert(fd);
e5c4bece7fa1 [svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents: 48
diff changeset
2828
e5c4bece7fa1 [svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents: 48
diff changeset
2829 if (fd->isNested()) Logger::println("nested");
e5c4bece7fa1 [svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents: 48
diff changeset
2830 Logger::println("kind = %s\n", fd->kind());
e5c4bece7fa1 [svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents: 48
diff changeset
2831
e5c4bece7fa1 [svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents: 48
diff changeset
2832 fd->toObjFile();
e5c4bece7fa1 [svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents: 48
diff changeset
2833
50
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
2834 llvm::Value* lval = NULL;
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
2835 if (!p->topexp() || p->topexp()->e2 != this) {
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
2836 const llvm::Type* dgty = DtoType(type);
50
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
2837 Logger::cout() << "delegate without explicit storage:" << '\n' << *dgty << '\n';
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
2838 lval = new llvm::AllocaInst(dgty,"dgstorage",p->topallocapoint());
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
2839 }
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
2840 else if (p->topexp()->e2 == this) {
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
2841 lval = p->topexp()->v;
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
2842 assert(lval);
50
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
2843 }
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
2844 else
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 53
diff changeset
2845 assert(0);
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
2846
e5c4bece7fa1 [svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents: 48
diff changeset
2847 elem* e = new elem;
e5c4bece7fa1 [svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents: 48
diff changeset
2848
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
2849 llvm::Value* context = DtoGEPi(lval,0,0,"tmp",p->scopebb());
50
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
2850 const llvm::PointerType* pty = llvm::cast<llvm::PointerType>(context->getType()->getContainedType(0));
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
2851 llvm::Value* llvmNested = p->func().decl->llvmNested;
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
2852 if (llvmNested == NULL) {
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
2853 llvm::Value* nullcontext = llvm::ConstantPointerNull::get(pty);
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
2854 p->ir->CreateStore(nullcontext, context);
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
2855 }
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
2856 else {
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
2857 llvm::Value* nestedcontext = p->ir->CreateBitCast(llvmNested, pty, "tmp");
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
2858 p->ir->CreateStore(nestedcontext, context);
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
2859 }
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
2860
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
2861 llvm::Value* fptr = DtoGEPi(lval,0,1,"tmp",p->scopebb());
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
2862
e5c4bece7fa1 [svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents: 48
diff changeset
2863 assert(fd->llvmValue);
e5c4bece7fa1 [svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents: 48
diff changeset
2864 llvm::Value* castfptr = new llvm::BitCastInst(fd->llvmValue,fptr->getType()->getContainedType(0),"tmp",p->scopebb());
e5c4bece7fa1 [svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents: 48
diff changeset
2865 new llvm::StoreInst(castfptr, fptr, p->scopebb());
e5c4bece7fa1 [svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents: 48
diff changeset
2866
e5c4bece7fa1 [svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents: 48
diff changeset
2867 e->inplace = true;
50
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
2868 e->mem = lval;
6fcc08a4d406 [svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents: 49
diff changeset
2869 e->type = elem::VAR;
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
2870
e5c4bece7fa1 [svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents: 48
diff changeset
2871 return e;
e5c4bece7fa1 [svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents: 48
diff changeset
2872 }
e5c4bece7fa1 [svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents: 48
diff changeset
2873
e5c4bece7fa1 [svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents: 48
diff changeset
2874 //////////////////////////////////////////////////////////////////////////////////////////
e5c4bece7fa1 [svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents: 48
diff changeset
2875
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2876 #define STUB(x) elem *x::toElem(IRState * p) {error("Exp type "#x" not implemented: %s", toChars()); fatal(); return 0; }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2877 //STUB(IdentityExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2878 //STUB(CondExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2879 //STUB(EqualExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2880 STUB(InExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2881 //STUB(CmpExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2882 //STUB(AndAndExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2883 //STUB(OrOrExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2884 //STUB(AndExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2885 //STUB(AndAssignExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2886 //STUB(OrExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2887 //STUB(OrAssignExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2888 //STUB(XorExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2889 //STUB(XorAssignExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2890 //STUB(ShrExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2891 //STUB(ShrAssignExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2892 //STUB(ShlExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2893 //STUB(ShlAssignExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2894 //STUB(UshrExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2895 //STUB(UshrAssignExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2896 //STUB(DivExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2897 //STUB(DivAssignExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2898 //STUB(MulExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2899 //STUB(MulAssignExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2900 //STUB(ModExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2901 //STUB(ModAssignExp);
36
c0967c4b2a74 [svn r40] Cleaned up some of the array routines to use gep/load/store instead of memcpy/memset.
lindquist
parents: 34
diff changeset
2902 //STUB(CatExp);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2903 //STUB(CatAssignExp);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2904 //STUB(AddExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2905 //STUB(AddAssignExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2906 STUB(Expression);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2907 //STUB(MinExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2908 //STUB(MinAssignExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2909 //STUB(PostExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2910 //STUB(NullExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2911 //STUB(ThisExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2912 //STUB(CallExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2913 STUB(DotTypeExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2914 STUB(TypeDotIdExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2915 //STUB(DotVarExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2916 //STUB(AssertExp);
49
e5c4bece7fa1 [svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
lindquist
parents: 48
diff changeset
2917 //STUB(FuncExp);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2918 //STUB(DelegateExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2919 //STUB(VarExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2920 //STUB(DeclarationExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2921 //STUB(NewExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2922 //STUB(SymOffExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2923 STUB(ScopeExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2924 //STUB(AssignExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2925
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2926 STUB(TypeExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2927 //STUB(RealExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2928 STUB(ComplexExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2929 //STUB(StringExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2930 //STUB(IntegerExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2931 STUB(BoolExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2932
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2933 //STUB(NotExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2934 //STUB(ComExp);
23
77e3d1ddae3f [svn r27] * Fixed bug in aggregate field lookup.
lindquist
parents: 21
diff changeset
2935 //STUB(NegExp);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2936 //STUB(PtrExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2937 //STUB(AddrExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2938 //STUB(SliceExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2939 //STUB(CastExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2940 //STUB(DeleteExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2941 //STUB(IndexExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2942 //STUB(CommaExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2943 //STUB(ArrayLengthExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2944 //STUB(HaltExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2945 STUB(RemoveExp);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2946 //STUB(ArrayLiteralExp);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2947 STUB(AssocArrayLiteralExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2948 //STUB(StructLiteralExp);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2949
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2950 #define CONSTSTUB(x) llvm::Constant* x::toConstElem(IRState * p) {error("const Exp type "#x" not implemented: '%s' type: '%s'", toChars(), type->toChars()); assert(0); fatal(); return NULL; }
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2951 CONSTSTUB(Expression);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2952 //CONSTSTUB(IntegerExp);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2953 //CONSTSTUB(RealExp);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2954 //CONSTSTUB(NullExp);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2955 //CONSTSTUB(StringExp);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2956 //CONSTSTUB(VarExp);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2957 //CONSTSTUB(ArrayLiteralExp);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2958 CONSTSTUB(AssocArrayLiteralExp);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2959 //CONSTSTUB(StructLiteralExp);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
2960
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2961 unsigned Type::totym() { return 0; }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2962
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
2963 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
2964 {
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
2965 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2966 return 0;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2967 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2968
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2969 type * Type::toCParamtype()
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2970 {
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
2971 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2972 return 0;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2973 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2974 Symbol * Type::toSymbol()
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2975 {
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
2976 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2977 return 0;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2978 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2979
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2980 type *
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2981 TypeTypedef::toCtype()
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2982 {
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
2983 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2984 return 0;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2985 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2986
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2987 type *
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2988 TypeTypedef::toCParamtype()
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2989 {
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
2990 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2991 return 0;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2992 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2993
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2994 void
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2995 TypedefDeclaration::toDebug()
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2996 {
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
2997 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2998 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
2999
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3000
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3001 type *
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3002 TypeEnum::toCtype()
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3003 {
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3004 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3005 return 0;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3006 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3007
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3008 type *
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3009 TypeStruct::toCtype()
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3010 {
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3011 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3012 return 0;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3013 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3014
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3015 void
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3016 StructDeclaration::toDebug()
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3017 {
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3018 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3019 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3020
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3021 Symbol * TypeClass::toSymbol()
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3022 {
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3023 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3024 return 0;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3025 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3026
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3027 unsigned TypeFunction::totym()
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3028 {
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3029 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3030 return 0;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3031 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3032
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3033 type * TypeFunction::toCtype()
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3034 {
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3035 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3036 return 0;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3037 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3038
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3039 type * TypeSArray::toCtype()
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3040 {
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3041 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3042 return 0;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3043 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3044
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3045 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
3046 {
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3047 assert(0);
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3048 return 0;
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3049 }
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3050
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3051 type * TypeDArray::toCtype()
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3052 {
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3053 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3054 return 0;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3055 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3056
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3057 type * TypeAArray::toCtype()
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3058 {
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3059 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3060 return 0;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3061 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3062
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3063 type * TypePointer::toCtype()
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3064 {
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3065 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3066 return 0;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3067 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3068
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3069 type * TypeDelegate::toCtype()
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3070 {
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3071 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3072 return 0;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3073 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3074
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3075 type * TypeClass::toCtype()
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3076 {
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3077 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3078 return 0;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3079 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3080
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3081 void ClassDeclaration::toDebug()
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3082 {
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3083 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3084 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3085
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents: 11
diff changeset
3086 //////////////////////////////////////////////////////////////////////////////
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3087
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3088 void
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3089 EnumDeclaration::toDebug()
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3090 {
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3091 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3092 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3093
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3094 int Dsymbol::cvMember(unsigned char*)
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3095 {
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3096 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3097 return 0;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3098 }
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3099 int EnumDeclaration::cvMember(unsigned char*)
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3100 {
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3101 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3102 return 0;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3103 }
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3104 int FuncDeclaration::cvMember(unsigned char*)
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3105 {
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3106 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3107 return 0;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3108 }
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3109 int VarDeclaration::cvMember(unsigned char*)
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3110 {
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3111 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3112 return 0;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3113 }
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3114 int TypedefDeclaration::cvMember(unsigned char*)
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3115 {
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3116 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3117 return 0;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3118 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3119
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3120 void obj_includelib(char*){}
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3121
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3122 AsmStatement::AsmStatement(Loc loc, Token *tokens) :
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3123 Statement(loc)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3124 {
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3125 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3126 }
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3127 Statement *AsmStatement::syntaxCopy()
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3128 {
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3129 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3130 return 0;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3131 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3132
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3133 Statement *AsmStatement::semantic(Scope *sc)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3134 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3135 return Statement::semantic(sc);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3136 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3137
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3138
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3139 void AsmStatement::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3140 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3141 Statement::toCBuffer(buf, hgs);
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3142 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3143
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3144 int AsmStatement::comeFrom()
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3145 {
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3146 assert(0);
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3147 return FALSE;
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3148 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3149
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3150 void
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3151 backend_init()
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3152 {
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 36
diff changeset
3153 // now lazily loaded
1
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3154 //LLVM_D_InitRuntime();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3155 }
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3156
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3157 void
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3158 backend_term()
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3159 {
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3160 LLVM_D_FreeRuntime();
c53b6e3fe49a [svn r5] Initial commit. Most things are very rough.
lindquist
parents:
diff changeset
3161 }