Mercurial > projects > ldc
comparison gen/abi.cpp @ 1051:dc608dc33081
Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
same LDC call.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sat, 07 Mar 2009 14:25:30 +0100 |
parents | 32ead42679d1 |
children | 15e9762bb620 |
comparison
equal
deleted
inserted
replaced
1050:32ead42679d1 | 1051:dc608dc33081 |
---|---|
165 return t->toBasetype()->ty == Tstruct; | 165 return t->toBasetype()->ty == Tstruct; |
166 } | 166 } |
167 | 167 |
168 void rewriteFunctionType(TypeFunction* tf) | 168 void rewriteFunctionType(TypeFunction* tf) |
169 { | 169 { |
170 IrFuncTy* fty = tf->fty; | 170 IrFuncTy& fty = tf->fty; |
171 Type* rt = fty->ret->type->toBasetype(); | 171 Type* rt = fty.ret->type->toBasetype(); |
172 | 172 |
173 // extern(D) | 173 // extern(D) |
174 if (tf->linkage == LINKd) | 174 if (tf->linkage == LINKd) |
175 { | 175 { |
176 // RETURN VALUE | 176 // RETURN VALUE |
177 | 177 |
178 // complex {re,im} -> {im,re} | 178 // complex {re,im} -> {im,re} |
179 if (rt->iscomplex()) | 179 if (rt->iscomplex()) |
180 { | 180 { |
181 Logger::println("Rewriting complex return value"); | 181 Logger::println("Rewriting complex return value"); |
182 fty->ret->rewrite = &swapComplex; | 182 fty.ret->rewrite = &swapComplex; |
183 } | 183 } |
184 | 184 |
185 // IMPLICIT PARAMETERS | 185 // IMPLICIT PARAMETERS |
186 | 186 |
187 // mark this/nested params inreg | 187 // mark this/nested params inreg |
188 if (fty->arg_this) | 188 if (fty.arg_this) |
189 { | 189 { |
190 Logger::println("Putting 'this' in register"); | 190 Logger::println("Putting 'this' in register"); |
191 fty->arg_this->attrs = llvm::Attribute::InReg; | 191 fty.arg_this->attrs = llvm::Attribute::InReg; |
192 } | 192 } |
193 else if (fty->arg_nest) | 193 else if (fty.arg_nest) |
194 { | 194 { |
195 Logger::println("Putting context ptr in register"); | 195 Logger::println("Putting context ptr in register"); |
196 fty->arg_nest->attrs = llvm::Attribute::InReg; | 196 fty.arg_nest->attrs = llvm::Attribute::InReg; |
197 } | 197 } |
198 // otherwise try to mark the last param inreg | 198 // otherwise try to mark the last param inreg |
199 else if (!fty->arg_sret && !fty->args.empty()) | 199 else if (!fty.arg_sret && !fty.args.empty()) |
200 { | 200 { |
201 // The last parameter is passed in EAX rather than being pushed on the stack if the following conditions are met: | 201 // The last parameter is passed in EAX rather than being pushed on the stack if the following conditions are met: |
202 // * It fits in EAX. | 202 // * It fits in EAX. |
203 // * It is not a 3 byte struct. | 203 // * It is not a 3 byte struct. |
204 // * It is not a floating point type. | 204 // * It is not a floating point type. |
205 | 205 |
206 IrFuncTyArg* last = fty->args.back(); | 206 IrFuncTyArg* last = fty.args.back(); |
207 Type* lastTy = last->type->toBasetype(); | 207 Type* lastTy = last->type->toBasetype(); |
208 unsigned sz = lastTy->size(); | 208 unsigned sz = lastTy->size(); |
209 | 209 |
210 if (last->byref && !last->isByVal()) | 210 if (last->byref && !last->isByVal()) |
211 { | 211 { |
232 | 232 |
233 // EXPLICIT PARAMETERS | 233 // EXPLICIT PARAMETERS |
234 | 234 |
235 // reverse parameter order | 235 // reverse parameter order |
236 // for non variadics | 236 // for non variadics |
237 if (!fty->args.empty() && tf->varargs != 1) | 237 if (!fty.args.empty() && tf->varargs != 1) |
238 { | 238 { |
239 fty->reverseParams = true; | 239 fty.reverseParams = true; |
240 } | 240 } |
241 } | 241 } |
242 | 242 |
243 // extern(C) and all others | 243 // extern(C) and all others |
244 else | 244 else |
246 // RETURN VALUE | 246 // RETURN VALUE |
247 | 247 |
248 // cfloat -> i64 | 248 // cfloat -> i64 |
249 if (tf->next->toBasetype() == Type::tcomplex32) | 249 if (tf->next->toBasetype() == Type::tcomplex32) |
250 { | 250 { |
251 fty->ret->rewrite = &cfloatToInt; | 251 fty.ret->rewrite = &cfloatToInt; |
252 fty->ret->ltype = LLType::Int64Ty; | 252 fty.ret->ltype = LLType::Int64Ty; |
253 } | 253 } |
254 | 254 |
255 // IMPLICIT PARAMETERS | 255 // IMPLICIT PARAMETERS |
256 | 256 |
257 // EXPLICIT PARAMETERS | 257 // EXPLICIT PARAMETERS |