Changeset 4171 in CLRX


Ignore:
Timestamp:
May 16, 2018, 9:48:58 AM (4 months ago)
Author:
matszpk
Message:

CLRadeonExtender: Asm: Add ISALinearDepHandler. Add '.rvlin' pseudo-op.

Location:
CLRadeonExtender/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • CLRadeonExtender/trunk/CLRX/amdasm/AsmDefs.h

    r4170 r4171  
    717717
    718718class ISAUsageHandler;
     719class ISALinearDepHandler;
    719720
    720721/// assembler section
     
    732733   
    733734    std::unique_ptr<ISAUsageHandler> usageHandler;  ///< usage handler
     735    std::unique_ptr<ISALinearDepHandler> linearDepHandler; ///< linear dep handler
    734736    std::vector<AsmCodeFlowEntry> codeFlow;  ///< code flow info
    735737   
  • CLRadeonExtender/trunk/CLRX/amdasm/Assembler.h

    r4170 r4171  
    164164};
    165165
    166 /// ISA (register and regvar) linear handler
     166/// ISA regvar linear handler
    167167class ISALinearDepHandler
    168168{
     
    171171    size_t regVarLinDepsPos;
    172172public:
     173    /// constructor
    173174    ISALinearDepHandler();
    174175   
     176    /// get reading position
     177    size_t getReadPos() const
     178    { return regVarLinDepsPos; }
     179    /// get reading position
     180    void setReadPos(size_t pos)
     181    { regVarLinDepsPos = pos; }
     182    /// push linear dependency
    175183    void pushLinearDep(const AsmRegVarLinearDep& linearDep);
    176    
     184    /// rewind read position to start
    177185    void rewind();
    178    
     186    /// return true if has next
     187    bool hasNext() const
     188    { return regVarLinDepsPos < regVarLinDeps.size(); }
     189    /// get next linear dependency
    179190    AsmRegVarLinearDep nextLinearDep();
    180191};
  • CLRadeonExtender/trunk/amdasm/AsmInternals.h

    r4132 r4171  
    304304    // .usereg ?
    305305    static void doUseReg(Assembler& asmr, const char* linePtr);
     306    // .rvlin
     307    static void declareRegVarLinearDeps(Assembler& asmr, const char* linePtr);
    306308    // .undef
    307309    static void undefSymbol(Assembler& asmr, const char* linePtr);
  • CLRadeonExtender/trunk/amdasm/AsmPseudoOps.cpp

    r4136 r4171  
    117117    "p2align", "policy", "print", "purgem", "quad",
    118118    "rawcode", "regvar", "rept", "rocm", "rodata",
    119     "sbttl", "scope", "section", "set",
     119    "rvlin", "sbttl", "scope", "section", "set",
    120120    "short", "single", "size", "skip",
    121121    "space", "string", "string16", "string32",
     
    160160    ASMOP_P2ALIGN, ASMOP_POLICY, ASMOP_PRINT, ASMOP_PURGEM, ASMOP_QUAD,
    161161    ASMOP_RAWCODE, ASMOP_REGVAR, ASMOP_REPT, ASMOP_ROCM, ASMOP_RODATA,
    162     ASMOP_SBTTL, ASMOP_SCOPE, ASMOP_SECTION, ASMOP_SET,
     162    ASMOP_RVLIN, ASMOP_SBTTL, ASMOP_SCOPE, ASMOP_SECTION, ASMOP_SET,
    163163    ASMOP_SHORT, ASMOP_SINGLE, ASMOP_SIZE, ASMOP_SKIP,
    164164    ASMOP_SPACE, ASMOP_STRING, ASMOP_STRING16, ASMOP_STRING32,
     
    634634        case ASMOP_RODATA:
    635635            AsmPseudoOps::goToSection(*this, stmtPlace, stmtPlace, true);
     636            break;
     637        case ASMOP_RVLIN:
     638            AsmPseudoOps::declareRegVarLinearDeps(*this, linePtr);
    636639            break;
    637640        case ASMOP_SCOPE:
  • CLRadeonExtender/trunk/amdasm/AsmPseudoOpsCode1.cpp

    r4136 r4171  
    19821982}
    19831983
     1984void AsmPseudoOps::declareRegVarLinearDeps(Assembler& asmr, const char* linePtr)
     1985{
     1986    const char* end = asmr.line+asmr.lineSize;
     1987    asmr.initializeOutputFormat();
     1988   
     1989    do {
     1990        skipSpacesToEnd(linePtr, end);
     1991        const char* regVarPlace = linePtr;
     1992        bool good = true;
     1993        cxuint regStart, regEnd;
     1994        const AsmRegVar* regVar;
     1995        good = asmr.isaAssembler->parseRegisterRange(linePtr, regStart, regEnd, regVar);
     1996       
     1997        if (good) // if good
     1998        {
     1999            // create isaLinearDepHandler if needed
     2000            if (asmr.sections[asmr.currentSection].linearDepHandler == nullptr)
     2001                    asmr.sections[asmr.currentSection].linearDepHandler.reset(
     2002                        new ISALinearDepHandler());
     2003            // put regVar usage
     2004            if (regVar != nullptr)
     2005                asmr.sections[asmr.currentSection].linearDepHandler->pushLinearDep(
     2006                        AsmRegVarLinearDep{ asmr.currentOutPos, regVar,
     2007                            uint16_t(regStart), uint16_t(regEnd) });
     2008            else
     2009                // otherwise, just ignore, print warning
     2010                asmr.printWarning(regVarPlace, "Normal register range is ignored");
     2011        }
     2012       
     2013    } while(skipCommaForMultipleArgs(asmr, linePtr));
     2014   
     2015    checkGarbagesAtEnd(asmr, linePtr);
     2016}
     2017
    19842018void AsmPseudoOps::stopUsing(Assembler& asmr, const char* linePtr)
    19852019{
  • CLRadeonExtender/trunk/amdasm/AsmRegAlloc.cpp

    r4134 r4171  
    258258    return rvu;
    259259}
     260
     261
     262ISALinearDepHandler::ISALinearDepHandler() : regVarLinDepsPos(0)
     263{ }
     264
     265void ISALinearDepHandler::pushLinearDep(const AsmRegVarLinearDep& linearDep)
     266{
     267    regVarLinDeps.push_back(linearDep);
     268}
     269
     270void ISALinearDepHandler::rewind()
     271{
     272    regVarLinDepsPos = 0;
     273}
     274
     275AsmRegVarLinearDep ISALinearDepHandler::nextLinearDep()
     276{
     277    if (regVarLinDepsPos >= regVarLinDeps.size())
     278        throw AsmException("No regvar linear deps in this code");
     279    return regVarLinDeps[regVarLinDepsPos++];
     280}
     281
     282/*
     283 * Asm register allocator stuff
     284 */
    260285
    261286AsmRegAllocator::AsmRegAllocator(Assembler& _assembler) : assembler(_assembler)
  • CLRadeonExtender/trunk/amdasm/Assembler.cpp

    r4132 r4171  
    30023002                                    sections[currentSection].content));
    30033003               
     3004                if (sections[currentSection].linearDepHandler == nullptr)
     3005                    sections[currentSection].linearDepHandler.reset(
     3006                            new ISALinearDepHandler());
     3007               
    30043008                isaAssembler->assemble(firstName, stmtPlace, linePtr, end,
    30053009                           sections[currentSection].content,
Note: See TracChangeset for help on using the changeset viewer.