Changeset 3291 in CLRX


Ignore:
Timestamp:
Sep 2, 2017, 4:47:18 PM (10 months ago)
Author:
matszpk
Message:

CLRadeonExtender: AsmGallium?/ROCm: Reuse code to parsing machine, code version and reserved gprs.

Location:
CLRadeonExtender/trunk/amdasm
Files:
3 edited

Legend:

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

    r3286 r3291  
    10391039{
    10401040    Assembler& asmr = handler.assembler;
    1041     const char* end = asmr.line + asmr.lineSize;
    10421041    if (asmr.currentKernel==ASMKERN_GLOBAL ||
    10431042        asmr.sections[asmr.currentSection].type != AsmSectionType::CONFIG)
     
    10521051    }
    10531052   
    1054     skipSpacesToEnd(linePtr, end);
    1055     uint64_t kindValue = BINGEN_NOTSUPPLIED;
    1056     uint64_t majorValue = BINGEN_NOTSUPPLIED;
    1057     uint64_t minorValue = BINGEN_NOTSUPPLIED;
    1058     uint64_t steppingValue = BINGEN_NOTSUPPLIED;
    1059     const char* valuePlace = linePtr;
    1060     bool good = getAbsoluteValueArg(asmr, kindValue, linePtr, true);
    1061     asmr.printWarningForRange(16, kindValue, asmr.getSourcePos(valuePlace), WS_UNSIGNED);
    1062     if (!skipRequiredComma(asmr, linePtr))
    1063         return;
    1064    
    1065     valuePlace = linePtr;
    1066     good &= getAbsoluteValueArg(asmr, majorValue, linePtr, true);
    1067     asmr.printWarningForRange(16, majorValue, asmr.getSourcePos(valuePlace), WS_UNSIGNED);
    1068     if (!skipRequiredComma(asmr, linePtr))
    1069         return;
    1070    
    1071     valuePlace = linePtr;
    1072     good &= getAbsoluteValueArg(asmr, minorValue, linePtr, true);
    1073     asmr.printWarningForRange(16, minorValue, asmr.getSourcePos(valuePlace), WS_UNSIGNED);
    1074     if (!skipRequiredComma(asmr, linePtr))
    1075         return;
    1076    
    1077     valuePlace = linePtr;
    1078     good &= getAbsoluteValueArg(asmr, steppingValue, linePtr, true);
    1079     asmr.printWarningForRange(16, steppingValue,
    1080                       asmr.getSourcePos(valuePlace), WS_UNSIGNED);
    1081    
    1082     if (!good || !checkGarbagesAtEnd(asmr, linePtr))
     1053    uint16_t kindValue = 0, majorValue = 0;
     1054    uint16_t minorValue = 0, steppingValue = 0;
     1055    if (!AsmROCmPseudoOps::parseMachine(asmr, linePtr, kindValue,
     1056                    majorValue, minorValue, steppingValue))
    10831057        return;
    10841058   
     
    10951069{
    10961070    Assembler& asmr = handler.assembler;
    1097     const char* end = asmr.line + asmr.lineSize;
    10981071    if (asmr.currentKernel==ASMKERN_GLOBAL ||
    10991072        asmr.sections[asmr.currentSection].type != AsmSectionType::CONFIG)
     
    11081081    }
    11091082   
    1110     skipSpacesToEnd(linePtr, end);
    1111     uint64_t majorValue = BINGEN_NOTSUPPLIED;
    1112     uint64_t minorValue = BINGEN_NOTSUPPLIED;
    1113     const char* valuePlace = linePtr;
    1114     bool good = getAbsoluteValueArg(asmr, majorValue, linePtr, true);
    1115     asmr.printWarningForRange(32, majorValue, asmr.getSourcePos(valuePlace), WS_UNSIGNED);
    1116     if (!skipRequiredComma(asmr, linePtr))
    1117         return;
    1118    
    1119     valuePlace = linePtr;
    1120     good &= getAbsoluteValueArg(asmr, minorValue, linePtr, true);
    1121     asmr.printWarningForRange(32, minorValue, asmr.getSourcePos(valuePlace), WS_UNSIGNED);
    1122    
    1123     if (!good || !checkGarbagesAtEnd(asmr, linePtr))
     1083    uint16_t majorValue = 0, minorValue = 0;
     1084    if (!AsmROCmPseudoOps::parseCodeVersion(asmr, linePtr, majorValue, minorValue))
    11241085        return;
    11251086   
     
    11341095{
    11351096    Assembler& asmr = handler.assembler;
    1136     const char* end = asmr.line + asmr.lineSize;
    11371097    if (asmr.currentKernel==ASMKERN_GLOBAL ||
    11381098        asmr.sections[asmr.currentSection].type != AsmSectionType::CONFIG)
     
    11471107    }
    11481108   
    1149     skipSpacesToEnd(linePtr, end);
    1150     const GPUArchitecture arch = getGPUArchitectureFromDeviceType(asmr.deviceType);
    1151     cxuint maxGPRsNum = getGPUMaxRegistersNum(arch,
    1152                        inVgpr ? REGTYPE_VGPR : REGTYPE_SGPR, 0);
    1153    
    1154     uint64_t firstReg = BINGEN_NOTSUPPLIED;
    1155     uint64_t lastReg = BINGEN_NOTSUPPLIED;
    1156     const char* valuePlace = linePtr;
    1157     bool haveFirstReg;
    1158     bool good = getAbsoluteValueArg(asmr, firstReg, linePtr, true);
    1159     haveFirstReg = good;
    1160     if (haveFirstReg && firstReg > maxGPRsNum-1)
    1161     {
    1162         char buf[64];
    1163         snprintf(buf, 64, "First reserved %s register out of range (0-%u)",
    1164                  inVgpr ? "VGPR" : "SGPR",  maxGPRsNum-1);
    1165         asmr.printError(valuePlace, buf);
    1166         good = false;
    1167     }
    1168     if (!skipRequiredComma(asmr, linePtr))
    1169         return;
    1170    
    1171     valuePlace = linePtr;
    1172     bool haveLastReg = getAbsoluteValueArg(asmr, lastReg, linePtr, true);
    1173     good &= haveLastReg;
    1174     if (haveLastReg && lastReg > maxGPRsNum-1)
    1175     {
    1176         char buf[64];
    1177         snprintf(buf, 64, "Last reserved %s register out of range (0-%u)",
    1178                  inVgpr ? "VGPR" : "SGPR", maxGPRsNum-1);
    1179         asmr.printError(valuePlace, buf);
    1180         good = false;
    1181     }
    1182     if (haveFirstReg && haveLastReg && firstReg > lastReg)
    1183     {
    1184         asmr.printError(valuePlace, "Wrong regsister range");
    1185         good = false;
    1186     }
    1187        
    1188    
    1189     if (!good || !checkGarbagesAtEnd(asmr, linePtr))
     1109    uint16_t gprFirst = 0, gprCount = 0;
     1110    if (!AsmROCmPseudoOps::parseReservedXgprs(asmr, linePtr, inVgpr, gprFirst, gprCount))
    11901111        return;
    11911112   
     
    11941115    if (inVgpr)
    11951116    {
    1196         config->reservedVgprFirst = firstReg;
    1197         config->reservedVgprCount = lastReg-firstReg+1;
     1117        config->reservedVgprFirst = gprFirst;
     1118        config->reservedVgprCount = gprCount;
    11981119    }
    11991120    else
    12001121    {
    1201         config->reservedSgprFirst = firstReg;
    1202         config->reservedSgprCount = lastReg-firstReg+1;
     1122        config->reservedSgprFirst = gprFirst;
     1123        config->reservedSgprCount = gprCount;
    12031124    }
    12041125}
  • CLRadeonExtender/trunk/amdasm/AsmInternals.h

    r3285 r3291  
    677677                      const char* linePtr);
    678678   
     679    static bool parseMachine(Assembler& asmr, const char* linePtr,
     680                uint16_t& machineKind, uint16_t& machineMajor, uint16_t& machineMinor,
     681                uint16_t& machineStepping);
     682   
    679683    static void setMachine(AsmROCmHandler& handler, const char* pseudoOpPlace,
    680684                      const char* linePtr);
    681685   
     686    static bool parseCodeVersion(Assembler& asmr, const char* linePtr,
     687                uint16_t& codeMajor, uint16_t& codeMinor);
     688   
    682689    static void setCodeVersion(AsmROCmHandler& handler, const char* pseudoOpPlace,
    683690                      const char* linePtr);
     691   
     692    static bool parseReservedXgprs(Assembler& asmr, const char* linePtr, bool inVgpr,
     693                uint16_t& gprFirst, uint16_t& gprCount);
    684694   
    685695    static void setReservedXgprs(AsmROCmHandler& handler, const char* pseudoOpPlace,
  • CLRadeonExtender/trunk/amdasm/AsmROCmFormat.cpp

    r3276 r3291  
    769769}
    770770
    771 void AsmROCmPseudoOps::setMachine(AsmROCmHandler& handler, const char* pseudoOpPlace,
    772                       const char* linePtr)
    773 {
    774     Assembler& asmr = handler.assembler;
     771bool AsmROCmPseudoOps::parseMachine(Assembler& asmr, const char* linePtr,
     772        uint16_t& machineKind, uint16_t& machineMajor, uint16_t& machineMinor,
     773        uint16_t& machineStepping)
     774{
    775775    const char* end = asmr.line + asmr.lineSize;
    776     if (asmr.currentKernel==ASMKERN_GLOBAL ||
    777         asmr.sections[asmr.currentSection].type != AsmSectionType::CONFIG)
    778     {
    779         asmr.printError(pseudoOpPlace, "Illegal place of configuration pseudo-op");
    780         return;
    781     }
    782776   
    783777    skipSpacesToEnd(linePtr, end);
     
    790784    asmr.printWarningForRange(16, kindValue, asmr.getSourcePos(valuePlace), WS_UNSIGNED);
    791785    if (!skipRequiredComma(asmr, linePtr))
    792         return;
     786        return false;
    793787   
    794788    valuePlace = linePtr;
     
    796790    asmr.printWarningForRange(16, majorValue, asmr.getSourcePos(valuePlace), WS_UNSIGNED);
    797791    if (!skipRequiredComma(asmr, linePtr))
    798         return;
     792        return false;
    799793   
    800794    valuePlace = linePtr;
     
    802796    asmr.printWarningForRange(16, minorValue, asmr.getSourcePos(valuePlace), WS_UNSIGNED);
    803797    if (!skipRequiredComma(asmr, linePtr))
    804         return;
     798        return false;
    805799   
    806800    valuePlace = linePtr;
     
    810804   
    811805    if (!good || !checkGarbagesAtEnd(asmr, linePtr))
     806        return false;
     807   
     808    machineKind = kindValue;
     809    machineMajor = majorValue;
     810    machineMinor = minorValue;
     811    machineStepping = steppingValue;
     812    return true;
     813}
     814
     815void AsmROCmPseudoOps::setMachine(AsmROCmHandler& handler, const char* pseudoOpPlace,
     816                      const char* linePtr)
     817{
     818    Assembler& asmr = handler.assembler;
     819    if (asmr.currentKernel==ASMKERN_GLOBAL ||
     820        asmr.sections[asmr.currentSection].type != AsmSectionType::CONFIG)
     821    {
     822        asmr.printError(pseudoOpPlace, "Illegal place of configuration pseudo-op");
     823        return;
     824    }
     825   
     826    uint16_t kindValue = 0, majorValue = 0;
     827    uint16_t minorValue = 0, steppingValue = 0;
     828    if (!parseMachine(asmr, linePtr, kindValue, majorValue, minorValue, steppingValue))
    812829        return;
    813830   
     
    820837}
    821838
    822 void AsmROCmPseudoOps::setCodeVersion(AsmROCmHandler& handler, const char* pseudoOpPlace,
    823                   const char* linePtr)
    824 {
    825     Assembler& asmr = handler.assembler;
     839bool AsmROCmPseudoOps::parseCodeVersion(Assembler& asmr, const char* linePtr,
     840                uint16_t& codeMajor, uint16_t& codeMinor)
     841{
    826842    const char* end = asmr.line + asmr.lineSize;
    827     if (asmr.currentKernel==ASMKERN_GLOBAL ||
    828         asmr.sections[asmr.currentSection].type != AsmSectionType::CONFIG)
    829     {
    830         asmr.printError(pseudoOpPlace, "Illegal place of configuration pseudo-op");
    831         return;
    832     }
    833843   
    834844    skipSpacesToEnd(linePtr, end);
     
    839849    asmr.printWarningForRange(32, majorValue, asmr.getSourcePos(valuePlace), WS_UNSIGNED);
    840850    if (!skipRequiredComma(asmr, linePtr))
    841         return;
     851        return false;
    842852   
    843853    valuePlace = linePtr;
     
    846856   
    847857    if (!good || !checkGarbagesAtEnd(asmr, linePtr))
     858        return false;
     859   
     860    codeMajor = majorValue;
     861    codeMinor = minorValue;
     862    return true;
     863}
     864
     865void AsmROCmPseudoOps::setCodeVersion(AsmROCmHandler& handler, const char* pseudoOpPlace,
     866                  const char* linePtr)
     867{
     868    Assembler& asmr = handler.assembler;
     869    if (asmr.currentKernel==ASMKERN_GLOBAL ||
     870        asmr.sections[asmr.currentSection].type != AsmSectionType::CONFIG)
     871    {
     872        asmr.printError(pseudoOpPlace, "Illegal place of configuration pseudo-op");
     873        return;
     874    }
     875   
     876    uint16_t majorValue = 0, minorValue = 0;
     877    if (!parseCodeVersion(asmr, linePtr, majorValue, minorValue))
    848878        return;
    849879   
     
    854884}
    855885
    856 void AsmROCmPseudoOps::setReservedXgprs(AsmROCmHandler& handler, const char* pseudoOpPlace,
    857                       const char* linePtr, bool inVgpr)
    858 {
    859     Assembler& asmr = handler.assembler;
     886bool AsmROCmPseudoOps::parseReservedXgprs(Assembler& asmr, const char* linePtr,
     887                bool inVgpr, uint16_t& gprFirst, uint16_t& gprCount)
     888{
    860889    const char* end = asmr.line + asmr.lineSize;
    861     if (asmr.currentKernel==ASMKERN_GLOBAL ||
    862         asmr.sections[asmr.currentSection].type != AsmSectionType::CONFIG)
    863     {
    864         asmr.printError(pseudoOpPlace, "Illegal place of configuration pseudo-op");
    865         return;
    866     }
    867    
    868890    skipSpacesToEnd(linePtr, end);
    869891    const GPUArchitecture arch = getGPUArchitectureFromDeviceType(asmr.deviceType);
     
    886908    }
    887909    if (!skipRequiredComma(asmr, linePtr))
    888         return;
     910        return false;
    889911   
    890912    valuePlace = linePtr;
     
    904926        good = false;
    905927    }
    906        
    907928   
    908929    if (!good || !checkGarbagesAtEnd(asmr, linePtr))
     930        return false;
     931   
     932    gprFirst = firstReg;
     933    gprCount = lastReg-firstReg+1;
     934    return true;
     935}
     936
     937void AsmROCmPseudoOps::setReservedXgprs(AsmROCmHandler& handler, const char* pseudoOpPlace,
     938                      const char* linePtr, bool inVgpr)
     939{
     940    Assembler& asmr = handler.assembler;
     941    if (asmr.currentKernel==ASMKERN_GLOBAL ||
     942        asmr.sections[asmr.currentSection].type != AsmSectionType::CONFIG)
     943    {
     944        asmr.printError(pseudoOpPlace, "Illegal place of configuration pseudo-op");
     945        return;
     946    }
     947   
     948    uint16_t gprFirst = 0, gprCount = 0;
     949    if (!parseReservedXgprs(asmr, linePtr, inVgpr, gprFirst, gprCount))
    909950        return;
    910951   
     
    913954    if (inVgpr)
    914955    {
    915         config->reservedVgprFirst = firstReg;
    916         config->reservedVgprCount = lastReg-firstReg+1;
     956        config->reservedVgprFirst = gprFirst;
     957        config->reservedVgprCount = gprCount;
    917958    }
    918959    else
    919960    {
    920         config->reservedSgprFirst = firstReg;
    921         config->reservedSgprCount = lastReg-firstReg+1;
     961        config->reservedSgprFirst = gprFirst;
     962        config->reservedSgprCount = gprCount;
    922963    }
    923964}
Note: See TracChangeset for help on using the changeset viewer.