Go to the documentation of this file.
67 tpef_(tpef), adf_(adf), aSpaceSection_(NULL), strings_(NULL),
68 undefASpace_(NULL), codeASpace_(NULL), nullSection_(NULL),
69 resourceSection_(NULL), lastFunctionUnitID_(0), lastRegisterFileID_(0),
70 lastOpOrSpecRegisterID_(0), parent_(parent) {
95 "ADF doesn't contain address space: " + name);
102 assert(adfAddressSpace != NULL);
115 "Method can't be used for getting code address space.");
145 Section::createSection(Section::ST_NULL));
187 Section::createSection(Section::ST_ADDRSP));
222 if (adfAddressSpace == NULL) {
225 "Control unit has no address space.");
253 Section::createSection(Section::ST_STRTAB));
298 std::cerr <<
"\ttype: " << term.
type << std::endl;
338 currentLine, term, slotNumber, type, resKey.
keyString);
353 std::cerr <<
"resKey: " << resKey.
keyString
354 <<
"\ttype: " << resKey.
type
386 Section::createSection(Section::ST_MR));
397 for (
int i = 0; i < busNavi.
count(); i++) {
402 newRes->
setId(i + 1);
403 newRes->
setType(ResourceElement::MRT_BUS);
425 std::cerr <<
"Added resource element: "
427 <<
"\t" << (int)resource->
type()
428 <<
"\t" << (int)resource->
id()
455 newRes->
setType(ResourceElement::MRT_UNIT);
491 newRes->
setType(ResourceElement::MRT_RF);
493 newRes->
setType(ResourceElement::MRT_IMM);
529 if (opOrPortString.find(
'.') == std::string::npos) {
532 newRes->
setType(ResourceElement::MRT_SR);
534 newRes->
setType(ResourceElement::MRT_PORT);
538 newRes->
setType(ResourceElement::MRT_OP);
542 newRes->
setId(generatedID);
563 default:
return "invalid request type";
596 "Can't find function unit from machine: " +
606 "Can't find port: " +
612 std::string regString;
620 " is not found from fu: " +
639 " is not bound to port: " +
651 newResID.
type = MoveElement::MF_UNIT;
672 RequestType type, std::string& resourceKeyString) {
696 std::string warning =
"Unit name '";
698 warning +=
"' is ambiguous. Because of disambiguity rules, '";
700 warning +=
"' is selected to refer the register file insread of";
701 warning +=
" the immediate unit.";
720 if (rf != NULL && fu != NULL) {
721 std::string warning =
"Unit name '";
723 warning +=
"' is ambiguous.";
728 fu, rf, currentLine, term, slotNumber, type, resourceKeyString);
733 rf, term, slotNumber, type, resourceKeyString);
758 std::string& resourceKeyString) {
771 std::stringstream newErrorMsg;
773 <<
"Too few busses for all moves in instruction."
782 bool isPossible =
false;
787 for (
int i = 0; i < rf->
portCount(); i++) {
805 "Selected different port for move"
806 "that was given by user.");
851 newResID.
type = MoveElement::MF_RF;
853 newResID.
type = MoveElement::MF_IMM;
861 if (rf == NULL && fu != NULL) {
875 "Can't find operand: " +
884 std::stringstream newErrorMsg;
886 <<
"Too few busses for all moves in instruction."
895 bool isPossible =
false;
922 if (guard->
port() == port &&
937 std::string operationRegisterStr =
945 newResID.
type = MoveElement::MF_UNIT;
959 if (rf == NULL && fu == NULL) {
963 "fu term: " + resourceKeyString);
985 RequestType type, std::string& resourceKeyString) {
988 newResID.
type = MoveElement::MF_RF;
994 " rf.index term: " + resourceKeyString);
1002 "Not enough registers in registerfile.");
1008 bool isPossible =
false;
1017 if (immUnit != NULL) {
1019 newResID.
type = MoveElement::MF_IMM;
1023 for (
int i = 0; i < rf->
portCount(); i++) {
1043 for (
int i = 0; i < bus->
guardCount(); i++) {
1047 if (guard != NULL) {
1075 " term: " + resourceKeyString);
virtual Socket * inputSocket() const
TPEF::Chunk * stringToChunk(const std::string aStr)
std::string requestTypeString(RequestType type) const
std::string part2
Port name.
bool part3Used
Is operation part of the term used.
virtual TCEString name() const
std::map< std::string, UValue > opOrPortIDs_
Bookkeeping of already added ports, operations and special registers.
TPEF::NullSection * nullSection_
The null section of TPEF.
TPEF::ASpaceElement * codeASpace_
The instruction address space element of TPEF.
UValue lastRegisterFileID_
For generating register file resource ids.
int registerIndex() const
UValue functionUnitID(TTAMachine::FunctionUnit *unit)
TPEF::ResourceSection * resourceSection()
bool prev
Previous or next bus register.
ResourceType type() const
virtual int width() const =0
UValue findBusWidth(UValue slotNumber)
UValue registerFileID(TTAMachine::BaseRegisterFile *rf)
const TTAMachine::Machine & adf_
Machine where manager tries to find used resources.
void addSection(Section *section)
void setCause(const Exception &cause)
BusTerm busTerm
The bus term, if type field is BUS. Otherwise not used.
TPEF::StringSection * stringSection()
virtual BaseFUPort * port(const std::string &name) const
virtual AddressSpace * addressSpace() const
std::string chunk2String(const Chunk *chunk) const
UValue index
TPEF Resource operand id or register file index.
@ RQST_READ
Register of port for reading.
virtual void addByte(Byte aByte)
TPEF::Section * nullSection()
static std::string toString(const T &source)
void setType(ResourceType aType)
std::string part2
Port or operation name.
MachineResourceManager(TPEF::Binary &tpef, const TTAMachine::Machine &adf, AssemblyParserDiagnostic *parent_)
AssemblyParserDiagnostic * parent_
Assembler root class for adding warnings.
virtual int numberOfRegisters() const
#define assert(condition)
std::string keyString
Key string for resource.
std::map< TTAMachine::FunctionUnit *, UValue > functionUnitIDs_
Bookkeeping of already added function units.
ResourceID indexResource(UValue currentLine, const RegisterTerm &term, UValue slotNumber, RequestType type, std::string &resourceKeyString)
virtual FUPort * port(int operand) const
virtual void addElement(SectionElement *element)
std::string part1
Unit name.
virtual ControlUnit * controlUnit() const
UValue index
Register or operand index.
int io(const FUPort &port) const
#define abortWithError(message)
TPEF::MoveElement::FieldType type
Resource type.
bool part2Used
Is port name used.
UValue width
Width of accessed port or other resource.
virtual ImmediateUnitNavigator immediateUnitNavigator() const
ResourceID rFPortOrFUIndexReference(TTAMachine::FunctionUnit *fu, TTAMachine::BaseRegisterFile *rf, UValue currentLine, const RegisterTerm &term, UValue slotNumber, RequestType type, std::string &resourceKeyString)
@ RQST_INVGUARD
Inverted register or port guard.
TermType type
Type of terminal that is represented by this object.
bool hasItem(const std::string &name) const
Chunk * string2Chunk(const std::string &str)
std::map< TTAMachine::BaseRegisterFile *, UValue > registerFileIDs_
Bookkeeping of already added register files.
ResourceID registerFileIndexReference(TTAMachine::BaseRegisterFile *rf, const RegisterTerm &term, UValue slotNumber, RequestType type, std::string &resourceKeyString)
virtual FunctionUnitNavigator functionUnitNavigator() const
TPEF::Binary & tpef_
Binary where all used resources are added.
RequestType type
Was resource read or written or was it guard.
virtual bool hasPort(const std::string &name) const
TPEF::StringSection * strings_
The string section of TPEF.
UValue lastOpOrSpecRegisterID_
For generating shared ids for ports, operations or special registers.
UValue opOrPortID(std::string opOrPortString, const TTAMachine::Port *port)
void initResourceSection()
virtual bool hasOperation(const std::string &name) const
virtual AddressSpaceNavigator addressSpaceNavigator() const
std::map< std::string, TPEF::ASpaceElement * > addressSpaces_
Bookkeeping for already requested address spaces.
bool isConnectedTo(const Bus &bus) const
void setName(const ReferenceManager::SafePointer *sectionName)
Guard * guard(int index) const
virtual int portCount() const
std::string errorMessage() const
TPEF::ASpaceElement * findDataAddressSpace(std::string name)
virtual int width() const
TPEF::ASpaceSection * aSpaceSection_
The address space section of TPEF.
UValue unit
TPEF Resource unit id.
virtual RFPort * port(const std::string &name) const
virtual RegisterFileNavigator registerFileNavigator() const
IndexTerm indexTerm
The index term, if type field is INDEX. Otherwise not used.
virtual bool isInverted() const
void setASpace(const ReferenceManager::SafePointer *addrSpace)
virtual std::string name() const
FUTerm fuTerm
The fu term, if type field is FUNCTION_UNIT. Otherwise not used.
@ RQST_GUARD
Register or port guard.
virtual BusNavigator busNavigator() const
ResourceID & resourceID(UValue currentLine, const RegisterTerm &term, UValue slotNumber, RequestType type)
void setLink(const ReferenceManager::SafePointer *aLink)
void setName(const ReferenceManager::SafePointer *aName)
virtual Socket * outputSocket() const
void setUndefinedASpace(ASpaceElement *aSpace)
std::map< ResourceKey, ResourceID > resourceMap_
Bookkeeping for already requested resources.
TPEF::ResourceSection * resourceSection_
The resource section of TPEF.
ResourceID functionUnitPortResource(const RegisterTerm &term)
ComponentType * item(int index) const
TPEF::ASpaceElement * undefinedAddressSpace()
virtual HWOperation * operation(const std::string &name) const
TPEF::ASpaceElement * codeAddressSpace()
virtual int width() const
void setStrings(StringSection *strTable)
void addWarning(UValue lineNumber, const std::string &message)
const RegisterFile * registerFile() const
UValue lastFunctionUnitID_
For generating function unit resource ids.
TPEF::ASpaceElement * undefASpace_
The undefined address space element of TPEF.
void setName(ReferenceManager::SafePointer *aName)
UValue slotNumber
Bus that was used.
void addResourceElement(TPEF::ResourceElement *resource)
std::string part1
Unit name.
@ RQST_WRITE
Register or port for writing.
std::string part3
Operation name.