Changeset 2525 in CLRX


Ignore:
Timestamp:
Nov 3, 2016, 8:36:55 PM (4 years ago)
Author:
matszpk
Message:

CLRadeonExtender: Disasm: Split beforeDisassemble into three parts (second is overridable). Use startOffset in storing label addresses.

Location:
CLRadeonExtender/trunk
Files:
3 edited

Legend:

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

    r2520 r2525  
    109109    /// write relocation to current place in instruction
    110110    bool writeRelocation(size_t pos, RelocIter& relocIter);
     111   
    111112public:
    112113    virtual ~ISADisassembler();
     
    123124    { dontPrintLabelsAfterCode = after; }
    124125   
     126    /// analyze code before disassemblying
     127    virtual void analyzeBeforeDisassemble() = 0;
     128   
     129    /// first part before disassemble - clear numbered labels
     130    void clearNumberedLabels();
     131    /// last part before disassemble - prepare labels (sorting)
     132    void prepareLabelsAndRelocations();
    125133    /// makes some things before disassemblying
    126     virtual void beforeDisassemble() = 0;
     134    void beforeDisassemble();
    127135    /// disassembles input code
    128136    virtual void disassemble() = 0;
     
    166174    ~GCNDisassembler();
    167175   
    168     /// routine called before main disassemblying
    169     void beforeDisassemble();
     176    /// analyze code before disassemblying
     177    void analyzeBeforeDisassemble();
    170178    /// disassemble code
    171179    void disassemble();
  • CLRadeonExtender/trunk/amdasm/Disassembler.cpp

    r2520 r2525  
    246246}
    247247
     248void ISADisassembler::clearNumberedLabels()
     249{
     250    labels.clear();
     251}
     252
     253void ISADisassembler::prepareLabelsAndRelocations()
     254{
     255    std::sort(labels.begin(), labels.end());
     256    const auto newEnd = std::unique(labels.begin(), labels.end());
     257    labels.resize(newEnd-labels.begin());
     258    mapSort(namedLabels.begin(), namedLabels.end());
     259    mapSort(relocations.begin(), relocations.end());
     260}
     261
     262void ISADisassembler::beforeDisassemble()
     263{
     264    clearNumberedLabels();
     265    analyzeBeforeDisassemble();
     266    prepareLabelsAndRelocations();
     267}
     268
    248269Disassembler::Disassembler(const AmdMainGPUBinary32& binary, std::ostream& _output,
    249270            Flags _flags) : fromBinary(true), binaryFormat(BinaryFormat::AMD),
  • CLRadeonExtender/trunk/amdasm/GCNDisasm.cpp

    r2520 r2525  
    267267};
    268268
    269 void GCNDisassembler::beforeDisassemble()
    270 {
    271     labels.clear();
    272    
     269void GCNDisassembler::analyzeBeforeDisassemble()
     270{
    273271    const uint32_t* codeWords = reinterpret_cast<const uint32_t*>(input);
    274272    const size_t codeWordsNum = (inputSize>>2);
     
    307305                            ((isGCN11 || isGCN12) &&
    308306                                    (opcode >= 23 && opcode <= 26))) // if jump
    309                             labels.push_back((pos+int16_t(insnCode&0xffff)+1)<<2);
     307                            labels.push_back(startOffset +
     308                                    ((pos+int16_t(insnCode&0xffff)+1)<<2));
    310309                    }
    311310                    else
     
    314313                        if ((!isGCN12 && opcode == 17) ||
    315314                            (isGCN12 && opcode == 16)) // if branch fork
    316                             labels.push_back((pos+int16_t(insnCode&0xffff)+1)<<2);
     315                            labels.push_back(startOffset +
     316                                    ((pos+int16_t(insnCode&0xffff)+1)<<2));
    317317                        else if ((!isGCN12 && opcode == 21) ||
    318318                            (isGCN12 && opcode == 20))
     
    366366   
    367367    instrOutOfCode = (pos != codeWordsNum);
    368    
    369     std::sort(labels.begin(), labels.end());
    370     const auto newEnd = std::unique(labels.begin(), labels.end());
    371     labels.resize(newEnd-labels.begin());
    372     mapSort(namedLabels.begin(), namedLabels.end());
    373     mapSort(relocations.begin(), relocations.end());
    374368}
    375369
Note: See TracChangeset for help on using the changeset viewer.