OpenASIP
2.0
|
#include <ProgramWriter.hh>
Public Member Functions | |
TPEFResourceUpdater (TTAMachine::Machine &mach, TPEF::ResourceSection &resources) | |
void | clearCache () |
TPEF::ResourceElement & | bus (const TTAMachine::Bus &bus) |
TPEF::ResourceElement & | functionUnitPort (const TTAMachine::Port &port) |
TPEF::ResourceElement & | operand (const TTAMachine::HWOperation &oper, int operandIndex) |
TPEF::ResourceElement & | functionUnit (const TTAMachine::FunctionUnit &fu) |
TPEF::ResourceElement & | registerFile (const TTAMachine::RegisterFile &rf) |
TPEF::ResourceElement & | immediateUnit (const TTAMachine::ImmediateUnit &immUnit) |
Private Types | |
typedef std::pair< const TTAMachine::MachinePart *, int > | CacheKey |
typedef std::map< CacheKey, TPEF::ResourceElement * > | ResourceCache |
Mapping from parts of the target processor model to TPEF machine resource entries. More... | |
Private Member Functions | |
void | initCache () |
Private Attributes | |
TTAMachine::Machine & | mach_ |
The model of the target processor architecture. More... | |
TPEF::ResourceSection & | resources_ |
The TPEF input section that contains all machine resource entries. More... | |
ResourceCache | cache_ |
Aggregate of all mappings between machine resource entries and target processor parts (machine parts). More... | |
HalfWord | lastBusId_ |
Last TPEF bus id that was generated. More... | |
HalfWord | lastUnitPortId_ |
Last TPEF unit port id that was generated. More... | |
HalfWord | lastFunctionUnitId_ |
Last TPEF function unit id that was generated. More... | |
HalfWord | lastRegisterFileId_ |
Last TPEF register file id that was generated. More... | |
HalfWord | lastImmediateUnitId_ |
Last TPEF immediate unit id that was generated. More... | |
Returns requested Machine parts as a TPEF resources.
Also adds new resources to resource section if resource is not already there.
NOTE: If resource section is modified externally, cache should be cleared.
Definition at line 81 of file ProgramWriter.hh.
|
private |
Definition at line 109 of file ProgramWriter.hh.
|
private |
Mapping from parts of the target processor model to TPEF machine resource entries.
Definition at line 112 of file ProgramWriter.hh.
TTAProgram::TPEFResourceUpdater::TPEFResourceUpdater | ( | TTAMachine::Machine & | mach, |
TPEF::ResourceSection & | resources | ||
) |
Definition at line 151 of file ProgramWriter.cc.
References initCache().
ResourceElement & TTAProgram::TPEFResourceUpdater::bus | ( | const TTAMachine::Bus & | bus | ) |
Finds and creates ResourceElement for the bus given in parameter.
If resource id not already created to TPEF method creates it and adds CacheKey for it.
bus | Bus whose tpef resource is looked for. |
Definition at line 317 of file ProgramWriter.cc.
References abortWithError, TPEF::Section::addElement(), cache_, TPEF::StringSection::chunk2String(), MapTools::containsKey(), TPEF::ResourceElement::id(), lastBusId_, TPEF::Section::link(), TPEF::ResourceElement::name(), resources_, TPEF::ResourceElement::setId(), TPEF::ResourceElement::setName(), TPEF::ResourceElement::setType(), TPEF::StringSection::string2Chunk(), TPEF::ResourceElement::type(), and UniversalMachine::universalBus().
Referenced by TTAProgram::ProgramWriter::createCodeSection(), and initCache().
void TTAProgram::TPEFResourceUpdater::clearCache | ( | ) |
Clears the temporary variables and reinits the cache.
Definition at line 296 of file ProgramWriter.cc.
References cache_, initCache(), lastBusId_, lastFunctionUnitId_, lastImmediateUnitId_, lastRegisterFileId_, and lastUnitPortId_.
ResourceElement & TTAProgram::TPEFResourceUpdater::functionUnit | ( | const TTAMachine::FunctionUnit & | fu | ) |
Finds and creates ResourceElement for a fu given in parameter.
If resource id not already created to TPEF method creates it and adds CacheKey for it.
fu | Function unit whose TPEF resource is looked for. |
Definition at line 512 of file ProgramWriter.cc.
References abortWithError, TPEF::Section::addElement(), cache_, TPEF::StringSection::chunk2String(), MapTools::containsKey(), TTAMachine::Machine::controlUnit(), TPEF::ResourceElement::id(), lastFunctionUnitId_, TPEF::Section::link(), TTAMachine::Component::machine(), TPEF::ResourceElement::name(), TTAMachine::Component::name(), resources_, TPEF::ResourceElement::setId(), TPEF::ResourceElement::setName(), TPEF::ResourceElement::setType(), TPEF::StringSection::string2Chunk(), TPEF::ResourceElement::type(), and UniversalMachine::universalFunctionUnit().
Referenced by TTAProgram::ProgramWriter::createCodeSection(), and TTAProgram::ProgramWriter::terminalResource().
ResourceElement & TTAProgram::TPEFResourceUpdater::functionUnitPort | ( | const TTAMachine::Port & | port | ) |
Finds and creates ResourceElement for a fu port given in parameter.
If resource id not already created to TPEF method creates it and adds CacheKey for it.
port | Port whose tpef resource is looked for. |
Definition at line 373 of file ProgramWriter.cc.
References abortWithError, TPEF::Section::addElement(), assert, cache_, TPEF::StringSection::chunk2String(), MapTools::containsKey(), TTAMachine::Machine::controlUnit(), TTAMachine::ControlUnit::hasReturnAddressPort(), TPEF::ResourceElement::id(), lastUnitPortId_, TPEF::Section::link(), TTAMachine::Component::machine(), TTAMachine::Port::name(), TPEF::ResourceElement::name(), TTAMachine::Port::parentUnit(), resources_, TTAMachine::ControlUnit::returnAddressPort(), TPEF::ResourceElement::setId(), TPEF::ResourceElement::setName(), TPEF::ResourceElement::setType(), TPEF::StringSection::string2Chunk(), and TPEF::ResourceElement::type().
Referenced by TTAProgram::ProgramWriter::createCodeSection(), and TTAProgram::ProgramWriter::terminalResource().
ResourceElement & TTAProgram::TPEFResourceUpdater::immediateUnit | ( | const TTAMachine::ImmediateUnit & | immUnit | ) |
Find and return the TPEF machine resource entry that corresponds to a given immediate unit of the target processor.
If no machine resource entry exists for the given unit, it is created, cached into the resource updater and added to the TPEF machine resource section.
immUnit | An immediate unit of the target processor. |
Definition at line 646 of file ProgramWriter.cc.
References TPEF::Section::addElement(), cache_, TPEF::StringSection::chunk2String(), MapTools::containsKey(), TPEF::ResourceElement::id(), lastImmediateUnitId_, TPEF::Section::link(), TPEF::ResourceElement::name(), TTAMachine::Component::name(), resources_, TPEF::ResourceElement::setId(), TPEF::ResourceElement::setName(), TPEF::ResourceElement::setType(), TPEF::StringSection::string2Chunk(), and TPEF::ResourceElement::type().
Referenced by TTAProgram::ProgramWriter::terminalResource().
|
private |
Initialises resource updater cache, for finding TPEF resources by machine resources.
This also checks already created TPEF resources to prevent multiple creation of the same ResourceElement.
Definition at line 169 of file ProgramWriter.cc.
References abortWithError, assert, bus(), TTAMachine::Machine::busNavigator(), cache_, TPEF::StringSection::chunk2String(), TPEF::Section::element(), TPEF::Section::elementCount(), TTAMachine::Machine::functionUnitNavigator(), TTAMachine::FunctionUnit::hasOperation(), TTAMachine::Unit::hasPort(), TPEF::ResourceElement::id(), TTAMachine::Machine::immediateUnitNavigator(), lastFunctionUnitId_, lastImmediateUnitId_, lastRegisterFileId_, lastUnitPortId_, TPEF::Section::link(), mach_, TPEF::ResourceElement::name(), TTAMachine::FunctionUnit::operation(), TTAMachine::FunctionUnit::port(), TTAMachine::Machine::registerFileNavigator(), resources_, Conversion::toInt(), and TPEF::ResourceElement::type().
Referenced by clearCache(), and TPEFResourceUpdater().
ResourceElement & TTAProgram::TPEFResourceUpdater::operand | ( | const TTAMachine::HWOperation & | oper, |
int | operandIndex | ||
) |
Finds and creates ResourceElement for a fu operand given in parameter.
If resource id not already created to TPEF method creates it and adds CacheKey for it.
oper | Operation whose TPEF resource is looked for. |
operandIndex | Index of the operand of operation. |
Definition at line 464 of file ProgramWriter.cc.
References abortWithError, TPEF::Section::addElement(), cache_, TPEF::StringSection::chunk2String(), MapTools::containsKey(), TTAMachine::FunctionUnit::hasOperation(), TPEF::ResourceElement::id(), lastUnitPortId_, TPEF::Section::link(), TTAMachine::HWOperation::name(), TPEF::ResourceElement::name(), TTAMachine::Component::name(), TTAMachine::FunctionUnit::operation(), TTAMachine::HWOperation::parentUnit(), resources_, TPEF::ResourceElement::setId(), TPEF::ResourceElement::setName(), TPEF::ResourceElement::setType(), TPEF::StringSection::string2Chunk(), Conversion::toString(), and TPEF::ResourceElement::type().
Referenced by TTAProgram::ProgramWriter::createCodeSection(), and TTAProgram::ProgramWriter::terminalResource().
ResourceElement & TTAProgram::TPEFResourceUpdater::registerFile | ( | const TTAMachine::RegisterFile & | rf | ) |
Finds and creates ResourceElement for a rf given in parameter.
If resource id not already created to TPEF method creates it and adds CacheKey for it.
rf | Register file whose TPEF resource is looked for. |
Definition at line 586 of file ProgramWriter.cc.
References abortWithError, TPEF::Section::addElement(), UniversalMachine::booleanRegisterFile(), cache_, TPEF::StringSection::chunk2String(), MapTools::containsKey(), UniversalMachine::doubleRegisterFile(), TPEF::ResourceElement::id(), UniversalMachine::integerRegisterFile(), lastRegisterFileId_, TPEF::Section::link(), TTAMachine::Component::machine(), TPEF::ResourceElement::name(), TTAMachine::Component::name(), resources_, TPEF::ResourceElement::setId(), TPEF::ResourceElement::setName(), TPEF::ResourceElement::setType(), TPEF::StringSection::string2Chunk(), and TPEF::ResourceElement::type().
Referenced by TTAProgram::ProgramWriter::createCodeSection(), and TTAProgram::ProgramWriter::terminalResource().
|
private |
Aggregate of all mappings between machine resource entries and target processor parts (machine parts).
Definition at line 116 of file ProgramWriter.hh.
Referenced by bus(), clearCache(), functionUnit(), functionUnitPort(), immediateUnit(), initCache(), operand(), and registerFile().
|
private |
Last TPEF bus id that was generated.
Definition at line 119 of file ProgramWriter.hh.
Referenced by bus(), and clearCache().
|
private |
Last TPEF function unit id that was generated.
Definition at line 123 of file ProgramWriter.hh.
Referenced by clearCache(), functionUnit(), and initCache().
|
private |
Last TPEF immediate unit id that was generated.
Definition at line 127 of file ProgramWriter.hh.
Referenced by clearCache(), immediateUnit(), and initCache().
|
private |
Last TPEF register file id that was generated.
Definition at line 125 of file ProgramWriter.hh.
Referenced by clearCache(), initCache(), and registerFile().
|
private |
Last TPEF unit port id that was generated.
Definition at line 121 of file ProgramWriter.hh.
Referenced by clearCache(), functionUnitPort(), initCache(), and operand().
|
private |
The model of the target processor architecture.
Definition at line 103 of file ProgramWriter.hh.
Referenced by initCache().
|
private |
The TPEF input section that contains all machine resource entries.
Definition at line 105 of file ProgramWriter.hh.
Referenced by bus(), functionUnit(), functionUnitPort(), immediateUnit(), initCache(), operand(), and registerFile().