Changeset 3770 in CLRX


Ignore:
Timestamp:
Feb 12, 2018, 4:38:21 PM (14 months ago)
Author:
matszpk
Message:

CLRadeonExtender: AsmExpr?: Calculate address (value) while comparing values (in section diffs mode).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • CLRadeonExtender/trunk/amdasm/AsmExpression.cpp

    r3769 r3770  
    149149static bool checkRelativesEquality(Assembler& assembler,
    150150            std::vector<RelMultiply>& relatives,
    151             const Array<RelMultiply>& relatives2, bool checkRelSpaces)
    152 {
     151            const Array<RelMultiply>& relatives2, bool checkRelSpaces,
     152            uint64_t& fixAddr1, uint64_t& fixAddr2)
     153{
     154    fixAddr1 = 0;
     155    fixAddr2 = 0;
    153156    // if no check relspaces or if no real rel spaces in relatives
    154157    bool equal = true;
     
    181184    std::vector<RelMultiply> relSpaces2(relatives2.size());
    182185    const std::vector<AsmSection>& sections = assembler.getSections();
     186    const std::vector<Array<cxuint> >& relSpacesSects = assembler.getRelSpacesSections();
    183187   
    184188    // convert sections to relspaces
    185189    for (size_t i = 0; i < relSpaces1.size(); i++)
    186190        if (sections[relatives[i].sectionId].relSpace != UINT_MAX)
     191        {
     192            cxuint osectId = relatives[i].sectionId;
    187193            relSpaces1[i] = { relatives[i].multiply,
    188                     sections[relatives[i].sectionId].relSpace };
     194                    sections[osectId].relSpace };
     195            cxuint rsectId = relSpacesSects[sections[osectId].relSpace][0];
     196            fixAddr1 = relatives[i].multiply*(sections[osectId].relAddress -
     197                    sections[rsectId].relAddress);
     198        }
    189199        else // treat as separate relSpace
    190200            relSpaces1[i] = { relatives[i].multiply,
     
    193203    for (size_t i = 0; i < relSpaces2.size(); i++)
    194204        if (sections[relatives2[i].sectionId].relSpace != UINT_MAX)
    195             relSpaces2[i] = { relatives2[i].multiply,
    196                     sections[relatives2[i].sectionId].relSpace };
     205        {
     206            cxuint osectId = relatives2[i].sectionId;
     207            relSpaces1[i] = { relatives2[i].multiply,
     208                    sections[osectId].relSpace };
     209            cxuint rsectId = relSpacesSects[sections[osectId].relSpace][0];
     210            fixAddr1 = relatives2[i].multiply*(sections[osectId].relAddress -
     211                    sections[rsectId].relAddress);
     212        }
    197213        else // treat as separate relSpace
    198214            relSpaces2[i] = { relatives2[i].multiply,
     
    739755                    case AsmExprOp::ABOVE_EQ:
    740756                    {
     757                        uint64_t fixAddr1 = 0, fixAddr2 = 0;
    741758                        if (!checkRelativesEquality(assembler, relatives, relatives2,
    742                                     withSectionDiffs && !sectDiffsPrepared))
     759                                    withSectionDiffs && !sectDiffsPrepared,
     760                                    fixAddr1, fixAddr2))
    743761                            ASMX_FAILED_BY_ERROR(sourcePos, "For comparisons "
    744762                                        "two values must have this same relatives!")
     
    747765                            tryLater = true; // must be evaluated later
    748766                        relatives.clear();
     767                        value += fixAddr1;
     768                        value2 += fixAddr2;
    749769                        switch(op)
    750770                        {
Note: See TracChangeset for help on using the changeset viewer.