Changeset 2581 in CLRX


Ignore:
Timestamp:
Nov 21, 2016, 7:06:37 AM (3 years ago)
Author:
matszpk
Message:

CLRadeonExtender: Add ROCm format handler's first code.

Location:
CLRadeonExtender/trunk
Files:
1 added
3 edited

Legend:

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

    r2212 r2581  
    3535#include <CLRX/amdbin/AmdBinGen.h>
    3636#include <CLRX/amdbin/AmdCL2BinGen.h>
     37#include <CLRX/amdbin/ROCmBinaries.h>
    3738#include <CLRX/utils/Utilities.h>
    3839#include <CLRX/amdasm/Commons.h>
     
    6263   
    6364    GALLIUM_COMMENT = LAST_COMMON+1,    ///< gallium comment section
     65   
     66    ROCM_COMMENT = LAST_COMMON+1,        ///< ROCm comment section
     67   
    6468    EXTRA_FIRST = 0xfc,
    6569    EXTRA_PROGBITS = 0xfc,
     
    413417};
    414418
     419/// handles ROCM binary format
     420class AsmROCmHandler: public AsmFormatHandler
     421{
     422private:
     423    typedef std::unordered_map<CString, cxuint> SectionMap;
     424    friend struct AsmROCmPseudoOps;
     425    ROCmInput output;
     426    struct Section
     427    {
     428        cxuint kernelId;
     429        AsmSectionType type;
     430        cxuint elfBinSectId;
     431        const char* name;    // must be available by whole lifecycle
     432    };
     433    struct Kernel
     434    {
     435        cxuint defaultSection;
     436        cxuint allocRegs[2];
     437        Flags allocRegFlags;
     438    };
     439    std::vector<Kernel> kernelStates;
     440    std::vector<Section> sections;
     441    std::vector<cxuint> kcodeSelection; // kcode
     442    std::stack<std::vector<cxuint> > kcodeSelStack;
     443    cxuint currentKcodeKernel;
     444    SectionMap extraSectionMap;
     445    cxuint codeSection;
     446    cxuint commentSection;
     447    cxuint savedSection;
     448    cxuint extraSectionCount;
     449   
     450    void restoreKcodeCurrentAllocRegs();
     451    void saveKcodeCurrentAllocRegs();
     452public:
     453    /// construcror
     454    explicit AsmROCmHandler(Assembler& assembler);
     455    /// destructor
     456    ~AsmROCmHandler() = default;
     457   
     458    cxuint addKernel(const char* kernelName);
     459    cxuint addSection(const char* sectionName, cxuint kernelId);
     460   
     461    cxuint getSectionId(const char* sectionName) const;
     462    void setCurrentKernel(cxuint kernel);
     463    void setCurrentSection(cxuint sectionId);
     464   
     465    SectionInfo getSectionInfo(cxuint sectionId) const;
     466    bool parsePseudoOp(const CString& firstName,
     467           const char* stmtPlace, const char* linePtr);
     468    void handleLabel(const CString& label);
     469   
     470    bool prepareBinary();
     471    void writeBinary(std::ostream& os) const;
     472    void writeBinary(Array<cxbyte>& array) const;
     473    /// get output object (input for bingenerator)
     474    const ROCmInput* getOutput() const
     475    { return &output; }
     476};
     477
    415478};
    416479
  • CLRadeonExtender/trunk/amdasm/Assembler.cpp

    r2490 r2581  
    17971797        case BinaryFormat::GALLIUM:
    17981798            formatHandler = new AsmGalliumHandler(*this);
     1799            break;
     1800        case BinaryFormat::ROCM:
     1801            //formatHandler = new AsmROCmHandler(*this);
    17991802            break;
    18001803        default:
  • CLRadeonExtender/trunk/amdasm/CMakeLists.txt

    r2511 r2581  
    2727        AsmGalliumFormat.cpp
    2828        AsmPseudoOps.cpp
     29        AsmROCmFormat.cpp
    2930        AsmSource.cpp
    3031        Assembler.cpp
Note: See TracChangeset for help on using the changeset viewer.