Changeset 3084 in CLRX


Ignore:
Timestamp:
May 27, 2017, 8:26:06 PM (2 years ago)
Author:
matszpk
Message:

CLRadeonExtender: GCNAsm: Update (some simplifications and changes in parseVOPModifiers).

Location:
CLRadeonExtender/trunk/amdasm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • CLRadeonExtender/trunk/amdasm/GCNAsmHelpers.cpp

    r3082 r3084  
    15341534 * modifier specific for VOP_SDWA and VOP_DPP stored in extraMods structure
    15351535 * withSDWAOperands - specify number of operand for that modifier will be parsed */
    1536 bool GCNAsmUtils::parseVOPModifiers(Assembler& asmr, const char*& linePtr, cxbyte& mods,
    1537                 VOPExtraModifiers* extraMods, bool withClamp, cxuint withSDWAOperands)
     1536bool GCNAsmUtils::parseVOPModifiers(Assembler& asmr, const char*& linePtr,
     1537                uint16_t arch, cxbyte& mods, VOPExtraModifiers* extraMods, bool withClamp,
     1538                cxuint withSDWAOperands)
    15381539{
    15391540    const char* end = asmr.line+asmr.lineSize;
     
    20372038            good = false;
    20382039    }
    2039     bool vopSDWA = (haveDstSel || haveDstUnused || haveSrc0Sel || haveSrc1Sel);
    2040     bool vopDPP = (haveDppCtrl || haveBoundCtrl || haveBankMask || haveRowMask);
    2041     bool vop3 = (mods & (3|VOP3_VOP3))!=0;
     2040    const bool vopSDWA = (haveDstSel || haveDstUnused || haveSrc0Sel || haveSrc1Sel);
     2041    const bool vopDPP = (haveDppCtrl || haveBoundCtrl || haveBankMask || haveRowMask);
     2042    const bool isGCN14 = (arch & ARCH_RXVEGA) != 0;
     2043    // mul/div modifier does not apply to vop3 if RXVEGA (this case will be checked later)
     2044    const bool vop3 = (mods & ((isGCN14 ? 0 : 3)|VOP3_VOP3))!=0;
    20422045    if (extraMods!=nullptr)
    20432046    {
     
    20452048        extraMods->needDPP = vopDPP;
    20462049    }
    2047        
    2048     if ((int(vop3)+vopSDWA+vopDPP)>1 || ((mods&VOP3_CLAMP)!=0 && vopDPP))
     2050    if ((int(vop3)+vopSDWA+vopDPP)>1 ||
     2051                // RXVEGA: mul/div modifier are accepted in VOP_SDWA but not for VOP_DPP
     2052                (isGCN14 && (mods & 3)!=0 && vopDPP) ||
     2053                ((mods&VOP3_CLAMP)!=0 && vopDPP))
    20492054    {
    20502055        asmr.printError(modsPlace, "Mixing modifiers from different encodings is illegal");
  • CLRadeonExtender/trunk/amdasm/GCNAsmInternals.h

    r3082 r3084  
    202202    /* withSDWAOperands - number operand that will be handled by SDWA modifer parser,
    203203     * (includes destination at begin) */
    204     static bool parseVOPModifiers(Assembler& asmr, const char*& linePtr, cxbyte& mods,
    205                        VOPExtraModifiers* extraMods = nullptr,
     204    static bool parseVOPModifiers(Assembler& asmr, const char*& linePtr, uint16_t arch,
     205                       cxbyte& mods, VOPExtraModifiers* extraMods = nullptr,
    206206                       bool withClamp = true, cxuint withSDWAOperands = 3);
    207207   
  • CLRadeonExtender/trunk/amdasm/GCNAssembler.cpp

    r3083 r3084  
    585585    RegRange dstReg(0, 0);
    586586    GCNAssembler* gcnAsm = static_cast<GCNAssembler*>(asmr.isaAssembler);
     587    const bool isGCN14 = (arch & ARCH_RXVEGA)!=0;
    587588   
    588589    gcnAsm->setCurrentRVU(0);
     
    648649        cxuint hwregId = 0;
    649650        const char* hwregNamePlace = linePtr;
    650         const size_t regMapSize = (arch & ARCH_RXVEGA) ?
    651                     hwregNamesGCN14MapSize : hwregNamesMapSize;
    652         const std::pair<const char*, cxuint>* regMap = (arch & ARCH_RXVEGA) ?
     651        const size_t regMapSize = isGCN14 ? hwregNamesGCN14MapSize : hwregNamesMapSize;
     652        const std::pair<const char*, cxuint>* regMap = isGCN14 ?
    653653                    hwregNamesGCN14Map : hwregNamesMap;
    654654        good &= getEnumeration(asmr, linePtr, "HWRegister",
     
    861861    GCNAssembler* gcnAsm = static_cast<GCNAssembler*>(asmr.isaAssembler);
    862862    bool good = true;
     863    const bool isGCN14 = (arch & ARCH_RXVEGA)!=0;
    863864    if (gcnEncSize==GCNEncSize::BIT64)
    864865    {
     
    907908            bool haveExpCnt = false;
    908909            bool haveVMCnt = false;
    909             imm16 = (arch & ARCH_RXVEGA) ? 0xcf7f : 0xf7f;
     910            imm16 = isGCN14 ? 0xcf7f : 0xf7f;
    910911            while (true)
    911912            {
     
    924925                        asmr.printWarning(funcNamePlace, "vmcnt was already defined");
    925926                    bitPos = 0;
    926                     bitMask = (arch & ARCH_RXVEGA) ? 63 : 15;
     927                    bitMask = isGCN14 ? 63 : 15;
    927928                    doVMCnt = haveVMCnt = true;
    928929                }
     
    963964                    if (value > bitMask)
    964965                        asmr.printWarning(argPlace, "Value out of range");
    965                     if ((arch & ARCH_RXVEGA)==0 || !doVMCnt)
     966                    if (!isGCN14 || !doVMCnt)
    966967                        imm16 = (imm16 & ~(bitMask<<bitPos)) | ((value&bitMask)<<bitPos);
    967968                    else // vmcnt for GFX9
     
    10061007                toLowerString(name);
    10071008                const size_t msgNameIndex = (::strncmp(name, "msg_", 4) == 0) ? 4 : 0;
    1008                 auto msgMap = (arch & ARCH_RXVEGA) ? sendMessageNamesGCN14Map :
     1009                auto msgMap = isGCN14 ? sendMessageNamesGCN14Map :
    10091010                        sendMessageNamesMap;
    1010                 const size_t msgMapSize = (arch & ARCH_RXVEGA) ?
     1011                const size_t msgMapSize = isGCN14 ?
    10111012                        sendMessageNamesGCN14MapSize : sendMessageNamesMapSize;
    10121013                size_t index = binaryMapFind(msgMap, msgMap + msgMapSize,
     
    12231224    std::unique_ptr<AsmExpression> soffset2Expr;
    12241225    const uint16_t mode1 = (gcnInsn.mode & GCN_MASK1);
     1226    const bool isGCN14 = (arch & ARCH_RXVEGA) != 0;
    12251227   
    12261228    const char* soffsetPlace = nullptr;
     
    12721274            good &= parseImm(asmr, linePtr, soffsetVal, &soffsetExpr,
    12731275                // for VEGA we check range later
    1274                 (arch & ARCH_RXVEGA) ? UINT_MAX : 20, WS_UNSIGNED);
     1276                isGCN14 ? UINT_MAX : 20, WS_UNSIGNED);
    12751277        }
    12761278    }
     
    12911293            if (::strcmp(name, "glc")==0)
    12921294                haveGlc = true;
    1293             else if ((arch & ARCH_RXVEGA)!=0 && ::strcmp(name, "nv")==0)
     1295            else if (isGCN14 && ::strcmp(name, "nv")==0)
    12941296                haveNv = true;
    1295             else if ((arch & ARCH_RXVEGA)!=0 && ::strcmp(name, "offset")==0)
     1297            else if (isGCN14 && ::strcmp(name, "offset")==0)
    12961298            {
    12971299                if (parseModImm(asmr, linePtr, soffset2Val, &soffset2Expr, "offset",
     
    13151317    }
    13161318    // check range for offset
    1317     if ((arch & ARCH_RXVEGA)!=0)
     1319    if (isGCN14)
    13181320        asmr.printWarningForRange(haveOffset ? 8 : 21, soffsetVal,
    13191321                    soffsetPos, WS_UNSIGNED);
     
    13281330   
    13291331    if (soffsetExpr!=nullptr)
    1330         soffsetExpr->setTarget(AsmExprTarget((arch & ARCH_RXVEGA) ?
     1332        soffsetExpr->setTarget(AsmExprTarget(isGCN14 ?
    13311333                    GCNTGT_SMEMOFFSETVEGA : GCNTGT_SMEMOFFSET,
    13321334                    asmr.currentSection, output.size()));
     
    14051407    const uint16_t mode2 = (gcnInsn.mode & GCN_MASK2);
    14061408    const bool isGCN12 = (arch & ARCH_GCN_1_2_4)!=0;
     1409    const bool isGCN14 = (arch & ARCH_RXVEGA)!=0;
    14071410    GCNAssembler* gcnAsm = static_cast<GCNAssembler*>(asmr.isaAssembler);
    14081411   
     
    14901493    cxbyte modifiers = 0;
    14911494    VOPExtraModifiers extraMods{};
    1492     good &= parseVOPModifiers(asmr, linePtr, modifiers, (isGCN12) ? &extraMods : nullptr,
    1493                               !haveDstCC || isGCN12);
     1495    good &= parseVOPModifiers(asmr, linePtr, arch, modifiers,
     1496                    (isGCN12) ? &extraMods : nullptr, !haveDstCC || isGCN12);
    14941497    if (!good || !checkGarbagesAtEnd(asmr, linePtr))
    14951498        return false;
     
    17221725    // modifiers
    17231726    VOPExtraModifiers extraMods{};
    1724     good &= parseVOPModifiers(asmr, linePtr, modifiers, (isGCN12)?&extraMods:nullptr,
     1727    good &= parseVOPModifiers(asmr, linePtr, arch, modifiers, (isGCN12)?&extraMods:nullptr,
    17251728                  true, (mode1!=GCN_VOP_ARG_NONE) ? 2 : 0);
    17261729    if (!good || !checkGarbagesAtEnd(asmr, linePtr))
     
    18761879    // modifiers
    18771880    VOPExtraModifiers extraMods{};
    1878     good &= parseVOPModifiers(asmr, linePtr, modifiers, (isGCN12)?&extraMods:nullptr, true);
     1881    good &= parseVOPModifiers(asmr, linePtr, arch, modifiers,
     1882                        (isGCN12)?&extraMods:nullptr, true);
    18791883    if (!good || !checkGarbagesAtEnd(asmr, linePtr))
    18801884        return false;
     
    21602164    // modifiers
    21612165    if (mode2 != GCN_VOP3_VINTRP)
    2162         good &= parseVOPModifiers(asmr, linePtr, modifiers, nullptr,
     2166        good &= parseVOPModifiers(asmr, linePtr, arch, modifiers, nullptr,
    21632167                              isGCN12 || gcnInsn.encoding!=GCNENC_VOP3B);
    21642168    if (!good || !checkGarbagesAtEnd(asmr, linePtr))
Note: See TracChangeset for help on using the changeset viewer.