Changeset 2587 in CLRX


Ignore:
Timestamp:
Nov 21, 2016, 8:08:37 PM (3 years ago)
Author:
matszpk
Message:

CLRadeonExtender: Update AsmROCm.

Location:
CLRadeonExtender/trunk
Files:
2 edited

Legend:

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

    r2584 r2587  
    434434    struct Kernel
    435435    {
    436         cxuint defaultSection;
    437         Flags allocRegFlags;
     436        cxuint configSection;
    438437        std::unique_ptr<ROCmKernelConfig> config;
    439438        cxuint ctrlDirSection;
    440439        cxuint savedSection;
     440        Flags allocRegFlags;
    441441        cxuint allocRegs[2];
     442       
     443        void initializeKernelConfig();
    442444    };
    443445    std::vector<Kernel> kernelStates;
     
    454456    void restoreKcodeCurrentAllocRegs();
    455457    void saveKcodeCurrentAllocRegs();
     458   
     459   
    456460public:
    457461    /// construcror
  • CLRadeonExtender/trunk/amdasm/AsmROCmFormat.cpp

    r2586 r2587  
    111111    /// add kernel config section
    112112    sections.push_back({ thisKernel, AsmSectionType::CONFIG, ELFSECTID_UNDEF, nullptr });
    113     kernelStates.push_back({ thisSection, 0, nullptr, ASMSECT_NONE, thisSection });
     113    kernelStates.push_back({ thisSection, nullptr, ASMSECT_NONE, thisSection });
    114114   
    115115    if (assembler.currentKernel == ASMKERN_GLOBAL)
     
    125125    const cxuint thisSection = sections.size();
    126126    Section section;
    127     if (::strcmp(sectionName, ".control_directive") == 0)
    128     {
    129         if (kernelId == ASMKERN_GLOBAL)
    130             throw AsmFormatException(".control_directive section must be "
    131                         "defined inside kernel");
    132         if (kernelStates[kernelId].ctrlDirSection != ASMSECT_NONE)
    133             throw AsmFormatException("Only one section "
    134                         "'.control_directive' can be in kernel");
    135         kernelStates[kernelId].ctrlDirSection = thisSection;
    136         section.type = AsmSectionType::ROCM_CONFIG_CTRL_DIRECTIVE;
    137         section.elfBinSectId = ELFSECTID_TEXT; // . in text
    138         section.name = ".control_directive";
    139     }
    140     else // otherwise
    141         section.kernelId = ASMKERN_GLOBAL;  // we ignore input kernelId, we go to main
     127    section.kernelId = ASMKERN_GLOBAL;  // we ignore input kernelId, we go to main
    142128       
    143129    if (::strcmp(sectionName, ".text") == 0) // code
     
    183169    else if (::strcmp(sectionName, ".comment") == 0) // comment
    184170        return commentSection;
    185     else if (assembler.currentKernel != ASMKERN_GLOBAL &&
    186         ::strcmp(sectionName, ".control_directive") == 0) // code
    187         return kernelStates[assembler.currentKernel].ctrlDirSection;
    188171    else
    189172    {
     
    283266}
    284267
     268void AsmROCmHandler::Kernel::initializeKernelConfig()
     269{
     270    config.reset(new ROCmKernelConfig{});
     271    ::memset(config.get(), 0, sizeof(ROCmKernelConfig));
     272}
     273
    285274namespace CLRX
    286275{
     
    315304    if (!checkGarbagesAtEnd(asmr, linePtr))
    316305        return;
     306    handler.kernelStates[asmr.currentKernel].initializeKernelConfig();
    317307}
    318308
     
    320310              const char* pseudoOpPlace, const char* linePtr)
    321311{
     312    Assembler& asmr = handler.assembler;
     313    const char* end = asmr.line + asmr.lineSize;
     314    if (asmr.currentKernel==ASMKERN_GLOBAL)
     315    {
     316        asmr.printError(pseudoOpPlace, "Kernel control directive can be defined "
     317                    "only inside kernel");
     318        return;
     319    }
     320    skipSpacesToEnd(linePtr, end);
     321    if (!checkGarbagesAtEnd(asmr, linePtr))
     322        return;
     323   
     324    AsmROCmHandler::Kernel& kernel = handler.kernelStates[asmr.currentKernel];
     325    if (kernel.ctrlDirSection == ASMSECT_NONE)
     326    {
     327        cxuint thisSection = handler.sections.size();
     328        handler.sections.push_back({ asmr.currentKernel,
     329            AsmSectionType::ROCM_CONFIG_CTRL_DIRECTIVE,
     330            ELFSECTID_UNDEF, nullptr });
     331        kernel.ctrlDirSection = thisSection;
     332    }
     333    asmr.goToSection(pseudoOpPlace, kernel.ctrlDirSection);
     334    handler.kernelStates[asmr.currentKernel].initializeKernelConfig();
    322335}
    323336
Note: See TracChangeset for help on using the changeset viewer.