37#include <boost/format.hpp> 
  123    binary_(&aBinary), machine_(&aMachine),
 
  126    adfInstrASpace_(NULL),
 
  127    tpefInstrASpace_(NULL) {
 
 
  139    binary_(&aBinary), machine_(&aMachine),
 
  142    adfInstrASpace_(NULL),
 
  143    tpefInstrASpace_(NULL) {
 
 
  155    binary_(&aBinary), machine_(NULL),
 
  158    adfInstrASpace_(NULL),
 
  159    tpefInstrASpace_(NULL) {
 
 
  182    const Section* chunkOwner)
 const {
 
 
  206            "No code sections in TPEF.");
 
  225                    "Tried to load a sequential program with ADF already " 
  238        if (aSpaceNav.
hasItem(aSpaceName )) {
 
  245                    "No instruction(gcu) address space in ADF.");
 
  256            "Tried to load a parallel TPEF without ADF.");
 
  292        Terminal &addressTerm = move->source();
 
  301                referencedInstruction);
 
  306        move->setSource(instrTerm);
 
  323                referencedInstruction);
 
  328        immediate->setValue(instrTerm);
 
 
  349     std::list<CodeSection*> sectionsToChop;
 
  357         if (sectionsToChop.empty()) {
 
  358             sectionsToChop.push_back(sectionToAdd);
 
  362         std::list<CodeSection*>::iterator iter = sectionsToChop.begin();
 
  364         while (iter != sectionsToChop.end()) {
 
  366             if ((*iter)->startingAddress() >
 
  368                 sectionsToChop.insert(iter, sectionToAdd);
 
  380     std::list<CodeSection*>::iterator sectionIterator =
 
  381         sectionsToChop.begin();
 
  383     while (sectionIterator != sectionsToChop.end()) {
 
  388         assert(resources != NULL);
 
  391         int currentInstructionNumber = 0;
 
  392         while (i < section->elementCount()) {
 
  402                 assert(instructionElement != NULL);
 
  405                     program.procedureCount() == 0) {
 
  415                     program.addProcedure(newProcedure);
 
  430                     if (instructionElement->
begin()) {
 
  431                         beginElement = instructionElement;
 
  434                     if (instructionElement->
isMove()) {
 
  435                         moveElements.push_back(
 
  447                             immElements[immKey] = imm;
 
  449                             longImmediates.push_back(imm);
 
  461                     assert(sectionElement != NULL);
 
  466                     assert(i < section->elementCount());
 
  468                 } 
while (instructionElement->
begin() == 
false);
 
  472                                       longImmediates, immElements);
 
  476                 assert(beginElement != NULL);
 
  480                 assert(currentInstruction != NULL);
 
  482                 program.addInstruction(currentInstruction);
 
  483                 currentInstructionNumber++;
 
  490                         "Instruction %d: ") % currentInstructionNumber).
 
 
  518    std::vector<SocketAllocation> allocatedSockets;
 
  523    for (
unsigned int i = 0; i < moveElements.size(); i++) {
 
  528            std::shared_ptr<TTAProgram::Move> newMove;
 
  571                    if (guardRegister != NULL) {
 
  572                        delete guardRegister;
 
  573                        guardRegister = NULL;
 
  577                if (source != NULL) {
 
  582                if (destination != NULL) {
 
  587                delete newInstruction;
 
  588                newInstruction = NULL;
 
  596                newMove = std::make_shared<TTAProgram::Move>(source, destination, bus, guard);
 
  598                newMove = std::make_shared<TTAProgram::Move>(source, destination, bus);
 
  609            for (
int i = 0; i < socketNav.
count(); i++) {
 
  613                    for (
int j = 0; j < currSocket->
portCount(); j++) {
 
  615                        if ((source->
isGPR() ||
 
  621                            newAlloc.
srcSocks.push_back(currSocket);
 
  624                        if ((destination->
isGPR() ||
 
  630                            newAlloc.
dstSocks.push_back(currSocket);
 
  636            allocatedSockets.push_back(newAlloc);
 
  640                for (Word annotationIndex = 0; 
 
  643                    newMove->addAnnotation(
 
  651            newInstruction->
addMove(newMove);
 
  653            if (newMove->source().isAddress() &&
 
  662                for (Word annotationIndex = 0;
 
  683    for (
unsigned int i = 0; i < longImmediates.size(); i++) {
 
  703        bool isInstructionReference = 
false;
 
  714                isInstructionReference = 
true;
 
  727        auto newImmediate = std::make_shared<Immediate>(immTerm, destination);
 
  731        if (isInstructionReference) {
 
  737    return newInstruction;
 
 
  762    HalfWord index, 
const ImmediateMap* immediateMap)
 const {
 
  778    CacheKey cacheKey(*aBus, direction, type, unitId, index);
 
  782    if (returnValue == NULL) {
 
  792                    *immediateMap, immKey);
 
  795                    << 
"Cannot find immediate with unitId/index " 
  796                    << 
static_cast<int>(unitId) << 
"/" << index << std::endl
 
  797                    << 
"immediateMap.size(): " << immediateMap->size()
 
  830                                    "Unable to find address space for " 
  831                                    "target of reloc element for immediate " 
  832                                    "'%d'.") % imm->
word()).
 
  844                assert(returnValue != NULL);
 
  847                    for (Word annotationIndex = 0; 
 
  860                               "should be already handled in same place " 
  861                               "with normal register references.");
 
  889                               "special register with index:" +
 
  894            assert(tpefResource != NULL);
 
  896            std::string tpefOpStr =
 
  909            bool opCodePort = 
false;
 
  910            std::string::size_type opNameLength = tpefOpStr.rfind(
'.');
 
  911            std::string tpefOpName = tpefOpStr;
 
  914            if (opNameLength != std::string::npos) {
 
  915                tpefOpName = tpefOpStr.substr(0, opNameLength);
 
  916                std::string::size_type opIndexStart = opNameLength + 1;
 
  917                std::string tpefOpIndexStr =
 
  919                        opIndexStart, tpefOpStr.length() - opIndexStart);
 
  937                    findPort(*aBus, functionUnit, tpefOpName));
 
  955        return returnValue->
copy();
 
 
  974    HalfWord busId)
 const {
 
  980                "TPEF needs universal machine for universal bus reference.");
 
  989                "TPEF needs real machine for non-universal bus reference.");
 
  998        std::string busName =
 
 1004                "ADF does not contain bus: " + busName);
 
 
 1023    HalfWord rfId)
 const {
 
 1034                "TPEF needs universal machine for universal integer RF " 
 1044                "TPEF needs universal machine for universal boolean RF " 
 1054                "TPEF needs universal machine for universal floating point " 
 1065                "TPEF needs real machine for non-universal RF reference.");
 
 1071        std::string rfName =
 
 1077                "Can't  find RF \"" + rfName + 
"\" from ADF.");
 
 
 1101    Byte immUnitId)
 const {
 
 1106            "TPEF needs real machine for immediate unit reference.");
 
 1112    std::string immUnitName =
 
 1118            "Can't  find immediate unit \"" + immUnitName + 
"\" from ADF.");
 
 
 1146    std::string tpefOpName)
 const {
 
 1155                "TPEF needs universal machine for getting universal FU.");
 
 1176            boost::format errMsg(
 
 1177                "Unknown operation '%1%'. Operation definition not found.");
 
 1179                __FILE__, __LINE__, 
__func__, (errMsg % tpefOpName).str());
 
 1187                "TPEF needs real target architecture for getting a " 
 1188                "non-universal FU.");
 
 1194        std::string fuName =
 
 1209                    "Can't  find RFU \"" + fuName + 
"\" from ADF.");
 
 
 1239    const Unit& portParent,
 
 1240    std::string tpefOpName,
 
 1241    int tpefOpIndex)
 const {
 
 1243    const Machine* machineOfBus = NULL;
 
 1252    assert(machineOfBus != NULL);
 
 1272                    "GCU needs return address port.");
 
 1280            if (fu->
hasOperation(tpefOpName) && tpefOpIndex != 0) {
 
 1283                return *(oper->
port(tpefOpIndex));
 
 1285            } 
else if (fu->
hasPort(tpefOpName)) {
 
 1289                        fu->
port(tpefOpName));
 
 1291                if (srPort != NULL) {
 
 1298                    return *fu->
port(tpefOpName);
 
 1303                    __FILE__, __LINE__, 
__func__, 
"Can't find port for: " +
 
 1304                    fu->
name() + 
"." + tpefOpName + 
"." +
 
 1313    std::string throwError = 
"Can't find port for: " + portParent.
name();
 
 1315    if (tpefOpName != 
"") {
 
 1316        throwError += 
"." + tpefOpName;
 
 
 1341        if (aSpaceNavi.
hasItem(aSpaceName)) {
 
 1342            return *aSpaceNavi.
item(aSpaceName);
 
 1349        } 
else if (aSpaceName == 
 
 1358        "Can't find address space by name: " + aSpaceName +
 
 
 1376    HalfWord unitId, HalfWord index, 
bool isInverted)
 const {
 
 1379    Port* guardPort = NULL;
 
 1410                           "special register with index:" +
 
 1416        std::string tpefOpStr =
 
 1420        if (guardUnit.
hasPort(tpefOpStr)) {
 
 1421            guardPort = guardUnit.
port(tpefOpStr);
 
 1424            std::string::size_type dotPos = tpefOpStr.find(
'.');
 
 1425            assert (dotPos != std::string::npos);
 
 1426            std::string operationName = tpefOpStr.substr(0, dotPos);
 
 1429                tpefOpStr.substr(dotPos+1, tpefOpStr.length() - dotPos - 1));
 
 1431            guardPort = oper->
port(operandIndex);
 
 1441            "Error: Unknown guard type. Guard must be either FU port " 
 1445    assert (
reinterpret_cast<long int>(guardPort) != 
 
 1446            reinterpret_cast<long int>(guardRF));
 
 1456            if (portGuard != NULL && guardPort != NULL) {
 
 1457                if (portGuard->
port() == guardPort) {
 
 1461            } 
else if (registerGuard != NULL && guardRF != NULL) {
 
 1470    std::string guardType;
 
 1477    if (guardRF != NULL) {
 
 1481    if (guardPort != NULL) {
 
 1482        guardType += 
"Some FU operation or special register.";
 
 1487        "Can't find suitable guard: " + guardType + 
"\tfrom bus: " +
 
 1490    return *bus.
guard(0);
 
 
 1514    std::map<ImmediateUnit*, int> bitsToWrite;
 
 1516    for (
unsigned int i = 0; i < longImmediates.size(); i++) {
 
 1526                "Can't write two immediates to the same immediate unit " 
 1527                " in the same instruction.");
 
 1543    for (
int i = 0; i < tempNav.
count(); i++) {
 
 1549            static_cast<int>(bitsToWrite.size())) {
 
 1551            bool templateIsGood = 
true;
 
 1554            for (std::map<ImmediateUnit*, int>::iterator iter =
 
 1555                     bitsToWrite.begin();
 
 1556                 iter != bitsToWrite.end();
 
 1562                    templateIsGood = 
false;
 
 1568            if (templateIsGood) {
 
 1569                for (
unsigned int j = 0; j < moves.size(); j++) {
 
 1581                        templateIsGood = 
false;
 
 1588            if (templateIsGood) {
 
 1589                if (bestiTempFound == NULL)
 
 1590                    bestiTempFound = insTemp;
 
 1595    if (bestiTempFound == NULL) {
 
 1596        std::string bitRequirementmsg;
 
 1597        for (
const auto& pair : bitsToWrite) {
 
 1599                + 
" bits to IU: " + pair.first->
name() + 
"\n";
 
 1602            "Valid instruction template is not found for instruction layout:\n" 
 1603            + 
"An instruction template is needed that can write:\n" 
 1604            + bitRequirementmsg);
 
 1606        return *bestiTempFound;
 
 
 1626    std::map<
Socket*, std::vector<SocketAllocation*> >& fixedSockets)
 const {
 
 1632        std::vector<SocketAllocation*>& socketAllocs = fixedSockets[currentSocket];
 
 1635        for (
unsigned int i = 0; i < socketAllocs.size(); i++) {
 
 1637            auto oldMove = socketAllocs[i]->move;
 
 1638            Terminal* oldTerminal = &(oldMove->source());
 
 1641            if (alloc.
move->source().index() != oldTerminal->
index() &&
 
 1642                (alloc.
move->isUnconditional() || oldMove->isUnconditional() ||
 
 1643                 !alloc.
move->guard().guard().isOpposite(oldMove->guard().guard()))) {
 
 
 1669    std::map<
Socket*, std::vector<SocketAllocation*> >& fixedSockets)
 const {
 
 1675        std::vector<SocketAllocation*>& socketAllocs = fixedSockets[currentSocket];
 
 1678        for (
unsigned int i = 0; i < socketAllocs.size(); i++) {
 
 1680            auto oldMove = socketAllocs[i]->move;
 
 1681            if (alloc.
move->isUnconditional() || oldMove->isUnconditional() ||
 
 1682                !alloc.
move->guard().guard().isOpposite(
 
 1683                    oldMove->guard().guard())) {
 
 
 1712    std::vector<SocketAllocation>& allocs)
 const {
 
 1715    std::map<Socket*, std::vector<SocketAllocation*> > fixedSockets;
 
 1718    unsigned currIndex = 0;
 
 1720    while (currIndex < allocs.size()) {
 
 1721        bool allocationWasSuccess = 
true;
 
 1737                    allocationWasSuccess = 
false;
 
 1742            allocationWasSuccess = 
false;
 
 1749        if (allocationWasSuccess) {
 
 1752            fixedSockets[currentSocket].push_back(&alloc);
 
 1759            unsigned int prevIndex = currIndex;
 
 1762                if (prevIndex == 0) {
 
 1765                        "Can't resolve src sockets for instruction.");
 
 1770            } 
while (allocs[prevIndex].srcSocks.empty());
 
 1774                allocs[prevIndex].srcSocks[allocs[prevIndex].src];
 
 1775            std::vector<SocketAllocation*>& freedAllocs =
 
 1776                fixedSockets[socketToFree];
 
 1778            bool prevFound = 
false;
 
 1780            for (
int k = prevIndex; k >= 0 && !prevFound; k--) {
 
 1781                for (std::vector<SocketAllocation*>::iterator j =
 
 1782                         freedAllocs.begin(); j != freedAllocs.end(); j++) {
 
 1784                    if (
static_cast<int>((*j)->index) == k) {
 
 1788                        freedAllocs.erase(j);
 
 1801    fixedSockets.clear();
 
 1804    while (currIndex < allocs.size()) {
 
 1805        bool allocationWasSuccess = 
true;
 
 1821                    allocationWasSuccess = 
false;
 
 1826            allocationWasSuccess = 
false;
 
 1833        if (allocationWasSuccess) {
 
 1836            fixedSockets[currentSocket].push_back(&alloc);
 
 1843            unsigned int prevIndex = currIndex;
 
 1846                if (prevIndex == 0) {
 
 1849                        "Can't resolve dst sockets for instruction.");
 
 1854            } 
while (allocs[prevIndex].dstSocks.empty());
 
 1858                allocs[prevIndex].dstSocks[allocs[prevIndex].dst];
 
 1859            std::vector<SocketAllocation*>& freedAllocs =
 
 1860                fixedSockets[socketToFree];
 
 1863            for (
unsigned int j = 0; j < freedAllocs.size(); j++) {
 
 1864                if (freedAllocs[j]->index < currIndex) {
 
 1865                    currIndex = freedAllocs[j]->index;
 
 1871            for (
unsigned int j = 0; j < freedAllocs.size(); j++) {
 
 1872                if (freedAllocs[j]->index != currIndex) {
 
 1873                    freedAllocs[j]->dst = 0;
 
 1875                    freedAllocs[j]->dst++;
 
 1879            fixedSockets.erase(socketToFree);
 
 1887    for (
unsigned i = 0; i < allocs.size(); i++) {
 
 1891        std::cerr << 
"next allocation source: "  
 1892                  << alloc.
move->source().isGPR()
 
 1894                  << alloc.
move->destination().isGPR() << std::endl;
 
 1899            Unit* parent = alloc.
move->source().port().parentUnit();
 
 1901            for (
int j = 0; j < srcSocket->
portCount(); j++) {
 
 1903                    alloc.
move->setSource(
 
 1905                            *srcSocket->
port(j),
 
 1906                            alloc.
move->source().index()));
 
 1908                    std::cerr << 
"source was replaced" << std::endl;
 
 1917            Unit* parent = alloc.
move->destination().port().parentUnit();
 
 1919            for (
int j = 0; j < dstSocket->
portCount(); j++) {
 
 1921                    alloc.
move->setDestination(
 
 1923                            *dstSocket->
port(j),
 
 1924                            alloc.
move->destination().index()));
 
 1926                    std::cerr << 
"dst was replaced" << std::endl;
 
 1933        if (alloc.
move->source().isGPR() &&
 
 1934            alloc.
move->destination().isGPR()) {
 
 1935            std::cerr << 
"next allocation source: " 
 1936                      << alloc.
move->source().port().name()
 
 1938                      << alloc.
move->destination().port().name() << std::endl;
 
 
 1972    cache_[key] = cachedTerm;
 
 
 2008            if (procedSymbol == NULL) {
 
 2018            assert(referencedInstruction != NULL);
 
 
 2038    std::map<string, std::pair<DataLabel*, bool> > dataLabels;
 
 2045        assert(currSect != NULL);
 
 2062                const std::string labelString = 
 
 2068                assert(dataSection != NULL);
 
 2078                            "Unable to find address space for target " 
 2079                            "of data label '%s'") % labelString).str());
 
 2108                        if (dataLabels[labelString].second) {
 
 2111                            for (std::map<
string, 
 
 2113                                     bool> >::iterator iter = 
 
 2115                                 iter != dataLabels.end(); iter++) {
 
 2116                                delete (*iter).second.first;
 
 2122                                "Found two global symbols with same name: " + 
 
 2126                        delete dataLabels[labelString].first;
 
 2127                        dataLabels[labelString].first = dataLabel;
 
 2128                        dataLabels[labelString].second = 
true;
 
 2132                    dataLabels[labelString].first = dataLabel;
 
 2133                    dataLabels[labelString].second = 
 
 2162    for (std::map<
string, std::pair<DataLabel*, bool> >::iterator iter =  
 
 2164         iter != dataLabels.end(); iter++) {
 
 
 2179    std::map<AddressSpace*, std::vector<UDataSection*> > memories;    
 
 2191            std::vector<UDataSection*>& secVec = memories[&aSpace];
 
 2195            for (
int j = 0; j < static_cast<int>(secVec.size()); j++) {
 
 2196                if (secVec[j]->startingAddress() > 
 
 2199                    secVec[j] = uDataSect;                    
 
 2204            secVec.push_back(uDataSect);
 
 2209    for (std::map<
AddressSpace*, std::vector<UDataSection*> >::iterator iter =
 
 2211         iter != memories.
end(); iter++) {
 
 2214        std::vector<UDataSection*>& secVec = (*iter).second;
 
 2218        for (
int i = 0; i < static_cast<int>(secVec.size()); i++) {
 
 2240                     j < static_cast<int>(
 
 2255                if (relocs != NULL) {
 
 2277                        Address startAddr(sourceAddress, aSpace);
 
 2280                        int mauSize = currElem->
size() / aSpace.
width(); 
 
 2292                            assert(tpefInstr != NULL);
 
 2301                                    startAddr, mauSize, instrRef,
 
 2313                            assert(dstChunk != NULL);
 
 2317                            std::vector<UDataSection*>& dstSecs = 
 
 2318                                memories[&dstSpace];
 
 2321                                 k < static_cast<int>(dstSecs.size()); k++) {
 
 2341                                    startAddr, mauSize, dstAddr,
 
 2356                std::vector<std::pair <int, int> > dataAreas;                
 
 2357                dataAreas.push_back(wholeSection);
 
 2364                    int prevIndex = dataAreas.
size()-1;
 
 2365                    std::pair<int, int>& lastArea = dataAreas[prevIndex];
 
 2372                        lastArea.first + lastArea.second) {
 
 2374                        int lastAreaStart = lastArea.first;
 
 2381                        int newAreaEnd = lastArea.first + lastArea.second;
 
 2384                        std::pair<int, int> newArea(
 
 2385                            newAreaStart, newAreaEnd - newAreaStart);
 
 2388                        lastArea.second = lastAreaEnd - lastAreaStart;
 
 2390                        if (lastArea.second == 0) {
 
 2391                            dataAreas.pop_back();
 
 2394                        if (newArea.second != 0) {
 
 2395                            dataAreas.push_back(newArea);
 
 2401                assert(dataSect != NULL);
 
 2404                for (
unsigned int k = 0; k < dataAreas.size(); k++) {
 
 2406                    std::pair<int, int>& currArea = dataAreas[k];
 
 2407                    std::vector<MinimumAddressableUnit> initData;
 
 2414                    assert(mauIndex + currArea.second <= 
 
 2417                    bool allZeros = 
true;
 
 2418                    for (
int l = 0; l < currArea.second; l++) {
 
 2419                        if(dataSect->
MAU(mauIndex + l) != 0) {
 
 2428                            Address(currArea.first, aSpace),
 
 2433                        for (
int l = 0; l < currArea.second; l++) {
 
 2434                            initData.push_back(dataSect->
MAU(mauIndex++));
 
 2438                            Address(currArea.first, aSpace),
 
 
 2477        return "unknownFunctionName";
 
 
#define abortWithError(message)
 
#define assert(condition)
 
UInt32 InstructionAddress
 
#define THROW_EXCEPTION(exceptionType, message)
Exception wrapper macro that automatically includes file name, line number and function name where th...
 
find Finds info of the inner loops in the program
 
static void abortProgram() __attribute__((noreturn))
 
static std::ostream & logStream()
 
static std::string toString(const T &source)
 
static int toInt(const T &source)
 
std::string errorMessage() const
 
void setCause(const Exception &cause)
 
@ FT_OBJSEQ
Sequential TTA object code.
 
@ FT_PARALLEL
Fully scheduled or mixed code.
 
@ FT_LIBSEQ
Collection of sequential object code files for linkage.
 
@ FT_PURESEQ
Sequential TTA code, no unresolved symbols.
 
Word sectionCount() const
 
Section * section(Word index) const
 
SectionOffset offset() const
 
virtual InstructionElement * element(Word index) const
 
InstructionElement * reference() const
 
virtual MinimumAddressableUnit MAU(Word index) const
 
Chunk * reference() const
 
const std::vector< Byte > & payload() const
 
Word annotationCount() const
 
InstructionAnnotation * annotation(Word index) const
 
FieldType destinationType() const
 
HalfWord destinationIndex() const
 
HalfWord destinationUnit() const
 
HalfWord guardUnit() const
 
HalfWord sourceUnit() const
 
FieldType guardType() const
 
HalfWord guardIndex() const
 
bool isGuardInverted() const
 
HalfWord sourceIndex() const
 
FieldType sourceType() const
 
virtual Word bytesToMAUs(Word byteCount) const
 
virtual Word chunkToMAUIndex(const Chunk *chunk) const
 
virtual Word lengthInMAUs() const
 
bool belongsToSection(const Chunk *chunk) const
 
SectionElement * destination() const
 
ASpaceElement * aSpace() const
 
SectionElement * location() const
 
Section * referencedSection() const
 
static const std::string RETURN_ADDRESS_NAME
Reserved string of return address special register.
 
@ MRT_SR
Special register.
 
@ MRT_PORT
Function unit port.
 
@ MRT_OP
Operation operand or function unit register.
 
@ UNIVERSAL_BUS
Universal bus.
 
@ UNIVERSAL_FU
Universal function unit.
 
@ INT_RF
Universal integer register file.
 
@ ILLEGAL_RF
Illegal register file.
 
@ BOOL_RF
Universal boolean register file.
 
@ FP_RF
Universal floating point register file.
 
@ INLINE_IMM
Inline immediate unit id.
 
ResourceElement & findResource(ResourceElement::ResourceType aType, HalfWord anId) const
 
bool hasResource(ResourceElement::ResourceType aType, HalfWord anId) const
 
AddressImage startingAddress() const
 
@ ST_DATA
Initialized data section.
 
@ ST_ADDRSP
Address space section.
 
@ ST_UDATA
Uninitialized data section.
 
@ ST_LEDATA
Initialized little endian data section.
 
@ ST_RELOC
Relocation section.
 
SectionElement * element(Word index) const
 
Word elementCount() const
 
virtual SectionType type() const =0
Returns SectioType of actual section instance.
 
ASpaceElement * aSpace() const
 
std::string chunk2String(const Chunk *chunk) const
 
@ STT_CODE
Associated with executable code.
 
@ STT_DATA
Associated with data object.
 
virtual SymbolType type() const =0
Returns type of symbol.
 
Section * section() const
 
SymbolBinding binding() const
 
@ STB_GLOBAL
Visible to all files that are combined in TPEF file.
 
virtual SectionType type() const
 
virtual ULongWord end() const
 
virtual int width() const
 
virtual RFPort * port(const std::string &name) const
 
int immediateWidth() const
 
Guard * guard(int index) const
 
virtual Machine * machine() const
 
virtual TCEString name() const
 
SpecialRegisterPort * returnAddressPort() const
 
bool hasReturnAddressPort() const
 
virtual HWOperation * operation(const std::string &name) const
 
virtual bool hasOperation(const std::string &name) const
 
virtual BaseFUPort * port(const std::string &name) const
 
virtual bool isInverted() const
 
virtual FUPort * port(int operand) const
 
virtual bool usesSlot(const std::string &slotName) const
 
virtual bool isOneOfDestinations(const ImmediateUnit &dstUnit) const
 
virtual int supportedWidth() const
 
virtual int numberOfDestinations() const
 
ComponentType * item(int index) const
 
bool hasItem(const std::string &name) const
 
virtual RegisterFileNavigator registerFileNavigator() const
 
virtual FunctionUnitNavigator functionUnitNavigator() const
 
virtual InstructionTemplateNavigator instructionTemplateNavigator() const
 
bool isLittleEndian() const
 
virtual SocketNavigator socketNavigator() const
 
virtual ImmediateUnitNavigator immediateUnitNavigator() const
 
virtual BusNavigator busNavigator() const
 
virtual AddressSpaceNavigator addressSpaceNavigator() const
 
virtual ControlUnit * controlUnit() const
 
static NullInstructionTemplate & instance()
 
Unit * parentUnit() const
 
int registerIndex() const
 
const RegisterFile * registerFile() const
 
@ OUTPUT
Data goes from port to bus.
 
@ INPUT
Data goes from bus to port.
 
bool isConnectedTo(const Bus &bus) const
 
Direction direction() const
 
Port * port(int index) const
 
virtual bool hasPort(const std::string &name) const
 
const TTAMachine::AddressSpace & space() const
 
InstructionAddress location() const
 
void addAnnotation(const ProgramAnnotation &annotation)
 
virtual Address startAddress() const
 
void addDataDefinition(DataDefinition *dataDef)
 
DataDefinition & dataDefinition(Address address) const
 
int dataDefinitionCount() const
 
FunctionStart(std::string aName)
 
InstructionReference createReference(Instruction &ins)
 
void addImmediate(std::shared_ptr< Immediate > imm)
 
void addMove(std::shared_ptr< Move > move)
 
void setInstructionTemplate(const TTAMachine::InstructionTemplate &insTemp)
 
Id
the ID in TPEF is 24 bits, here enum
 
std::vector< Instruction * > InstructionVector
Vector for instructions.
 
GlobalScope & globalScope()
 
Address startAddress() const
 
TTAMachine::Machine & targetProcessor() const
 
void addDataMemory(DataMemory *dataMem)
 
InstructionReferenceManager & instructionReferenceManager() const
 
InstructionVector instructionVector() const
 
void setUniversalMachine(UniversalMachine *umach)
 
virtual void addDataLabel(const DataLabel *dataLabel)
 
virtual void addCodeLabel(const CodeLabel *codeLabel)
 
Cache key for resources that are accessed from MOM(s)
 
std::vector< TPEF::ImmediateElement * > ImmediateVector
 
std::vector< TPEF::MoveElement * > MoveVector
 
const TTAMachine::Machine * machine_
Target machine of program.
 
TTAMachine::Bus & findBus(const TPEF::ResourceSection &resources, HalfWord busId) const
 
bool canDestinationBeAssigned(SocketAllocation &alloc, std::map< TTAMachine::Socket *, std::vector< SocketAllocation * > > &fixedSockets) const
 
std::string stringOfChunk(const TPEF::Chunk *chunk, const TPEF::Section *chunkOwner) const
 
bool canSourceBeAssigned(SocketAllocation &alloc, std::map< TTAMachine::Socket *, std::vector< SocketAllocation * > > &fixedSockets) const
 
TPEF::ASpaceElement * tpefInstrASpace_
Instruction address space element of TPEF.
 
TTAMachine::RegisterFile & findRegisterFile(const TPEF::ResourceSection &resources, HalfWord rfId) const
 
TTAMachine::AddressSpace & findAddressSpace(const TPEF::ASpaceElement *aSpace) const
 
std::string functionName(const TPEF::InstructionElement &instructionElement) const
 
std::map< ImmediateKey, TPEF::ImmediateElement * > ImmediateMap
 
const TPEF::Binary * binary_
Binary that is used for creating program.
 
TTAMachine::Guard & findGuard(const TPEF::ResourceSection &resources, TTAMachine::Bus &bus, TPEF::MoveElement::FieldType type, HalfWord unitId, HalfWord index, bool isInverted) const
 
bool isFunctionStart(const TPEF::InstructionElement &instructionElement) const
 
void createDataMemories(Program &prog)
 
TPEFProgramFactory(const TPEF::Binary &aBinary, const TTAMachine::Machine &aMachine)
 
std::list< std::shared_ptr< Immediate > > longInstructionImmediates_
Long immediates whose value terminals refers to instructions.
 
TTAMachine::ImmediateUnit & findImmediateUnit(const TPEF::ResourceSection &resources, Byte immUnitId) const
 
void seekFunctionStartPoints()
 
TTAMachine::AddressSpace * adfInstrASpace_
Instruction address space of machine.
 
void resolveSocketAllocations(std::vector< SocketAllocation > &allocs) const
 
TPEF::TPEFTools tpefTools_
TPEFTools object for helper functions.
 
std::map< const CacheKey, Terminal * > cache_
Cache map of terminals that are returned by different search parameters.
 
void addToCache(const CacheKey &key, Terminal *cachedTerm) const
 
virtual ~TPEFProgramFactory()
 
std::pair< Word, Word > ImmediateKey
 
Terminal * getFromCache(const CacheKey &key) const
 
void addProcedures(Program &program, const TTAMachine::AddressSpace &programASpace) const
 
TTAMachine::FunctionUnit & findFunctionUnit(const TPEF::ResourceSection &resources, HalfWord unitId, std::string tpefOpName="") const
 
void createLabels(Program &prog)
 
Instruction * createInstruction(const TPEF::ResourceSection &resources, MoveVector &moveElements, ImmediateVector &longImmediates, ImmediateMap &immElements) const
 
Terminal * createTerminal(const TPEF::ResourceSection &resources, const TTAMachine::Bus *aBus, TTAMachine::Socket::Direction direction, TPEF::MoveElement::FieldType type, HalfWord unitId, HalfWord index, const ImmediateMap *immediateMap=NULL) const
 
TTAMachine::Port & findPort(const TTAMachine::Bus &bus, const TTAMachine::Unit &portParent, std::string tpefOpName="", int tpefOpIndex=0) const
 
UniversalMachine * universalMachine_
Universal machine of program.
 
std::map< TPEF::InstructionElement *, Instruction * > instructionMap_
Program instruction by TPEF instruction element.
 
TTAMachine::InstructionTemplate & findInstrTemplate(const TPEF::ResourceSection &resources, ImmediateVector &longImmediates, MoveVector &moves) const
 
std::list< std::shared_ptr< Move > > instructionImmediates_
Moves whose source terminals are addresses referring to instructions.
 
std::map< const TPEF::InstructionElement *, class FunctionStart * > functionStartPositions_
Stores information of start points of procedures that were found.
 
virtual int index() const
 
virtual Address address() const
 
virtual Terminal * copy() const =0
 
virtual bool isGPR() const
 
virtual bool isImmediateRegister() const
 
virtual const TTAMachine::Port & port() const
 
TTAMachine::AddressSpace & dataAddressSpace() const
 
TTAMachine::AddressSpace & instructionAddressSpace() const
 
TTAMachine::RegisterFile & booleanRegisterFile() const
 
UniversalFunctionUnit & universalFunctionUnit() const
 
UnboundedRegisterFile & integerRegisterFile() const
 
TTAMachine::Bus & universalBus() const
 
UnboundedRegisterFile & doubleRegisterFile() const
 
std::shared_ptr< Move > move
 
std::vector< TTAMachine::Socket * > dstSocks
 
std::vector< TTAMachine::Socket * > srcSocks