Changeset 720:e177ae483f8e
- Timestamp:
- 10/22/08 18:34:46
(3 months ago)
- Author:
- Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
- branch:
- default
- Message:
Added inreg attribute where appropriate on x86 to follow ABI docs.
Removed now unnecessary temporary variable in StringExp?.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r717 |
r720 |
|
| 2673 | 2673 | this->usesNest = false; |
|---|
| 2674 | 2674 | this->retAttrs = 0; |
|---|
| | 2675 | this->thisAttrs = 0; |
|---|
| 2675 | 2676 | } |
|---|
| 2676 | 2677 | |
|---|
| … | … | |
| 2684 | 2685 | t->usesNest = usesNest; |
|---|
| 2685 | 2686 | t->retAttrs = retAttrs; |
|---|
| | 2687 | t->thisAttrs = thisAttrs; |
|---|
| 2686 | 2688 | return t; |
|---|
| 2687 | 2689 | } |
|---|
| r715 |
r720 |
|
| 440 | 440 | bool usesNest; |
|---|
| 441 | 441 | unsigned retAttrs; |
|---|
| | 442 | unsigned thisAttrs; // also used for nest |
|---|
| 442 | 443 | }; |
|---|
| 443 | 444 | |
|---|
| r719 |
r720 |
|
| 172 | 172 | llvm::FunctionType* functype = llvm::FunctionType::get(actualRettype, paramvec, isvararg); |
|---|
| 173 | 173 | |
|---|
| | 174 | // tell first param to be passed in a register if we can |
|---|
| | 175 | // ONLY extern(D) functions ! |
|---|
| | 176 | if ((n > 0 || usesthis || usesnest) && f->linkage == LINKd) |
|---|
| | 177 | { |
|---|
| | 178 | // FIXME: Only x86 right now ... |
|---|
| | 179 | if (global.params.cpu == ARCHx86) |
|---|
| | 180 | { |
|---|
| | 181 | // pass first param in EAX if it fits, is not floating point and is not a 3 byte struct. |
|---|
| | 182 | // FIXME: struct are not passed in EAX yet |
|---|
| | 183 | |
|---|
| | 184 | // if there is a implicit context parameter, pass it in EAX |
|---|
| | 185 | if (usesthis || usesnest) |
|---|
| | 186 | { |
|---|
| | 187 | f->thisAttrs |= llvm::Attribute::InReg; |
|---|
| | 188 | } |
|---|
| | 189 | // otherwise check the first formal parameter |
|---|
| | 190 | else |
|---|
| | 191 | { |
|---|
| | 192 | Argument* arg = Argument::getNth(f->parameters, 0); |
|---|
| | 193 | Type* t = arg->type->toBasetype(); |
|---|
| | 194 | |
|---|
| | 195 | // 32bit ints, pointers, classes and static arrays are candidate for being passed in EAX |
|---|
| | 196 | if ((arg->storageClass & STCin) && |
|---|
| | 197 | ((t->isscalar() && !t->isfloating()) || t->ty == Tclass || t->ty == Tsarray) && |
|---|
| | 198 | (t->size() <= PTRSIZE)) |
|---|
| | 199 | { |
|---|
| | 200 | arg->llvmAttrs |= llvm::Attribute::InReg; |
|---|
| | 201 | } |
|---|
| | 202 | } |
|---|
| | 203 | } |
|---|
| | 204 | } |
|---|
| | 205 | |
|---|
| | 206 | // done |
|---|
| 174 | 207 | f->retInPtr = retinptr; |
|---|
| 175 | 208 | f->usesThis = usesthis; |
|---|
| … | … | |
| 348 | 381 | PAWI.Index = 1; |
|---|
| 349 | 382 | PAWI.Attrs = llvm::Attribute::StructRet; |
|---|
| | 383 | attrs.push_back(PAWI); |
|---|
| | 384 | } |
|---|
| | 385 | |
|---|
| | 386 | // set this/nest param attrs |
|---|
| | 387 | if (f->thisAttrs) |
|---|
| | 388 | { |
|---|
| | 389 | PAWI.Index = f->retInPtr ? 2 : 1; |
|---|
| | 390 | PAWI.Attrs = f->thisAttrs; |
|---|
| 350 | 391 | attrs.push_back(PAWI); |
|---|
| 351 | 392 | } |
|---|
| r719 |
r720 |
|
| 258 | 258 | ++argiter; |
|---|
| 259 | 259 | args.push_back(retvar); |
|---|
| | 260 | |
|---|
| | 261 | // add attrs for hidden ptr |
|---|
| 260 | 262 | palist = palist.addAttr(1, llvm::Attribute::StructRet); |
|---|
| 261 | 263 | } |
|---|
| … | … | |
| 300 | 302 | fatal(); |
|---|
| 301 | 303 | } |
|---|
| | 304 | |
|---|
| | 305 | // add attributes for context argument |
|---|
| | 306 | if (tf->thisAttrs) |
|---|
| | 307 | palist = palist.addAttr(retinptr?2:1, tf->thisAttrs); |
|---|
| 302 | 308 | } |
|---|
| 303 | 309 | |
|---|
| r719 |
r720 |
|
| 374 | 374 | if (dtype->ty == Tarray) { |
|---|
| 375 | 375 | LLConstant* clen = llvm::ConstantInt::get(DtoSize_t(),len,false); |
|---|
| 376 | | LLValue* tmpmem = DtoAlloca(DtoType(dtype),"tempstring"); |
|---|
| 377 | | DtoSetArray(tmpmem, clen, arrptr); |
|---|
| 378 | | return new DVarValue(type, tmpmem); |
|---|
| | 376 | return new DImValue(type, DtoConstSlice(clen, arrptr)); |
|---|
| 379 | 377 | } |
|---|
| 380 | 378 | else if (dtype->ty == Tsarray) { |
|---|