Changeset 3564 in CLRX


Ignore:
Timestamp:
Dec 25, 2017, 4:32:15 PM (6 months ago)
Author:
matszpk
Message:

CLRadeonExtender: Asm: Add AsmParseUtils::setSymbolValue (helper for '.get_XXX' pseudo-ops).

Location:
CLRadeonExtender/trunk/amdasm
Files:
6 edited

Legend:

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

    r3562 r3564  
    484484void AsmAmdCL2PseudoOps::getDriverVersion(AsmAmdCL2Handler& handler, const char* linePtr)
    485485{
    486     Assembler& asmr = handler.assembler;
    487     const char* end = asmr.line + asmr.lineSize;
    488     skipSpacesToEnd(linePtr, end);
    489    
    490     const char* symNamePlace = linePtr;
    491     const CString symName = extractScopedSymName(linePtr, end, false);
    492     if (symName.empty())
    493         ASM_RETURN_BY_ERROR(symNamePlace, "Illegal symbol name")
    494     size_t symNameLength = symName.size();
    495     // special case for '.' symbol (check whether is in global scope)
    496     if (symNameLength >= 3 && symName.compare(symNameLength-3, 3, "::.")==0)
    497         ASM_RETURN_BY_ERROR(symNamePlace, "Symbol '.' can be only in global scope")
    498     if (!checkGarbagesAtEnd(asmr, linePtr))
    499         return;
    500    
    501     cxuint driverVersion = handler.getDriverVersion();
    502     std::pair<AsmSymbolEntry*, bool> res = asmr.insertSymbolInScope(symName,
    503                 AsmSymbol(ASMSECT_ABS, driverVersion));
    504     if (!res.second)
    505     {
    506         // if symbol found
    507         if (res.first->second.onceDefined && res.first->second.isDefined()) // if label
    508             asmr.printError(symNamePlace, (std::string("Symbol '")+symName.c_str()+
    509                         "' is already defined").c_str());
    510         else // set value of symbol
    511             asmr.setSymbol(*res.first, driverVersion, ASMSECT_ABS);
    512     }
     486    AsmParseUtils::setSymbolValue(handler.assembler, linePtr,
     487                    handler.getDriverVersion(), ASMSECT_ABS);
    513488}
    514489
  • CLRadeonExtender/trunk/amdasm/AsmAmdFormat.cpp

    r3427 r3564  
    339339void AsmAmdPseudoOps::getDriverVersion(AsmAmdHandler& handler, const char* linePtr)
    340340{
    341     Assembler& asmr = handler.assembler;
    342     const char* end = asmr.line + asmr.lineSize;
    343     skipSpacesToEnd(linePtr, end);
    344    
    345     const char* symNamePlace = linePtr;
    346     const CString symName = extractScopedSymName(linePtr, end, false);
    347     if (symName.empty())
    348         ASM_RETURN_BY_ERROR(symNamePlace, "Illegal symbol name")
    349     // special case for '.' symbol (check whether is in global scope)
    350     size_t symNameLength = symName.size();
    351     if (symNameLength >= 3 && symName.compare(symNameLength-3, 3, "::.")==0)
    352         ASM_RETURN_BY_ERROR(symNamePlace, "Symbol '.' can be only in global scope")
    353     if (!checkGarbagesAtEnd(asmr, linePtr))
    354         return;
    355    
    356     cxuint driverVersion = 0;
    357     driverVersion = handler.determineDriverVersion();
    358    
    359     std::pair<AsmSymbolEntry*, bool> res = asmr.insertSymbolInScope(symName,
    360                 AsmSymbol(ASMSECT_ABS, driverVersion));
    361     if (!res.second)
    362     {
    363         // if symbol found
    364         if (res.first->second.onceDefined && res.first->second.isDefined()) // if label
    365             asmr.printError(symNamePlace, (std::string("Symbol '")+symName.c_str()+
    366                         "' is already defined").c_str());
    367         else
    368             asmr.setSymbol(*res.first, driverVersion, ASMSECT_ABS);
    369     }
     341    AsmParseUtils::setSymbolValue(handler.assembler, linePtr,
     342                handler.determineDriverVersion(), ASMSECT_ABS);
    370343}
    371344
  • CLRadeonExtender/trunk/amdasm/AsmGalliumFormat.cpp

    r3562 r3564  
    450450            bool getLLVMVersion)
    451451{
    452     Assembler& asmr = handler.assembler;
    453     const char* end = asmr.line + asmr.lineSize;
    454     skipSpacesToEnd(linePtr, end);
    455    
    456     const char* symNamePlace = linePtr;
    457     const CString symName = extractScopedSymName(linePtr, end, false);
    458     if (symName.empty())
    459         ASM_RETURN_BY_ERROR(symNamePlace, "Illegal symbol name")
    460     size_t symNameLength = symName.size();
    461     // special case for '.' symbol (check whether is in global scope)
    462     if (symNameLength >= 3 && symName.compare(symNameLength-3, 3, "::.")==0)
    463         ASM_RETURN_BY_ERROR(symNamePlace, "Symbol '.' can be only in global scope")
    464     if (!checkGarbagesAtEnd(asmr, linePtr))
    465         return;
    466    
    467452    cxuint driverVersion = 0;
    468453    if (getLLVMVersion)
     
    471456        driverVersion = handler.determineDriverVersion();
    472457   
    473     std::pair<AsmSymbolEntry*, bool> res = asmr.insertSymbolInScope(symName,
    474                 AsmSymbol(ASMSECT_ABS, driverVersion));
    475     if (!res.second)
    476     {
    477         // if symbol found,
    478         if (res.first->second.onceDefined && res.first->second.isDefined()) // if label
    479             asmr.printError(symNamePlace, (std::string("Symbol '")+symName.c_str()+
    480                         "' is already defined").c_str());
    481         else
    482             asmr.setSymbol(*res.first, driverVersion, ASMSECT_ABS);
    483     }
     458    AsmParseUtils::setSymbolValue(handler.assembler, linePtr, driverVersion, ASMSECT_ABS);
    484459}
    485460
     
    12991274{
    13001275    Assembler& asmr = handler.assembler;
    1301     const char* end = asmr.line + asmr.lineSize;
    1302     skipSpacesToEnd(linePtr, end);
    1303    
    1304     const char* symNamePlace = linePtr;
    1305     const CString symName = extractScopedSymName(linePtr, end, false);
    1306     if (symName.empty())
    1307         ASM_RETURN_BY_ERROR(symNamePlace, "Illegal symbol name")
    1308     size_t symNameLength = symName.size();
    1309     // special case for '.' symbol (check whether is in global scope)
    1310     if (symNameLength >= 3 && symName.compare(symNameLength-3, 3, "::.")==0)
    1311         ASM_RETURN_BY_ERROR(symNamePlace, "Symbol '.' can be only in global scope")
    1312     if (!checkGarbagesAtEnd(asmr, linePtr))
    1313         return;
    1314    
    13151276    if (handler.scratchSection == ASMSECT_NONE)
    13161277    {
     
    13241285    }
    13251286   
    1326     std::pair<AsmSymbolEntry*, bool> res = asmr.insertSymbolInScope(symName,
    1327                 AsmSymbol(handler.scratchSection, 0));
    1328     if (!res.second)
    1329     {
    1330         // if symbol found,
    1331         if (res.first->second.onceDefined && res.first->second.isDefined()) // if label
    1332             asmr.printError(symNamePlace, (std::string("Symbol '")+symName.c_str()+
    1333                         "' is already defined").c_str());
    1334         else
    1335             asmr.setSymbol(*res.first, 0, handler.scratchSection);
    1336     }
    1337     else
    1338         res.first->second.hasValue = false; // make
     1287    AsmParseUtils::setSymbolValue(asmr, linePtr, 0, handler.scratchSection);
    13391288}
    13401289
  • CLRadeonExtender/trunk/amdasm/AsmInternals.h

    r3452 r3564  
    129129   
    130130    static bool parseDimensions(Assembler& asmr, const char*& linePtr, cxuint& dimMask);
     131   
     132    static void setSymbolValue(Assembler& asmr, const char* linePtr,
     133                    uint64_t value, cxuint sectionId);
    131134};
    132135
  • CLRadeonExtender/trunk/amdasm/AsmPseudoOps.cpp

    r3452 r3564  
    21512151                            AsmPredefined predefined)
    21522152{
    2153     const char* end = asmr.line + asmr.lineSize;
    2154     skipSpacesToEnd(linePtr, end);
    2155    
    2156     const char* symNamePlace = linePtr;
    2157     const CString symName = extractScopedSymName(linePtr, end, false);
    2158     if (symName.empty())
    2159         ASM_RETURN_BY_ERROR(symNamePlace, "Illegal symbol name")
    2160     size_t symNameLength = symName.size();
    2161     if (symNameLength >= 3 && symName.compare(symNameLength-3, 3, "::.")==0)
    2162         ASM_RETURN_BY_ERROR(symNamePlace, "Symbol '.' can be only in global scope")
    2163     if (!checkGarbagesAtEnd(asmr, linePtr))
    2164         return;
    2165    
    21662153    cxuint predefValue = 0;
    21672154    // we must initialize output format before getting any arch, gpu or format
     
    21892176            break;
    21902177    }
    2191     std::pair<AsmSymbolEntry*, bool> res = asmr.insertSymbolInScope(symName,
    2192                 AsmSymbol(ASMSECT_ABS, predefValue));
    2193     if (!res.second)
    2194     {
    2195         // if symbol found
    2196         if (res.first->second.onceDefined && res.first->second.isDefined()) // if label
    2197             asmr.printError(symNamePlace, (std::string("Symbol '")+symName.c_str()+
    2198                         "' is already defined").c_str());
    2199         else
    2200             asmr.setSymbol(*res.first, predefValue, ASMSECT_ABS);
    2201     }
     2178    AsmParseUtils::setSymbolValue(asmr, linePtr, predefValue, ASMSECT_ABS);
    22022179}
    22032180
  • CLRadeonExtender/trunk/amdasm/Assembler.cpp

    r3457 r3564  
    522522        return false;
    523523    return true;
     524}
     525
     526void AsmParseUtils::setSymbolValue(Assembler& asmr, const char* linePtr,
     527                    uint64_t value, cxuint sectionId)
     528{
     529    const char* end = asmr.line + asmr.lineSize;
     530    skipSpacesToEnd(linePtr, end);
     531   
     532    const char* symNamePlace = linePtr;
     533    const CString symName = extractScopedSymName(linePtr, end, false);
     534    if (symName.empty())
     535        ASM_RETURN_BY_ERROR(symNamePlace, "Illegal symbol name")
     536    size_t symNameLength = symName.size();
     537    // special case for '.' symbol (check whether is in global scope)
     538    if (symNameLength >= 3 && symName.compare(symNameLength-3, 3, "::.")==0)
     539        ASM_RETURN_BY_ERROR(symNamePlace, "Symbol '.' can be only in global scope")
     540    if (!checkGarbagesAtEnd(asmr, linePtr))
     541        return;
     542   
     543    std::pair<AsmSymbolEntry*, bool> res = asmr.insertSymbolInScope(symName,
     544                AsmSymbol(sectionId, value));
     545    if (!res.second)
     546    {
     547        // if symbol found
     548        if (res.first->second.onceDefined && res.first->second.isDefined()) // if label
     549            asmr.printError(symNamePlace, (std::string("Symbol '")+symName.c_str()+
     550                        "' is already defined").c_str());
     551        else // set value of symbol
     552            asmr.setSymbol(*res.first, value, sectionId);
     553    }
     554    else // set hasValue (by isResolvableSection
     555        res.first->second.hasValue = asmr.isResolvableSection(sectionId);
    524556}
    525557
Note: See TracChangeset for help on using the changeset viewer.