Changeset 4132 in CLRX


Ignore:
Timestamp:
May 10, 2018, 9:27:08 AM (6 months ago)
Author:
matszpk
Message:

CLRadeonExtender: Remove obsolete argument from AsmPseudoOps::doEnum. Add assembler's policy version to control behaviour in later versions.
Make SGPRs counting same for all binary formats when policy version >=200. Update documentation and editor's syntaxes.

Location:
CLRadeonExtender/trunk
Files:
1 added
21 edited

Legend:

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

    r4124 r4132  
    4646namespace CLRX
    4747{
     48
     49enum: cxuint {
     50    ASM_POLICY_DEFAULT = CLRX_MAJOR_VERSION*10000U + CLRX_MINOR_VERSION*100U +
     51                CLRX_MICRO_VERSION,        // version 107
     52    ASM_POLICY_UNIFIED_SGPR_COUNT = 200
     53};
    4854
    4955enum: Flags
     
    471477    bool resolvingRelocs;
    472478    bool doNotRemoveFromSymbolClones;
     479    cxuint policyVersion;
    473480    ISAAssembler* isaAssembler;
    474481    std::vector<DefSym> defSyms;
     
    776783    void setNewROCmBinFormat(bool newFmt)
    777784    { newROCmBinFormat = newFmt; }
     785    /// get policy version
     786    cxuint getPolicyVersion() const
     787    { return policyVersion; }
     788    /// set policy version
     789    void setPolicyVersion(cxuint pv)
     790    { policyVersion = pv; }
    778791    /// get flags
    779792    Flags getFlags() const
  • CLRadeonExtender/trunk/amdasm/AsmAmdCL2Format.cpp

    r3809 r4132  
    18961896            if (config.usedSGPRsNum!=BINGEN_DEFAULT)
    18971897            {
     1898                if (assembler.policyVersion >= ASM_POLICY_UNIFIED_SGPR_COUNT)
     1899                    config.usedSGPRsNum = std::max(extraSGPRsNum, config.usedSGPRsNum) -
     1900                            extraSGPRsNum;
    18981901                // check only if sgprsnum set explicitly
    18991902                if (maxTotalSgprsNum-extraSGPRsNum < config.usedSGPRsNum)
  • CLRadeonExtender/trunk/amdasm/AsmAmdFormat.cpp

    r3830 r4132  
    702702                            asmr.deviceType);
    703703                cxuint maxSGPRsNum = getGPUMaxRegistersNum(arch, REGTYPE_SGPR,
    704                                        REGCOUNT_NO_VCC);
     704                          (asmr.policyVersion<ASM_POLICY_UNIFIED_SGPR_COUNT ?
     705                          REGCOUNT_NO_VCC : 0));
    705706                if (value > maxSGPRsNum)
    706707                {
     
    784785    {
    785786        case AMDCVAL_SGPRSNUM:
    786             config.usedSGPRsNum = value;
     787            if (asmr.policyVersion < ASM_POLICY_UNIFIED_SGPR_COUNT)
     788                config.usedSGPRsNum = value;
     789            else
     790                config.usedSGPRsNum = std::max(value, uint64_t(2))-2;
    787791            break;
    788792        case AMDCVAL_VGPRSNUM:
  • CLRadeonExtender/trunk/amdasm/AsmInternals.h

    r4102 r4132  
    142142    FORMAT,
    143143    GPU,
    144     VERSION
     144    VERSION,
     145    POLICY
    145146};
    146147
     
    317318   
    318319    // enumerate
    319     static void doEnum(Assembler& asmr, const char* pseudoOpPlace, const char* linePtr);
     320    static void doEnum(Assembler& asmr, const char* linePtr);
     321    // set policy version
     322    static void setPolicyVersion(Assembler& asmr, const char* linePtr);
    320323   
    321324    static void ignoreString(Assembler& asmr, const char* linePtr);
  • CLRadeonExtender/trunk/amdasm/AsmPseudoOps.cpp

    r4115 r4132  
    112112    "fail", "file", "fill", "fillq",
    113113    "float", "for", "format", "gallium", "get_64bit", "get_arch",
    114     "get_format", "get_gpu", "get_version", "global",
     114    "get_format", "get_gpu", "get_policy", "get_version", "global",
    115115    "globl", "gpu", "half", "hword", "if", "if32", "if64",
    116116    "ifarch", "ifb", "ifc", "ifdef", "ifeq",
     
    123123    "nobuggyfplit", "nomacrocase", "nooldmodparam", "octa",
    124124    "offset", "oldmodparam", "org",
    125     "p2align", "print", "purgem", "quad",
     125    "p2align", "policy", "print", "purgem", "quad",
    126126    "rawcode", "regvar", "rept", "rocm", "rodata",
    127127    "sbttl", "scope", "section", "set",
     
    155155    ASMOP_FAIL, ASMOP_FILE, ASMOP_FILL, ASMOP_FILLQ,
    156156    ASMOP_FLOAT, ASMOP_FOR, ASMOP_FORMAT, ASMOP_GALLIUM, ASMOP_GET_64BIT, ASMOP_GET_ARCH,
    157     ASMOP_GET_FORMAT, ASMOP_GET_GPU, ASMOP_GET_VERSION, ASMOP_GLOBAL,
     157    ASMOP_GET_FORMAT, ASMOP_GET_GPU, ASMOP_GET_POLICY, ASMOP_GET_VERSION, ASMOP_GLOBAL,
    158158    ASMOP_GLOBL, ASMOP_GPU, ASMOP_HALF, ASMOP_HWORD, ASMOP_IF, ASMOP_IF32, ASMOP_IF64,
    159159    ASMOP_IFARCH, ASMOP_IFB, ASMOP_IFC, ASMOP_IFDEF, ASMOP_IFEQ,
     
    166166    ASMOP_NOBUGGYFPLIT, ASMOP_NOMACROCASE, ASMOP_NOOLDMODPARAM, ASMOP_OCTA,
    167167    ASMOP_OFFSET, ASMOP_OLDMODPARAM, ASMOP_ORG,
    168     ASMOP_P2ALIGN, ASMOP_PRINT, ASMOP_PURGEM, ASMOP_QUAD,
     168    ASMOP_P2ALIGN, ASMOP_POLICY, ASMOP_PRINT, ASMOP_PURGEM, ASMOP_QUAD,
    169169    ASMOP_RAWCODE, ASMOP_REGVAR, ASMOP_REPT, ASMOP_ROCM, ASMOP_RODATA,
    170170    ASMOP_SBTTL, ASMOP_SCOPE, ASMOP_SECTION, ASMOP_SET,
     
    22962296                    CLRX_MICRO_VERSION;
    22972297            break;
     2298        case AsmPredefined::POLICY:
     2299            predefValue = asmr.policyVersion;
     2300            break;
    22982301        default:
    22992302            break;
     
    23022305}
    23032306
    2304 void AsmPseudoOps::doEnum(Assembler& asmr, const char* pseudoOpPlace, const char* linePtr)
     2307void AsmPseudoOps::doEnum(Assembler& asmr, const char* linePtr)
    23052308{
    23062309    const char* end = asmr.line + asmr.lineSize;
     
    23422345    } while(skipCommaForMultipleArgs(asmr, linePtr));
    23432346    checkGarbagesAtEnd(asmr, linePtr);
     2347}
     2348
     2349void AsmPseudoOps::setPolicyVersion(Assembler& asmr, const char* linePtr)
     2350{
     2351    const char* end = asmr.line + asmr.lineSize;
     2352    skipSpacesToEnd(linePtr, end);
     2353    uint64_t value = 0;
     2354    skipSpacesToEnd(linePtr, end);
     2355    const char* valuePlace = linePtr;
     2356    if (!getAbsoluteValueArg(asmr, value, linePtr, true))
     2357        return;
     2358    if (!checkGarbagesAtEnd(asmr, linePtr))
     2359        return;
     2360   
     2361    asmr.printWarningForRange(sizeof(cxuint)*8, value,
     2362                    asmr.getSourcePos(valuePlace), WS_UNSIGNED);
     2363    asmr.setPolicyVersion(value);
    23442364}
    23452365
     
    25712591            break;
    25722592        case ASMOP_ENUM:
    2573             AsmPseudoOps::doEnum(*this, stmtPlace, linePtr);
     2593            AsmPseudoOps::doEnum(*this, linePtr);
    25742594            break;
    25752595        case ASMOP_EQU:
     
    26282648            AsmPseudoOps::getPredefinedValue(*this, linePtr, AsmPredefined::GPU);
    26292649            break;
     2650        case ASMOP_GET_POLICY:
     2651            AsmPseudoOps::getPredefinedValue(*this, linePtr, AsmPredefined::POLICY);
     2652            break;
    26302653        case ASMOP_GET_VERSION:
    26312654            AsmPseudoOps::getPredefinedValue(*this, linePtr, AsmPredefined::VERSION);
     
    27912814        case ASMOP_P2ALIGN:
    27922815            AsmPseudoOps::doAlign(*this, stmtPlace, linePtr, true);
     2816            break;
     2817        case ASMOP_POLICY:
     2818            AsmPseudoOps::setPolicyVersion(*this, linePtr);
    27932819            break;
    27942820        case ASMOP_PRINT:
  • CLRadeonExtender/trunk/amdasm/Assembler.cpp

    r4102 r4132  
    728728          driverVersion(0), llvmVersion(0),
    729729          _64bit(false), newROCmBinFormat(false),
     730          policyVersion(ASM_POLICY_DEFAULT),
    730731          isaAssembler(nullptr),
    731732          // initialize global scope: adds '.' to symbols
     
    766767          driverVersion(0), llvmVersion(0),
    767768          _64bit(false), newROCmBinFormat(false),
     769          policyVersion(ASM_POLICY_DEFAULT),
    768770          isaAssembler(nullptr),
    769771          // initialize global scope: adds '.' to symbols
  • CLRadeonExtender/trunk/clwrapper/CLInternals.cpp

    r3575 r4132  
    15831583    // drivers since 200406 version uses AmdCL2 binary format by default for >=GCN1.1
    15841584    bool useCL2StdForGCN11 = detectAmdDriverVersion() >= 200406;
     1585    bool havePolicy = false;
     1586    cxuint policyVersion = 0;
    15851587   
    15861588    try
     
    16481650                }
    16491651            }
     1652            else if (word == "-policy=")
     1653            {
     1654                const CString policyVersionStr = word.substr(8, word.size()-8);
     1655                const char* str = policyVersionStr.c_str();
     1656                const char* outStr;
     1657                policyVersion = cstrtoui(str, nullptr, outStr);
     1658                havePolicy = true;
     1659            }
    16501660            else if (word == "-x" )
    16511661                nextIsLang = true;
     
    17741784        for (const auto& defSym: defSyms)
    17751785            assembler.addInitialDefSym(defSym.first, defSym.second);
     1786        if (havePolicy)
     1787            assembler.setPolicyVersion(policyVersion);
     1788       
    17761789        /// call main assembler routine
    17771790        bool good = false;
  • CLRadeonExtender/trunk/doc/CMakeLists.txt

    r3836 r4132  
    3232          "${PROJECT_SOURCE_DIR}/doc/ClrxAsmRocm.md"
    3333          "${PROJECT_SOURCE_DIR}/doc/ClrxAsmInvoke.md"
     34          "${PROJECT_SOURCE_DIR}/doc/ClrxAsmPolicy.md"
    3435          "${PROJECT_SOURCE_DIR}/doc/ClrxAsmPseudoOps.md"
    3536          "${PROJECT_SOURCE_DIR}/doc/ClrxAsmSyntax.md"
  • CLRadeonExtender/trunk/doc/ClrxAsmAmd.md

    r3996 r4132  
    3232
    3333To used scalar registers, assembler add 2 additional registers for handling VCC.
    34 The `.sgprsnum` set number of all SGPRs except VCC.
     34The `.sgprsnum` set number of all SGPRs except VCC. Since CLRX policy 0.2 (200)
     35a `.sgprsnum` set number of all SGPRs including VCC.
    3536
    3637## List of the specific pseudo-operations
  • CLRadeonExtender/trunk/doc/ClrxAsmAmdCl2.md

    r3996 r4132  
    6767While using kernel configuration (`.config`) the `.sgprsnum` set number of all SGPRs
    6868except VCC and FLAT_SCRATCH and XNACK_MASK (rule from AMD binary format support).
     69Since CLRX policy 0.2 (200) a `.sgprsnum` set number of all SGPRs including
     70VCC, FLAT_SCRATCH and XNACK_MASK (extra registers) for both old style configuration and
     71HSA configuration.
    6972
    7073## List of the specific pseudo-operations
  • CLRadeonExtender/trunk/doc/ClrxAsmInvoke.md

    r3822 r4132  
    1616[--arch=ARCH] [--driverVersion=VERSION] [--llvmVersion=VERSION] [--newROCmBinFormat]
    1717[--forceAddSymbols] [--noWarnings] [--alternate] [--buggyFPLit] [--oldModParam]
    18 [--noMacroCase] [--help] [--usage] [--version] [file...]
     18[--noMacroCase] [--policy=VERSION] [--help] [--usage] [--version] [file...]
    1919
    2020### Input
     
    106106
    107107    Do not ignore letter's case in macro names (by default is ignored).
    108    
     108
     109* **--policy=VERSION**
     110
     111    Set CLRX policy version.
     112
    109113* **-?**, **--help**
    110114
  • CLRadeonExtender/trunk/doc/ClrxAsmPseudoOps.md

    r4108 r4132  
    439439 27 | gfx905 (Radeon RX VEGA)
    440440
     441### .get_policy
     442
     443Syntax: .get_version SYMBOL
     444
     445Store current CLRX policy version to symbol. Version stored as integer in form:
     446`major_version*10000 + minor_version*100 + micro_version`.
     447
    441448### .get_version
    442449
     
    794801same alignment.
    795802
     803### .policy
     804
     805Syntax: .policy VERSION
     806
     807Set current CLRX assembler's policy version. Version stored as integer in form:
     808`major_version*10000 + minor_version*100 + micro_version`. This number controls
     809behaviour of the same assembler for some things like  SGPRs counting. Refer to
     810[Asssembler policy](ClrxAsmPolicy).
     811
    796812### .print
    797813
  • CLRadeonExtender/trunk/doc/ClrxToc.md

    r3836 r4132  
    2626    * [Invoking assembler](ClrxAsmInvoke)
    2727    * [Assembler syntax](ClrxAsmSyntax)
     28    * [Assembler policy](ClrxAsmPolicy)
    2829    * [Assembler pseudo-operations](ClrxAsmPseudoOps)
    2930    * [AMD Catalyst OpenCL 1.2 handling](ClrxAsmAmd)
  • CLRadeonExtender/trunk/doc/ClrxWrapper.md

    r3401 r4132  
    6868    Force use legacy AMD Catalyst OpenCL 1.2 binary format instead AMD OpemCL 2.0.
    6969
     70* **-policy=VERSION**
     71    Set CLRX assembler policy version.
     72
    7073### Environment variables
    7174
  • CLRadeonExtender/trunk/editors/clrx.vim

    r4105 r4132  
    245245syntax match asmPseudoOps "\.pgmrsrc1"
    246246syntax match asmPseudoOps "\.pgmrsrc2"
     247syntax match asmPseudoOps "\.policy"
    247248syntax match asmPseudoOps "\.print"
    248249syntax match asmPseudoOps "\.printfid"
  • CLRadeonExtender/trunk/editors/gedit.lang

    r4105 r4132  
    286286            <keyword>pgmrsrc1</keyword>
    287287            <keyword>pgmrsrc2</keyword>
     288            <keyword>policy</keyword>
    288289            <keyword>print</keyword>
    289290            <keyword>printfid</keyword>
  • CLRadeonExtender/trunk/editors/kate.xml

    r4105 r4132  
    19941994            <item>.pgmrsrc1</item>
    19951995            <item>.pgmrsrc2</item>
     1996            <item>.policy</item>
    19961997            <item>.print</item>
    19971998            <item>.printfid</item>
  • CLRadeonExtender/trunk/editors/notepad++.xml

    r4105 r4132  
    16141614.pgmrsrc1
    16151615.pgmrsrc2
     1616.policy
    16161617.print
    16171618.printfid
  • CLRadeonExtender/trunk/programs/clrxasm.cpp

    r3803 r4132  
    6262    { "noMacroCase", 'm', CLIArgType::NONE, false, false,
    6363        "do not ignore letter's case in macro names", nullptr },
     64    { "policy", 0, CLIArgType::UINT, false, false,
     65        "set policy version", "VERSION" },
    6466    { "noWarnings", 'w', CLIArgType::NONE, false, false, "disable warnings", nullptr },
    6567    CLRX_CLI_AUTOHELP
     
    9496    Flags flags = 0;
    9597    bool newROCmBinFormat = false;
     98    bool havePolicy = false;
     99    cxuint policyVersion = 0;
    96100    if (cli.hasShortOption('b'))
    97101    {
     
    136140    if (cli.hasLongOption("newROCmBinFormat"))
    137141        newROCmBinFormat = true;
     142    if (cli.hasLongOption("policy"))
     143    {
     144        policyVersion = cli.getLongOptArg<cxuint>("policy");
     145        havePolicy = true;
     146    }
    138147   
    139148    cxuint argsNum = cli.getArgsNum();
     
    151160    assembler->setLLVMVersion(llvmVersion);
    152161    assembler->setNewROCmBinFormat(newROCmBinFormat);
     162    if (havePolicy)
     163        assembler->setPolicyVersion(policyVersion);
    153164   
    154165    size_t defSymsNum = 0;
  • CLRadeonExtender/trunk/programs/clrxasm.pod

    r3822 r4132  
    1212[--arch=ARCH] [--driverVersion=VERSION] [--llvmVersion=VERSION] [--newROCmBinFormat]
    1313[--forceAddSymbols] [--noWarnings] [--alternate] [--buggyFPLit] [--oldModParam]
    14 [--noMacroCase] [--help] [--usage] [--version] [file...]
     14[--noMacroCase] [--policy=VERSION] [--help] [--usage] [--version] [file...]
    1515
    1616=head1 DESCRIPTION
     
    111111Do not ignore letter's case in macro names (by default is ignored).
    112112
     113=item B<--policy=VERSION>
     114
     115Set CLRX policy version.
     116
    113117=item B<-?>, B<--help>
    114118
  • CLRadeonExtender/trunk/tests/amdasm/AsmBasicsCases2.cpp

    r4108 r4132  
    23872387        ""
    23882388    },
     2389    /* 83 - policy version */
     2390    {   R"ffDXD(.amdcl2
     2391            .get_policy POLICY0
     2392            .policy 12
     2393            .get_policy POLICY1
     2394            .policy 1112222233333
     2395)ffDXD",
     2396        BinaryFormat::AMDCL2, GPUDeviceType::CAPE_VERDE, false, { },
     2397        {
     2398            { ".rodata", ASMKERN_GLOBAL, AsmSectionType::DATA, { } }
     2399        },
     2400        {
     2401            { ".", 0U, 0, 0U, true, false, false, 0, 0 },
     2402            { "POLICY0", CLRX_MAJOR_VERSION*10000U + CLRX_MINOR_VERSION*100U +
     2403                    CLRX_MICRO_VERSION, ASMSECT_ABS, 0U, true, false, false, 0, 0 },
     2404            { "POLICY1", 12, ASMSECT_ABS, 0U, true, false, false, 0, 0 }
     2405        }, true,
     2406        "test.s:5:21: Warning: Value 0x102f59c72f5 truncated to 0xf59c72f5\n", ""
     2407    },
    23892408    { nullptr }
    23902409};
Note: See TracChangeset for help on using the changeset viewer.