Changeset 3788 in CLRX


Ignore:
Timestamp:
Feb 14, 2018, 9:38:02 AM (17 months ago)
Author:
matszpk
Message:

CLRadeonExtender: Asm: Evaluate old expression of symbol if this symbol value replaced by regrange.
Rename createTempSymbolIfNeeded to cloneSymbolIfNeeded.

Location:
CLRadeonExtender/trunk
Files:
3 edited

Legend:

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

    r3787 r3788  
    655655    bool resolveExprTarget(const AsmExpression* expr, uint64_t value, cxuint sectionId);
    656656   
    657     void createTempSymEntryIfNeeded(AsmSymbolEntry& symEntry);
     657    void cloneSymEntryIfNeeded(AsmSymbolEntry& symEntry);
    658658   
    659659    void undefineSymbol(AsmSymbolEntry& symEntry);
  • CLRadeonExtender/trunk/amdasm/Assembler.cpp

    r3787 r3788  
    639639void Assembler::undefineSymbol(AsmSymbolEntry& symEntry)
    640640{
    641     createTempSymEntryIfNeeded(symEntry);
     641    cloneSymEntryIfNeeded(symEntry);
    642642    symEntry.second.undefine();
    643643}
     
    13991399}
    14001400
    1401 void Assembler::createTempSymEntryIfNeeded(AsmSymbolEntry& symEntry)
     1401void Assembler::cloneSymEntryIfNeeded(AsmSymbolEntry& symEntry)
    14021402{
    14031403    if (!symEntry.second.base && !symEntry.second.regRange &&
    14041404        symEntry.second.expression != nullptr && (
     1405        // if symbol have unevaluated expression but we clone symbol only if
     1406        // before section diffs preparation
    14051407        (symEntry.second.withUnevalExpr && !sectionDiffsPrepared) ||
    1406                 symEntry.second.expression->getSymOccursNum()!=0))
     1408        // or expression have unresolved symbols
     1409                symEntry.second.expression->getSymOccursNum()!=0) &&
     1410        !symEntry.second.occurrencesInExprs.empty())
    14071411    {   // create new symbol with this expression
    14081412        std::unique_ptr<AsmSymbolEntry> newSymEntry(new AsmSymbolEntry(symEntry.first,
     
    14261430bool Assembler::setSymbol(AsmSymbolEntry& symEntry, uint64_t value, cxuint sectionId)
    14271431{
    1428     createTempSymEntryIfNeeded(symEntry);
     1432    cloneSymEntryIfNeeded(symEntry);
    14291433    symEntry.second.value = value;
    14301434    symEntry.second.expression = nullptr;
     
    14781482                    {   // try later if can not be evaluated
    14791483                        unevalExpressions.push_back(occurrence.expression);
     1484                        // mark that symbol with this expression have unevaluated
     1485                        // expression and it can be cloned while replacing value
    14801486                        if (target.type==ASMXTGT_SYMBOL)
    14811487                            target.symbol->second.withUnevalExpr = true;
     
    15321538                entry.first = nullptr;
    15331539            }
     1540            // if detached (cloned symbol) while replacing value by unevaluated expression
    15341541            if (entry.first!=nullptr && entry.first->second.detached)
    15351542            {
     
    15751582            return false;
    15761583        }
     1584       
     1585        // create symbol clone before setting value
     1586            cloneSymEntryIfNeeded(*res.first);
     1587       
    15771588        if (!res.first->second.occurrencesInExprs.empty())
    15781589        {
     
    16101621            return false;
    16111622        }
     1623       
    16121624        // setup symbol entry (required)
    16131625        AsmSymbolEntry& symEntry = *res.first;
     
    16941706    if (tryLater) // set expression
    16951707    {
    1696         createTempSymEntryIfNeeded(symEntry);
     1708        cloneSymEntryIfNeeded(symEntry);
    16971709        expr->setTarget(AsmExprTarget::symbolTarget(&symEntry));
    16981710        if (expr->getSymOccursNum() == 0)
    16991711        {
    17001712            unevalExpressions.push_back(expr.get());
     1713            // mark that symbol with this expression have unevaluated
     1714            // expression and it can be cloned while replacing value
     1715            // we set it after cloning previous symbol state
    17011716            symEntry.second.withUnevalExpr = true;
    17021717        }
    1703         else
     1718        else // standard behaviour
    17041719            symEntry.second.withUnevalExpr = false;
    17051720        symEntry.second.expression = expr.release();
  • CLRadeonExtender/trunk/tests/amdasm/AsmBasicsCases1.cpp

    r3787 r3788  
    24562456        true, "", ""
    24572457    },
    2458     /* 66 - evaluate old expressions of symbols (after undef symbol) */
     2458    /* 67 - evaluate old expressions of symbols (after undef symbol) */
    24592459    {
    24602460        R"ffDXD(.int aa0
     
    24792479        true, "", ""
    24802480    },
     2481    /* 68 - evaluate old expressions of symbols (replaced by regrange) */
     2482    {
     2483        R"ffDXD(.int aa0
     2484aa1=aa2
     2485aa0=aa1
     2486aa1=bb2
     2487bb0=aa1
     2488aa1=%v[1:2]
     2489aa2=6
     2490bb2=11)ffDXD",
     2491        BinaryFormat::AMD, GPUDeviceType::CAPE_VERDE, false, { },
     2492        { { nullptr, ASMKERN_GLOBAL, AsmSectionType::DATA,
     2493            { 0x06, 0x00, 0x00, 0x00 } } },
     2494        {
     2495            { ".", 4U, 0, 0U, true, false, false, 0, 0 },
     2496            { "aa0", 6U, ASMSECT_ABS, 0U, true, false, false, 0, 0 },
     2497            { "aa1", 1112396529921U, ASMSECT_ABS, 0U, true, false, false, 0, 0, true },
     2498            { "aa2", 6U, ASMSECT_ABS, 0U, true, false, false, 0, 0 },
     2499            { "bb0", 11U, ASMSECT_ABS, 0U, true, false, false, 0, 0 },
     2500            { "bb2", 11U, ASMSECT_ABS, 0U, true, false, false, 0, 0 }
     2501        },
     2502        true, "", ""
     2503    },
    24812504    { nullptr }
    24822505};
Note: See TracChangeset for help on using the changeset viewer.