OpenASIP 2.2
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
MachineResourceManager Class Reference

#include <MachineResourceManager.hh>

Collaboration diagram for MachineResourceManager:
Collaboration graph

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::SectionnullSection ()
 
TPEF::StringSectionstringSection ()
 
TPEF::ResourceSectionresourceSection ()
 
TPEF::ASpaceElementfindDataAddressSpace (std::string name)
 
UValue findBusWidth (UValue slotNumber)
 
TPEF::ASpaceElementundefinedAddressSpace ()
 
TPEF::ASpaceElementcodeAddressSpace ()
 
TPEF::ChunkstringToChunk (const std::string aStr)
 
ResourceIDresourceID (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::Binarytpef_
 Binary where all used resources are added.
 
const TTAMachine::Machineadf_
 Machine where manager tries to find used resources.
 
TPEF::ASpaceSectionaSpaceSection_
 The address space section of TPEF.
 
TPEF::StringSectionstrings_
 The string section of TPEF.
 
TPEF::ASpaceElementundefASpace_
 The undefined address space element of TPEF.
 
TPEF::ASpaceElementcodeASpace_
 The instruction address space element of TPEF.
 
std::map< std::string, TPEF::ASpaceElement * > addressSpaces_
 Bookkeeping for already requested address spaces.
 
TPEF::NullSectionnullSection_
 The null section of TPEF.
 
TPEF::ResourceSectionresourceSection_
 The resource section of TPEF.
 
std::map< ResourceKey, ResourceIDresourceMap_
 Bookkeeping for already requested resources.
 
UValue lastFunctionUnitID_
 For generating function unit resource ids.
 
std::map< TTAMachine::FunctionUnit *, UValuefunctionUnitIDs_
 Bookkeeping of already added function units.
 
UValue lastRegisterFileID_
 For generating register file resource ids.
 
std::map< TTAMachine::BaseRegisterFile *, UValueregisterFileIDs_
 Bookkeeping of already added register files.
 
UValue lastOpOrSpecRegisterID_
 For generating shared ids for ports, operations or special registers.
 
std::map< std::string, UValueopOrPortIDs_
 Bookkeeping of already added ports, operations and special registers.
 
AssemblyParserDiagnosticparent_
 Assembler root class for adding warnings.
 

Detailed Description

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.

Member Enumeration Documentation

◆ RequestType

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.

81 {
82 RQST_READ, ///< Register of port for reading.
83 RQST_WRITE, ///< Register or port for writing.
84 RQST_GUARD, ///< Register or port guard.
85 RQST_INVGUARD ///< Inverted register or port guard.
86 };
@ RQST_INVGUARD
Inverted register or port guard.
@ RQST_READ
Register of port for reading.
@ RQST_WRITE
Register or port for writing.
@ RQST_GUARD
Register or port guard.

Constructor & Destructor Documentation

◆ MachineResourceManager()

MachineResourceManager::MachineResourceManager ( TPEF::Binary tpef,
const TTAMachine::Machine adf,
AssemblyParserDiagnostic parent 
)

Constructor.

Parameters
tpefBinary where to generated resources are added.
adfMachine where from requested resources are found.
parentAssembler root class for adding warning information.

Definition at line 63 of file MachineResourceManager.cc.

66 :
67 tpef_(tpef), adf_(adf), aSpaceSection_(NULL), strings_(NULL),
68 undefASpace_(NULL), codeASpace_(NULL), nullSection_(NULL),
71}
TPEF::StringSection * strings_
The string section of TPEF.
AssemblyParserDiagnostic * parent_
Assembler root class for adding warnings.
const TTAMachine::Machine & adf_
Machine where manager tries to find used resources.
UValue lastRegisterFileID_
For generating register file resource ids.
TPEF::ResourceSection * resourceSection_
The resource section of TPEF.
UValue lastOpOrSpecRegisterID_
For generating shared ids for ports, operations or special registers.
TPEF::Binary & tpef_
Binary where all used resources are added.
TPEF::ASpaceSection * aSpaceSection_
The address space section of TPEF.
TPEF::ASpaceElement * codeASpace_
The instruction address space element of TPEF.
UValue lastFunctionUnitID_
For generating function unit resource ids.
TPEF::ASpaceElement * undefASpace_
The undefined address space element of TPEF.
TPEF::NullSection * nullSection_
The null section of TPEF.

Member Function Documentation

◆ addResourceElement()

void MachineResourceManager::addResourceElement ( TPEF::ResourceElement resource)
private

Adds resource element to TPEF.

Definition at line 418 of file MachineResourceManager.cc.

418 {
420 assert(resourceSection_ != NULL);
421
422#if 0
423 // Valuable debug info... about resources that are added to
424 // resource section
425 std::cerr << "Added resource element: "
426 << strings_->chunk2String(resource->name())
427 << "\t" << (int)resource->type()
428 << "\t" << (int)resource->id()
429 << std::endl;
430#endif
431
432 resourceSection_->addElement(resource);
433}
#define assert(condition)
ResourceType type() const
HalfWord id() const
Chunk * name() const
virtual void addElement(SectionElement *element)
Definition Section.cc:133
std::string chunk2String(const Chunk *chunk) const

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().

Here is the call graph for this function:

◆ codeAddressSpace()

ASpaceElement * MachineResourceManager::codeAddressSpace ( )

Returns the code address space.

Returns
The code address space.

Definition at line 213 of file MachineResourceManager.cc.

213 {
214
215 if (codeASpace_ == NULL) {
216 // make sure that there is address space section created...
218
219 // find codeAddressSpace, create tpef version and add it to section
220 AddressSpace* adfAddressSpace = adf_.controlUnit()->addressSpace();
221
222 if (adfAddressSpace == NULL) {
223 throw IllegalMachine(
224 __FILE__, __LINE__, __func__,
225 "Control unit has no address space.");
226 }
227
228 ASpaceElement* newASpace = new ASpaceElement();
229 newASpace->setMAU(0);
230 newASpace->setName(stringToChunk(adfAddressSpace->name()));
231
232 addressSpaces_[adfAddressSpace->name()] = newASpace;
233 codeASpace_ = newASpace;
234
235 aSpaceSection_->addElement(newASpace);
236 }
237
238 return codeASpace_;
239}
#define __func__
std::map< std::string, TPEF::ASpaceElement * > addressSpaces_
Bookkeeping for already requested address spaces.
TPEF::ASpaceElement * undefinedAddressSpace()
TPEF::Chunk * stringToChunk(const std::string aStr)
void setName(const ReferenceManager::SafePointer *aName)
void setMAU(Byte aMAU)
virtual TCEString name() const
virtual AddressSpace * addressSpace() const
virtual ControlUnit * controlUnit() const
Definition Machine.cc:345

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 AssemblerParser::definition< ScannerT >::definition(), CodeSectionCreator::finalize(), and findDataAddressSpace().

Here is the call graph for this function:

◆ findBusWidth()

UValue MachineResourceManager::findBusWidth ( UValue  slotNumber)

Returns bitwidth of requested bus.

Parameters
Slotnumber of requested bus.
Returns
Bitwidth of requested bus.
Exceptions
OutOfRangeIf slot number is out of bounds.

Definition at line 129 of file MachineResourceManager.cc.

129 {
130 Bus* bus = adf_.busNavigator().item(slotNumber);
131 return bus->width();
132}
int width() const
Definition Bus.cc:149
ComponentType * item(int index) const
virtual BusNavigator busNavigator() const
Definition Machine.cc:356

References adf_, TTAMachine::Machine::busNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), and TTAMachine::Bus::width().

Referenced by CodeSectionCreator::addMove().

Here is the call graph for this function:

◆ findDataAddressSpace()

ASpaceElement * MachineResourceManager::findDataAddressSpace ( std::string  name)

Finds data address space by name from ADF and adds it to TPEF.

Parameters
nameName of requested address space.
Returns
ASpaceElement or NULL if not found.
Exceptions
IllegalMachineAddress space was not found from ADF.
InvalidDataFound address space is the code address space.

Definition at line 83 of file MachineResourceManager.cc.

83 {
84 // check if address space is already created
86
87 // try to find address space for name
89
90 // Check that address space is found from machine and create address
91 // space section and address undef address space if needed to TPEF.
92 if (!aSpaces.hasItem(name)) {
93 throw IllegalMachine(
94 __FILE__, __LINE__, __func__,
95 "ADF doesn't contain address space: " + name);
96 }
97
99
100 // create new address space and add it to TPEF
101 AddressSpace* adfAddressSpace = aSpaces.item(name);
102 assert(adfAddressSpace != NULL);
103
104 ASpaceElement* newASpace = new ASpaceElement();
105 newASpace->setMAU(adfAddressSpace->width());
106 newASpace->setName(stringToChunk(name));
107 addressSpaces_[name] = newASpace;
108
109 aSpaceSection_->addElement(newASpace);
110 }
111
112 if (addressSpaces_[name] == codeAddressSpace()) {
113 throw InvalidData(
114 __FILE__, __LINE__, __func__,
115 "Method can't be used for getting code address space.");
116 }
117
118 return addressSpaces_[name];
119}
TPEF::ASpaceElement * codeAddressSpace()
static bool containsKey(const MapType &aMap, const KeyType &aKey)
virtual int width() const
bool hasItem(const std::string &name) const
virtual AddressSpaceNavigator addressSpaceNavigator() const
Definition Machine.cc:392

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().

Here is the call graph for this function:

◆ functionUnitID()

UValue MachineResourceManager::functionUnitID ( TTAMachine::FunctionUnit unit)
private

Returns TPEF resource ID of function unit.

If resource is not already in TPEF method creates resource and adds it.

Parameters
unitFunction unit whose ID is needed.
Returns
TPEF resource ID of function unit.

Definition at line 446 of file MachineResourceManager.cc.

446 {
447
449 // create resource element and add its unit id to map
451
452 ResourceElement* newRes = new ResourceElement();
453
454 newRes->setId(lastFunctionUnitID_);
456 newRes->setName(stringToChunk(unit->name()));
457
458 addResourceElement(newRes);
459
461 }
462
464
465 return functionUnitIDs_[unit];
466}
void addResourceElement(TPEF::ResourceElement *resource)
std::map< TTAMachine::FunctionUnit *, UValue > functionUnitIDs_
Bookkeeping of already added function units.
void setId(HalfWord aId)
void setName(ReferenceManager::SafePointer *aName)
@ MRT_UNIT
Function unit.
void setType(ResourceType aType)

References addResourceElement(), assert, MapTools::containsKey(), functionUnitIDs_, lastFunctionUnitID_, TPEF::ResourceElement::MRT_UNIT, TTAMachine::Component::name(), TPEF::ResourceElement::setId(), TPEF::ResourceElement::setName(), TPEF::ResourceElement::setType(), and stringToChunk().

Referenced by functionUnitPortResource(), and rFPortOrFUIndexReference().

Here is the call graph for this function:

◆ functionUnitPortResource()

MachineResourceManager::ResourceID MachineResourceManager::functionUnitPortResource ( const RegisterTerm term)
private

Finds resource for fu.port or fu.port.operation term.

Helper method for resourceID method.

Parameters
termRequested term.
Returns
TPEF resource information of requested term.
Exceptions
IllegalMachineThere was problems finding resource from ADF.

Definition at line 577 of file MachineResourceManager.cc.

577 {
578 ResourceID newResID;
579
582
583 FunctionUnit* fu = NULL;
584
585 if (fuNavi.hasItem(term.fuTerm.part1)) {
586 fu = fuNavi.item(term.fuTerm.part1);
587
588 } else if (adf_.controlUnit()->name() == term.fuTerm.part1) {
589 // NOTE: it would be easier, if control unit would be just
590 // same that any fu and it would exist in fuNavigator.
591 fu = adf_.controlUnit();
592
593 } else {
594 throw IllegalMachine(
595 __FILE__, __LINE__, __func__,
596 "Can't find function unit from machine: " +
597 term.fuTerm.part1);
598 }
599
600 assert(fu != NULL);
601
602 // find out port
603 if (!fu->hasPort(term.fuTerm.part2)) {
604 throw IllegalMachine(
605 __FILE__, __LINE__, __func__,
606 "Can't find port: " +
607 term.fuTerm.part2);
608 }
609
610 Port* port = fu->port(term.fuTerm.part2);
611
612 std::string regString;
613
614 if (term.fuTerm.part3Used) {
615 // find out operand
616 if (!fu->hasOperation(term.fuTerm.part3)) {
617 throw IllegalMachine(
618 __FILE__, __LINE__, __func__,
619 "Operation " + term.fuTerm.part3 +
620 " is not found from fu: " +
621 term.fuTerm.part1);
622 }
623
624 HWOperation* oper = fu->operation(term.fuTerm.part3);
625
626 TTAMachine::FUPort* fuPort =
627 dynamic_cast<TTAMachine::FUPort*>(port);
628
629 try {
630 regString =
631 term.fuTerm.part3 + "." +
632 Conversion::toString(oper->io(*fuPort));
633
634 } catch (InstanceNotFound& e) {
635
636 throw IllegalMachine(
637 __FILE__, __LINE__, __func__,
638 "Operation " + term.fuTerm.part3 +
639 " is not bound to port: " +
640 term.fuTerm.part2);
641 }
642
643 } else {
644 // plain port reference
645 regString = term.fuTerm.part2;
646 }
647
648 newResID.width = port->width();
649 newResID.unit = functionUnitID(fu);
650 newResID.index = opOrPortID(regString, port);
651 newResID.type = MoveElement::MF_UNIT;
652
653 return newResID;
654}
static std::string toString(const T &source)
std::string part3
Operation name.
std::string part2
Port name.
std::string part1
Unit name.
bool part3Used
Is operation part of the term used.
UValue functionUnitID(TTAMachine::FunctionUnit *unit)
UValue opOrPortID(std::string opOrPortString, const TTAMachine::Port *port)
FUTerm fuTerm
The fu term, if type field is FUNCTION_UNIT. Otherwise not used.
@ MF_UNIT
Function unit.
virtual HWOperation * operation(const std::string &name) const
virtual bool hasOperation(const std::string &name) const
virtual BaseFUPort * port(const std::string &name) const
int io(const FUPort &port) const
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition Machine.cc:380
virtual int width() const =0
virtual bool hasPort(const std::string &name) const
Definition Unit.cc:96

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(), TPEF::MoveElement::MF_UNIT, 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, MachineResourceManager::ResourceID::width, and TTAMachine::Port::width().

Referenced by resourceID().

Here is the call graph for this function:

◆ indexResource()

MachineResourceManager::ResourceID MachineResourceManager::indexResource ( UValue  currentLine,
const RegisterTerm term,
UValue  slotNumber,
RequestType  type,
std::string &  resourceKeyString 
)
private

Finds resource for fu.operation.index, rf.index or rf.port.index term.

Helper method for resourceID method.

Parameters
currentLineLine number information for warning messages.
termRequested term.
slotNumberNumber of move slot, that was used.
typeRequest type.
resourceKeyStringResource key string for error messages.
Returns
TPEF resource information of requested term.
Exceptions
IllegalMachineThere was problems finding resource from ADF.

Definition at line 670 of file MachineResourceManager.cc.

672 {
673 ResourceID newResID;
674
677
680
683
684 BaseRegisterFile* rf = NULL;
685 FunctionUnit* fu = NULL;
686
687 if (immNavi.hasItem(term.indexTerm.part1)) {
688 rf = immNavi.item(term.indexTerm.part1);
689 }
690
691 // If the a unit is found in both immediate unit and register file
692 // navigators, the unit from the register file navigator is selected
693 // and a warning is displayed.
694 if (rfNavi.hasItem(term.indexTerm.part1)) {
695 if (rf != NULL) {
696 std::string warning = "Unit name '";
697 warning += term.indexTerm.part1;
698 warning += "' is ambiguous. Because of disambiguity rules, '";
699 warning += term.indexTerm.part1;
700 warning += "' is selected to refer the register file insread of";
701 warning += " the immediate unit.";
702 parent_->addWarning(currentLine, warning);
703 }
704 rf = rfNavi.item(term.indexTerm.part1);
705 }
706
707 // if normal fu or gcu...
708 if (fuNavi.hasItem(term.indexTerm.part1)) {
709 fu = fuNavi.item(term.indexTerm.part1);
710 } else {
711 // NOTE: GCU isn't found by name with FunctionUnitNavigator,
712 // but it must be requested explicitely
713 fu = adf_.controlUnit();
714 if (fu->name() != term.indexTerm.part1) {
715 fu = NULL;
716 }
717 }
718
719 if (term.indexTerm.part2Used) {
720 if (rf != NULL && fu != NULL) {
721 std::string warning = "Unit name '";
722 warning += term.indexTerm.part1;
723 warning += "' is ambiguous.";
724 parent_->addWarning(currentLine, warning);
725 }
726 // rf.port.index or fu.operation.index reference
727 newResID = rFPortOrFUIndexReference(
728 fu, rf, currentLine, term, slotNumber, type, resourceKeyString);
729
730 } else {
731 // this must be rf.index reference
733 rf, term, slotNumber, type, resourceKeyString);
734 }
735
736 return newResID;
737}
void addWarning(UValue lineNumber, const std::string &message)
std::string part1
Unit name.
bool part2Used
Is port name used.
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)
IndexTerm indexTerm
The index term, if type field is INDEX. Otherwise not used.
virtual RegisterFileNavigator registerFileNavigator() const
Definition Machine.cc:450
virtual ImmediateUnitNavigator immediateUnitNavigator() const
Definition Machine.cc:416

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().

Here is the call graph for this function:

◆ initResourceSection()

void MachineResourceManager::initResourceSection ( )
private

Initialises resource section if its not initialised already.

Definition at line 382 of file MachineResourceManager.cc.

382 {
383 // init resource section if needed and add new resource element.
384 if (resourceSection_ == NULL) {
385 resourceSection_ = dynamic_cast<ResourceSection*>(
387
388 assert(resourceSection_ != NULL);
389
393
394 // add all busses at once
396
397 for (int i = 0; i < busNavi.count(); i++) {
398 Bus* bus = busNavi.item(i);
399
400 ResourceElement* newRes = new ResourceElement();
401
402 newRes->setId(i + 1);
404 newRes->setName(stringToChunk(bus->name()));
405
407 }
408
410 }
411}
void addSection(Section *section)
@ MRT_BUS
Transport bus.
static Section * createSection(SectionType type)
Definition Section.cc:91
@ ST_MR
Machine resources section.
Definition Section.hh:78
void setLink(const ReferenceManager::SafePointer *aLink)
void setASpace(const ReferenceManager::SafePointer *addrSpace)
void setName(const ReferenceManager::SafePointer *sectionName)

References TPEF::Section::addElement(), TPEF::Binary::addSection(), adf_, assert, TTAMachine::Machine::busNavigator(), TTAMachine::Machine::Navigator< ComponentType >::count(), TPEF::Section::createSection(), TTAMachine::Machine::Navigator< ComponentType >::item(), TPEF::ResourceElement::MRT_BUS, TTAMachine::Component::name(), resourceSection_, TPEF::Section::setASpace(), TPEF::ResourceElement::setId(), TPEF::Section::setLink(), TPEF::Section::setName(), TPEF::ResourceElement::setName(), TPEF::ResourceElement::setType(), TPEF::Section::ST_MR, strings_, stringToChunk(), tpef_, and undefinedAddressSpace().

Referenced by addResourceElement(), and resourceSection().

Here is the call graph for this function:

◆ nullSection()

Section * MachineResourceManager::nullSection ( )

Returns NullSection instance of TPEF.

Returns
NullSection instance of TPEF.

Definition at line 140 of file MachineResourceManager.cc.

140 {
141
142 if (nullSection_ == NULL) {
143
144 nullSection_ = dynamic_cast<NullSection*>(
146
147 assert(nullSection_ != NULL);
148
152
154 }
155
156 return nullSection_;
157}
@ ST_NULL
NULL Section.
Definition Section.hh:70

References TPEF::Binary::addSection(), assert, TPEF::Section::createSection(), nullSection_, TPEF::Section::setASpace(), TPEF::Section::setLink(), TPEF::Section::setName(), TPEF::Section::ST_NULL, stringToChunk(), tpef_, and undefinedAddressSpace().

Referenced by stringToChunk().

Here is the call graph for this function:

◆ opOrPortID()

UValue MachineResourceManager::opOrPortID ( std::string  opOrPortString,
const TTAMachine::Port port 
)
private

Returns TPEF resource ID of operand or port.

If resource is not already in TPEF method creates resource and adds it.

Parameters
opPortStringTPEF resource string of port or operand.
portPort that is connected with requested resource in ADF.
Returns
TPEF resource ID of port or operand.

Definition at line 518 of file MachineResourceManager.cc.

519 {
520
521 if (!MapTools::containsKey(opOrPortIDs_, opOrPortString)) {
522 // create resource element and add its unit id to map
524 UValue generatedID = lastOpOrSpecRegisterID_;
525
526 ResourceElement* newRes = new ResourceElement();
527
528 // check if string is port or operand by string format
529 if (opOrPortString.find('.') == std::string::npos) {
530
531 if (dynamic_cast<const SpecialRegisterPort*>(port) != NULL) {
533 } else {
535 }
536
537 } else {
539 }
540
541 newRes->setName(stringToChunk(opOrPortString));
542 newRes->setId(generatedID);
543 addResourceElement(newRes);
544 opOrPortIDs_[opOrPortString] = generatedID;
545 }
546
547 return opOrPortIDs_[opOrPortString];
548}
unsigned long UValue
std::map< std::string, UValue > opOrPortIDs_
Bookkeeping of already added ports, operations and special registers.
@ MRT_SR
Special register.
@ MRT_PORT
Function unit port.
@ MRT_OP
Operation operand or function unit register.

References addResourceElement(), MapTools::containsKey(), lastOpOrSpecRegisterID_, TPEF::ResourceElement::MRT_OP, TPEF::ResourceElement::MRT_PORT, TPEF::ResourceElement::MRT_SR, opOrPortIDs_, TPEF::ResourceElement::setId(), TPEF::ResourceElement::setName(), TPEF::ResourceElement::setType(), and stringToChunk().

Referenced by functionUnitPortResource(), and rFPortOrFUIndexReference().

Here is the call graph for this function:

◆ registerFileID()

UValue MachineResourceManager::registerFileID ( TTAMachine::BaseRegisterFile rf)
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.

Parameters
rfA register file.
Returns
TPEF resource ID of the register file.

Definition at line 480 of file MachineResourceManager.cc.

480 {
481
483 // create resource element and add its unit id to map
485
486 ResourceElement* newRes = new ResourceElement();
487
488 newRes->setId(lastRegisterFileID_);
489
490 if (dynamic_cast<ImmediateUnit*>(rf) == NULL) {
492 } else {
494 }
495
496 newRes->setName(stringToChunk(rf->name()));
497 addResourceElement(newRes);
498
500 }
501
503
504 return registerFileIDs_[rf];
505}
std::map< TTAMachine::BaseRegisterFile *, UValue > registerFileIDs_
Bookkeeping of already added register files.
@ MRT_IMM
Immediate unit.

References addResourceElement(), assert, MapTools::containsKey(), lastRegisterFileID_, TPEF::ResourceElement::MRT_IMM, TPEF::ResourceElement::MRT_RF, TTAMachine::Component::name(), registerFileIDs_, TPEF::ResourceElement::setId(), TPEF::ResourceElement::setName(), TPEF::ResourceElement::setType(), and stringToChunk().

Referenced by registerFileIndexReference(), and rFPortOrFUIndexReference().

Here is the call graph for this function:

◆ registerFileIndexReference()

MachineResourceManager::ResourceID MachineResourceManager::registerFileIndexReference ( TTAMachine::BaseRegisterFile rf,
const RegisterTerm term,
UValue  slotNumber,
RequestType  type,
std::string &  resourceKeyString 
)
private

Finds resource for rf.index term.

Helper method for indexResource method.

Parameters
rfRegister file of term.
termRequested term.
slotNumberNumber of move slot, that was used.
typeRequest type.
resourceKeyStringResource key string for error messages.
Returns
TPEF resource information of requested term.
Exceptions
IllegalMachineThere was problems finding resource from ADF.

Definition at line 983 of file MachineResourceManager.cc.

985 {
986 ResourceID newResID;
987 // this is normal rf reference unless register is immediate unit...
988 newResID.type = MoveElement::MF_RF;
989
990 if (rf == NULL) {
991 throw IllegalMachine(
992 __FILE__, __LINE__, __func__,
993 "Can't find connection for " + requestTypeString(type) +
994 " rf.index term: " + resourceKeyString);
995 }
996
997 // check that there is enough registers in file
998 if(static_cast<UValue>(rf->numberOfRegisters()) <= term.indexTerm.index) {
999
1000 throw IllegalMachine(
1001 __FILE__, __LINE__, __func__,
1002 "Not enough registers in registerfile.");
1003 }
1004
1005 // check defined if port can be used for current direction
1006 // and bus
1007 Bus* bus = adf_.busNavigator().item(slotNumber);
1008 bool isPossible = false;
1009
1010 switch (type) {
1011
1012 case RQST_READ:
1013 case RQST_WRITE: {
1014 ImmediateUnit* immUnit = dynamic_cast<ImmediateUnit*>(rf);
1015
1016 // Code section creator checks in the end if it's really possible...
1017 if (immUnit != NULL) {
1018 isPossible = true;
1019 newResID.type = MoveElement::MF_IMM;
1020 break;
1021 }
1022
1023 for (int i = 0; i < rf->portCount(); i++) {
1024 Port* port = rf->port(i);
1025
1026 Socket* sock =
1027 (type == RQST_WRITE) ?
1028 (port->inputSocket()) :
1029 (port->outputSocket());
1030
1031 if (sock != NULL && sock->isConnectedTo(*bus)) {
1032 isPossible = true;
1033 break;
1034 }
1035 }
1036
1037 } break;
1038
1039 case RQST_INVGUARD:
1040 case RQST_GUARD: {
1041 bool invertedRequested = (type == RQST_INVGUARD);
1042
1043 for (int i = 0; i < bus->guardCount(); i++) {
1044 RegisterGuard* guard =
1045 dynamic_cast<RegisterGuard*>(bus->guard(i));
1046
1047 if (guard != NULL) {
1048 if (guard->registerFile() == rf &&
1049 guard->registerIndex() ==
1050 static_cast<int>(term.indexTerm.index) &&
1051 guard->isInverted() == invertedRequested) {
1052
1053 isPossible = true;
1054 break;
1055 }
1056 }
1057 }
1058
1059 } break;
1060
1061 default:
1062 abortWithError("Unknown request type: " +
1063 Conversion::toString(type));
1064 }
1065
1066 if (isPossible) {
1067 newResID.width = rf->width();
1068 newResID.unit = registerFileID(rf);
1069 newResID.index = term.indexTerm.index;
1070
1071 } else {
1072 throw IllegalMachine(
1073 __FILE__, __LINE__, __func__,
1074 "Can't find connection for " + requestTypeString(type) +
1075 " term: " + resourceKeyString);
1076 }
1077
1078 return newResID;
1079}
#define abortWithError(message)
UValue index
Register or operand index.
std::string requestTypeString(RequestType type) const
UValue registerFileID(TTAMachine::BaseRegisterFile *rf)
@ MF_RF
Register file.
@ MF_IMM
Immediate.
virtual int numberOfRegisters() const
virtual int width() const
virtual RFPort * port(const std::string &name) const
Guard * guard(int index) const
Definition Bus.cc:456
int guardCount() const
Definition Bus.cc:441
virtual bool isInverted() const
virtual Socket * inputSocket() const
Definition Port.cc:261
virtual RegisterFile::Type type() const
const RegisterFile * registerFile() const
bool isConnectedTo(const Bus &bus) const
Definition Socket.cc:331
virtual int portCount() const
Definition Unit.cc:135

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(), TPEF::MoveElement::MF_IMM, TPEF::MoveElement::MF_RF, 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, MachineResourceManager::ResourceID::width, and TTAMachine::BaseRegisterFile::width().

Referenced by indexResource().

Here is the call graph for this function:

◆ requestTypeString()

std::string MachineResourceManager::requestTypeString ( RequestType  type) const
private

Returns debug string for request type for error message generation.

Parameters
typeRequest type.
Returns
Debug string for request type.

Definition at line 557 of file MachineResourceManager.cc.

557 {
558 switch (type) {
559 case RQST_READ: return "read";
560 case RQST_WRITE: return "write";
561 case RQST_GUARD: return "guard";
562 case RQST_INVGUARD: return "inverted guard";
563 default: return "invalid request type";
564 }
565}

References RQST_GUARD, RQST_INVGUARD, RQST_READ, and RQST_WRITE.

Referenced by registerFileIndexReference(), and rFPortOrFUIndexReference().

◆ resourceID()

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.

Parameters
currentLineline number where term is located in assembly code.
termTerm to resolve.
slotNumberNumber of move slot, that was used.
typeIs read, write or guard.
Returns
Information of Term's type, unit and index for instruction element.
Exceptions
IllegalMachineThere is problem to find or access the resource.

Definition at line 285 of file MachineResourceManager.cc.

287 {
288 // create resource key for reference
289 ResourceID newResID;
290
291 ResourceKey resKey;
292 resKey.slotNumber = slotNumber;
293 resKey.type = type;
294
295#if 0
296 // Valuable debug info (currently resolved term)
297 term.clear();
298 std::cerr << "\ttype: " << term.type << std::endl;
299#endif
300
301 // create key for requested resource
302 if (term.type == RegisterTerm::INDEX) {
303 resKey.keyString = term.indexTerm.part1;
304
305 if (term.indexTerm.part2Used) {
306 resKey.keyString += "." + term.indexTerm.part2;
307 }
308
309 resKey.keyString += "." + Conversion::toString(term.indexTerm.index);
310
311 } else if (term.type == RegisterTerm::FUNCTION_UNIT) {
312 resKey.keyString =
313 term.fuTerm.part1 + "." + term.fuTerm.part2;
314
315 if (term.fuTerm.part3Used) {
316 resKey.keyString += "." + term.fuTerm.part3;
317 }
318
319 } else if (term.type == RegisterTerm::BUS) {
320 if (term.busTerm.prev) {
321 resKey.keyString = "{prev}";
322 } else {
323 resKey.keyString = "{next}";
324 }
325
326 } else {
328 "Unknown term type." + Conversion::toString(term.type));
329 }
330
331 // check if resource is used before or do we have to
332 // retrieve it and add it to resource section
333 if (!MapTools::containsKey(resourceMap_, resKey)) {
334
335 if (term.type == RegisterTerm::INDEX) {
336 // check if rf[.port].index or fu.operation.index
337 newResID = indexResource(
338 currentLine, term, slotNumber, type, resKey.keyString);
339
340 } else if (term.type == RegisterTerm::FUNCTION_UNIT) {
341 // this is definately unit.port[.operation]
342 newResID = functionUnitPortResource(term);
343
344 } else if (term.type == RegisterTerm::BUS) {
345 abortWithError("{prev} and {next} might never be supported.");
346
347 } else {
348 assert(false);
349 }
350
351#if 0
352 // Very useful debugging information
353 std::cerr << "resKey: " << resKey.keyString
354 << "\ttype: " << resKey.type
355 << "\tslot:" << resKey.slotNumber
356 << std::endl;
357#endif
358 // copy to map
359 resourceMap_[resKey] = newResID;
360 }
361
362 // get resource id from map and give it away
364
365 return resourceMap_[resKey];
366}
bool prev
Previous or next bus register.
std::string part2
Port or operation name.
ResourceID functionUnitPortResource(const RegisterTerm &term)
ResourceID indexResource(UValue currentLine, const RegisterTerm &term, UValue slotNumber, RequestType type, std::string &resourceKeyString)
std::map< ResourceKey, ResourceID > resourceMap_
Bookkeeping for already requested resources.
@ BUS
Bus term.
@ FUNCTION_UNIT
FU term.
@ INDEX
Index term.
TermType type
Type of terminal that is represented by this object.
BusTerm busTerm
The bus term, if type field is BUS. Otherwise not used.

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().

Here is the call graph for this function:

◆ resourceSection()

ResourceSection * MachineResourceManager::resourceSection ( )

Returns the resource section of TPEF.

Returns
The resource section of TPEF.

Definition at line 373 of file MachineResourceManager.cc.

373 {
375 return resourceSection_;
376}

References initResourceSection(), and resourceSection_.

Referenced by CodeSectionCreator::finalize().

Here is the call graph for this function:

◆ rFPortOrFUIndexReference()

MachineResourceManager::ResourceID MachineResourceManager::rFPortOrFUIndexReference ( TTAMachine::FunctionUnit fu,
TTAMachine::BaseRegisterFile rf,
UValue  currentLine,
const RegisterTerm term,
UValue  slotNumber,
RequestType  type,
std::string &  resourceKeyString 
)
private

Finds resource for fu.operation.index or rf.port.index term.

Helper method for indexResource method.

Parameters
fuFunction unit of term, might be NULL.
rfRegister file of term, might be NULL.
currentLineLine number information for warning messages.
termRequested term.
slotNumberNumber of move slot, that was used.
typeRequest type.
resourceKeyStringResource key string for error messages.
Returns
TPEF resource information of requested term.
Exceptions
IllegalMachineThere was problems finding resource from ADF.

Definition at line 755 of file MachineResourceManager.cc.

758 {
759 ResourceID newResID;
760
761 // NOTE: disambiguation rule says that rf.port.index has higher
762 // priority than fu.operation.index ...
763 if (rf != NULL) {
764
765 // check defined if port can be used for current
766 // direction and bus
767 Bus* bus = NULL;
768 try {
769 bus = adf_.busNavigator().item(slotNumber);
770 } catch (OutOfRange &e) {
771 std::stringstream newErrorMsg;
772 newErrorMsg
773 << "Too few busses for all moves in instruction."
774 << std::endl;
775
776 IllegalMachine error(
777 __FILE__, __LINE__, __func__,
778 newErrorMsg.str() + e.errorMessage());
779 error.setCause(e);
780 throw error;
781 }
782 bool isPossible = false;
783
784 switch (type) {
785 case RQST_READ:
786 case RQST_WRITE: {
787 for (int i = 0; i < rf->portCount(); i++) {
788 Port* port = rf->port(i);
789
790 Socket* sock =
791 (type == RQST_WRITE) ?
792 (port->inputSocket()) :
793 (port->outputSocket());
794
795 if (sock != NULL && sock->isConnectedTo(*bus)) {
796 isPossible = true;
797
798 // we never store information that which port of RF
799 // was used for reading or writing, since TPEF doesn't
800 // support storing that data :(
801 if (port->name() != term.indexTerm.part2) {
802
804 currentLine,
805 "Selected different port for move"
806 "that was given by user.");
807 }
808
809 newResID.width = port->width();
810 break;
811 }
812 }
813
814 } break;
815
816 case RQST_INVGUARD:
817 case RQST_GUARD: {
818 bool isInverted =
819 (type == RQST_GUARD) ?
820 (false) : (true);
821
822 for (int i = 0; i < bus->guardCount(); i++) {
823 RegisterGuard* guard =
824 dynamic_cast<RegisterGuard*>(bus->guard(i));
825
826 if (guard != NULL) {
827 if (guard->registerFile() == rf &&
828 guard->registerIndex() ==
829 static_cast<int>(term.indexTerm.index) &&
830 guard->isInverted() == isInverted) {
831
832 isPossible = true;
833 break;
834 }
835 }
836 }
837
838 } break;
839
840 default:
841 abortWithError("Unknown request type: " +
843 }
844
845 // if request is possible
846 if (isPossible) {
847 newResID.unit = registerFileID(rf);
848 newResID.index = term.indexTerm.index;
849
850 if (dynamic_cast<ImmediateUnit*>(rf) == NULL) {
851 newResID.type = MoveElement::MF_RF;
852 } else {
853 newResID.type = MoveElement::MF_IMM;
854 }
855
856 } else {
857 rf = NULL;
858 }
859 }
860
861 if (rf == NULL && fu != NULL) {
862 // check if operation is found from fu
863 if (fu->hasOperation(term.indexTerm.part2)) {
864
865 // check that requested port is possible
866 HWOperation* oper =
867 fu->operation(term.indexTerm.part2);
868
869
870 Port* port = oper->port(term.indexTerm.index);
871
872 if (port == NULL) {
873 throw IllegalMachine(
874 __FILE__, __LINE__, __func__,
875 "Can't find operand: " +
876 term.indexTerm.part2 + "." +
878 }
879
880 Bus* bus = NULL;
881 try {
882 bus = adf_.busNavigator().item(slotNumber);
883 } catch (OutOfRange &e) {
884 std::stringstream newErrorMsg;
885 newErrorMsg
886 << "Too few busses for all moves in instruction."
887 << std::endl;
888
889 IllegalMachine error(
890 __FILE__, __LINE__, __func__,
891 newErrorMsg.str() + e.errorMessage());
892 error.setCause(e);
893 throw error;
894 }
895 bool isPossible = false;
896
897 switch (type) {
898 case RQST_WRITE:
899 case RQST_READ: {
900 Socket* sock =
901 (type == RQST_WRITE) ?
902 (port->inputSocket()) :
903 (port->outputSocket());
904
905 if (sock != NULL && sock->isConnectedTo(*bus)) {
906 isPossible = true;
907 break;
908 }
909 } break;
910
911 case RQST_GUARD:
912 case RQST_INVGUARD: {
913 bool isInverted =
914 (type == RQST_GUARD) ?
915 (false) : (true);
916
917 for (int i = 0; i < bus->guardCount(); i++) {
918 PortGuard* guard =
919 dynamic_cast<PortGuard*>(bus->guard(i));
920
921 if (guard != NULL) {
922 if (guard->port() == port &&
923 guard->isInverted() == isInverted) {
924
925 isPossible = true;
926 break;
927 }
928 }
929 }
930 } break;
931
932 default:
933 abortWithError("Unknown request type: " +
935 }
936
937 std::string operationRegisterStr =
938 term.indexTerm.part2 + "." +
940
941 if (isPossible) {
942 newResID.width = port->width();
943 newResID.unit = functionUnitID(fu);
944 newResID.index = opOrPortID(operationRegisterStr, port);
945 newResID.type = MoveElement::MF_UNIT;
946
947 } else {
948 fu = NULL;
949 }
950
951 } else {
952 throw IllegalMachine(
953 __FILE__, __LINE__, __func__,
954 "Can't find operation: " + term.indexTerm.part2);
955 }
956 }
957
958 // if both tests failed
959 if (rf == NULL && fu == NULL) {
960 throw IllegalMachine(
961 __FILE__, __LINE__, __func__,
962 "Can't find connection for " + requestTypeString(type) +
963 "fu term: " + resourceKeyString);
964 }
965
966 return newResID;
967}
std::string errorMessage() const
Definition Exception.cc:123
virtual FUPort * port(int operand) const
FUPort * port() const
virtual std::string name() const
Definition Port.cc:141

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(), TPEF::MoveElement::MF_IMM, TPEF::MoveElement::MF_RF, TPEF::MoveElement::MF_UNIT, TTAMachine::Port::name(), TTAMachine::FunctionUnit::operation(), opOrPortID(), TTAMachine::Port::outputSocket(), parent_, IndexTerm::part2, TTAMachine::PortGuard::port(), TTAMachine::BaseRegisterFile::port(), TTAMachine::HWOperation::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, MachineResourceManager::ResourceID::width, and TTAMachine::Port::width().

Referenced by indexResource().

Here is the call graph for this function:

◆ stringSection()

StringSection * MachineResourceManager::stringSection ( )

Returns string table of TPEF.

Returns
String table of TPEF.

Definition at line 166 of file MachineResourceManager.cc.

166 {
167 // makes sure that strings section is initialized
169 return strings_;
170}

References strings_, and undefinedAddressSpace().

Referenced by LabelManager::finalize().

Here is the call graph for this function:

◆ stringToChunk()

Chunk * MachineResourceManager::stringToChunk ( const std::string  aStr)

Finds or adds string to TPEF string section and returns chunk pointing to it.

Parameters
aStrString whose chunk is needed.
Returns
Chunk pointing to string stored in TPEF.

Definition at line 249 of file MachineResourceManager.cc.

249 {
250
251 if (strings_ == NULL) {
252 strings_ = dynamic_cast<StringSection*>(
254
255 // first byte must be zero
256 strings_->addByte(0);
257
260
261 // start zero of string section must be added befor this, since
262 // undefined address space calls this function to get chunk(0)
265 }
266
267 return strings_->string2Chunk(aStr);
268}
void setStrings(StringSection *strTable)
virtual void addByte(Byte aByte)
@ ST_STRTAB
String table.
Definition Section.hh:71
Chunk * string2Chunk(const std::string &str)

References TPEF::DataSection::addByte(), TPEF::Binary::addSection(), TPEF::Section::createSection(), nullSection(), TPEF::Section::setASpace(), TPEF::Section::setLink(), TPEF::Binary::setStrings(), TPEF::Section::ST_STRTAB, TPEF::StringSection::string2Chunk(), strings_, tpef_, and undefinedAddressSpace().

Referenced by codeAddressSpace(), CodeSectionCreator::finalize(), DataSectionCreator::finalize(), findDataAddressSpace(), functionUnitID(), initResourceSection(), nullSection(), opOrPortID(), registerFileID(), and undefinedAddressSpace().

Here is the call graph for this function:

◆ undefinedAddressSpace()

ASpaceElement * MachineResourceManager::undefinedAddressSpace ( )

Returns undefined address space element.

Returns
undefined address space element.

Definition at line 179 of file MachineResourceManager.cc.

179 {
180
181 // create address space section when needed
182 if (aSpaceSection_ == NULL) {
183
184 // create address space section with undefined address space element
186 dynamic_cast<ASpaceSection*>(
188
189 assert(aSpaceSection_ != NULL);
190
193
198
201 }
202
203 return undefASpace_;
204}
void setUndefinedASpace(ASpaceElement *aSpace)
@ ST_ADDRSP
Address space section.
Definition Section.hh:77

References TPEF::Section::addElement(), TPEF::Binary::addSection(), aSpaceSection_, assert, TPEF::Section::createSection(), TPEF::Section::setASpace(), TPEF::Section::setLink(), TPEF::ASpaceElement::setName(), TPEF::Section::setName(), TPEF::ASpaceSection::setUndefinedASpace(), TPEF::Section::ST_ADDRSP, strings_, stringToChunk(), tpef_, undefASpace_, and undefinedAddressSpace().

Referenced by codeAddressSpace(), LabelManager::finalize(), findDataAddressSpace(), LabelManager::findOrCreateRelocationSection(), initResourceSection(), nullSection(), stringSection(), stringToChunk(), and undefinedAddressSpace().

Here is the call graph for this function:

Member Data Documentation

◆ addressSpaces_

std::map<std::string, TPEF::ASpaceElement*> MachineResourceManager::addressSpaces_
private

Bookkeeping for already requested address spaces.

Definition at line 216 of file MachineResourceManager.hh.

Referenced by codeAddressSpace(), and findDataAddressSpace().

◆ adf_

const TTAMachine::Machine& MachineResourceManager::adf_
private

◆ aSpaceSection_

TPEF::ASpaceSection* MachineResourceManager::aSpaceSection_
private

The address space section of TPEF.

Definition at line 205 of file MachineResourceManager.hh.

Referenced by codeAddressSpace(), findDataAddressSpace(), and undefinedAddressSpace().

◆ codeASpace_

TPEF::ASpaceElement* MachineResourceManager::codeASpace_
private

The instruction address space element of TPEF.

Definition at line 214 of file MachineResourceManager.hh.

Referenced by codeAddressSpace().

◆ functionUnitIDs_

std::map<TTAMachine::FunctionUnit*, UValue> MachineResourceManager::functionUnitIDs_
private

Bookkeeping of already added function units.

Definition at line 229 of file MachineResourceManager.hh.

Referenced by functionUnitID().

◆ lastFunctionUnitID_

UValue MachineResourceManager::lastFunctionUnitID_
private

For generating function unit resource ids.

Definition at line 227 of file MachineResourceManager.hh.

Referenced by functionUnitID().

◆ lastOpOrSpecRegisterID_

UValue MachineResourceManager::lastOpOrSpecRegisterID_
private

For generating shared ids for ports, operations or special registers.

Definition at line 237 of file MachineResourceManager.hh.

Referenced by opOrPortID().

◆ lastRegisterFileID_

UValue MachineResourceManager::lastRegisterFileID_
private

For generating register file resource ids.

Definition at line 232 of file MachineResourceManager.hh.

Referenced by registerFileID().

◆ nullSection_

TPEF::NullSection* MachineResourceManager::nullSection_
private

The null section of TPEF.

Definition at line 219 of file MachineResourceManager.hh.

Referenced by nullSection().

◆ opOrPortIDs_

std::map<std::string, UValue> MachineResourceManager::opOrPortIDs_
private

Bookkeeping of already added ports, operations and special registers.

Definition at line 239 of file MachineResourceManager.hh.

Referenced by opOrPortID().

◆ parent_

AssemblyParserDiagnostic* MachineResourceManager::parent_
private

Assembler root class for adding warnings.

Definition at line 242 of file MachineResourceManager.hh.

Referenced by indexResource(), and rFPortOrFUIndexReference().

◆ registerFileIDs_

std::map<TTAMachine::BaseRegisterFile*, UValue> MachineResourceManager::registerFileIDs_
private

Bookkeeping of already added register files.

Definition at line 234 of file MachineResourceManager.hh.

Referenced by registerFileID().

◆ resourceMap_

std::map<ResourceKey, ResourceID> MachineResourceManager::resourceMap_
private

Bookkeeping for already requested resources.

Definition at line 224 of file MachineResourceManager.hh.

Referenced by resourceID().

◆ resourceSection_

TPEF::ResourceSection* MachineResourceManager::resourceSection_
private

The resource section of TPEF.

Definition at line 222 of file MachineResourceManager.hh.

Referenced by addResourceElement(), initResourceSection(), and resourceSection().

◆ strings_

TPEF::StringSection* MachineResourceManager::strings_
private

◆ tpef_

TPEF::Binary& MachineResourceManager::tpef_
private

Binary where all used resources are added.

Definition at line 199 of file MachineResourceManager.hh.

Referenced by initResourceSection(), nullSection(), stringToChunk(), and undefinedAddressSpace().

◆ undefASpace_

TPEF::ASpaceElement* MachineResourceManager::undefASpace_
private

The undefined address space element of TPEF.

Definition at line 211 of file MachineResourceManager.hh.

Referenced by undefinedAddressSpace().


The documentation for this class was generated from the following files: