Changeset 4968 in CLRX


Ignore:
Timestamp:
Sep 18, 2019, 9:23:22 AM (4 weeks ago)
Author:
matszpk
Message:

CLRadeonExtender: Asm: Add to AsmKcodeHandler? codeFlags. Add handling codeFlags in AsmROCm.

Location:
CLRadeonExtender/trunk
Files:
7 edited

Legend:

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

    r4964 r4968  
    148148        cxuint allocRegs[MAX_REGTYPES_NUM];
    149149        Flags allocRegFlags;
     150        Flags codeFlags;
    150151    };
    151152protected:
     
    214215    /// prepare before section diference resolving
    215216    virtual bool prepareSectionDiffsResolving();
     217    virtual void setCodeFlags(Flags codeFlags);
    216218};
    217219
     
    632634    KernelBase& getKernelBase(AsmKernelId index);
    633635    size_t getKernelsNum() const;
     636    void setCodeFlags(Flags codeFlags);
    634637};
    635638
  • CLRadeonExtender/trunk/CLRX/amdasm/Assembler.h

    r4967 r4968  
    249249    /// check if name is mnemonic
    250250    virtual bool checkMnemonic(const CString& mnemonic) const = 0;
     251    virtual Flags getImportantCodeFlags() const = 0;
    251252    /// set allocated registers (if regs is null then reset them)
    252253    virtual void setAllocatedRegisters(const cxuint* regs = nullptr,
    253254                Flags regFlags = 0) = 0;
     255    void setCodeFlags(Flags codeFlags);
    254256    /// get allocated register numbers after assemblying
    255257    virtual const cxuint* getAllocatedRegisters(size_t& regTypesNum,
    256258                Flags& regFlags) const = 0;
     259    Flags getCodeFlags() const;
    257260    /// get max registers number
    258261    virtual void getMaxRegistersNum(size_t& regTypesNum, cxuint* maxRegs) const = 0;
     
    348351                 AsmSectionId sectionId, uint64_t value);
    349352    bool checkMnemonic(const CString& mnemonic) const;
     353    Flags getImportantCodeFlags() const;
    350354    void setAllocatedRegisters(const cxuint* regs, Flags regFlags);
    351355    const cxuint* getAllocatedRegisters(size_t& regTypesNum, Flags& regFlags) const;
     
    982986{ assembler.sections[sectionId].addCodeFlowEntry(entry); }
    983987
     988inline void ISAAssembler::setCodeFlags(Flags codeFlags)
     989{ assembler.setCodeFlags(codeFlags); }
     990
     991inline Flags ISAAssembler::getCodeFlags() const
     992{ return assembler.getCodeFlags(); }
     993
    984994};
    985995
  • CLRadeonExtender/trunk/amdasm/AsmFormats.cpp

    r4965 r4968  
    7070{ }
    7171
     72void AsmFormatHandler::setCodeFlags(Flags codeFlags)
     73{ }
     74
    7275bool AsmFormatHandler::resolveSymbol(const AsmSymbol& symbol, uint64_t& value,
    7376                 AsmSectionId& sectionId)
     
    188191        assembler.isaAssembler->setAllocatedRegisters(newKernel.allocRegs,
    189192                            newKernel.allocRegFlags);
     193        assembler.isaAssembler->setCodeFlags(newKernel.codeFlags);
    190194    }
    191195}
     
    201205                            regTypesNum, oldKernel.allocRegFlags);
    202206        std::copy(regs, regs+regTypesNum, oldKernel.allocRegs);
     207        oldKernel.codeFlags = assembler.isaAssembler->getCodeFlags();
    203208    }
    204209}
     
    215220            {
    216221                // pop from kcode stack and apply changes
    217                 AsmKcodePseudoOps::updateKCodeSel(*this, kcodeSelection);
     222                AsmKcodePseudoOps::updateKCodeSel(*this, kcodeSelection, nullptr);
    218223                kcodeSelection = kcodeSelStack.top();
    219224                kcodeSelStack.pop();
     
    252257 * current kernel regalloc */
    253258void AsmKcodePseudoOps::updateKCodeSel(AsmKcodeHandler& handler,
    254                     const std::vector<AsmKernelId>& oldset)
     259                    const std::vector<AsmKernelId>& oldset, const char* pseudoOpPlace)
    255260{
    256261    Assembler& asmr = handler.assembler;
    257262    // old elements - join current regstate with all them
    258263    size_t regTypesNum;
     264    bool first = true;
     265    bool codeFlagsMismatch = false;
    259266    for (auto it = oldset.begin(); it != oldset.end(); ++it)
    260267    {
    261268        Flags curAllocRegFlags;
     269        Flags curCodeFlags = asmr.isaAssembler->getCodeFlags();
     270        Flags importantCodeFlags = asmr.isaAssembler->getImportantCodeFlags();
    262271        const cxuint* curAllocRegs = asmr.isaAssembler->getAllocatedRegisters(regTypesNum,
    263272                               curAllocRegFlags);
     
    267276            newAllocRegs[i] = std::max(curAllocRegs[i], kernel.allocRegs[i]);
    268277        kernel.allocRegFlags |= curAllocRegFlags;
     278        if (!first && ((kernel.codeFlags ^ curCodeFlags) & importantCodeFlags) != 0)
     279            codeFlagsMismatch = true;
     280        kernel.codeFlags |= curCodeFlags;
    269281        std::copy(newAllocRegs, newAllocRegs+regTypesNum, kernel.allocRegs);
     282        first = false;
     283    }
     284    if (codeFlagsMismatch)
     285    {
     286        if (pseudoOpPlace!=nullptr)
     287            asmr.printError(pseudoOpPlace, "Code flags mismatch for kernel set");
     288        else
     289            asmr.printError(AsmSourcePos{}, "Code flags mismatch for kernel set");
    270290    }
    271291    asmr.isaAssembler->setAllocatedRegisters();
     
    347367    }
    348368   
    349     updateKCodeSel(handler, handler.kcodeSelStack.top());
     369    updateKCodeSel(handler, handler.kcodeSelStack.top(), pseudoOpPlace);
    350370}
    351371
     
    361381        return;
    362382   
    363     updateKCodeSel(handler, handler.kcodeSelection);
     383    updateKCodeSel(handler, handler.kcodeSelection, pseudoOpPlace);
    364384    std::vector<AsmKernelId> oldKCodeSel = handler.kcodeSelection;
    365385    handler.kcodeSelection = handler.kcodeSelStack.top();
  • CLRadeonExtender/trunk/amdasm/AsmInternals.h

    r4517 r4968  
    342342                      const char* linePtr);
    343343    static void updateKCodeSel(AsmKcodeHandler& handler,
    344                       const std::vector<cxuint>& oldset);
     344                      const std::vector<cxuint>& oldset, const char* pseudoOpPlace);
    345345};
    346346
  • CLRadeonExtender/trunk/amdasm/AsmPseudoOps.cpp

    r4967 r4968  
    600600        case ASMOP_NOWAVE32:
    601601            if (AsmPseudoOps::checkGarbagesAtEnd(*this, linePtr))
     602            {
    602603                codeFlags &= ~ASM_CODE_WAVE32;
     604                if (formatHandler != nullptr)
     605                    formatHandler->setCodeFlags(codeFlags);
     606            }
    603607            break;
    604608        case ASMOP_OCTA:
     
    704708        case ASMOP_WAVE32:
    705709            if (AsmPseudoOps::checkGarbagesAtEnd(*this, linePtr))
     710            {
    706711                codeFlags |= ASM_CODE_WAVE32;
     712                if (formatHandler != nullptr)
     713                    formatHandler->setCodeFlags(codeFlags);
     714            }
    707715            break;
    708716        case ASMOP_WEAK:
  • CLRadeonExtender/trunk/amdasm/AsmROCmFormat.cpp

    r4966 r4968  
    167167    sections.push_back({ thisKernel, AsmSectionType::CONFIG, ELFSECTID_UNDEF, nullptr });
    168168    kernelStates.push_back(new Kernel(thisSection));
     169    kernelStates.back()->codeFlags = assembler.codeFlags;
    169170    output.metadataInfo.kernels.push_back(ROCmKernelMetadata());
    170171    output.metadataInfo.kernels.back().initialize();
     
    316317    info.name = sections[sectionId].name;
    317318    return info;
     319}
     320
     321void AsmROCmHandler::setCodeFlags(Flags codeFlags)
     322{
     323    if (assembler.currentKernel != ASMKERN_GLOBAL)
     324        kernelStates[assembler.currentKernel]->codeFlags = codeFlags;
    318325}
    319326
     
    15291536   
    15301537    setConfigBoolValueMain(config, target);
     1538   
     1539    if (target == ROCMCVAL_USE_WAVE32)
     1540    {
     1541        AsmROCmHandler::KernelBase& kbase = *(handler.kernelStates[asmr.currentKernel]);
     1542        kbase.codeFlags |= ASM_CODE_WAVE32;
     1543    }
    15311544}
    15321545
  • CLRadeonExtender/trunk/amdasm/GCNAssembler.cpp

    r4869 r4968  
    181181{
    182182    return new GCNUsageHandler();
     183}
     184
     185Flags GCNAssembler::getImportantCodeFlags() const
     186{
     187    return (curArchMask & ARCH_GCN_1_5)!=0 ? ASM_CODE_WAVE32 : 0;
    183188}
    184189
Note: See TracChangeset for help on using the changeset viewer.