OpenASIP
2.0
|
#include <MachineResourceManager.hh>
Classes | |
struct | ResourceID |
struct | ResourceKey |
Public Types | |
enum | RequestType { RQST_READ, RQST_WRITE, RQST_GUARD, RQST_INVGUARD } |
Public Member Functions | |
MachineResourceManager (TPEF::Binary &tpef, const TTAMachine::Machine &adf, AssemblyParserDiagnostic *parent_) | |
TPEF::Section * | nullSection () |
TPEF::StringSection * | stringSection () |
TPEF::ResourceSection * | resourceSection () |
TPEF::ASpaceElement * | findDataAddressSpace (std::string name) |
UValue | findBusWidth (UValue slotNumber) |
TPEF::ASpaceElement * | undefinedAddressSpace () |
TPEF::ASpaceElement * | codeAddressSpace () |
TPEF::Chunk * | stringToChunk (const std::string aStr) |
ResourceID & | resourceID (UValue currentLine, const RegisterTerm &term, UValue slotNumber, RequestType type) |
Private Member Functions | |
void | initResourceSection () |
void | addResourceElement (TPEF::ResourceElement *resource) |
UValue | registerFileID (TTAMachine::BaseRegisterFile *rf) |
UValue | functionUnitID (TTAMachine::FunctionUnit *unit) |
UValue | opOrPortID (std::string opOrPortString, const TTAMachine::Port *port) |
std::string | requestTypeString (RequestType type) const |
ResourceID | functionUnitPortResource (const RegisterTerm &term) |
ResourceID | indexResource (UValue currentLine, const RegisterTerm &term, UValue slotNumber, RequestType type, std::string &resourceKeyString) |
ResourceID | rFPortOrFUIndexReference (TTAMachine::FunctionUnit *fu, TTAMachine::BaseRegisterFile *rf, UValue currentLine, const RegisterTerm &term, UValue slotNumber, RequestType type, std::string &resourceKeyString) |
ResourceID | registerFileIndexReference (TTAMachine::BaseRegisterFile *rf, const RegisterTerm &term, UValue slotNumber, RequestType type, std::string &resourceKeyString) |
Private Attributes | |
TPEF::Binary & | tpef_ |
Binary where all used resources are added. More... | |
const TTAMachine::Machine & | adf_ |
Machine where manager tries to find used resources. More... | |
TPEF::ASpaceSection * | aSpaceSection_ |
The address space section of TPEF. More... | |
TPEF::StringSection * | strings_ |
The string section of TPEF. More... | |
TPEF::ASpaceElement * | undefASpace_ |
The undefined address space element of TPEF. More... | |
TPEF::ASpaceElement * | codeASpace_ |
The instruction address space element of TPEF. More... | |
std::map< std::string, TPEF::ASpaceElement * > | addressSpaces_ |
Bookkeeping for already requested address spaces. More... | |
TPEF::NullSection * | nullSection_ |
The null section of TPEF. More... | |
TPEF::ResourceSection * | resourceSection_ |
The resource section of TPEF. More... | |
std::map< ResourceKey, ResourceID > | resourceMap_ |
Bookkeeping for already requested resources. More... | |
UValue | lastFunctionUnitID_ |
For generating function unit resource ids. More... | |
std::map< TTAMachine::FunctionUnit *, UValue > | functionUnitIDs_ |
Bookkeeping of already added function units. More... | |
UValue | lastRegisterFileID_ |
For generating register file resource ids. More... | |
std::map< TTAMachine::BaseRegisterFile *, UValue > | registerFileIDs_ |
Bookkeeping of already added register files. More... | |
UValue | lastOpOrSpecRegisterID_ |
For generating shared ids for ports, operations or special registers. More... | |
std::map< std::string, UValue > | opOrPortIDs_ |
Bookkeeping of already added ports, operations and special registers. More... | |
AssemblyParserDiagnostic * | parent_ |
Assembler root class for adding warnings. More... | |
Provides all TPEF and machine resources needed by CodeSectionCreator and DataSectionCreator.
Search resources from Machine and returns corresponding TPEF resources. Class also provides easy way to get common TPEF resource like strings, null section and required null elements. After all needed resources are returned the Binary that was given for MachineResourceManager will contain valid TPEF with NullSection, ASpaceSection, StringSection and ResourceSection.
Definition at line 76 of file MachineResourceManager.hh.
Type of resource id request.
Enumerator | |
---|---|
RQST_READ | Register of port for reading. |
RQST_WRITE | Register or port for writing. |
RQST_GUARD | Register or port guard. |
RQST_INVGUARD | Inverted register or port guard. |
Definition at line 81 of file MachineResourceManager.hh.
MachineResourceManager::MachineResourceManager | ( | TPEF::Binary & | tpef, |
const TTAMachine::Machine & | adf, | ||
AssemblyParserDiagnostic * | parent | ||
) |
Constructor.
tpef | Binary where to generated resources are added. |
adf | Machine where from requested resources are found. |
parent | Assembler root class for adding warning information. |
Definition at line 63 of file MachineResourceManager.cc.
|
private |
Adds resource element to TPEF.
Definition at line 418 of file MachineResourceManager.cc.
References TPEF::Section::addElement(), assert, TPEF::StringSection::chunk2String(), TPEF::ResourceElement::id(), initResourceSection(), TPEF::ResourceElement::name(), resourceSection_, strings_, and TPEF::ResourceElement::type().
Referenced by functionUnitID(), opOrPortID(), and registerFileID().
ASpaceElement * MachineResourceManager::codeAddressSpace | ( | ) |
Returns the code address space.
Definition at line 213 of file MachineResourceManager.cc.
References __func__, TPEF::Section::addElement(), TTAMachine::FunctionUnit::addressSpace(), addressSpaces_, adf_, aSpaceSection_, codeASpace_, TTAMachine::Machine::controlUnit(), TTAMachine::Component::name(), TPEF::ASpaceElement::setMAU(), TPEF::ASpaceElement::setName(), stringToChunk(), and undefinedAddressSpace().
Referenced by CodeSectionCreator::finalize(), and findDataAddressSpace().
Returns bitwidth of requested bus.
Slot | number of requested bus. |
OutOfRange | If slot number is out of bounds. |
Definition at line 129 of file MachineResourceManager.cc.
References adf_, TTAMachine::Machine::busNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), and TTAMachine::Bus::width().
Referenced by CodeSectionCreator::addMove().
ASpaceElement * MachineResourceManager::findDataAddressSpace | ( | std::string | name | ) |
Finds data address space by name from ADF and adds it to TPEF.
name | Name of requested address space. |
IllegalMachine | Address space was not found from ADF. |
InvalidData | Found address space is the code address space. |
Definition at line 83 of file MachineResourceManager.cc.
References __func__, TPEF::Section::addElement(), TTAMachine::Machine::addressSpaceNavigator(), addressSpaces_, adf_, aSpaceSection_, assert, codeAddressSpace(), MapTools::containsKey(), TTAMachine::Machine::Navigator< ComponentType >::hasItem(), TTAMachine::Machine::Navigator< ComponentType >::item(), TPEF::ASpaceElement::setMAU(), TPEF::ASpaceElement::setName(), stringToChunk(), undefinedAddressSpace(), and TTAMachine::AddressSpace::width().
Referenced by DataSectionCreator::finalize(), and DataSectionCreator::resolveDataAreaSizesAndLabelAddresses().
|
private |
Returns TPEF resource ID of function unit.
If resource is not already in TPEF method creates resource and adds it.
unit | Function unit whose ID is needed. |
Definition at line 446 of file MachineResourceManager.cc.
References addResourceElement(), assert, MapTools::containsKey(), functionUnitIDs_, lastFunctionUnitID_, TTAMachine::Component::name(), TPEF::ResourceElement::setId(), TPEF::ResourceElement::setName(), TPEF::ResourceElement::setType(), and stringToChunk().
Referenced by functionUnitPortResource(), and rFPortOrFUIndexReference().
|
private |
Finds resource for fu.port or fu.port.operation term.
Helper method for resourceID method.
term | Requested term. |
IllegalMachine | There was problems finding resource from ADF. |
Definition at line 577 of file MachineResourceManager.cc.
References __func__, adf_, assert, TTAMachine::Machine::controlUnit(), functionUnitID(), TTAMachine::Machine::functionUnitNavigator(), RegisterTerm::fuTerm, TTAMachine::Machine::Navigator< ComponentType >::hasItem(), TTAMachine::FunctionUnit::hasOperation(), TTAMachine::Unit::hasPort(), MachineResourceManager::ResourceID::index, TTAMachine::HWOperation::io(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Component::name(), TTAMachine::FunctionUnit::operation(), opOrPortID(), FUTerm::part1, FUTerm::part2, FUTerm::part3, FUTerm::part3Used, TTAMachine::FunctionUnit::port(), Conversion::toString(), MachineResourceManager::ResourceID::type, MachineResourceManager::ResourceID::unit, TTAMachine::Port::width(), and MachineResourceManager::ResourceID::width.
Referenced by resourceID().
|
private |
Finds resource for fu.operation.index, rf.index or rf.port.index term.
Helper method for resourceID method.
currentLine | Line number information for warning messages. |
term | Requested term. |
slotNumber | Number of move slot, that was used. |
type | Request type. |
resourceKeyString | Resource key string for error messages. |
IllegalMachine | There was problems finding resource from ADF. |
Definition at line 670 of file MachineResourceManager.cc.
References AssemblyParserDiagnostic::addWarning(), adf_, TTAMachine::Machine::controlUnit(), TTAMachine::Machine::functionUnitNavigator(), TTAMachine::Machine::Navigator< ComponentType >::hasItem(), TTAMachine::Machine::immediateUnitNavigator(), RegisterTerm::indexTerm, TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Component::name(), parent_, IndexTerm::part1, IndexTerm::part2Used, registerFileIndexReference(), TTAMachine::Machine::registerFileNavigator(), and rFPortOrFUIndexReference().
Referenced by resourceID().
|
private |
Initialises resource section if its not initialised already.
Definition at line 382 of file MachineResourceManager.cc.
References TPEF::Section::addElement(), TPEF::Binary::addSection(), adf_, assert, TTAMachine::Machine::busNavigator(), TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Component::name(), resourceSection_, TPEF::Section::setASpace(), TPEF::ResourceElement::setId(), TPEF::Section::setLink(), TPEF::ResourceElement::setName(), TPEF::Section::setName(), TPEF::ResourceElement::setType(), strings_, stringToChunk(), tpef_, and undefinedAddressSpace().
Referenced by addResourceElement(), and resourceSection().
Section * MachineResourceManager::nullSection | ( | ) |
Returns NullSection instance of TPEF.
Definition at line 140 of file MachineResourceManager.cc.
References TPEF::Binary::addSection(), assert, nullSection_, TPEF::Section::setASpace(), TPEF::Section::setLink(), TPEF::Section::setName(), stringToChunk(), tpef_, and undefinedAddressSpace().
Referenced by stringToChunk().
|
private |
Returns TPEF resource ID of operand or port.
If resource is not already in TPEF method creates resource and adds it.
opPortString | TPEF resource string of port or operand. |
port | Port that is connected with requested resource in ADF. |
Definition at line 518 of file MachineResourceManager.cc.
References addResourceElement(), MapTools::containsKey(), lastOpOrSpecRegisterID_, opOrPortIDs_, TPEF::ResourceElement::setId(), TPEF::ResourceElement::setName(), TPEF::ResourceElement::setType(), and stringToChunk().
Referenced by functionUnitPortResource(), and rFPortOrFUIndexReference().
|
private |
Returns TPEF resource ID corresponding to a register file.
If there is no resource entry in TPEF for the given register file, this method creates it, assigns a new unique ID code to it and adds it to the pool of managed TPEF resources.
rf | A register file. |
Definition at line 480 of file MachineResourceManager.cc.
References addResourceElement(), assert, MapTools::containsKey(), lastRegisterFileID_, TTAMachine::Component::name(), registerFileIDs_, TPEF::ResourceElement::setId(), TPEF::ResourceElement::setName(), TPEF::ResourceElement::setType(), and stringToChunk().
Referenced by registerFileIndexReference(), and rFPortOrFUIndexReference().
|
private |
Finds resource for rf.index term.
Helper method for indexResource method.
rf | Register file of term. |
term | Requested term. |
slotNumber | Number of move slot, that was used. |
type | Request type. |
resourceKeyString | Resource key string for error messages. |
IllegalMachine | There was problems finding resource from ADF. |
Definition at line 983 of file MachineResourceManager.cc.
References __func__, abortWithError, adf_, TTAMachine::Machine::busNavigator(), TTAMachine::Bus::guard(), TTAMachine::Bus::guardCount(), MachineResourceManager::ResourceID::index, IndexTerm::index, RegisterTerm::indexTerm, TTAMachine::Port::inputSocket(), TTAMachine::Socket::isConnectedTo(), TTAMachine::Guard::isInverted(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::BaseRegisterFile::numberOfRegisters(), TTAMachine::Port::outputSocket(), TTAMachine::BaseRegisterFile::port(), TTAMachine::Unit::portCount(), TTAMachine::RegisterGuard::registerFile(), registerFileID(), TTAMachine::RegisterGuard::registerIndex(), requestTypeString(), RQST_GUARD, RQST_INVGUARD, RQST_READ, RQST_WRITE, Conversion::toString(), MachineResourceManager::ResourceID::type, MachineResourceManager::ResourceID::unit, TTAMachine::BaseRegisterFile::width(), and MachineResourceManager::ResourceID::width.
Referenced by indexResource().
|
private |
Returns debug string for request type for error message generation.
type | Request type. |
Definition at line 557 of file MachineResourceManager.cc.
References RQST_GUARD, RQST_INVGUARD, RQST_READ, and RQST_WRITE.
Referenced by registerFileIndexReference(), and rFPortOrFUIndexReference().
MachineResourceManager::ResourceID & MachineResourceManager::resourceID | ( | UValue | currentLine, |
const RegisterTerm & | term, | ||
UValue | slotNumber, | ||
RequestType | type | ||
) |
Resolves type, unit and index fields, of given register term.
Also checks if requested term is possible and creates machine resource section.
currentLine | line number where term is located in assembly code. |
term | Term to resolve. |
slotNumber | Number of move slot, that was used. |
type | Is read, write or guard. |
IllegalMachine | There is problem to find or access the resource. |
Definition at line 285 of file MachineResourceManager.cc.
References abortWithError, assert, RegisterTerm::BUS, RegisterTerm::busTerm, MapTools::containsKey(), RegisterTerm::FUNCTION_UNIT, functionUnitPortResource(), RegisterTerm::fuTerm, IndexTerm::index, RegisterTerm::INDEX, indexResource(), RegisterTerm::indexTerm, MachineResourceManager::ResourceKey::keyString, FUTerm::part1, IndexTerm::part1, FUTerm::part2, IndexTerm::part2, IndexTerm::part2Used, FUTerm::part3, FUTerm::part3Used, BusTerm::prev, resourceMap_, MachineResourceManager::ResourceKey::slotNumber, Conversion::toString(), MachineResourceManager::ResourceKey::type, and RegisterTerm::type.
Referenced by CodeSectionCreator::addMove().
ResourceSection * MachineResourceManager::resourceSection | ( | ) |
Returns the resource section of TPEF.
Definition at line 373 of file MachineResourceManager.cc.
References initResourceSection(), and resourceSection_.
Referenced by CodeSectionCreator::finalize().
|
private |
Finds resource for fu.operation.index or rf.port.index term.
Helper method for indexResource method.
fu | Function unit of term, might be NULL. |
rf | Register file of term, might be NULL. |
currentLine | Line number information for warning messages. |
term | Requested term. |
slotNumber | Number of move slot, that was used. |
type | Request type. |
resourceKeyString | Resource key string for error messages. |
IllegalMachine | There was problems finding resource from ADF. |
Definition at line 755 of file MachineResourceManager.cc.
References __func__, abortWithError, AssemblyParserDiagnostic::addWarning(), adf_, TTAMachine::Machine::busNavigator(), Exception::errorMessage(), functionUnitID(), TTAMachine::Bus::guard(), TTAMachine::Bus::guardCount(), TTAMachine::FunctionUnit::hasOperation(), MachineResourceManager::ResourceID::index, IndexTerm::index, RegisterTerm::indexTerm, TTAMachine::Port::inputSocket(), TTAMachine::Socket::isConnectedTo(), TTAMachine::Guard::isInverted(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Port::name(), TTAMachine::FunctionUnit::operation(), opOrPortID(), TTAMachine::Port::outputSocket(), parent_, IndexTerm::part2, TTAMachine::BaseRegisterFile::port(), TTAMachine::HWOperation::port(), TTAMachine::PortGuard::port(), TTAMachine::Unit::portCount(), TTAMachine::RegisterGuard::registerFile(), registerFileID(), TTAMachine::RegisterGuard::registerIndex(), requestTypeString(), RQST_GUARD, RQST_INVGUARD, RQST_READ, RQST_WRITE, Exception::setCause(), Conversion::toString(), MachineResourceManager::ResourceID::type, MachineResourceManager::ResourceID::unit, TTAMachine::Port::width(), and MachineResourceManager::ResourceID::width.
Referenced by indexResource().
StringSection * MachineResourceManager::stringSection | ( | ) |
Returns string table of TPEF.
Definition at line 166 of file MachineResourceManager.cc.
References strings_, and undefinedAddressSpace().
Referenced by LabelManager::finalize().
Chunk * MachineResourceManager::stringToChunk | ( | const std::string | aStr | ) |
Finds or adds string to TPEF string section and returns chunk pointing to it.
aStr | String whose chunk is needed. |
Definition at line 249 of file MachineResourceManager.cc.
References TPEF::DataSection::addByte(), TPEF::Binary::addSection(), nullSection(), TPEF::Section::setASpace(), TPEF::Section::setLink(), TPEF::Binary::setStrings(), TPEF::StringSection::string2Chunk(), strings_, tpef_, and undefinedAddressSpace().
Referenced by codeAddressSpace(), DataSectionCreator::finalize(), CodeSectionCreator::finalize(), findDataAddressSpace(), functionUnitID(), initResourceSection(), nullSection(), opOrPortID(), registerFileID(), and undefinedAddressSpace().
ASpaceElement * MachineResourceManager::undefinedAddressSpace | ( | ) |
Returns undefined address space element.
Definition at line 179 of file MachineResourceManager.cc.
References TPEF::Section::addElement(), TPEF::Binary::addSection(), aSpaceSection_, assert, TPEF::Section::setASpace(), TPEF::Section::setLink(), TPEF::ASpaceElement::setName(), TPEF::Section::setName(), TPEF::ASpaceSection::setUndefinedASpace(), strings_, stringToChunk(), tpef_, and undefASpace_.
Referenced by codeAddressSpace(), LabelManager::finalize(), findDataAddressSpace(), LabelManager::findOrCreateRelocationSection(), initResourceSection(), nullSection(), stringSection(), and stringToChunk().
|
private |
Bookkeeping for already requested address spaces.
Definition at line 216 of file MachineResourceManager.hh.
Referenced by codeAddressSpace(), and findDataAddressSpace().
|
private |
Machine where manager tries to find used resources.
Definition at line 202 of file MachineResourceManager.hh.
Referenced by codeAddressSpace(), findBusWidth(), findDataAddressSpace(), functionUnitPortResource(), indexResource(), initResourceSection(), registerFileIndexReference(), and rFPortOrFUIndexReference().
|
private |
The address space section of TPEF.
Definition at line 205 of file MachineResourceManager.hh.
Referenced by codeAddressSpace(), findDataAddressSpace(), and undefinedAddressSpace().
|
private |
The instruction address space element of TPEF.
Definition at line 214 of file MachineResourceManager.hh.
Referenced by codeAddressSpace().
|
private |
Bookkeeping of already added function units.
Definition at line 229 of file MachineResourceManager.hh.
Referenced by functionUnitID().
|
private |
For generating function unit resource ids.
Definition at line 227 of file MachineResourceManager.hh.
Referenced by functionUnitID().
|
private |
For generating shared ids for ports, operations or special registers.
Definition at line 237 of file MachineResourceManager.hh.
Referenced by opOrPortID().
|
private |
For generating register file resource ids.
Definition at line 232 of file MachineResourceManager.hh.
Referenced by registerFileID().
|
private |
The null section of TPEF.
Definition at line 219 of file MachineResourceManager.hh.
Referenced by nullSection().
|
private |
Bookkeeping of already added ports, operations and special registers.
Definition at line 239 of file MachineResourceManager.hh.
Referenced by opOrPortID().
|
private |
Assembler root class for adding warnings.
Definition at line 242 of file MachineResourceManager.hh.
Referenced by indexResource(), and rFPortOrFUIndexReference().
|
private |
Bookkeeping of already added register files.
Definition at line 234 of file MachineResourceManager.hh.
Referenced by registerFileID().
|
private |
Bookkeeping for already requested resources.
Definition at line 224 of file MachineResourceManager.hh.
Referenced by resourceID().
|
private |
The resource section of TPEF.
Definition at line 222 of file MachineResourceManager.hh.
Referenced by addResourceElement(), initResourceSection(), and resourceSection().
|
private |
The string section of TPEF.
Definition at line 208 of file MachineResourceManager.hh.
Referenced by addResourceElement(), initResourceSection(), stringSection(), stringToChunk(), and undefinedAddressSpace().
|
private |
Binary where all used resources are added.
Definition at line 199 of file MachineResourceManager.hh.
Referenced by initResourceSection(), nullSection(), stringToChunk(), and undefinedAddressSpace().
|
private |
The undefined address space element of TPEF.
Definition at line 211 of file MachineResourceManager.hh.
Referenced by undefinedAddressSpace().