Mercurial > projects > ldc
annotate gen/functions.cpp @ 614:452e6e2618bf
Don't delete the header file after it has been generated!
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sun, 21 Sep 2008 17:35:27 +0200 |
parents | fbb1a366cfbc |
children | 26fce59fe80a |
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); |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
546
diff
changeset
|
125 |
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
546
diff
changeset
|
126 // FIXME: using the llvm type for these is a bad idea... aggregates are first class now and we're starting to use it ... |
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
546
diff
changeset
|
127 |
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
546
diff
changeset
|
128 if (argT->iscomplex()) { |
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
546
diff
changeset
|
129 goto Lbadstuff; |
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
546
diff
changeset
|
130 } |
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
546
diff
changeset
|
131 else if (isaStruct(at)) { |
100 | 132 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
|
133 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
|
134 if (!refOrOut) |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
135 arg->llvmAttrs |= llvm::ParamAttr::ByVal; |
100 | 136 } |
137 else if (isaArray(at)) { | |
275
665b81613475
[svn r296] Removed: the 'suite' dir, it never took off!
lindquist
parents:
262
diff
changeset
|
138 // static array are passed by reference |
100 | 139 Logger::println("sarray param"); |
140 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
|
141 paramvec.push_back(getPtrToType(at)); |
100 | 142 } |
143 else if (llvm::isa<llvm::OpaqueType>(at)) { | |
144 Logger::println("opaque param"); | |
145 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
|
146 paramvec.push_back(getPtrToType(at)); |
100 | 147 } |
148 else { | |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
546
diff
changeset
|
149 Lbadstuff: |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
150 if (refOrOut) { |
131 | 151 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
|
152 at = getPtrToType(at); |
100 | 153 } |
154 else { | |
155 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
|
156 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
|
157 { |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
158 arg->llvmAttrs |= ea; |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
159 } |
100 | 160 } |
161 paramvec.push_back(at); | |
162 } | |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
163 |
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
|
164 // 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
|
165 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
|
166 { |
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 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
|
168 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
|
169 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
|
170 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
|
171 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
|
172 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
|
173 // 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
|
174 } |
100 | 175 } |
176 | |
177 // 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
|
178 bool isvararg = !(typesafeVararg || arrayVararg) && f->varargs; |
100 | 179 llvm::FunctionType* functype = llvm::FunctionType::get(actualRettype, paramvec, isvararg); |
180 | |
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
|
181 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
|
182 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
|
183 f->usesNest = usesnest; |
100 | 184 |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
185 f->ir.type = new llvm::PATypeHolder(functype); |
100 | 186 |
187 return functype; | |
188 } | |
189 | |
190 ////////////////////////////////////////////////////////////////////////////////////////// | |
191 | |
192 static const llvm::FunctionType* DtoVaFunctionType(FuncDeclaration* fdecl) | |
193 { | |
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
|
194 // type has already been resolved |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
195 if (fdecl->type->ir.type != 0) { |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
196 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
|
197 } |
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
|
198 |
100 | 199 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
|
200 const llvm::FunctionType* fty = 0; |
100 | 201 |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
202 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
|
203 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
|
204 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
|
205 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
|
206 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
|
207 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
|
208 assert(fty); |
100 | 209 |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
210 f->ir.type = new llvm::PATypeHolder(fty); |
100 | 211 return fty; |
212 } | |
213 | |
214 ////////////////////////////////////////////////////////////////////////////////////////// | |
215 | |
216 const llvm::FunctionType* DtoFunctionType(FuncDeclaration* fdecl) | |
217 { | |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
218 // 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
|
219 if (fdecl->isVaIntrinsic()) |
100 | 220 return DtoVaFunctionType(fdecl); |
221 | |
222 // 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
|
223 if (fdecl->type->ir.type != 0) |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
224 return llvm::cast<llvm::FunctionType>(fdecl->type->ir.type->get()); |
100 | 225 |
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
|
226 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
|
227 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
|
228 |
100 | 229 if (fdecl->needThis()) { |
132 | 230 if (AggregateDeclaration* ad = fdecl->isMember2()) { |
231 Logger::println("isMember = this is: %s", ad->type->toChars()); | |
100 | 232 thisty = DtoType(ad->type); |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
233 //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
|
234 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
|
235 thisty = getPtrToType(thisty); |
100 | 236 } |
132 | 237 else { |
238 Logger::println("chars: %s type: %s kind: %s", fdecl->toChars(), fdecl->type->toChars(), fdecl->kind()); | |
239 assert(0); | |
240 } | |
100 | 241 } |
242 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
|
243 nestty = getPtrToType(LLType::Int8Ty); |
100 | 244 } |
245 | |
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
|
246 const llvm::FunctionType* functype = DtoFunctionType(fdecl->type, thisty, nestty, fdecl->isMain()); |
100 | 247 |
248 return functype; | |
249 } | |
250 | |
251 ////////////////////////////////////////////////////////////////////////////////////////// | |
252 | |
253 static llvm::Function* DtoDeclareVaFunction(FuncDeclaration* fdecl) | |
254 { | |
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
|
255 TypeFunction* f = (TypeFunction*)fdecl->type->toBasetype(); |
100 | 256 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
|
257 llvm::Function* func = 0; |
100 | 258 |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
259 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
|
260 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
|
261 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
|
262 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
|
263 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
|
264 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
|
265 assert(func); |
100 | 266 |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
267 fdecl->ir.irFunc->func = func; |
100 | 268 return func; |
269 } | |
270 | |
271 ////////////////////////////////////////////////////////////////////////////////////////// | |
272 | |
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
|
273 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
|
274 { |
121
9c79b61fb638
[svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents:
119
diff
changeset
|
275 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
|
276 return; // ignore declaration completely |
9c79b61fb638
[svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents:
119
diff
changeset
|
277 } |
9c79b61fb638
[svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents:
119
diff
changeset
|
278 |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
279 // 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
|
280 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
|
281 { |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
282 if (fdecl->prot() == PROTprivate) |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
283 return; |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
284 } |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
285 |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
286 if (fdecl->ir.resolved) return; |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
287 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
|
288 |
132 | 289 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
|
290 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
|
291 |
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 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
|
293 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
|
294 { |
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
|
295 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
|
296 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
|
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 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
|
299 fdecl->llvmInternal = LLVMva_arg; |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
300 fdecl->ir.declared = true; |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
301 fdecl->ir.initialized = true; |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
302 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
|
303 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
|
304 } |
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
|
305 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
|
306 { |
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
|
307 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
|
308 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
|
309 } |
527
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
526
diff
changeset
|
310 else if (tempdecl->llvmInternal == LLVMintrinsic) |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
526
diff
changeset
|
311 { |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
526
diff
changeset
|
312 Logger::println("overloaded intrinsic found"); |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
526
diff
changeset
|
313 fdecl->llvmInternal = LLVMintrinsic; |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
526
diff
changeset
|
314 DtoOverloadedIntrinsicName(tinst, tempdecl, fdecl->intrinsicName); |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
526
diff
changeset
|
315 } |
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 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
|
319 |
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
|
320 // queue declaration |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
321 if (!fdecl->isAbstract()) |
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
109
diff
changeset
|
322 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
|
323 } |
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
|
324 |
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
|
325 ////////////////////////////////////////////////////////////////////////////////////////// |
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
|
326 |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
327 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
|
328 { |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
329 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
|
330 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
|
331 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
|
332 else if (f->usesNest) ++llidx; |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
333 if (f->linkage == LINKd && f->varargs == 1) |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
334 llidx += 2; |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
335 |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
336 int funcNumArgs = func->getArgumentList().size(); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
337 std::vector<llvm::ParamAttrsWithIndex> attrs; |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
338 int k = 0; |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
339 |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
340 llvm::ParamAttrsWithIndex PAWI; |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
341 |
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
|
342 // 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
|
343 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
|
344 { |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
345 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
|
346 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
|
347 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
|
348 } |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
349 |
454
283d113d4753
Added generation of the llvm 'sret' parameter attribute where applicable.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
452
diff
changeset
|
350 // 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
|
351 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
|
352 { |
283d113d4753
Added generation of the llvm 'sret' parameter attribute where applicable.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
452
diff
changeset
|
353 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
|
354 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
|
355 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
|
356 } |
283d113d4753
Added generation of the llvm 'sret' parameter attribute where applicable.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
452
diff
changeset
|
357 |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
358 // 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
|
359 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
|
360 { |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
361 PAWI.Index = llidx; |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
362 PAWI.Attrs = llvm::ParamAttr::ByVal; |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
363 attrs.push_back(PAWI); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
364 llidx++; |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
365 } |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
366 |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
367 // 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
|
368 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
|
369 { |
454
283d113d4753
Added generation of the llvm 'sret' parameter attribute where applicable.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
452
diff
changeset
|
370 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
|
371 assert(fnarg); |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
372 |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
373 PAWI.Index = llidx; |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
374 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
|
375 |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
376 if (PAWI.Attrs) |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
377 attrs.push_back(PAWI); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
378 } |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
379 |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
380 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
|
381 func->setParamAttrs(palist); |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
382 } |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
383 |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
384 ////////////////////////////////////////////////////////////////////////////////////////// |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
385 |
100 | 386 void DtoDeclareFunction(FuncDeclaration* fdecl) |
387 { | |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
388 if (fdecl->ir.declared) return; |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
389 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
|
390 |
132 | 391 Logger::println("DtoDeclareFunction(%s): %s", fdecl->toPrettyChars(), fdecl->loc.toChars()); |
100 | 392 LOG_SCOPE; |
393 | |
121
9c79b61fb638
[svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents:
119
diff
changeset
|
394 // intrinsic sanity check |
9c79b61fb638
[svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents:
119
diff
changeset
|
395 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
|
396 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
|
397 fatal(); |
9c79b61fb638
[svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents:
119
diff
changeset
|
398 } |
9c79b61fb638
[svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents:
119
diff
changeset
|
399 |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
400 // 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
|
401 Type* t = fdecl->type->toBasetype(); |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
402 TypeFunction* f = (TypeFunction*)t; |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
403 |
100 | 404 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
|
405 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
|
406 if (!templInst && fdecl->getModule() != gIR->dmodule) |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
139
diff
changeset
|
407 { |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
139
diff
changeset
|
408 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
|
409 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
|
410 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
|
411 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
|
412 else { |
d632801b15f0
Introducing opaque type to dmd frontent to be used with certain runtime array
Christian Kamm <kamm incasoftware de>
parents:
378
diff
changeset
|
413 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
|
414 } |
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
|
415 declareOnly = true; |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
139
diff
changeset
|
416 } |
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
|
417 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
|
418 declareOnly = true; |
100 | 419 |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
420 if (!fdecl->ir.irFunc) { |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
421 fdecl->ir.irFunc = new IrFunction(fdecl); |
100 | 422 } |
423 | |
424 // 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
|
425 const char* mangled_name; |
100 | 426 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
|
427 mangled_name = fdecl->intrinsicName.c_str(); |
100 | 428 else |
429 mangled_name = fdecl->mangle(); | |
430 | |
431 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
|
432 if (fdecl->isVaIntrinsic()) |
100 | 433 vafunc = DtoDeclareVaFunction(fdecl); |
434 | |
435 // construct function | |
436 const llvm::FunctionType* functype = DtoFunctionType(fdecl); | |
437 llvm::Function* func = vafunc ? vafunc : gIR->module->getFunction(mangled_name); | |
438 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
|
439 func = llvm::Function::Create(functype, DtoLinkage(fdecl), mangled_name, gIR->module); |
100 | 440 |
441 // add func to IRFunc | |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
442 fdecl->ir.irFunc->func = func; |
100 | 443 |
444 // calling convention | |
445 if (!vafunc && fdecl->llvmInternal != LLVMintrinsic) | |
446 func->setCallingConv(DtoCallingConv(f->linkage)); | |
149
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
447 else // fall back to C, it should be the right thing to do |
132 | 448 func->setCallingConv(llvm::CallingConv::C); |
449 | |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
450 fdecl->ir.irFunc->func = func; |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
451 assert(llvm::isa<llvm::FunctionType>(f->ir.type->get())); |
100 | 452 |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
453 // 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
|
454 if (!fdecl->isIntrinsic()) { |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
234
diff
changeset
|
455 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
|
456 } |
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
457 |
116
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
458 // main |
100 | 459 if (fdecl->isMain()) { |
460 gIR->mainFunc = func; | |
461 } | |
462 | |
116
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
463 // static ctor |
163
a8cd9bc1021a
[svn r179] lots and lots of fixes, much more of tango now compiles/works.
lindquist
parents:
162
diff
changeset
|
464 if (fdecl->isStaticCtorDeclaration() && fdecl->getModule() == gIR->dmodule) { |
116
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
465 gIR->ctors.push_back(fdecl); |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
466 } |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
467 // static dtor |
163
a8cd9bc1021a
[svn r179] lots and lots of fixes, much more of tango now compiles/works.
lindquist
parents:
162
diff
changeset
|
468 else if (fdecl->isStaticDtorDeclaration() && fdecl->getModule() == gIR->dmodule) { |
116
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
469 gIR->dtors.push_back(fdecl); |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
470 } |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
471 |
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
|
472 // 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
|
473 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
|
474 { |
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 // 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
|
476 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
|
477 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
|
478 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
|
479 iarg->setName(".sretarg"); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
480 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
|
481 ++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
|
482 } |
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
|
483 |
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 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
|
485 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
|
486 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
|
487 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
|
488 ++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
|
489 } |
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
|
490 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
|
491 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
|
492 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
|
493 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
|
494 ++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
|
495 } |
119
79c9ac745fbc
[svn r123] Fixed some typeinfo module name mismatches.
lindquist
parents:
117
diff
changeset
|
496 |
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
|
497 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
|
498 iarg->setName("_arguments"); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
499 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
|
500 ++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
|
501 iarg->setName("_argptr"); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
502 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
|
503 ++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
|
504 } |
119
79c9ac745fbc
[svn r123] Fixed some typeinfo module name mismatches.
lindquist
parents:
117
diff
changeset
|
505 |
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
|
506 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
|
507 { |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
508 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
|
509 { |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
510 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
|
511 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
|
512 assert(argvd); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
513 assert(!argvd->ir.irLocal); |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
514 argvd->ir.irLocal = new IrLocal(argvd); |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
515 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
|
516 iarg->setName(argvd->ident->toChars()); |
100 | 517 } |
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
|
518 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
|
519 { |
1856c62af24b
[svn r178] Fixed codegen values for function arguments, the old approach was completely broken, amazing it even worked...
lindquist
parents:
157
diff
changeset
|
520 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
|
521 } |
100 | 522 } |
523 } | |
524 | |
121
9c79b61fb638
[svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents:
119
diff
changeset
|
525 if (fdecl->isUnitTestDeclaration()) |
9c79b61fb638
[svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents:
119
diff
changeset
|
526 gIR->unitTests.push_back(fdecl); |
9c79b61fb638
[svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents:
119
diff
changeset
|
527 |
100 | 528 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
|
529 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
|
530 else |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
531 assert(func->getLinkage() != llvm::GlobalValue::InternalLinkage); |
100 | 532 |
533 Logger::cout() << "func decl: " << *func << '\n'; | |
534 } | |
535 | |
536 ////////////////////////////////////////////////////////////////////////////////////////// | |
537 | |
538 void DtoDefineFunc(FuncDeclaration* fd) | |
539 { | |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
540 if (fd->ir.defined) return; |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
541 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
|
542 |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
543 assert(fd->ir.declared); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
102
diff
changeset
|
544 |
132 | 545 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
|
546 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
|
547 |
546
406aee3416bb
Removed D_InlineAsm and D_InlineAsm_X86 versions.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
527
diff
changeset
|
548 // error on naked |
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
|
549 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
|
550 { |
546
406aee3416bb
Removed D_InlineAsm and D_InlineAsm_X86 versions.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
527
diff
changeset
|
551 fd->error("naked is not supported"); |
406aee3416bb
Removed D_InlineAsm and D_InlineAsm_X86 versions.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
527
diff
changeset
|
552 fatal(); |
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 } |
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
|
554 |
100 | 555 // debug info |
556 if (global.params.symdebug) { | |
557 Module* mo = fd->getModule(); | |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
245
diff
changeset
|
558 fd->ir.irFunc->dwarfSubProg = DtoDwarfSubProgram(fd); |
100 | 559 } |
560 | |
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
|
561 Type* t = fd->type->toBasetype(); |
100 | 562 TypeFunction* f = (TypeFunction*)t; |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
563 assert(f->ir.type); |
100 | 564 |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
565 llvm::Function* func = fd->ir.irFunc->func; |
100 | 566 const llvm::FunctionType* functype = func->getFunctionType(); |
567 | |
568 // 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
|
569 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
|
570 return; |
100 | 571 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
572 // 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
|
573 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
|
574 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
575 // 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
|
576 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
|
577 return; |
100 | 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 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
|
580 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
|
581 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
|
582 gIR->functions.push_back(irfunction); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
102
diff
changeset
|
583 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
584 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
|
585 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
|
586 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
587 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
|
588 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
|
589 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
590 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
|
591 llvm::BasicBlock* endbb = llvm::BasicBlock::Create("endentry",func); |
100 | 592 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
593 //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
|
594 gIR->scopes.push_back(IRScope(beginbb, endbb)); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
102
diff
changeset
|
595 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
596 // 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
|
597 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
|
598 irfunction->allocapoint = allocaPoint; |
100 | 599 |
452
30ef3c7bddca
Fixed problems with nested 'this'. Fixes #39 .
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
449
diff
changeset
|
600 // 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
|
601 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
|
602 |
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
|
603 // 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
|
604 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
|
605 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
|
606 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
|
607 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
|
608 } |
526
642f6fa854e5
First step towards D abi compliance.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
523
diff
changeset
|
609 |
642f6fa854e5
First step towards D abi compliance.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
523
diff
changeset
|
610 // 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
|
611 // 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
|
612 // 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
|
613 if (fd->inlineAsm && !fd->naked) |
642f6fa854e5
First step towards D abi compliance.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
523
diff
changeset
|
614 { |
642f6fa854e5
First step towards D abi compliance.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
523
diff
changeset
|
615 // 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
|
616 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
|
617 gIR->ir->CreateCall(hack, ""); |
642f6fa854e5
First step towards D abi compliance.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
523
diff
changeset
|
618 } |
100 | 619 |
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
|
620 // 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
|
621 if (f->usesThis) |
254
8187884566fa
[svn r271] Fixed debug info for implicit 'this' param.
lindquist
parents:
250
diff
changeset
|
622 { |
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
|
623 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
|
624 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
|
625 |
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
|
626 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
|
627 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
|
628 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
|
629 |
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 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
|
631 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
|
632 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
|
633 |
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 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
|
635 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
|
636 |
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
|
637 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
|
638 fd->nestedVars.insert(fd->vthis); |
254
8187884566fa
[svn r271] Fixed debug info for implicit 'this' param.
lindquist
parents:
250
diff
changeset
|
639 } |
8187884566fa
[svn r271] Fixed debug info for implicit 'this' param.
lindquist
parents:
250
diff
changeset
|
640 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
641 // 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
|
642 // 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
|
643 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
|
644 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
645 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
|
646 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
|
647 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
648 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
|
649 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
|
650 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
|
651 |
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 (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
|
653 fd->nestedVars.insert(vd); |
100 | 654 |
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
|
655 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
|
656 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
|
657 |
457
d82ebdba4191
Fixed debug info and lazy arguments.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
455
diff
changeset
|
658 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
|
659 |
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
|
660 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
|
661 { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
662 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
|
663 } |
254
8187884566fa
[svn r271] Fixed debug info for implicit 'this' param.
lindquist
parents:
250
diff
changeset
|
664 else if (DtoIsPassedByRef(vd->type)) |
8187884566fa
[svn r271] Fixed debug info for implicit 'this' param.
lindquist
parents:
250
diff
changeset
|
665 { |
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 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
|
667 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
|
668 DtoDwarfLocalVariable(vdirval, vd); |
254
8187884566fa
[svn r271] Fixed debug info for implicit 'this' param.
lindquist
parents:
250
diff
changeset
|
669 continue; |
8187884566fa
[svn r271] Fixed debug info for implicit 'this' param.
lindquist
parents:
250
diff
changeset
|
670 } |
100 | 671 |
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
|
672 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
|
673 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
|
674 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
|
675 irloc->value = v; |
100 | 676 } |
677 } | |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
678 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
679 // 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
|
680 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
|
681 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
|
682 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
|
683 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
684 |
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
|
685 // 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
|
686 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
|
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 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
|
689 // 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
|
690 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
|
691 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
|
692 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
|
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 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
|
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 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
|
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 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
|
699 { |
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 // 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
|
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 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
|
703 { |
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 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
|
705 } |
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 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
|
707 } |
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
|
708 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
|
709 |
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 // 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
|
711 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
|
712 |
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 // 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
|
714 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
|
715 |
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 // 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
|
717 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
|
718 { |
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 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
|
720 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
|
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 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
|
723 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
|
724 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
|
725 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
|
726 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
|
727 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
|
728 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
|
729 } |
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 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
|
731 } |
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
|
732 |
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
|
733 // 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
|
734 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
|
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 // 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
|
737 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
|
738 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
|
739 { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
740 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
|
741 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
|
742 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
|
743 |
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 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
|
745 { |
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
|
746 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
|
747 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
|
748 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
|
749 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
|
750 } |
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
|
751 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
|
752 { |
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 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
|
754 } |
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
|
755 |
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 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
|
757 } |
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
|
758 |
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
|
759 // 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
|
760 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
|
761 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
|
762 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
|
763 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
|
764 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
|
765 } |
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 // 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
|
769 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
|
770 { |
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
|
771 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
|
772 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
|
773 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
|
774 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
775 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
776 // 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
|
777 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
|
778 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
779 // 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
|
780 // 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
|
781 if (!gIR->scopereturned()) { |
8b7cee241e91
Enable insertion of missing terminator instruction for main.
Christian Kamm <kamm incasoftware de>
parents:
399
diff
changeset
|
782 // 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
|
783 if (global.params.symdebug) DtoDwarfFuncEnd(fd); |
8b7cee241e91
Enable insertion of missing terminator instruction for main.
Christian Kamm <kamm incasoftware de>
parents:
399
diff
changeset
|
784 if (func->getReturnType() == LLType::VoidTy) { |
8b7cee241e91
Enable insertion of missing terminator instruction for main.
Christian Kamm <kamm incasoftware de>
parents:
399
diff
changeset
|
785 llvm::ReturnInst::Create(gIR->scopebb()); |
8b7cee241e91
Enable insertion of missing terminator instruction for main.
Christian Kamm <kamm incasoftware de>
parents:
399
diff
changeset
|
786 } |
8b7cee241e91
Enable insertion of missing terminator instruction for main.
Christian Kamm <kamm incasoftware de>
parents:
399
diff
changeset
|
787 else { |
8b7cee241e91
Enable insertion of missing terminator instruction for main.
Christian Kamm <kamm incasoftware de>
parents:
399
diff
changeset
|
788 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
|
789 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
|
790 else |
8b7cee241e91
Enable insertion of missing terminator instruction for main.
Christian Kamm <kamm incasoftware de>
parents:
399
diff
changeset
|
791 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
|
792 } |
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 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
795 // 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
|
796 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
|
797 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
|
798 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
|
799 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
800 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
|
801 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
802 // 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
|
803 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
|
804 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
|
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 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
|
807 // 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
|
808 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
|
809 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
|
810 { |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
258
diff
changeset
|
811 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
|
812 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
813 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
814 // 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
|
815 // 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
|
816 // 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
|
817 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
|
818 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
|
819 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
820 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
|
821 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
|
822 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
|
823 else |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
824 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
|
825 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
826 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
241
diff
changeset
|
827 gIR->functions.pop_back(); |
100 | 828 } |
829 | |
830 ////////////////////////////////////////////////////////////////////////////////////////// | |
831 | |
117 | 832 const llvm::FunctionType* DtoBaseFunctionType(FuncDeclaration* fdecl) |
833 { | |
834 Dsymbol* parent = fdecl->toParent(); | |
835 ClassDeclaration* cd = parent->isClassDeclaration(); | |
836 assert(cd); | |
837 | |
838 FuncDeclaration* f = fdecl; | |
839 | |
840 while (cd) | |
841 { | |
842 ClassDeclaration* base = cd->baseClass; | |
843 if (!base) | |
844 break; | |
845 FuncDeclaration* f2 = base->findFunc(fdecl->ident, (TypeFunction*)fdecl->type); | |
846 if (f2) { | |
847 f = f2; | |
848 cd = base; | |
849 } | |
850 else | |
851 break; | |
852 } | |
853 | |
854 DtoResolveDsymbol(f); | |
855 return llvm::cast<llvm::FunctionType>(DtoType(f->type)); | |
856 } | |
857 | |
858 ////////////////////////////////////////////////////////////////////////////////////////// | |
131 | 859 |
860 DValue* DtoArgument(Argument* fnarg, Expression* argexp) | |
861 { | |
862 Logger::println("DtoArgument"); | |
863 LOG_SCOPE; | |
864 | |
865 DValue* arg = argexp->toElem(gIR); | |
866 | |
867 // ref/out arg | |
868 if (fnarg && ((fnarg->storageClass & STCref) || (fnarg->storageClass & STCout))) | |
869 { | |
870 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
|
871 arg = new DImValue(argexp->type, arg->getLVal()); |
131 | 872 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
|
873 arg = new DImValue(argexp->type, arg->getRVal()); |
131 | 874 } |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
215
diff
changeset
|
875 // byval arg, but expr has no storage yet |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
546
diff
changeset
|
876 else if (DtoIsPassedByRef(argexp->type) && (arg->isSlice() || arg->isNull())) |
131 | 877 { |
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
|
878 LLValue* alloc = DtoAlloca(DtoType(argexp->type), ".tmp_arg"); |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
546
diff
changeset
|
879 DVarValue* vv = new DVarValue(argexp->type, alloc); |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
379
diff
changeset
|
880 DtoAssign(argexp->loc, vv, arg); |
131 | 881 arg = vv; |
882 } | |
883 | |
884 return arg; | |
885 } | |
886 | |
887 ////////////////////////////////////////////////////////////////////////////////////////// | |
888 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
205
diff
changeset
|
889 void DtoVariadicArgument(Expression* argexp, LLValue* dst) |
131 | 890 { |
891 Logger::println("DtoVariadicArgument"); | |
892 LOG_SCOPE; | |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
546
diff
changeset
|
893 DVarValue vv(argexp->type, dst); |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
379
diff
changeset
|
894 DtoAssign(argexp->loc, &vv, argexp->toElem(gIR)); |
131 | 895 } |
896 | |
897 ////////////////////////////////////////////////////////////////////////////////////////// | |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
898 |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
899 bool FuncDeclaration::isIntrinsic() |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
900 { |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
901 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
|
902 } |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
903 |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
904 bool FuncDeclaration::isVaIntrinsic() |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
905 { |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
906 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
|
907 llvmInternal == LLVMva_copy || |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
908 llvmInternal == LLVMva_end); |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
443
diff
changeset
|
909 } |