Wiki Roadmap Timeline Tickets New Ticket Source Search Help / Guide About Trac Login

Changeset 720:e177ae483f8e

Show
Ignore:
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
  • dmd/mtype.c

    r717 r720  
    26732673    this->usesNest = false; 
    26742674    this->retAttrs = 0; 
     2675    this->thisAttrs = 0; 
    26752676} 
    26762677 
     
    26842685    t->usesNest = usesNest; 
    26852686    t->retAttrs = retAttrs; 
     2687    t->thisAttrs = thisAttrs; 
    26862688    return t; 
    26872689} 
  • dmd/mtype.h

    r715 r720  
    440440    bool usesNest; 
    441441    unsigned retAttrs; 
     442    unsigned thisAttrs; // also used for nest 
    442443}; 
    443444 
  • gen/functions.cpp

    r719 r720  
    172172    llvm::FunctionType* functype = llvm::FunctionType::get(actualRettype, paramvec, isvararg); 
    173173 
     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 
    174207    f->retInPtr = retinptr; 
    175208    f->usesThis = usesthis; 
     
    348381        PAWI.Index = 1; 
    349382        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; 
    350391        attrs.push_back(PAWI); 
    351392    } 
  • gen/tocall.cpp

    r719 r720  
    258258        ++argiter; 
    259259        args.push_back(retvar); 
     260 
     261        // add attrs for hidden ptr 
    260262        palist = palist.addAttr(1, llvm::Attribute::StructRet); 
    261263    } 
     
    300302            fatal(); 
    301303        } 
     304 
     305        // add attributes for context argument 
     306        if (tf->thisAttrs) 
     307            palist = palist.addAttr(retinptr?2:1, tf->thisAttrs); 
    302308    } 
    303309 
  • gen/toir.cpp

    r719 r720  
    374374    if (dtype->ty == Tarray) { 
    375375        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)); 
    379377    } 
    380378    else if (dtype->ty == Tsarray) { 
Copyright © 2008, LDC Development Team.