Mercurial > projects > ldc
annotate gen/functions.cpp @ 537:bfbd71f60572
Don't use -u in build.sh; not all cp implementations support it.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sun, 24 Aug 2008 17:01:40 +0200 |
parents | cecfee2d01a8 |
children | 406aee3416bb |
rev | line source |
---|---|
100 | 1 #include "gen/llvm.h" |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
258
diff
changeset
|
2 #include "llvm/Support/CFG.h" |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
3 #include "llvm/Intrinsics.h" |
100 | 4 |
5 #include "mtype.h" | |
6 #include "aggregate.h" | |
7 #include "init.h" | |
8 #include "declaration.h" | |
9 #include "template.h" | |
10 #include "module.h" | |
11 #include "statement.h" | |
12 | |
13 #include "gen/irstate.h" | |
14 #include "gen/tollvm.h" | |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
15 #include "gen/llvmhelpers.h" |
100 | 16 #include "gen/runtime.h" |
17 #include "gen/arrays.h" | |
18 #include "gen/logger.h" | |
19 #include "gen/functions.h" | |
20 #include "gen/todebug.h" | |
21 #include "gen/classes.h" | |
131 | 22 #include "gen/dvalue.h" |
100 | 23 |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
24 const llvm::FunctionType* DtoFunctionType(Type* type, const LLType* thistype, const LLType* nesttype, bool ismain) |
100 | 25 { |
435
74101be2a553
Added type param to DVarValue as DMD sometimes overrides the type of the VarDeclaration.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
428
diff
changeset
|
26 assert(type->ty == Tfunction); |
100 | 27 TypeFunction* f = (TypeFunction*)type; |
28 | |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
29 if (type->ir.type != NULL) { |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
30 return llvm::cast<llvm::FunctionType>(type->ir.type->get()); |
100 | 31 } |
32 | |
33 bool typesafeVararg = false; | |
162
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
34 bool arrayVararg = false; |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
35 if (f->linkage == LINKd) |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
36 { |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
37 if (f->varargs == 1) |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
38 typesafeVararg = true; |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
39 else if (f->varargs == 2) |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
40 arrayVararg = true; |
100 | 41 } |
42 | |
43 // return value type | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
205
diff
changeset
|
44 const LLType* rettype; |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
205
diff
changeset
|
45 const LLType* actualRettype; |
100 | 46 Type* rt = f->next; |
47 bool retinptr = false; | |
48 bool usesthis = false; | |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
49 bool usesnest = false; |
100 | 50 |
234
9760f54af0b7
[svn r250] Fixed the warning about dropping arguments to _Dmain when optimizing.
lindquist
parents:
225
diff
changeset
|
51 // parameter types |
9760f54af0b7
[svn r250] Fixed the warning about dropping arguments to _Dmain when optimizing.
lindquist
parents:
225
diff
changeset
|
52 std::vector<const LLType*> paramvec; |
9760f54af0b7
[svn r250] Fixed the warning about dropping arguments to _Dmain when optimizing.
lindquist
parents:
225
diff
changeset
|
53 |
9760f54af0b7
[svn r250] Fixed the warning about dropping arguments to _Dmain when optimizing.
lindquist
parents:
225
diff
changeset
|
54 if (ismain) |
9760f54af0b7
[svn r250] Fixed the warning about dropping arguments to _Dmain when optimizing.
lindquist
parents:
225
diff
changeset
|
55 { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
56 rettype = LLType::Int32Ty; |
100 | 57 actualRettype = rettype; |
234
9760f54af0b7
[svn r250] Fixed the warning about dropping arguments to _Dmain when optimizing.
lindquist
parents:
225
diff
changeset
|
58 if (Argument::dim(f->parameters) == 0) |
9760f54af0b7
[svn r250] Fixed the warning about dropping arguments to _Dmain when optimizing.
lindquist
parents:
225
diff
changeset
|
59 { |
9760f54af0b7
[svn r250] Fixed the warning about dropping arguments to _Dmain when optimizing.
lindquist
parents:
225
diff
changeset
|
60 const LLType* arrTy = DtoArrayType(LLType::Int8Ty); |
9760f54af0b7
[svn r250] Fixed the warning about dropping arguments to _Dmain when optimizing.
lindquist
parents:
225
diff
changeset
|
61 const LLType* arrArrTy = DtoArrayType(arrTy); |
9760f54af0b7
[svn r250] Fixed the warning about dropping arguments to _Dmain when optimizing.
lindquist
parents:
225
diff
changeset
|
62 paramvec.push_back(getPtrToType(arrArrTy)); |
9760f54af0b7
[svn r250] Fixed the warning about dropping arguments to _Dmain when optimizing.
lindquist
parents:
225
diff
changeset
|
63 } |
100 | 64 } |
234
9760f54af0b7
[svn r250] Fixed the warning about dropping arguments to _Dmain when optimizing.
lindquist
parents:
225
diff
changeset
|
65 else{ |
100 | 66 assert(rt); |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
67 if (DtoIsReturnedInArg(rt)) { |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
68 rettype = getPtrToType(DtoType(rt)); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
69 actualRettype = LLType::VoidTy; |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
70 f->retInPtr = retinptr = true; |
100 | 71 } |
72 else { | |
73 rettype = DtoType(rt); | |
74 actualRettype = rettype; | |
75 } | |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
76 |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
77 if (unsigned ea = DtoShouldExtend(rt)) |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
78 { |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
79 f->retAttrs |= ea; |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
80 } |
100 | 81 } |
82 | |
83 if (retinptr) { | |
123
7f9a0a58394b
[svn r127] Updated the lphobos build scripts a little. Created a new rebuild profile.
lindquist
parents:
121
diff
changeset
|
84 //Logger::cout() << "returning through pointer parameter: " << *rettype << '\n'; |
100 | 85 paramvec.push_back(rettype); |
86 } | |
87 | |
88 if (thistype) { | |
89 paramvec.push_back(thistype); | |
90 usesthis = true; | |
91 } | |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
92 else if (nesttype) { |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
93 paramvec.push_back(nesttype); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
94 usesnest = true; |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
95 } |
100 | 96 |
97 if (typesafeVararg) { | |
98 ClassDeclaration* ti = Type::typeinfo; | |
336 | 99 ti->toObjFile(0); // TODO: multiobj |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
100 DtoForceConstInitDsymbol(ti); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
101 assert(ti->ir.irStruct->constInit); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
205
diff
changeset
|
102 std::vector<const LLType*> types; |
100 | 103 types.push_back(DtoSize_t()); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
104 types.push_back(getPtrToType(getPtrToType(ti->ir.irStruct->constInit->getType()))); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
205
diff
changeset
|
105 const LLType* t1 = llvm::StructType::get(types); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
106 paramvec.push_back(getPtrToType(t1)); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
107 paramvec.push_back(getPtrToType(LLType::Int8Ty)); |
100 | 108 } |
162
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
109 else if (arrayVararg) |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
110 { |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
111 // do nothing? |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
112 } |
100 | 113 |
114 size_t n = Argument::dim(f->parameters); | |
115 | |
116 for (int i=0; i < n; ++i) { | |
117 Argument* arg = Argument::getNth(f->parameters, i); | |
118 // ensure scalar | |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
119 Type* argT = arg->type->toBasetype(); |
100 | 120 assert(argT); |
121 | |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
122 bool refOrOut = ((arg->storageClass & STCref) || (arg->storageClass & STCout)); |
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
123 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
205
diff
changeset
|
124 const LLType* at = DtoType(argT); |
100 | 125 if (isaStruct(at)) { |
126 Logger::println("struct param"); | |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
127 paramvec.push_back(getPtrToType(at)); |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
128 if (!refOrOut) |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
129 arg->llvmAttrs |= llvm::ParamAttr::ByVal; |
100 | 130 } |
131 else if (isaArray(at)) { | |
275
665b81613475
[svn r296] Removed: the 'suite' dir, it never took off!
lindquist
parents:
262
diff
changeset
|
132 // static array are passed by reference |
100 | 133 Logger::println("sarray param"); |
134 assert(argT->ty == Tsarray); | |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
135 paramvec.push_back(getPtrToType(at)); |
100 | 136 } |
137 else if (llvm::isa<llvm::OpaqueType>(at)) { | |
138 Logger::println("opaque param"); | |
139 assert(argT->ty == Tstruct || argT->ty == Tclass); | |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
140 paramvec.push_back(getPtrToType(at)); |
100 | 141 } |
142 else { | |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
143 if (refOrOut) { |
131 | 144 Logger::println("by ref param"); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
145 at = getPtrToType(at); |
100 | 146 } |
147 else { | |
148 Logger::println("in param"); | |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
149 if (unsigned ea = DtoShouldExtend(argT)) |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
150 { |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
151 arg->llvmAttrs |= ea; |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
152 } |
100 | 153 } |
154 paramvec.push_back(at); | |
155 } | |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
156 |
329
8c1dc3e705da
[svn r350] Fixed incorrect function types for lazy arguments. looks like lazy arguments have never even worked :o well.. now they should.
lindquist
parents:
328
diff
changeset
|
157 // handle lazy args |
8c1dc3e705da
[svn r350] Fixed incorrect function types for lazy arguments. looks like lazy arguments have never even worked :o well.. now they should.
lindquist
parents:
328
diff
changeset
|
158 if (arg->storageClass & STClazy) |
8c1dc3e705da
[svn r350] Fixed incorrect function types for lazy arguments. looks like lazy arguments have never even worked :o well.. now they should.
lindquist
parents:
328
diff
changeset
|
159 { |
8c1dc3e705da
[svn r350] Fixed incorrect function types for lazy arguments. looks like lazy arguments have never even worked :o well.. now they should.
lindquist
parents:
328
diff
changeset
|
160 Logger::cout() << "for lazy got: " << *paramvec.back() << '\n'; |
8c1dc3e705da
[svn r350] Fixed incorrect function types for lazy arguments. looks like lazy arguments have never even worked :o well.. now they should.
lindquist
parents:
328
diff
changeset
|
161 TypeFunction *ltf = new TypeFunction(NULL, arg->type, 0, LINKd); |
8c1dc3e705da
[svn r350] Fixed incorrect function types for lazy arguments. looks like lazy arguments have never even worked :o well.. now they should.
lindquist
parents:
328
diff
changeset
|
162 TypeDelegate *ltd = new TypeDelegate(ltf); |
8c1dc3e705da
[svn r350] Fixed incorrect function types for lazy arguments. looks like lazy arguments have never even worked :o well.. now they should.
lindquist
parents:
328
diff
changeset
|
163 at = getPtrToType(DtoType(ltd)); |
8c1dc3e705da
[svn r350] Fixed incorrect function types for lazy arguments. looks like lazy arguments have never even worked :o well.. now they should.
lindquist
parents:
328
diff
changeset
|
164 Logger::cout() << "lazy updated to: " << *at << '\n'; |
8c1dc3e705da
[svn r350] Fixed incorrect function types for lazy arguments. looks like lazy arguments have never even worked :o well.. now they should.
lindquist
parents:
328
diff
changeset
|
165 paramvec.back() = at; |
454
283d113d4753
Added generation of the llvm 'sret' parameter attribute where applicable.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
452
diff
changeset
|
166 // lazy doesn't need byval as the delegate is not visible to the user |
329
8c1dc3e705da
[svn r350] Fixed incorrect function types for lazy arguments. looks like lazy arguments have never even worked :o well.. now they should.
lindquist
parents:
328
diff
changeset
|
167 } |
100 | 168 } |
169 | |
170 // construct function type | |
162
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
171 bool isvararg = !(typesafeVararg || arrayVararg) && f->varargs; |
100 | 172 llvm::FunctionType* functype = llvm::FunctionType::get(actualRettype, paramvec, isvararg); |
173 | |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
174 f->retInPtr = retinptr; |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
175 f->usesThis = usesthis; |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
176 f->usesNest = usesnest; |
100 | 177 |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
178 f->ir.type = new llvm::PATypeHolder(functype); |
100 | 179 |
180 return functype; | |
181 } | |
182 | |
183 ////////////////////////////////////////////////////////////////////////////////////////// | |
184 | |
185 static const llvm::FunctionType* DtoVaFunctionType(FuncDeclaration* fdecl) | |
186 { | |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
187 // type has already been resolved |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
188 if (fdecl->type->ir.type != 0) { |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
189 return llvm::cast<llvm::FunctionType>(fdecl->type->ir.type->get()); |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
190 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
191 |
100 | 192 TypeFunction* f = (TypeFunction*)fdecl->type; |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
193 const llvm::FunctionType* fty = 0; |
100 | 194 |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
195 if (fdecl->llvmInternal == LLVMva_start) |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
196 fty = GET_INTRINSIC_DECL(vastart)->getFunctionType(); |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
197 else if (fdecl->llvmInternal == LLVMva_copy) |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
198 fty = GET_INTRINSIC_DECL(vacopy)->getFunctionType(); |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
199 else if (fdecl->llvmInternal == LLVMva_end) |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
200 fty = GET_INTRINSIC_DECL(vaend)->getFunctionType(); |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
201 assert(fty); |
100 | 202 |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
203 f->ir.type = new llvm::PATypeHolder(fty); |
100 | 204 return fty; |
205 } | |
206 | |
207 ////////////////////////////////////////////////////////////////////////////////////////// | |
208 | |
209 const llvm::FunctionType* DtoFunctionType(FuncDeclaration* fdecl) | |
210 { | |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
211 // handle for C vararg intrinsics |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
212 if (fdecl->isVaIntrinsic()) |
100 | 213 return DtoVaFunctionType(fdecl); |
214 | |
215 // type has already been resolved | |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
216 if (fdecl->type->ir.type != 0) |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
217 return llvm::cast<llvm::FunctionType>(fdecl->type->ir.type->get()); |
100 | 218 |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
219 const LLType* thisty = 0; |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
220 const LLType* nestty = 0; |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
221 |
100 | 222 if (fdecl->needThis()) { |
132 | 223 if (AggregateDeclaration* ad = fdecl->isMember2()) { |
224 Logger::println("isMember = this is: %s", ad->type->toChars()); | |
100 | 225 thisty = DtoType(ad->type); |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
226 //Logger::cout() << "this llvm type: " << *thisty << '\n'; |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
227 if (isaStruct(thisty) || (!gIR->structs.empty() && thisty == gIR->topstruct()->recty.get())) |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
228 thisty = getPtrToType(thisty); |
100 | 229 } |
132 | 230 else { |
231 Logger::println("chars: %s type: %s kind: %s", fdecl->toChars(), fdecl->type->toChars(), fdecl->kind()); | |
232 assert(0); | |
233 } | |
100 | 234 } |
235 else if (fdecl->isNested()) { | |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
236 nestty = getPtrToType(LLType::Int8Ty); |
100 | 237 } |
238 | |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
239 const llvm::FunctionType* functype = DtoFunctionType(fdecl->type, thisty, nestty, fdecl->isMain()); |
100 | 240 |
241 return functype; | |
242 } | |
243 | |
244 ////////////////////////////////////////////////////////////////////////////////////////// | |
245 | |
246 static llvm::Function* DtoDeclareVaFunction(FuncDeclaration* fdecl) | |
247 { | |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
248 TypeFunction* f = (TypeFunction*)fdecl->type->toBasetype(); |
100 | 249 const llvm::FunctionType* fty = DtoVaFunctionType(fdecl); |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
250 llvm::Function* func = 0; |
100 | 251 |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
252 if (fdecl->llvmInternal == LLVMva_start) |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
253 func = GET_INTRINSIC_DECL(vastart); |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
254 else if (fdecl->llvmInternal == LLVMva_copy) |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
255 func = GET_INTRINSIC_DECL(vacopy); |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
256 else if (fdecl->llvmInternal == LLVMva_end) |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
257 func = GET_INTRINSIC_DECL(vaend); |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
258 assert(func); |
100 | 259 |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
260 fdecl->ir.irFunc->func = func; |
100 | 261 return func; |
262 } | |
263 | |
264 ////////////////////////////////////////////////////////////////////////////////////////// | |
265 | |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
266 void DtoResolveFunction(FuncDeclaration* fdecl) |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
267 { |
121
9c79b61fb638
[svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents:
119
diff
changeset
|
268 if (!global.params.useUnitTests && fdecl->isUnitTestDeclaration()) { |
9c79b61fb638
[svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents:
119
diff
changeset
|
269 return; // ignore declaration completely |
9c79b61fb638
[svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents:
119
diff
changeset
|
270 } |
9c79b61fb638
[svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents:
119
diff
changeset
|
271 |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
272 // is imported and we don't have access? |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
273 if (fdecl->getModule() != gIR->dmodule) |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
274 { |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
275 if (fdecl->prot() == PROTprivate) |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
276 return; |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
277 } |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
278 |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
279 if (fdecl->ir.resolved) return; |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
280 fdecl->ir.resolved = true; |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
281 |
132 | 282 Logger::println("DtoResolveFunction(%s): %s", fdecl->toPrettyChars(), fdecl->loc.toChars()); |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
283 LOG_SCOPE; |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
284 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
285 if (fdecl->parent) |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
286 if (TemplateInstance* tinst = fdecl->parent->isTemplateInstance()) |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
287 { |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
288 TemplateDeclaration* tempdecl = tinst->tempdecl; |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
289 if (tempdecl->llvmInternal == LLVMva_arg) |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
290 { |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
291 Logger::println("magic va_arg found"); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
292 fdecl->llvmInternal = LLVMva_arg; |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
293 fdecl->ir.declared = true; |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
294 fdecl->ir.initialized = true; |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
295 fdecl->ir.defined = true; |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
296 return; // this gets mapped to an instruction so a declaration makes no sence |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
297 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
298 else if (tempdecl->llvmInternal == LLVMva_start) |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
299 { |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
300 Logger::println("magic va_start found"); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
301 fdecl->llvmInternal = LLVMva_start; |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
302 } |
527
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
526
diff
changeset
|
303 else if (tempdecl->llvmInternal == LLVMintrinsic) |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
526
diff
changeset
|
304 { |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
526
diff
changeset
|
305 Logger::println("overloaded intrinsic found"); |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
526
diff
changeset
|
306 fdecl->llvmInternal = LLVMintrinsic; |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
526
diff
changeset
|
307 DtoOverloadedIntrinsicName(tinst, tempdecl, fdecl->intrinsicName); |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
526
diff
changeset
|
308 } |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
309 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
310 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
311 DtoFunctionType(fdecl); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
312 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
313 // queue declaration |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
314 if (!fdecl->isAbstract()) |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
315 gIR->declareList.push_back(fdecl); |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
316 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
317 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
318 ////////////////////////////////////////////////////////////////////////////////////////// |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
319 |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
320 static void set_param_attrs(TypeFunction* f, llvm::Function* func, FuncDeclaration* fdecl) |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
321 { |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
322 int llidx = 1; |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
323 if (f->retInPtr) ++llidx; |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
324 if (f->usesThis) ++llidx; |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
325 else if (f->usesNest) ++llidx; |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
326 if (f->linkage == LINKd && f->varargs == 1) |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
327 llidx += 2; |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
328 |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
329 int funcNumArgs = func->getArgumentList().size(); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
330 std::vector<llvm::ParamAttrsWithIndex> attrs; |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
331 int k = 0; |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
332 |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
333 llvm::ParamAttrsWithIndex PAWI; |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
334 |
446
7a67dedbf933
Fixed param attrs for return values (not really broken, but would be if more return attrs were added)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
445
diff
changeset
|
335 // set return value attrs if any |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
336 if (f->retAttrs) |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
337 { |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
338 PAWI.Index = 0; |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
339 PAWI.Attrs = f->retAttrs; |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
340 attrs.push_back(PAWI); |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
341 } |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
342 |
454
283d113d4753
Added generation of the llvm 'sret' parameter attribute where applicable.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
452
diff
changeset
|
343 // set sret param |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
344 if (f->retInPtr) |
454
283d113d4753
Added generation of the llvm 'sret' parameter attribute where applicable.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
452
diff
changeset
|
345 { |
283d113d4753
Added generation of the llvm 'sret' parameter attribute where applicable.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
452
diff
changeset
|
346 PAWI.Index = 1; |
283d113d4753
Added generation of the llvm 'sret' parameter attribute where applicable.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
452
diff
changeset
|
347 PAWI.Attrs = llvm::ParamAttr::StructRet; |
283d113d4753
Added generation of the llvm 'sret' parameter attribute where applicable.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
452
diff
changeset
|
348 attrs.push_back(PAWI); |
283d113d4753
Added generation of the llvm 'sret' parameter attribute where applicable.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
452
diff
changeset
|
349 } |
283d113d4753
Added generation of the llvm 'sret' parameter attribute where applicable.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
452
diff
changeset
|
350 |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
351 // set byval attrs on implicit main arg |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
352 if (fdecl->isMain() && Argument::dim(f->parameters) == 0) |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
353 { |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
354 PAWI.Index = llidx; |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
355 PAWI.Attrs = llvm::ParamAttr::ByVal; |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
356 attrs.push_back(PAWI); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
357 llidx++; |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
358 } |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
359 |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
360 // set attrs on the rest of the arguments |
454
283d113d4753
Added generation of the llvm 'sret' parameter attribute where applicable.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
452
diff
changeset
|
361 for (; llidx <= funcNumArgs && Argument::dim(f->parameters) > k; ++llidx,++k) |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
362 { |
454
283d113d4753
Added generation of the llvm 'sret' parameter attribute where applicable.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
452
diff
changeset
|
363 Argument* fnarg = Argument::getNth(f->parameters, k); |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
364 assert(fnarg); |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
365 |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
366 PAWI.Index = llidx; |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
367 PAWI.Attrs = fnarg->llvmAttrs; |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
368 |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
369 if (PAWI.Attrs) |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
370 attrs.push_back(PAWI); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
371 } |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
372 |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
373 llvm::PAListPtr palist = llvm::PAListPtr::get(attrs.begin(), attrs.end()); |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
374 func->setParamAttrs(palist); |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
375 } |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
376 |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
377 ////////////////////////////////////////////////////////////////////////////////////////// |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
378 |
100 | 379 void DtoDeclareFunction(FuncDeclaration* fdecl) |
380 { | |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
381 if (fdecl->ir.declared) return; |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
382 fdecl->ir.declared = true; |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
383 |
132 | 384 Logger::println("DtoDeclareFunction(%s): %s", fdecl->toPrettyChars(), fdecl->loc.toChars()); |
100 | 385 LOG_SCOPE; |
386 | |
121
9c79b61fb638
[svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents:
119
diff
changeset
|
387 // intrinsic sanity check |
9c79b61fb638
[svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents:
119
diff
changeset
|
388 if (fdecl->llvmInternal == LLVMintrinsic && fdecl->fbody) { |
9c79b61fb638
[svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents:
119
diff
changeset
|
389 error(fdecl->loc, "intrinsics cannot have function bodies"); |
9c79b61fb638
[svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents:
119
diff
changeset
|
390 fatal(); |
9c79b61fb638
[svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents:
119
diff
changeset
|
391 } |
9c79b61fb638
[svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents:
119
diff
changeset
|
392 |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
393 // get TypeFunction* |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
394 Type* t = fdecl->type->toBasetype(); |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
395 TypeFunction* f = (TypeFunction*)t; |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
396 |
100 | 397 bool declareOnly = false; |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
398 bool templInst = fdecl->parent && DtoIsTemplateInstance(fdecl->parent); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
399 if (!templInst && fdecl->getModule() != gIR->dmodule) |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
139
diff
changeset
|
400 { |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
139
diff
changeset
|
401 Logger::println("not template instance, and not in this module. declare only!"); |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
139
diff
changeset
|
402 Logger::println("current module: %s", gIR->dmodule->ident->toChars()); |
378
d8234836b40f
Get rid of runTimeHack and instead add proper argument info to the frontend
Christian Kamm <kamm incasoftware de>
parents:
363
diff
changeset
|
403 if(fdecl->getModule()) |
d8234836b40f
Get rid of runTimeHack and instead add proper argument info to the frontend
Christian Kamm <kamm incasoftware de>
parents:
363
diff
changeset
|
404 Logger::println("func module: %s", fdecl->getModule()->ident->toChars()); |
379
d632801b15f0
Introducing opaque type to dmd frontent to be used with certain runtime array
Christian Kamm <kamm incasoftware de>
parents:
378
diff
changeset
|
405 else { |
d632801b15f0
Introducing opaque type to dmd frontent to be used with certain runtime array
Christian Kamm <kamm incasoftware de>
parents:
378
diff
changeset
|
406 Logger::println("func not in a module, is runtime"); |
d632801b15f0
Introducing opaque type to dmd frontent to be used with certain runtime array
Christian Kamm <kamm incasoftware de>
parents:
378
diff
changeset
|
407 } |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
408 declareOnly = true; |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
139
diff
changeset
|
409 } |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
410 else if (fdecl->llvmInternal == LLVMva_start) |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
411 declareOnly = true; |
100 | 412 |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
413 if (!fdecl->ir.irFunc) { |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
414 fdecl->ir.irFunc = new IrFunction(fdecl); |
100 | 415 } |
416 | |
417 // mangled name | |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
435
diff
changeset
|
418 const char* mangled_name; |
100 | 419 if (fdecl->llvmInternal == LLVMintrinsic) |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
435
diff
changeset
|
420 mangled_name = fdecl->intrinsicName.c_str(); |
100 | 421 else |
422 mangled_name = fdecl->mangle(); | |
423 | |
424 llvm::Function* vafunc = 0; | |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
425 if (fdecl->isVaIntrinsic()) |
100 | 426 vafunc = DtoDeclareVaFunction(fdecl); |
427 | |
428 // construct function | |
429 const llvm::FunctionType* functype = DtoFunctionType(fdecl); | |
430 llvm::Function* func = vafunc ? vafunc : gIR->module->getFunction(mangled_name); | |
431 if (!func) | |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
173
diff
changeset
|
432 func = llvm::Function::Create(functype, DtoLinkage(fdecl), mangled_name, gIR->module); |
100 | 433 |
434 // add func to IRFunc | |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
435 fdecl->ir.irFunc->func = func; |
100 | 436 |
437 // calling convention | |
438 if (!vafunc && fdecl->llvmInternal != LLVMintrinsic) | |
439 func->setCallingConv(DtoCallingConv(f->linkage)); | |
149
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
440 else // fall back to C, it should be the right thing to do |
132 | 441 func->setCallingConv(llvm::CallingConv::C); |
442 | |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
443 fdecl->ir.irFunc->func = func; |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
444 assert(llvm::isa<llvm::FunctionType>(f->ir.type->get())); |
100 | 445 |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
446 // parameter attributes |
454
283d113d4753
Added generation of the llvm 'sret' parameter attribute where applicable.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
452
diff
changeset
|
447 if (!fdecl->isIntrinsic()) { |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
448 set_param_attrs(f, func, fdecl); |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
449 } |
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
450 |
116
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
451 // main |
100 | 452 if (fdecl->isMain()) { |
453 gIR->mainFunc = func; | |
454 } | |
455 | |
116
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
456 // static ctor |
163
a8cd9bc1021a
[svn r179] lots and lots of fixes, much more of tango now compiles/works.
lindquist
parents:
162
diff
changeset
|
457 if (fdecl->isStaticCtorDeclaration() && fdecl->getModule() == gIR->dmodule) { |
116
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
458 gIR->ctors.push_back(fdecl); |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
459 } |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
460 // static dtor |
163
a8cd9bc1021a
[svn r179] lots and lots of fixes, much more of tango now compiles/works.
lindquist
parents:
162
diff
changeset
|
461 else if (fdecl->isStaticDtorDeclaration() && fdecl->getModule() == gIR->dmodule) { |
116
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
462 gIR->dtors.push_back(fdecl); |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
463 } |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
464 |
162
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
465 // we never reference parameters of function prototypes |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
466 if (!declareOnly) |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
467 { |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
468 // name parameters |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
469 llvm::Function::arg_iterator iarg = func->arg_begin(); |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
470 int k = 0; |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
471 if (f->retInPtr) { |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
472 iarg->setName(".sretarg"); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
473 fdecl->ir.irFunc->retArg = iarg; |
162
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
474 ++iarg; |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
475 } |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
476 |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
477 if (f->usesThis) { |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
478 iarg->setName("this"); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
479 fdecl->ir.irFunc->thisArg = iarg; |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
480 assert(fdecl->ir.irFunc->thisArg); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
481 ++iarg; |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
482 } |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
483 else if (f->usesNest) { |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
484 iarg->setName(".nest"); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
485 fdecl->ir.irFunc->nestArg = iarg; |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
486 assert(fdecl->ir.irFunc->nestArg); |
162
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
487 ++iarg; |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
488 } |
119
79c9ac745fbc
[svn r123] Fixed some typeinfo module name mismatches.
lindquist
parents:
117
diff
changeset
|
489 |
162
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
490 if (f->linkage == LINKd && f->varargs == 1) { |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
491 iarg->setName("_arguments"); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
492 fdecl->ir.irFunc->_arguments = iarg; |
162
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
493 ++iarg; |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
494 iarg->setName("_argptr"); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
495 fdecl->ir.irFunc->_argptr = iarg; |
162
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
496 ++iarg; |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
497 } |
119
79c9ac745fbc
[svn r123] Fixed some typeinfo module name mismatches.
lindquist
parents:
117
diff
changeset
|
498 |
162
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
499 for (; iarg != func->arg_end(); ++iarg) |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
500 { |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
501 if (fdecl->parameters && fdecl->parameters->dim > k) |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
502 { |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
503 Dsymbol* argsym = (Dsymbol*)fdecl->parameters->data[k++]; |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
504 VarDeclaration* argvd = argsym->isVarDeclaration(); |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
505 assert(argvd); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
506 assert(!argvd->ir.irLocal); |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
507 argvd->ir.irLocal = new IrLocal(argvd); |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
508 argvd->ir.irLocal->value = iarg; |
162
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
509 iarg->setName(argvd->ident->toChars()); |
100 | 510 } |
162
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
511 else |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
512 { |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
513 iarg->setName("unnamed"); |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
514 } |
100 | 515 } |
516 } | |
517 | |
121
9c79b61fb638
[svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents:
119
diff
changeset
|
518 if (fdecl->isUnitTestDeclaration()) |
9c79b61fb638
[svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents:
119
diff
changeset
|
519 gIR->unitTests.push_back(fdecl); |
9c79b61fb638
[svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents:
119
diff
changeset
|
520 |
100 | 521 if (!declareOnly) |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
522 gIR->defineList.push_back(fdecl); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
523 else |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
524 assert(func->getLinkage() != llvm::GlobalValue::InternalLinkage); |
100 | 525 |
526 Logger::cout() << "func decl: " << *func << '\n'; | |
527 } | |
528 | |
529 ////////////////////////////////////////////////////////////////////////////////////////// | |
530 | |
531 void DtoDefineFunc(FuncDeclaration* fd) | |
532 { | |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
533 if (fd->ir.defined) return; |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
534 fd->ir.defined = true; |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
535 |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
536 assert(fd->ir.declared); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
102
diff
changeset
|
537 |
132 | 538 Logger::println("DtoDefineFunc(%s): %s", fd->toPrettyChars(), fd->loc.toChars()); |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
539 LOG_SCOPE; |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
540 |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
541 // warn about naked |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
542 if (fd->naked) |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
543 { |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
544 warning("%s: naked is currently ignored", fd->locToChars()); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
545 } |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
546 |
100 | 547 // debug info |
548 if (global.params.symdebug) { | |
549 Module* mo = fd->getModule(); | |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
245
diff
changeset
|
550 fd->ir.irFunc->dwarfSubProg = DtoDwarfSubProgram(fd); |
100 | 551 } |
552 | |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
553 Type* t = fd->type->toBasetype(); |
100 | 554 TypeFunction* f = (TypeFunction*)t; |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
555 assert(f->ir.type); |
100 | 556 |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
557 llvm::Function* func = fd->ir.irFunc->func; |
100 | 558 const llvm::FunctionType* functype = func->getFunctionType(); |
559 | |
560 // only members of the current module or template instances maybe be defined | |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
561 if (!(fd->getModule() == gIR->dmodule || DtoIsTemplateInstance(fd->parent))) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
562 return; |
100 | 563 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
564 // set module owner |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
565 fd->ir.DModule = gIR->dmodule; |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
173
diff
changeset
|
566 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
567 // is there a body? |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
568 if (fd->fbody == NULL) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
569 return; |
100 | 570 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
571 Logger::println("Doing function body for: %s", fd->toChars()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
572 assert(fd->ir.irFunc); |
468
45a67b6f1310
Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
457
diff
changeset
|
573 IrFunction* irfunction = fd->ir.irFunc; |
45a67b6f1310
Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
457
diff
changeset
|
574 gIR->functions.push_back(irfunction); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
102
diff
changeset
|
575 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
576 if (fd->isMain()) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
577 gIR->emitMain = true; |
162
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
578 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
579 std::string entryname("entry_"); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
580 entryname.append(fd->toPrettyChars()); |
162
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
581 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
582 llvm::BasicBlock* beginbb = llvm::BasicBlock::Create(entryname,func); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
583 llvm::BasicBlock* endbb = llvm::BasicBlock::Create("endentry",func); |
100 | 584 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
585 //assert(gIR->scopes.empty()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
586 gIR->scopes.push_back(IRScope(beginbb, endbb)); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
102
diff
changeset
|
587 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
588 // create alloca point |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
589 llvm::Instruction* allocaPoint = new llvm::AllocaInst(LLType::Int32Ty, "alloca point", beginbb); |
468
45a67b6f1310
Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
457
diff
changeset
|
590 irfunction->allocapoint = allocaPoint; |
100 | 591 |
452
30ef3c7bddca
Fixed problems with nested 'this'. Fixes #39 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
449
diff
changeset
|
592 // debug info - after all allocas, but before any llvm.dbg.declare etc |
30ef3c7bddca
Fixed problems with nested 'this'. Fixes #39 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
449
diff
changeset
|
593 if (global.params.symdebug) DtoDwarfFuncStart(fd); |
30ef3c7bddca
Fixed problems with nested 'this'. Fixes #39 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
449
diff
changeset
|
594 |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
595 // need result variable? |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
596 if (fd->vresult) { |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
597 Logger::println("vresult value"); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
598 fd->vresult->ir.irLocal = new IrLocal(fd->vresult); |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
599 fd->vresult->ir.irLocal->value = DtoAlloca(DtoType(fd->vresult->type), "function_vresult"); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
600 } |
526
642f6fa854e5
First step towards D abi compliance.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
523
diff
changeset
|
601 |
642f6fa854e5
First step towards D abi compliance.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
523
diff
changeset
|
602 // this hack makes sure the frame pointer elimination optimization is disabled. |
642f6fa854e5
First step towards D abi compliance.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
523
diff
changeset
|
603 // this this eliminates a bunch of inline asm related issues. |
642f6fa854e5
First step towards D abi compliance.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
523
diff
changeset
|
604 // naked must always eliminate the framepointer however... |
642f6fa854e5
First step towards D abi compliance.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
523
diff
changeset
|
605 if (fd->inlineAsm && !fd->naked) |
642f6fa854e5
First step towards D abi compliance.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
523
diff
changeset
|
606 { |
642f6fa854e5
First step towards D abi compliance.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
523
diff
changeset
|
607 // emit a call to llvm_eh_unwind_init |
642f6fa854e5
First step towards D abi compliance.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
523
diff
changeset
|
608 LLFunction* hack = GET_INTRINSIC_DECL(eh_unwind_init); |
642f6fa854e5
First step towards D abi compliance.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
523
diff
changeset
|
609 gIR->ir->CreateCall(hack, ""); |
642f6fa854e5
First step towards D abi compliance.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
523
diff
changeset
|
610 } |
100 | 611 |
468
45a67b6f1310
Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
457
diff
changeset
|
612 // give the 'this' argument storage and debug info |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
613 if (f->usesThis) |
254
8187884566fa
[svn r271] Fixed debug info for implicit 'this' param.
lindquist
parents:
250
diff
changeset
|
614 { |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
615 LLValue* thisvar = irfunction->thisArg; |
468
45a67b6f1310
Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
457
diff
changeset
|
616 assert(thisvar); |
45a67b6f1310
Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
457
diff
changeset
|
617 |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
618 LLValue* thismem = DtoAlloca(thisvar->getType(), ".this"); |
468
45a67b6f1310
Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
457
diff
changeset
|
619 DtoStore(thisvar, thismem); |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
620 irfunction->thisArg = thismem; |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
621 |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
622 assert(!fd->vthis->ir.irLocal); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
623 fd->vthis->ir.irLocal = new IrLocal(fd->vthis); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
624 fd->vthis->ir.irLocal->value = thismem; |
468
45a67b6f1310
Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
457
diff
changeset
|
625 |
45a67b6f1310
Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
457
diff
changeset
|
626 if (global.params.symdebug) |
45a67b6f1310
Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
457
diff
changeset
|
627 DtoDwarfLocalVariable(thismem, fd->vthis); |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
628 |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
629 if (fd->vthis->nestedref) |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
630 fd->nestedVars.insert(fd->vthis); |
254
8187884566fa
[svn r271] Fixed debug info for implicit 'this' param.
lindquist
parents:
250
diff
changeset
|
631 } |
8187884566fa
[svn r271] Fixed debug info for implicit 'this' param.
lindquist
parents:
250
diff
changeset
|
632 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
633 // give arguments storage |
468
45a67b6f1310
Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
457
diff
changeset
|
634 // and debug info |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
635 if (fd->parameters) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
636 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
637 size_t n = fd->parameters->dim; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
638 for (int i=0; i < n; ++i) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
639 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
640 Dsymbol* argsym = (Dsymbol*)fd->parameters->data[i]; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
641 VarDeclaration* vd = argsym->isVarDeclaration(); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
642 assert(vd); |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
643 |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
644 if (vd->nestedref) |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
645 fd->nestedVars.insert(vd); |
100 | 646 |
468
45a67b6f1310
Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
457
diff
changeset
|
647 IrLocal* irloc = vd->ir.irLocal; |
45a67b6f1310
Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
457
diff
changeset
|
648 assert(irloc); |
45a67b6f1310
Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
457
diff
changeset
|
649 |
457
d82ebdba4191
Fixed debug info and lazy arguments.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
455
diff
changeset
|
650 bool refoutlazy = vd->storage_class & (STCref | STCout | STClazy); |
d82ebdba4191
Fixed debug info and lazy arguments.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
455
diff
changeset
|
651 |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
652 if (refoutlazy) |
449
56265fa07c7d
Fixed problem where global variables did not resolve type before using it.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
446
diff
changeset
|
653 { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
654 continue; |
449
56265fa07c7d
Fixed problem where global variables did not resolve type before using it.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
446
diff
changeset
|
655 } |
254
8187884566fa
[svn r271] Fixed debug info for implicit 'this' param.
lindquist
parents:
250
diff
changeset
|
656 else if (DtoIsPassedByRef(vd->type)) |
8187884566fa
[svn r271] Fixed debug info for implicit 'this' param.
lindquist
parents:
250
diff
changeset
|
657 { |
468
45a67b6f1310
Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
457
diff
changeset
|
658 LLValue* vdirval = irloc->value; |
455
d3d3519b72e8
Fixed inserting an AA entry with 'this' as key.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
454
diff
changeset
|
659 if (global.params.symdebug && !(isaArgument(vdirval) && !isaArgument(vdirval)->hasByValAttr())) |
d3d3519b72e8
Fixed inserting an AA entry with 'this' as key.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
454
diff
changeset
|
660 DtoDwarfLocalVariable(vdirval, vd); |
254
8187884566fa
[svn r271] Fixed debug info for implicit 'this' param.
lindquist
parents:
250
diff
changeset
|
661 continue; |
8187884566fa
[svn r271] Fixed debug info for implicit 'this' param.
lindquist
parents:
250
diff
changeset
|
662 } |
100 | 663 |
468
45a67b6f1310
Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
457
diff
changeset
|
664 LLValue* a = irloc->value; |
479
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
665 LLValue* v = DtoAlloca(a->getType(), "."+a->getName()); |
468
45a67b6f1310
Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
457
diff
changeset
|
666 DtoStore(a,v); |
45a67b6f1310
Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
457
diff
changeset
|
667 irloc->value = v; |
100 | 668 } |
669 } | |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
670 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
671 // need result variable? (nested) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
672 if (fd->vresult && fd->vresult->nestedref) { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
673 Logger::println("nested vresult value: %s", fd->vresult->toChars()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
674 fd->nestedVars.insert(fd->vresult); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
675 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
676 |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
677 // construct nested variables array |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
678 if (!fd->nestedVars.empty()) |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
679 { |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
680 Logger::println("has nested frame"); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
681 // start with add all enclosing parent frames |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
682 int nparelems = 0; |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
683 Dsymbol* par = fd->toParent2(); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
684 while (par) |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
685 { |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
686 if (FuncDeclaration* parfd = par->isFuncDeclaration()) |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
687 { |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
688 nparelems += parfd->nestedVars.size(); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
689 } |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
690 else if (ClassDeclaration* parcd = par->isClassDeclaration()) |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
691 { |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
692 // nothing needed |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
693 } |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
694 else |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
695 { |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
696 break; |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
697 } |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
698 par = par->toParent2(); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
699 } |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
700 int nelems = fd->nestedVars.size() + nparelems; |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
701 |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
702 // make array type for nested vars |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
703 const LLType* nestedVarsTy = LLArrayType::get(getVoidPtrType(), nelems); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
704 |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
705 // alloca it |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
706 LLValue* nestedVars = DtoAlloca(nestedVarsTy, ".nested_vars"); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
707 |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
708 // copy parent frame into beginning |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
709 if (nparelems) |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
710 { |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
711 LLValue* src = irfunction->nestArg; |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
712 if (!src) |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
713 { |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
714 assert(irfunction->thisArg); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
715 assert(fd->isMember2()); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
716 LLValue* thisval = DtoLoad(irfunction->thisArg); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
717 ClassDeclaration* cd = fd->isMember2()->isClassDeclaration(); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
718 assert(cd); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
719 assert(cd->vthis); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
720 src = DtoLoad(DtoGEPi(thisval, 0,2+cd->vthis->ir.irField->index, ".vthis")); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
721 } |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
722 DtoMemCpy(nestedVars, src, DtoConstSize_t(nparelems*PTRSIZE)); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
723 } |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
724 |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
725 // store in IrFunction |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
726 irfunction->nestedVar = nestedVars; |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
727 |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
728 // go through all nested vars and assign indices |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
729 int idx = nparelems; |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
730 for (std::set<VarDeclaration*>::iterator i=fd->nestedVars.begin(); i!=fd->nestedVars.end(); ++i) |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
731 { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
732 VarDeclaration* vd = *i; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
733 if (!vd->ir.irLocal) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
734 vd->ir.irLocal = new IrLocal(vd); |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
735 |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
736 if (vd->isParameter()) |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
737 { |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
738 Logger::println("nested param: %s", vd->toChars()); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
739 LLValue* gep = DtoGEPi(nestedVars, 0, idx); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
740 LLValue* val = DtoBitCast(vd->ir.irLocal->value, getVoidPtrType()); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
741 DtoStore(val, gep); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
742 } |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
743 else |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
744 { |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
745 Logger::println("nested var: %s", vd->toChars()); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
746 } |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
747 |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
748 vd->ir.irLocal->nestedIndex = idx++; |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
749 } |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
750 |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
751 // fixup nested result variable |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
752 if (fd->vresult && fd->vresult->nestedref) { |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
753 Logger::println("nested vresult value: %s", fd->vresult->toChars()); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
754 LLValue* gep = DtoGEPi(nestedVars, 0, fd->vresult->ir.irLocal->nestedIndex); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
755 LLValue* val = DtoBitCast(fd->vresult->ir.irLocal->value, getVoidPtrType()); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
756 DtoStore(val, gep); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
757 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
758 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
759 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
760 // copy _argptr to a memory location |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
761 if (f->linkage == LINKd && f->varargs == 1) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
762 { |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
763 LLValue* argptrmem = DtoAlloca(fd->ir.irFunc->_argptr->getType(), "_argptr_mem"); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
764 new llvm::StoreInst(fd->ir.irFunc->_argptr, argptrmem, gIR->scopebb()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
765 fd->ir.irFunc->_argptr = argptrmem; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
766 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
767 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
768 // output function body |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
769 fd->fbody->toIR(gIR); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
770 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
771 // llvm requires all basic blocks to end with a TerminatorInst but DMD does not put a return statement |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
772 // in automatically, so we do it here. |
428
8b7cee241e91
Enable insertion of missing terminator instruction for main.
Christian Kamm <kamm incasoftware de>
parents:
399
diff
changeset
|
773 if (!gIR->scopereturned()) { |
8b7cee241e91
Enable insertion of missing terminator instruction for main.
Christian Kamm <kamm incasoftware de>
parents:
399
diff
changeset
|
774 // pass the previous block into this block |
8b7cee241e91
Enable insertion of missing terminator instruction for main.
Christian Kamm <kamm incasoftware de>
parents:
399
diff
changeset
|
775 if (global.params.symdebug) DtoDwarfFuncEnd(fd); |
8b7cee241e91
Enable insertion of missing terminator instruction for main.
Christian Kamm <kamm incasoftware de>
parents:
399
diff
changeset
|
776 if (func->getReturnType() == LLType::VoidTy) { |
8b7cee241e91
Enable insertion of missing terminator instruction for main.
Christian Kamm <kamm incasoftware de>
parents:
399
diff
changeset
|
777 llvm::ReturnInst::Create(gIR->scopebb()); |
8b7cee241e91
Enable insertion of missing terminator instruction for main.
Christian Kamm <kamm incasoftware de>
parents:
399
diff
changeset
|
778 } |
8b7cee241e91
Enable insertion of missing terminator instruction for main.
Christian Kamm <kamm incasoftware de>
parents:
399
diff
changeset
|
779 else { |
8b7cee241e91
Enable insertion of missing terminator instruction for main.
Christian Kamm <kamm incasoftware de>
parents:
399
diff
changeset
|
780 if (!fd->isMain()) |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
781 llvm::ReturnInst::Create(llvm::UndefValue::get(func->getReturnType()), gIR->scopebb()); |
428
8b7cee241e91
Enable insertion of missing terminator instruction for main.
Christian Kamm <kamm incasoftware de>
parents:
399
diff
changeset
|
782 else |
8b7cee241e91
Enable insertion of missing terminator instruction for main.
Christian Kamm <kamm incasoftware de>
parents:
399
diff
changeset
|
783 llvm::ReturnInst::Create(llvm::Constant::getNullValue(func->getReturnType()), gIR->scopebb()); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
784 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
785 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
786 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
787 // erase alloca point |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
788 allocaPoint->eraseFromParent(); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
789 allocaPoint = 0; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
790 gIR->func()->allocapoint = 0; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
791 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
792 gIR->scopes.pop_back(); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
793 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
794 // get rid of the endentry block, it's never used |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
795 assert(!func->getBasicBlockList().empty()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
796 func->getBasicBlockList().pop_back(); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
797 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
798 // if the last block is empty now, it must be unreachable or it's a bug somewhere else |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
799 // would be nice to figure out how to assert that this is correct |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
800 llvm::BasicBlock* lastbb = &func->getBasicBlockList().back(); |
328
7086a84ab3d6
[svn r349] Fixed problems with static arrays of void as well as a static arrays with zero length.
lindquist
parents:
275
diff
changeset
|
801 if (lastbb->empty()) |
7086a84ab3d6
[svn r349] Fixed problems with static arrays of void as well as a static arrays with zero length.
lindquist
parents:
275
diff
changeset
|
802 { |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
258
diff
changeset
|
803 new llvm::UnreachableInst(lastbb); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
804 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
805 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
806 // if the last block is not terminated we return a null value or void |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
807 // for some unknown reason this is needed when a void main() has a inline asm block ... |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
808 // this should be harmless for well formed code! |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
809 lastbb = &func->getBasicBlockList().back(); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
810 if (!lastbb->getTerminator()) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
811 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
812 Logger::println("adding missing return statement"); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
813 if (func->getReturnType() == LLType::VoidTy) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
814 llvm::ReturnInst::Create(lastbb); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
815 else |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
816 llvm::ReturnInst::Create(llvm::Constant::getNullValue(func->getReturnType()), lastbb); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
817 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
818 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
819 gIR->functions.pop_back(); |
100 | 820 } |
821 | |
822 ////////////////////////////////////////////////////////////////////////////////////////// | |
823 | |
117 | 824 const llvm::FunctionType* DtoBaseFunctionType(FuncDeclaration* fdecl) |
825 { | |
826 Dsymbol* parent = fdecl->toParent(); | |
827 ClassDeclaration* cd = parent->isClassDeclaration(); | |
828 assert(cd); | |
829 | |
830 FuncDeclaration* f = fdecl; | |
831 | |
832 while (cd) | |
833 { | |
834 ClassDeclaration* base = cd->baseClass; | |
835 if (!base) | |
836 break; | |
837 FuncDeclaration* f2 = base->findFunc(fdecl->ident, (TypeFunction*)fdecl->type); | |
838 if (f2) { | |
839 f = f2; | |
840 cd = base; | |
841 } | |
842 else | |
843 break; | |
844 } | |
845 | |
846 DtoResolveDsymbol(f); | |
847 return llvm::cast<llvm::FunctionType>(DtoType(f->type)); | |
848 } | |
849 | |
850 ////////////////////////////////////////////////////////////////////////////////////////// | |
131 | 851 |
852 DValue* DtoArgument(Argument* fnarg, Expression* argexp) | |
853 { | |
854 Logger::println("DtoArgument"); | |
855 LOG_SCOPE; | |
856 | |
857 DValue* arg = argexp->toElem(gIR); | |
858 | |
859 // ref/out arg | |
860 if (fnarg && ((fnarg->storageClass & STCref) || (fnarg->storageClass & STCout))) | |
861 { | |
862 if (arg->isVar() || arg->isLRValue()) | |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
863 arg = new DImValue(argexp->type, arg->getLVal()); |
131 | 864 else |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
865 arg = new DImValue(argexp->type, arg->getRVal()); |
131 | 866 } |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
867 // byval arg, but expr has no storage yet |
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
868 else if (DtoIsPassedByRef(argexp->type) && (arg->isSlice() || arg->isComplex() || arg->isNull())) |
131 | 869 { |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
870 LLValue* alloc = DtoAlloca(DtoType(argexp->type), ".tmp_arg"); |
131 | 871 DVarValue* vv = new DVarValue(argexp->type, alloc, true); |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
379
diff
changeset
|
872 DtoAssign(argexp->loc, vv, arg); |
131 | 873 arg = vv; |
874 } | |
875 | |
876 return arg; | |
877 } | |
878 | |
879 ////////////////////////////////////////////////////////////////////////////////////////// | |
880 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
205
diff
changeset
|
881 void DtoVariadicArgument(Expression* argexp, LLValue* dst) |
131 | 882 { |
883 Logger::println("DtoVariadicArgument"); | |
884 LOG_SCOPE; | |
347
6057fdf797d8
[svn r368] Fixed custom class allocators with arbitrary user arguments. Closes #25
lindquist
parents:
336
diff
changeset
|
885 DVarValue vv(argexp->type, dst, true); |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
379
diff
changeset
|
886 DtoAssign(argexp->loc, &vv, argexp->toElem(gIR)); |
131 | 887 } |
888 | |
889 ////////////////////////////////////////////////////////////////////////////////////////// | |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
890 |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
891 bool FuncDeclaration::isIntrinsic() |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
892 { |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
893 return (llvmInternal == LLVMintrinsic || isVaIntrinsic()); |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
894 } |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
895 |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
896 bool FuncDeclaration::isVaIntrinsic() |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
897 { |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
898 return (llvmInternal == LLVMva_start || |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
899 llvmInternal == LLVMva_copy || |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
900 llvmInternal == LLVMva_end); |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
901 } |