OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
TTAProgram::TerminalFUPort Class Reference

#include <TerminalFUPort.hh>

Inheritance diagram for TTAProgram::TerminalFUPort:
Inheritance graph
Collaboration diagram for TTAProgram::TerminalFUPort:
Collaboration graph

Public Member Functions

 TerminalFUPort (const TTAMachine::FUPort &opcodeSettingPort, const TTAMachine::HWOperation &opcode)
 
 TerminalFUPort (const TTAMachine::BaseFUPort &port)
 
 TerminalFUPort (const TTAMachine::HWOperation &operation, int opIndex)
 
virtual ~TerminalFUPort ()
 
virtual bool isOpcodeSetting () const
 
virtual bool isTriggering () const
 
virtual bool isFUPort () const
 
virtual bool isRA () const
 
virtual const TTAMachine::FunctionUnitfunctionUnit () const
 
virtual Operationoperation () const
 
virtual OperationhintOperation () const
 
virtual void setOperation (const TTAMachine::HWOperation &hwOp)
 
void setHintOperation (const char *name)
 
virtual int operationIndex () const
 
virtual void setOperationIndex (int index)
 
virtual const TTAMachine::Portport () const
 
virtual Terminalcopy () const
 
virtual bool equals (const Terminal &other) const
 
virtual const TTAMachine::HWOperationhwOperation () const
 
bool hasProgramOperation () const
 these methods are used to group terminals belonging to a single program operation invocation
 
void setProgramOperation (ProgramOperationPtr po)
 
ProgramOperationPtr programOperation () const
 
virtual TCEString toString () const
 
- Public Member Functions inherited from TTAProgram::Terminal
 Terminal ()
 
virtual ~Terminal ()
 
virtual bool isImmediate () const
 
virtual bool isAddress () const
 
virtual bool isInstructionAddress () const
 
virtual bool isImmediateRegister () const
 
virtual bool isGPR () const
 
virtual bool isBasicBlockReference () const
 
virtual bool isProgramOperationReference () const
 
virtual bool isCodeSymbolReference () const
 
virtual bool isUniversalMachineRegister () const
 
virtual SimValue value () const
 
virtual Address address () const
 
virtual const InstructionReferenceinstructionReference () const
 
virtual InstructionReferenceinstructionReference ()
 
virtual const TTAMachine::RegisterFileregisterFile () const
 
virtual const TTAMachine::ImmediateUnitimmediateUnit () const
 
virtual const BasicBlockbasicBlock () const
 
virtual int index () const
 
virtual void setIndex (int index)
 
virtual void setInstructionReference (InstructionReference ref)
 
bool operator== (const Terminal &other) const
 

Private Member Functions

 TerminalFUPort (const TerminalFUPort &tfup)
 
TerminalFUPortoperator= (const TerminalFUPort &)
 Assignment not allowed.
 
int findNewOperationIndex () const
 

Private Attributes

const TTAMachine::BaseFUPortport_
 Port of the unit.
 
const TTAMachine::HWOperationoperation_
 Operation code transported to the port.
 
Operationopcode_
 The OSAL operation.
 
int opIndex_
 Operation index.
 
ProgramOperationPtr po_
 The ProgramOperation this terminal belongs to, if applicable. The instance is shared by all the TerminalFUs belonging to the operation.
 

Detailed Description

Represents an input or output port of a function unit and (when applicable) the operation code written into it.

Notice that, in principle, operation codes can be written into FU output ports.

Definition at line 56 of file TerminalFUPort.hh.

Constructor & Destructor Documentation

◆ TerminalFUPort() [1/4]

TTAProgram::TerminalFUPort::TerminalFUPort ( const TTAMachine::FUPort opcodeSettingPort,
const TTAMachine::HWOperation opcode 
)

Creates a destination that writes to an opcode setting FU port.

Parameters
opcodeSettingPortThe port of the terminal.
opcodeThe operation to trigger.

Definition at line 72 of file TerminalFUPort.cc.

74 :
75 port_(opcodeSettingPort), operation_(&opcode), opcode_(NULL) {
76
77 assert(opcodeSettingPort.isOpcodeSetting());
78
79 opIndex_ = opcode.io(opcodeSettingPort);
80
81 static OperationPool pool;
82 // opcode is NullOperation instance if operation for that name was not
83 // found
84 try {
85 opcode_ = &pool.operation(operation_->name().c_str());
86 } catch (const Exception& e) {
88 __FILE__, __LINE__, __func__,
89 (boost::format(
90 "Error loading the operation '%s' definition: '%s'.")
91 % operation_->name() % e.errorMessage()).str());
92 ip.setCause(e);
93 throw ip;
94 }
95}
#define __func__
#define assert(condition)
std::string errorMessage() const
Definition Exception.cc:123
virtual bool isOpcodeSetting() const
Definition FUPort.cc:195
int io(const FUPort &port) const
const std::string & name() const
int opIndex_
Operation index.
const TTAMachine::HWOperation * operation_
Operation code transported to the port.
const TTAMachine::BaseFUPort & port_
Port of the unit.
Operation * opcode_
The OSAL operation.
std::unique_ptr< OperationPool > pool

References __func__, assert, Exception::errorMessage(), TTAMachine::HWOperation::io(), TTAMachine::FUPort::isOpcodeSetting(), TTAMachine::HWOperation::name(), opcode_, operation_, opIndex_, and Exception::setCause().

Here is the call graph for this function:

◆ TerminalFUPort() [2/4]

TTAProgram::TerminalFUPort::TerminalFUPort ( const TTAMachine::BaseFUPort port)

Constructor.

Parameters
portThe port of the terminal.

Definition at line 57 of file TerminalFUPort.cc.

58 : port_(port), operation_(NULL), opcode_(NULL) {
59 if (port_.isOpcodeSetting()) {
60 std::string msg =
61 "Opcode setting port terminals must have opcode set!";
62 throw IllegalParameters(__FILE__, __LINE__, __func__, msg);
63 }
64}
virtual bool isOpcodeSetting() const =0
virtual const TTAMachine::Port & port() const

References __func__, TTAMachine::BaseFUPort::isOpcodeSetting(), and port_.

Here is the call graph for this function:

◆ TerminalFUPort() [3/4]

TTAProgram::TerminalFUPort::TerminalFUPort ( const TTAMachine::HWOperation operation,
int  opIndex 
)

Constructor.

Parameters
operationOperation of terminal.
opIndexOperation index.

Definition at line 104 of file TerminalFUPort.cc.

105 : port_(*operation.port(opIndex)),
107 opIndex_(opIndex) {
108 /* In case the operand cannot be resolved to a legal port, it's an
109 error in the loaded input program. Thus, we cannot abort the program but
110 we'll throw an exception instead. */
111 if (dynamic_cast<const FUPort*>(&port_) == NULL) {
112 throw IllegalParameters(
113 __FILE__, __LINE__, __func__,
114 (boost::format(
115 "Port binding of operand %d of operation '%s' "
116 "cannot be resolved.") % opIndex % operation.name()).
117 str());
118 }
119 static OperationPool pool;
120 // opcode is NullOperation instance if operation for that name was not
121 // found
122 try {
123 opcode_ = &pool.operation(operation_->name().c_str());
124 } catch (const Exception& e) {
126 __FILE__, __LINE__, __func__,
127 (boost::format(
128 "Error loading the operation '%s' definition: '%s'.")
129 % operation_->name() % e.errorMessage()).str());
130 ip.setCause(e);
131 throw ip;
132 }
133}
virtual TCEString name() const
Definition Operation.cc:93
virtual Operation & operation() const

References __func__, Exception::errorMessage(), TTAMachine::HWOperation::name(), Operation::name(), opcode_, operation(), operation_, port_, and Exception::setCause().

Here is the call graph for this function:

◆ ~TerminalFUPort()

TTAProgram::TerminalFUPort::~TerminalFUPort ( )
virtual

The destructor.

Definition at line 148 of file TerminalFUPort.cc.

148 {
149}

◆ TerminalFUPort() [4/4]

TTAProgram::TerminalFUPort::TerminalFUPort ( const TerminalFUPort tfup)
private

Copy Constructor. private, only called internally by copy().

Parameters
tfupobject to copy from.

Definition at line 140 of file TerminalFUPort.cc.

140 :
141 Terminal(), port_(tfup.port_), operation_(tfup.operation_),
142 opcode_(tfup.opcode_), opIndex_(tfup.opIndex_), po_(tfup.po_) {
143}
ProgramOperationPtr po_
The ProgramOperation this terminal belongs to, if applicable. The instance is shared by all the Termi...

Member Function Documentation

◆ copy()

Terminal * TTAProgram::TerminalFUPort::copy ( ) const
virtual

Creates an exact copy of the terminal and returns it.

Note
The returned copy is a deep cope but the copied ProgramOperation, if contained, will not be updated to refer to the new moves. This should be done in the caller.
Returns
A copy of the terminal.

Implements TTAProgram::Terminal.

Definition at line 305 of file TerminalFUPort.cc.

305 {
306 return new TerminalFUPort(*this);
307}
TerminalFUPort(const TTAMachine::FUPort &opcodeSettingPort, const TTAMachine::HWOperation &opcode)

◆ equals()

bool TTAProgram::TerminalFUPort::equals ( const Terminal other) const
virtual

Checks if terminals are equal.

Parameters
otherTerminal to compare.
Returns
true if terminals are equal.

Implements TTAProgram::Terminal.

Definition at line 316 of file TerminalFUPort.cc.

316 {
317
318 if (!other.isFUPort()) {
319 return false;
320 }
321
322 const TerminalFUPort& subclass =
323 dynamic_cast<const TerminalFUPort&>(other);
324
325 // if ports are same
326 if (&port_ == &subclass.port_) {
327
328 // we care about opcodes only if they are necessary data
329 if (port_.isOpcodeSetting()) {
330
331 // if opcodes are the same
332 if (operation_ == subclass.operation_) {
333 // same port same operation
334 return true;
335 } else {
336 // if opcodes are not defined -> error
337 if (operation_ == NULL ||
338 subclass.operation_ == NULL) {
339
341 "Opcode _must_ be set for terminals that "
342 "refers opcode setting port!");
343 }
344
345 // same port different operations
346 return false;
347 }
348 } else {
349 // same ports not opcode setting
350 return true;
351 }
352 }
353
354 // different ports
355 return false;
356}
#define abortWithError(message)

References abortWithError, TTAProgram::Terminal::isFUPort(), TTAMachine::BaseFUPort::isOpcodeSetting(), operation_, and port_.

Here is the call graph for this function:

◆ findNewOperationIndex()

int TTAProgram::TerminalFUPort::findNewOperationIndex ( ) const
private

Return operation index bound to the terminal port for a given operation.

Used if operation in terminal is changed.

Returns
Operation index bound to the terminal port for a given operation.

Definition at line 366 of file TerminalFUPort.cc.

366 {
367 const FunctionUnit* fu = port_.parentUnit();
368 const HWOperation* hwop = fu->operation(operation_->name());
369 return hwop->io(dynamic_cast<const FUPort&>(port_));
370}
FunctionUnit * parentUnit() const
Definition BaseFUPort.cc:96
virtual HWOperation * operation(const std::string &name) const

References TTAMachine::HWOperation::io(), TTAMachine::HWOperation::name(), TTAMachine::FunctionUnit::operation(), operation_, TTAMachine::BaseFUPort::parentUnit(), and port_.

Here is the call graph for this function:

◆ functionUnit()

const FunctionUnit & TTAProgram::TerminalFUPort::functionUnit ( ) const
virtual

Returns the function unit of the port.

Returns
The function unit of the port.
Exceptions
WrongSubclassnever.

Reimplemented from TTAProgram::Terminal.

Definition at line 202 of file TerminalFUPort.cc.

202 {
203 return *port_.parentUnit();
204}

References TTAMachine::BaseFUPort::parentUnit(), and port_.

Referenced by ProcedurePass::copyCfgToProcedure(), InputFUBroker::unassign(), and OutputFUBroker::unassign().

Here is the call graph for this function:

◆ hasProgramOperation()

bool TTAProgram::TerminalFUPort::hasProgramOperation ( ) const
inline

these methods are used to group terminals belonging to a single program operation invocation

Definition at line 91 of file TerminalFUPort.hh.

91 {
92 return po_ != NULL && po_.get() != NULL;
93 }

References po_.

Referenced by DataDependenceGraphBuilder::processOperand(), and DataDependenceGraphBuilder::processTriggerPO().

◆ hintOperation()

Operation & TTAProgram::TerminalFUPort::hintOperation ( ) const
virtual

Return the operation to which this terminal was originally bound.

NOTE! : Method must not be used for checkin if terminal contains opcode. See. operation().

Method is mainly used for preserving information to which operation port reference is bound, during TPEF -> POM -> TPEF write cycles.

Returns
The operation code to which terminal was originally bound. Null operation if terminal does not contain operation code.

Reimplemented from TTAProgram::Terminal.

Definition at line 262 of file TerminalFUPort.cc.

262 {
263 if (opcode_ != NULL) {
264 return *opcode_;
265 } else {
267 }
268}
static NullOperation & instance()

References NullOperation::instance(), and opcode_.

Referenced by InputFUBroker::allAvailableResources(), OutputFUBroker::allAvailableResources(), InputFUBroker::assign(), OutputFUBroker::assign(), POMDisassembler::createFUPort(), SimpleIfConverter::fixTerminalPO(), TTAProgram::Move::isCall(), TTAProgram::Move::isControlFlowMove(), TTAProgram::Move::isJump(), DataDependenceGraphBuilder::processDestination(), TTAProgram::ProgramWriter::terminalResource(), and DataDependenceGraphBuilder::updateBB().

Here is the call graph for this function:

◆ hwOperation()

const HWOperation * TTAProgram::TerminalFUPort::hwOperation ( ) const
virtual

Returns a pointer to the HW operation

Returns
a pointer to the HW operation

Definition at line 379 of file TerminalFUPort.cc.

379 {
380 return operation_;
381}

References operation_.

Referenced by ControlFlowGraph::buildMBBFromBB(), POMDisassembler::createFUPort(), CodeCompressorPlugin::encodeFUTerminal(), CompiledSimCodeGenerator::generateInstruction(), DataDependenceEdge::latencySt(), and DataDependenceEdge::saveState().

◆ isFUPort()

bool TTAProgram::TerminalFUPort::isFUPort ( ) const
virtual

Tells whether the terminal is a function unit port (possibly, including an operation code).

Returns
True always.

Reimplemented from TTAProgram::Terminal.

Definition at line 158 of file TerminalFUPort.cc.

158 {
159 return true;
160}

◆ isOpcodeSetting()

bool TTAProgram::TerminalFUPort::isOpcodeSetting ( ) const
virtual

Tells whether terminal transports an opcode to a function unit port.

Returns
True if the terminal transports an opcode to a function unit port.
Exceptions
WrongSubclassnever.

Reimplemented from TTAProgram::Terminal.

Definition at line 180 of file TerminalFUPort.cc.

180 {
181 return port_.isOpcodeSetting();
182}

References TTAMachine::BaseFUPort::isOpcodeSetting(), and port_.

Referenced by POMDisassembler::createFUPort(), TTAProgram::Move::isCall(), TTAProgram::Move::isControlFlowMove(), TTAProgram::Move::isJump(), DataDependenceGraphBuilder::processDestination(), and TTAProgram::ProgramWriter::terminalResource().

Here is the call graph for this function:

◆ isRA()

bool TTAProgram::TerminalFUPort::isRA ( ) const
virtual

Tells whether the terminal is the return address port of gcu.

Returns
returns true if this is the RA.

Reimplemented from TTAProgram::Terminal.

Definition at line 168 of file TerminalFUPort.cc.

168 {
169 return dynamic_cast<const TTAMachine::SpecialRegisterPort*>
170 (&port()) != NULL;
171}

References port().

Here is the call graph for this function:

◆ isTriggering()

bool TTAProgram::TerminalFUPort::isTriggering ( ) const
virtual

Tells whether terminal is a triggering port.

Returns
True if the terminal transports an opcode to a function unit port.
Exceptions
WrongSubclassnever.

Reimplemented from TTAProgram::Terminal.

Definition at line 191 of file TerminalFUPort.cc.

191 {
192 return port_.isTriggering();
193}
virtual bool isTriggering() const =0

References TTAMachine::BaseFUPort::isTriggering(), and port_.

Referenced by TTAProgram::Move::isTriggering().

Here is the call graph for this function:

◆ operation()

Operation & TTAProgram::TerminalFUPort::operation ( ) const
virtual

Return the operation code transported into the function unit port.

Returns
The operation code transported into the function unit port.
Exceptions
InvalidDataIf terminal does not set opcode for FU.

Reimplemented from TTAProgram::Terminal.

Definition at line 213 of file TerminalFUPort.cc.

213 {
214 if (port_.isOpcodeSetting() && opcode_ != NULL) {
215 return *opcode_;
216 } else {
217 std::cerr
218 << "operation == NULL || !port_.isopcodesetting()" << std::endl;
219 }
220
221 throw InvalidData(__FILE__, __LINE__, __func__,
222 "Terminal does not set opcode for FU.");
223}

References __func__, TTAMachine::BaseFUPort::isOpcodeSetting(), opcode_, and port_.

Referenced by POMDisassembler::createFUPort(), TTAProgram::Move::isCall(), TTAProgram::Move::isControlFlowMove(), TTAProgram::Move::isJump(), TerminalFUPort(), and TTAProgram::ProgramWriter::terminalResource().

Here is the call graph for this function:

◆ operationIndex()

int TTAProgram::TerminalFUPort::operationIndex ( ) const
virtual

Return the index that identifies the operation input or output that is represented by this terminal.

Returns
The index that identifies the operation input or output that is represented by this terminal.
Exceptions
WrongSubclassNever.
InvalidDataIf the terminal is of the the right class type, but the FU port of the terminal is not opcode-setting and bears no auxiliary "hint operation" information.
Todo:
Rename to operandIndex()?

Reimplemented from TTAProgram::Terminal.

Definition at line 238 of file TerminalFUPort.cc.

238 {
239 if (operation_ != NULL || opcode_ != nullptr) {
240 return opIndex_;
241 } else {
242 const string msg =
243 "FU port of the terminal is not opcode-setting "
244 "and bears no auxiliary 'hint operation' information.";
245 throw InvalidData(__FILE__, __LINE__, __func__, msg);
246 }
247}

References __func__, opcode_, operation_, and opIndex_.

Referenced by InputFUBroker::allAvailableResources(), OutputFUBroker::allAvailableResources(), InputFUBroker::assign(), OutputFUBroker::assign(), and MachineConnectivityCheck::busConnectedToAnyFU().

◆ operator=()

TerminalFUPort & TTAProgram::TerminalFUPort::operator= ( const TerminalFUPort )
private

Assignment not allowed.

◆ port()

const Port & TTAProgram::TerminalFUPort::port ( ) const
virtual

Return the port.

Returns
The port.
Exceptions
WrongSubclassnever.

Reimplemented from TTAProgram::Terminal.

Definition at line 291 of file TerminalFUPort.cc.

291 {
292 return port_;
293}

References port_.

Referenced by InputFUBroker::allAvailableResources(), OutputFUBroker::allAvailableResources(), InputFUBroker::assign(), OutputFUBroker::assign(), POMDisassembler::createFUPort(), isRA(), and toString().

◆ programOperation()

ProgramOperationPtr TTAProgram::TerminalFUPort::programOperation ( ) const
inline

◆ setHintOperation()

void TTAProgram::TerminalFUPort::setHintOperation ( const char *  name)

Definition at line 270 of file TerminalFUPort.cc.

270 {
271 OperationPool opPool;
272 assert(&opPool.operation(name) != &NullOperation::instance());
273 opcode_ = &opPool.operation(name);
274 operation_ = nullptr;
275}
Operation & operation(const char *name)

References assert, NullOperation::instance(), opcode_, OperationPool::operation(), and operation_.

Referenced by ProgramOperation::setOperation().

Here is the call graph for this function:

◆ setOperation()

void TTAProgram::TerminalFUPort::setOperation ( const TTAMachine::HWOperation hwOp)
virtual

Definition at line 278 of file TerminalFUPort.cc.

278 {
279 OperationPool opPool;
280 opcode_ = &opPool.operation(hwOp.name().c_str());
281 operation_ = &hwOp;
282}

References TTAMachine::HWOperation::name(), opcode_, OperationPool::operation(), and operation_.

Here is the call graph for this function:

◆ setOperationIndex()

virtual void TTAProgram::TerminalFUPort::setOperationIndex ( int  index)
inlinevirtual

Definition at line 82 of file TerminalFUPort.hh.

82{ opIndex_ = index; }
virtual int index() const
Definition Terminal.cc:274

References TTAProgram::Terminal::index(), and opIndex_.

Here is the call graph for this function:

◆ setProgramOperation()

void TTAProgram::TerminalFUPort::setProgramOperation ( ProgramOperationPtr  po)
inline

Definition at line 94 of file TerminalFUPort.hh.

94 {
95 po_ = po;
96 }

References po_.

Referenced by InputFUBroker::assign(), llvm::LLVMTCEIRBuilder::createMoveNode(), and SimpleIfConverter::fixTerminalPO().

◆ toString()

TCEString TTAProgram::TerminalFUPort::toString ( ) const
virtual

Implements TTAProgram::Terminal.

Definition at line 384 of file TerminalFUPort.cc.

384 {
385 if (operation_ != NULL) {
387 port().parentUnit()->name(), port().name(), operation_->name());
388 return disasm.toString();
389 } else {
390 DisassemblyFUPort disasm(port().parentUnit()->name(), port().name());
391 return disasm.toString();
392 }
393}

References TTAMachine::HWOperation::name(), operation_, port(), DisassemblyFUOpcodePort::toString(), and DisassemblyFUPort::toString().

Here is the call graph for this function:

Member Data Documentation

◆ opcode_

Operation* TTAProgram::TerminalFUPort::opcode_
private

◆ operation_

const TTAMachine::HWOperation* TTAProgram::TerminalFUPort::operation_
private

◆ opIndex_

int TTAProgram::TerminalFUPort::opIndex_
private

Operation index.

Definition at line 119 of file TerminalFUPort.hh.

Referenced by operationIndex(), setOperationIndex(), and TerminalFUPort().

◆ po_

ProgramOperationPtr TTAProgram::TerminalFUPort::po_
private

The ProgramOperation this terminal belongs to, if applicable. The instance is shared by all the TerminalFUs belonging to the operation.

Definition at line 123 of file TerminalFUPort.hh.

Referenced by hasProgramOperation(), programOperation(), and setProgramOperation().

◆ port_

const TTAMachine::BaseFUPort& TTAProgram::TerminalFUPort::port_
private

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