Changeset 3668 in CLRX


Ignore:
Timestamp:
Jan 27, 2018, 3:45:22 PM (15 months ago)
Author:
matszpk
Message:

CLRadeonExtender: AsmROCm: Add '.newbinfmt' and '.globaldata' pseudo-ops. ROCmBinGen: small fixes.

Location:
CLRadeonExtender/trunk
Files:
9 edited

Legend:

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

    r3665 r3668  
    510510    cxuint commentSection;
    511511    cxuint metadataSection;
     512    cxuint dataSection;
    512513    cxuint savedSection;
    513514    cxuint extraSectionCount;
  • CLRadeonExtender/trunk/amdasm/AsmROCmFormat.cpp

    r3666 r3668  
    4242    "debugmode", "default_hsa_features", "dims", "dx10clamp",
    4343    "eflags", "exceptions", "fkernel", "floatmode", "gds_segment_size",
    44     "group_segment_align", "ieeemode", "kcode",
     44    "globaldata", "group_segment_align", "ieeemode", "kcode",
    4545    "kcodeend", "kernarg_segment_align",
    4646    "kernarg_segment_size", "kernel_code_entry_offset",
    4747    "kernel_code_prefetch_offset", "kernel_code_prefetch_size",
    4848    "localsize", "machine", "max_scratch_backing_memory",
    49     "metadata", "pgmrsrc1", "pgmrsrc2", "priority",
     49    "metadata", "newbinfmt", "pgmrsrc1", "pgmrsrc2", "priority",
    5050    "private_elem_size", "private_segment_align",
    5151    "privmode", "reserved_sgprs", "reserved_vgprs",
     
    7373    ROCMOP_DEBUGMODE, ROCMOP_DEFAULT_HSA_FEATURES, ROCMOP_DIMS, ROCMOP_DX10CLAMP,
    7474    ROCMOP_EFLAGS, ROCMOP_EXCEPTIONS, ROCMOP_FKERNEL,
    75     ROCMOP_FLOATMODE, ROCMOP_GDS_SEGMENT_SIZE,
     75    ROCMOP_FLOATMODE, ROCMOP_GDS_SEGMENT_SIZE, ROCMOP_GLOBALDATA,
    7676    ROCMOP_GROUP_SEGMENT_ALIGN, ROCMOP_IEEEMODE, ROCMOP_KCODE,
    7777    ROCMOP_KCODEEND, ROCMOP_KERNARG_SEGMENT_ALIGN,
     
    7979    ROCMOP_KERNEL_CODE_PREFETCH_OFFSET, ROCMOP_KERNEL_CODE_PREFETCH_SIZE,
    8080    ROCMOP_LOCALSIZE, ROCMOP_MACHINE, ROCMOP_MAX_SCRATCH_BACKING_MEMORY,
    81     ROCMOP_METADATA, ROCMOP_PGMRSRC1, ROCMOP_PGMRSRC2, ROCMOP_PRIORITY,
     81    ROCMOP_METADATA, ROCMOP_NEWBINFMT, ROCMOP_PGMRSRC1, ROCMOP_PGMRSRC2, ROCMOP_PRIORITY,
    8282    ROCMOP_PRIVATE_ELEM_SIZE, ROCMOP_PRIVATE_SEGMENT_ALIGN,
    8383    ROCMOP_PRIVMODE, ROCMOP_RESERVED_SGPRS, ROCMOP_RESERVED_VGPRS,
     
    102102AsmROCmHandler::AsmROCmHandler(Assembler& assembler): AsmFormatHandler(assembler),
    103103             output{}, codeSection(0), commentSection(ASMSECT_NONE),
    104              metadataSection(ASMSECT_NONE), extraSectionCount(0)
     104             metadataSection(ASMSECT_NONE), dataSection(ASMSECT_NONE), extraSectionCount(0)
    105105{
    106106    output.archMinor = output.archStepping = UINT32_MAX;
     
    144144    Section section;
    145145    section.kernelId = ASMKERN_GLOBAL;  // we ignore input kernelId, we go to main
    146        
    147     if (::strcmp(sectionName, ".text") == 0)
     146   
     147    if (::strcmp(sectionName, ".rodata") == 0)
     148    {
     149         // data (global data/ rodata) section
     150        if (dataSection!=ASMSECT_NONE)
     151            throw AsmFormatException("Only section '.rodata' can be in binary");
     152        dataSection = thisSection;
     153        section.type = AsmSectionType::DATA;
     154        section.elfBinSectId = ELFSECTID_RODATA;
     155        section.name = ".rodata"; // set static name (available by whole lifecycle)
     156    }
     157    else if (::strcmp(sectionName, ".text") == 0)
    148158    {
    149159         // code section
     
    186196cxuint AsmROCmHandler::getSectionId(const char* sectionName) const
    187197{
    188     if (::strcmp(sectionName, ".text") == 0) // code
     198    if (::strcmp(sectionName, ".rodata") == 0) // data
     199        return dataSection;
     200    else if (::strcmp(sectionName, ".text") == 0) // code
    189201        return codeSection;
    190202    else if (::strcmp(sectionName, ".comment") == 0) // comment
     
    419431    asmr.goToSection(pseudoOpPlace, kernel.ctrlDirSection);
    420432    handler.kernelStates[asmr.currentKernel]->initializeKernelConfig();
     433}
     434
     435void AsmROCmPseudoOps::doGlobalData(AsmROCmHandler& handler,
     436                   const char* pseudoOpPlace, const char* linePtr)
     437{
     438    Assembler& asmr = handler.assembler;
     439    if (!checkGarbagesAtEnd(asmr, linePtr))
     440        return;
     441    // go to global data (named in ELF as '.rodata')
     442    asmr.goToSection(pseudoOpPlace, ".rodata");
     443}
     444
     445void AsmROCmPseudoOps::setNewBinFormat(AsmROCmHandler& handler, const char* linePtr)
     446{
     447    Assembler& asmr = handler.assembler;
     448    if (!checkGarbagesAtEnd(asmr, linePtr))
     449        return;
     450    handler.output.newBinFormat = true;
    421451}
    422452
     
    12061236                             ROCMCVAL_FLOATMODE);
    12071237            break;
     1238        case ROCMOP_GLOBALDATA:
     1239            AsmROCmPseudoOps::doGlobalData(*this, stmtPlace, linePtr);
     1240            break;
    12081241        case ROCMOP_GDS_SEGMENT_SIZE:
    12091242            AsmROCmPseudoOps::setConfigValue(*this, stmtPlace, linePtr,
     
    12601293        case ROCMOP_METADATA:
    12611294            AsmROCmPseudoOps::addMetadata(*this, stmtPlace, linePtr);
     1295            break;
     1296        case ROCMOP_NEWBINFMT:
     1297            AsmROCmPseudoOps::setNewBinFormat(*this, linePtr);
    12621298            break;
    12631299        case ROCMOP_PGMRSRC1:
     
    14601496                output.commentSize = sectionSize;
    14611497                output.comment = (const char*)sectionData;
     1498                break;
     1499            case AsmSectionType::DATA:
     1500                output.globalDataSize = sectionSize;
     1501                output.globalData = sectionData;
    14621502                break;
    14631503            case AsmSectionType::ROCM_METADATA:
  • CLRadeonExtender/trunk/amdasm/AsmROCmInternals.h

    r3665 r3668  
    111111    static void doFKernel(AsmROCmHandler& handler, const char* pseudoOpPlace,
    112112                      const char* linePtr);
     113    // .globaldata (go to global data (.rodata))
     114    static void doGlobalData(AsmROCmHandler& handler, const char* pseudoOpPlace,
     115                      const char* linePtr);
     116    // .newbinfmt
     117    static void setNewBinFormat(AsmROCmHandler& handler, const char* linePtr);
    113118   
    114119    // checkConfigValue, setConfigValueMain routines used by other handlers
  • CLRadeonExtender/trunk/amdbin/ROCmBinaries.cpp

    r3667 r3668  
    416416    if (input->newBinFormat)
    417417        // program header for note (new binary format)
    418         elfBinGen64.addProgramHeader({ PT_NOTE, PF_R, 1, 1, true, 0, 0, 0 });
     418        elfBinGen64.addProgramHeader({ PT_NOTE, PF_R, 1, 1, true,
     419                    Elf64Types::nobase, Elf64Types::nobase, 0, 4 });
    419420   
    420421    // elf notes
  • CLRadeonExtender/trunk/doc/ClrxAsmRocm.md

    r3663 r3668  
    129129This pseudo-op must be inside kernel configuration (`.config`). Set
    130130`gds_segment_size` field in kernel configuration.
     131
     132### .globaldata
     133
     134Go to constant global data section (`.rodata`).
    131135
    132136### .group_segment_align
     
    233237This pseudo-op must be inside kernel configuration (`.config`). Set
    234238`max_scratch_backing_memory_byte_size` field in kernel configuration.
     239
     240### .newbinfmt
     241
     242This pseudo-ops set new binary format.
    235243
    236244### .pgmrsrc1
  • CLRadeonExtender/trunk/editors/clrx.vim

    r3664 r3668  
    218218syntax match asmPseudoOps "\.max_scratch_backing_memory"
    219219syntax match asmPseudoOps "\.metadata"
     220syntax match asmPseudoOps "\.newbinfmt"
    220221syntax match asmPseudoOps "\.noaltmacro"
    221222syntax match asmPseudoOps "\.nobuggyfplit"
  • CLRadeonExtender/trunk/editors/gedit.lang

    r3664 r3668  
    258258            <keyword>main</keyword>
    259259            <keyword>max_scratch_backing_memory</keyword>
     260            <keyword>newbinfmt</keyword>
    260261            <keyword>metadata</keyword>
    261262            <keyword>noaltmacro</keyword>
  • CLRadeonExtender/trunk/editors/kate.xml

    r3664 r3668  
    19671967            <item>.max_scratch_backing_memory</item>
    19681968            <item>.metadata</item>
     1969            <item>.newbinfmt</item>
    19691970            <item>.noaltmacro</item>
    19701971            <item>.nobuggyfplit</item>
  • CLRadeonExtender/trunk/editors/notepad++.xml

    r3664 r3668  
    15871587.max_scratch_backing_memory
    15881588.metadata
     1589.newbinfmt
    15891590.noaltmacro
    15901591.nobuggyfplit
Note: See TracChangeset for help on using the changeset viewer.