OpenASIP
2.0
|
#include <OperationPimpl.hh>
Classes | |
struct | OperationDAGInfo |
Public Member Functions | |
~OperationPimpl () | |
int | numberOfInputs () const |
int | numberOfOutputs () const |
TCEString | name () const |
void | setCall (bool setting) |
void | setBranch (bool setting) |
void | setControlFlowOperation (bool setting) |
Operand & | operand (int id) const |
Private Types | |
typedef std::vector< OperationDAGInfo > | DAGContainer |
Private Member Functions | |
OperationPimpl (const TCEString &name, OperationBehavior &behavior) | |
OperationPimpl () | |
OperationPimpl (const OperationPimpl &) | |
Copying not allowed. More... | |
OperationPimpl & | operator= (const OperationPimpl &) |
Assignment not allowed. More... | |
TCEString | description () const |
void | addDag (const TCEString &code) |
void | removeDag (int index) |
int | dagCount () const |
OperationDAG & | dag (int index) const |
TCEString | dagCode (int index) const |
void | setDagCode (int index, const TCEString &code) |
TCEString | dagError (int index) const |
bool | usesMemory () const |
bool | readsMemory () const |
bool | writesMemory () const |
bool | canTrap () const |
bool | hasSideEffects () const |
bool | isClocked () const |
bool | isControlFlowOperation () const |
bool | isCall () const |
bool | isBranch () const |
bool | dependsOn (const Operation &op) const |
void | setReadsMemory (bool setting) |
void | setWritesMemory (bool setting) |
int | affectsCount () const |
int | affectedByCount () const |
TCEString | affects (unsigned int i) const |
TCEString | affectedBy (unsigned int i) const |
bool | canSwap (int id1, int id2) const |
Operand & | input (int index) const |
void | addInput (Operand *operand) |
Operand & | output (int index) const |
void | addOutput (Operand *operand) |
void | setBehavior (OperationBehavior &behavior) |
OperationBehavior & | behavior () const |
void | loadState (const ObjectState *state) |
ObjectState * | saveState () const |
bool | simulateTrigger (SimValue **, OperationContext &context) const |
void | createState (OperationContext &context) const |
void | deleteState (OperationContext &context) const |
bool | canBeSimulated () const |
bool | isNull () const |
TCEString | emulationFunctionName () const |
void | clear () |
Operand & | fetchOperand (int id, const std::vector< Operand * > &ops) const |
Operand & | fetchOperand (int id) const |
void | insertOperand (Operand *operand, std::vector< Operand * > &ops) |
Private Attributes | |
OperationBehavior * | behavior_ |
The behavior of the Operation. More... | |
std::string | name_ |
Name of the Operation. More... | |
std::string | description_ |
Description of the Operation. More... | |
DAGContainer | dags_ |
Table of DAGs and their source codes of an operation. More... | |
int | inputs_ |
The number of inputs of the Operation. More... | |
int | outputs_ |
The number of outputs of the Operation. More... | |
bool | readsMemory_ |
Flag indicating if Operation reads from memory. More... | |
bool | writesMemory_ |
Flag indicating if Operation writes to memory. More... | |
bool | canTrap_ |
Flag indicating if Operation can trap. More... | |
bool | hasSideEffects_ |
Flag indicating if Operation has side effects. More... | |
bool | isClocked_ |
Flag indicating if Operation is clocked and needs AdvanceClock. More... | |
bool | controlFlowOperation_ |
Flag indicating if the Operation can change program flow. More... | |
std::set< std::string > | affects_ |
Operations that affects this Operation. More... | |
std::set< std::string > | affectedBy_ |
Operations that are affected by this Operation. More... | |
std::vector< Operand * > | inputOperands_ |
Input Operands of the Operation. More... | |
std::vector< Operand * > | outputOperands_ |
Output Operands of the Operation. More... | |
bool | isCall_ |
Flag indicating if Operation is call. More... | |
bool | isBranch_ |
Flag indicating if Operation is branch changing control flow. More... | |
Friends | |
class | Operation |
A private implementation class for Operation
Definition at line 54 of file OperationPimpl.hh.
|
private |
Definition at line 146 of file OperationPimpl.hh.
OperationPimpl::~OperationPimpl | ( | ) |
Destructor.
Operands are destroyed.
Definition at line 80 of file OperationPimpl.cc.
References clear().
|
private |
|
private |
|
private |
Copying not allowed.
|
private |
Creates new DAG and adds it's code for operation.
code | Source code written in DAG language. |
Definition at line 140 of file OperationPimpl.cc.
References OperationPimpl::OperationDAGInfo::code, OperationPimpl::OperationDAGInfo::compilationFailed, OperationPimpl::OperationDAGInfo::dag, dags_, and OperationDAG::null.
Referenced by Operation::addDag(), and loadState().
|
private |
Definition at line 620 of file OperationPimpl.cc.
References inputOperands_, inputs_, and operand().
Referenced by Operation::addInput().
|
private |
Definition at line 626 of file OperationPimpl.cc.
References operand(), outputOperands_, and outputs_.
Referenced by Operation::addOutput().
|
private |
Returns the name of the operation that is affected by this operation.
i | The index of the operation. |
OutOfRange | If index is illegal. |
Definition at line 389 of file OperationPimpl.cc.
References affectedBy_.
Referenced by Operation::affectedBy(), loadState(), and saveState().
|
private |
Returns the number of operations affected by this operation.
Definition at line 353 of file OperationPimpl.cc.
References affectedBy_.
Referenced by Operation::affectedByCount().
|
private |
Returns the name of the operation this operation affects.
i | The index of the operation. |
Definition at line 364 of file OperationPimpl.cc.
References affects_.
Referenced by Operation::affects(), loadState(), and saveState().
|
private |
Returns the number of operations that affect this operation.
Definition at line 343 of file OperationPimpl.cc.
References affects_.
Referenced by Operation::affectsCount().
|
private |
Returns the behavior of Operation.
Definition at line 333 of file OperationPimpl.cc.
References behavior_.
Referenced by Operation::areValid(), Operation::behavior(), and setBehavior().
|
private |
Returns true if this operation has behavior, or dag which is simulateable (doesn't contain infinite recursion loop).
Definition at line 786 of file OperationPimpl.cc.
References behavior_, and OperationBehavior::canBeSimulated().
Referenced by Operation::canBeSimulated().
|
private |
Returns true if Operands can be swapped.
Definition at line 435 of file OperationPimpl.cc.
References Operand::canSwap(), fetchOperand(), and NullOperand::instance().
Referenced by Operation::canSwap().
|
private |
Returns true if Operation can trap.
Definition at line 258 of file OperationPimpl.cc.
References canTrap_.
Referenced by Operation::canTrap().
|
private |
Clears the operation.
Definition at line 88 of file OperationPimpl.cc.
References affectedBy_, affects_, canTrap_, controlFlowOperation_, dag(), dagCount(), dags_, SequenceTools::deleteAllItems(), hasSideEffects_, inputOperands_, inputs_, isBranch_, isCall_, OperationDAG::isNull(), name_, outputOperands_, outputs_, readsMemory_, and writesMemory_.
Referenced by loadState(), and ~OperationPimpl().
|
private |
Creates an instance of operation state for this operation and adds it to the operation context.
context | The operation context to add the state in. |
Definition at line 764 of file OperationPimpl.cc.
References behavior_, and OperationBehavior::createState().
Referenced by Operation::createState().
|
private |
Returns an operation DAG for operation.
Compiles DAG from code to object if necessary.
index | Index of returned DAG. |
Definition at line 186 of file OperationPimpl.cc.
References OperationDAGConverter::createDAG(), dags_, Exception::errorMessage(), OperationDAG::isNull(), and OperationDAG::null.
Referenced by clear(), Operation::dag(), and setDagCode().
|
private |
Returns source code of DAG.
index | Index of DAG whose source code is requested. |
Definition at line 220 of file OperationPimpl.cc.
References dags_.
Referenced by Operation::dagCode(), and saveState().
|
private |
Returns number of DAGs stored for operation.
Definition at line 172 of file OperationPimpl.cc.
References dags_.
Referenced by clear(), Operation::dagCount(), and saveState().
|
private |
Error message if DAG source code could not be compiled.
index | Index of DAG whose error is returned. |
Definition at line 248 of file OperationPimpl.cc.
References dags_.
Referenced by Operation::dagError().
|
private |
Deletes an instance of operation state for this operation from the operation context.
context | The operation context to delete the state from. |
Definition at line 775 of file OperationPimpl.cc.
References behavior_, and OperationBehavior::deleteState().
Referenced by Operation::deleteState().
|
private |
Returns true if Operation depends on the given operation.
op | The Operation being investigated. |
Definition at line 413 of file OperationPimpl.cc.
References affectedBy_, affects_, and Operation::name().
Referenced by Operation::dependsOn().
|
private |
Returns the description of the Operation.
Definition at line 131 of file OperationPimpl.cc.
References description_.
Referenced by Operation::description().
|
private |
Name of emulation function which is called if the operation is emulated in program.
Definition at line 819 of file OperationPimpl.cc.
References llvmOperandType(), name(), numberOfInputs(), numberOfOutputs(), operand(), Conversion::toString(), and Operand::type().
Referenced by Operation::emulationFunctionName().
|
private |
Returns an operand with a certain id if it exists.
If operand is not found, NullOperand is returned.
id | Id of the operand. |
Definition at line 696 of file OperationPimpl.cc.
References assert, inputOperands_, NullOperand::instance(), and outputOperands_.
|
private |
Returns an operand with a certain id if it exists.
If operand is not found, a null operand is returned.
id | The id of an operand. |
ops | Vector where operand is searched. |
Definition at line 674 of file OperationPimpl.cc.
References assert, and NullOperand::instance().
Referenced by canSwap(), and operand().
|
private |
Return true if operation has side effects.
Definition at line 268 of file OperationPimpl.cc.
References hasSideEffects_.
Referenced by Operation::hasSideEffects().
|
inlineprivate |
Referenced by Operation::input().
Inserts operand to the right place.
Operands are inserted according to their indexes.
operand | Operand to be inserted. |
ops | Vector in which operand is inserted. |
Definition at line 723 of file OperationPimpl.cc.
References Operand::index(), and operand().
Referenced by loadState().
|
private |
Return true if the operation is branch.
Branches of different type have this property set.
Definition at line 313 of file OperationPimpl.cc.
References isBranch_.
Referenced by Operation::isBranch().
|
private |
Return true if the operation is call.
Calls of different type have this property set.
Definition at line 302 of file OperationPimpl.cc.
References isCall_.
Referenced by Operation::isCall().
|
private |
Returns true if the operation is clocked.
Definition at line 278 of file OperationPimpl.cc.
References isClocked_.
Referenced by Operation::isClocked().
|
private |
Return true if the operation can change control flow.
Branches and calls of different type have this property set.
Definition at line 290 of file OperationPimpl.cc.
References controlFlowOperation_.
Referenced by Operation::isControlFlowOperation().
|
private |
|
private |
Loads the Operation from ObjectState object.
state | The state of the Operation. |
Definition at line 453 of file OperationPimpl.cc.
References addDag(), affectedBy(), affectedBy_, affects(), affects_, ObjectState::boolAttribute(), canTrap_, ObjectState::child(), ObjectState::childCount(), clear(), controlFlowOperation_, description_, Exception::errorMessage(), hasSideEffects_, Operand::index(), inputOperands_, inputs_, insertOperand(), NullOperand::instance(), ObjectState::intAttribute(), isBranch_, isCall_, isClocked_, Operand::loadState(), ObjectState::name(), name_, operand(), Operation::OPRN_AFFECTED_BY, Operation::OPRN_AFFECTS, Operation::OPRN_CLOCKED, Operation::OPRN_CONTROL_FLOW, Operation::OPRN_DESCRIPTION, Operation::OPRN_IN, Operation::OPRN_INPUTS, Operation::OPRN_ISBRANCH, Operation::OPRN_ISCALL, Operation::OPRN_NAME, Operation::OPRN_OUT, Operation::OPRN_OUTPUTS, Operation::OPRN_READS_MEMORY, Operation::OPRN_SIDE_EFFECTS, Operation::OPRN_TRAP, Operation::OPRN_TRIGGER, Operation::OPRN_WRITES_MEMORY, outputOperands_, outputs_, readsMemory_, Exception::setCause(), Operand::SINT_WORD, ObjectState::stringAttribute(), StringTools::stringToUpper(), ObjectState::stringValue(), and writesMemory_.
Referenced by Operation::loadState().
TCEString OperationPimpl::name | ( | ) | const |
Returns the name of the Operation.
Definition at line 121 of file OperationPimpl.cc.
References name_.
Referenced by OperationDAGBuilder::connectOperandToNode(), FUGen::constantName(), FUGen::DAGNodeOperandWidth(), emulationFunctionName(), OperationDAGBuilder::finalize(), Operation::name(), and FUGen::subOpConnection().
|
inline |
Referenced by emulationFunctionName(), OperationDAGBuilder::finalize(), and Operation::numberOfInputs().
|
inline |
Referenced by emulationFunctionName(), OperationDAGBuilder::finalize(), and Operation::numberOfOutputs().
Operand & OperationPimpl::operand | ( | int | id | ) | const |
Returns the Operand with the given id if found, otherwise null Operand.
id | The id of Operand. |
Definition at line 655 of file OperationPimpl.cc.
References assert, fetchOperand(), inputOperands_, NullOperand::instance(), and outputOperands_.
Referenced by addInput(), addOutput(), emulationFunctionName(), insertOperand(), loadState(), Operation::operand(), saveState(), and OperationDAGConverter::writeNode().
|
private |
Assignment not allowed.
|
private |
Returns the output Operand with the given index.
This method can be used to traverse the list of output operands (the max index is numberOfOutput() - 1).
index | The index of Operand. |
Definition at line 640 of file OperationPimpl.cc.
References outputOperands_.
Referenced by Operation::output().
|
inlineprivate |
Referenced by Operation::readsMemory().
|
private |
Removes DAG of given index from operation.
index | Index of dag to delete. |
Definition at line 154 of file OperationPimpl.cc.
References dags_, and OperationDAG::null.
Referenced by Operation::removeDag().
|
private |
Saves the state of the Operation in ObjectState object.
Definition at line 557 of file OperationPimpl.cc.
References ObjectState::addChild(), affectedBy(), affectedBy_, affects(), affects_, canTrap_, controlFlowOperation_, dagCode(), dagCount(), description_, hasSideEffects_, inputOperands_, inputs_, isBranch_, isCall_, isClocked_, name_, operand(), Operation::OPRN_AFFECTED_BY, Operation::OPRN_AFFECTS, Operation::OPRN_CLOCKED, Operation::OPRN_CONTROL_FLOW, Operation::OPRN_DESCRIPTION, Operation::OPRN_IN, Operation::OPRN_INPUTS, Operation::OPRN_ISBRANCH, Operation::OPRN_ISCALL, Operation::OPRN_NAME, Operation::OPRN_OPERATION, Operation::OPRN_OUT, Operation::OPRN_OUTPUTS, Operation::OPRN_READS_MEMORY, Operation::OPRN_SIDE_EFFECTS, Operation::OPRN_TRAP, Operation::OPRN_TRIGGER, Operation::OPRN_WRITES_MEMORY, outputOperands_, outputs_, readsMemory_, ObjectState::setAttribute(), ObjectState::setValue(), and writesMemory_.
Referenced by Operation::saveState().
|
private |
Sets the behavior for operation.
behavior | Behavior for an operation. |
Definition at line 323 of file OperationPimpl.cc.
References behavior(), and behavior_.
Referenced by Operation::setBehavior().
void OperationPimpl::setBranch | ( | bool | setting | ) |
Sets property of operation indicating that the operation is branch changing control flow.
Definition at line 861 of file OperationPimpl.cc.
References isBranch_.
Referenced by Operation::setBranch().
void OperationPimpl::setCall | ( | bool | setting | ) |
Sets property of operation indicating that the operation is function call.
Definition at line 852 of file OperationPimpl.cc.
References isCall_.
Referenced by Operation::setCall().
void OperationPimpl::setControlFlowOperation | ( | bool | setting | ) |
Sets property of operation indicating that the operation is changing control flow.
Definition at line 844 of file OperationPimpl.cc.
References controlFlowOperation_.
Referenced by Operation::setControlFlowOperation().
|
private |
Set new source code for DAG and automatically tries to compile latest version to object.
index | Index of DAG whose source code is updated. |
code | New source code in DAG Osal Language. |
Definition at line 232 of file OperationPimpl.cc.
References dag(), dags_, OperationDAG::isNull(), and OperationDAG::null.
Referenced by Operation::setDagCode().
|
private |
Specifies if operation reads memory.
Definition at line 869 of file OperationPimpl.cc.
References readsMemory_.
Referenced by Operation::setReadsMemory().
|
private |
Specifies if operation writes memory.
Definition at line 877 of file OperationPimpl.cc.
References writesMemory_.
Referenced by Operation::setWritesMemory().
|
private |
Simulates the process of starting execution of an operation.
io | The input and output operands. |
context | The operation context. |
Exception | Depends on the operation behavior. |
Definition at line 750 of file OperationPimpl.cc.
References behavior_, and OperationBehavior::simulateTrigger().
Referenced by Operation::simulateTrigger().
|
inlineprivate |
Referenced by Operation::usesMemory().
|
inlineprivate |
Referenced by Operation::writesMemory().
|
friend |
Definition at line 56 of file OperationPimpl.hh.
|
private |
Operations that are affected by this Operation.
Definition at line 182 of file OperationPimpl.hh.
Referenced by affectedBy(), affectedByCount(), clear(), dependsOn(), loadState(), and saveState().
|
private |
Operations that affects this Operation.
Definition at line 180 of file OperationPimpl.hh.
Referenced by affects(), affectsCount(), clear(), dependsOn(), loadState(), and saveState().
|
private |
The behavior of the Operation.
Definition at line 155 of file OperationPimpl.hh.
Referenced by behavior(), canBeSimulated(), createState(), deleteState(), setBehavior(), and simulateTrigger().
|
private |
Flag indicating if Operation can trap.
Definition at line 172 of file OperationPimpl.hh.
Referenced by canTrap(), clear(), loadState(), and saveState().
|
private |
Flag indicating if the Operation can change program flow.
Definition at line 178 of file OperationPimpl.hh.
Referenced by clear(), isControlFlowOperation(), loadState(), saveState(), and setControlFlowOperation().
|
mutableprivate |
Table of DAGs and their source codes of an operation.
Definition at line 161 of file OperationPimpl.hh.
Referenced by addDag(), clear(), dag(), dagCode(), dagCount(), dagError(), removeDag(), and setDagCode().
|
private |
Description of the Operation.
Definition at line 159 of file OperationPimpl.hh.
Referenced by description(), loadState(), and saveState().
|
private |
Flag indicating if Operation has side effects.
Definition at line 174 of file OperationPimpl.hh.
Referenced by clear(), hasSideEffects(), loadState(), and saveState().
|
private |
Input Operands of the Operation.
Definition at line 184 of file OperationPimpl.hh.
Referenced by addInput(), clear(), fetchOperand(), loadState(), operand(), and saveState().
|
private |
The number of inputs of the Operation.
Definition at line 164 of file OperationPimpl.hh.
Referenced by addInput(), clear(), loadState(), and saveState().
|
private |
Flag indicating if Operation is branch changing control flow.
Definition at line 190 of file OperationPimpl.hh.
Referenced by clear(), isBranch(), loadState(), saveState(), and setBranch().
|
private |
Flag indicating if Operation is call.
Definition at line 188 of file OperationPimpl.hh.
Referenced by clear(), isCall(), loadState(), saveState(), and setCall().
|
private |
Flag indicating if Operation is clocked and needs AdvanceClock.
Definition at line 176 of file OperationPimpl.hh.
Referenced by isClocked(), loadState(), and saveState().
|
private |
Name of the Operation.
Definition at line 157 of file OperationPimpl.hh.
Referenced by clear(), loadState(), name(), and saveState().
|
private |
Output Operands of the Operation.
Definition at line 186 of file OperationPimpl.hh.
Referenced by addOutput(), clear(), fetchOperand(), loadState(), operand(), output(), and saveState().
|
private |
The number of outputs of the Operation.
Definition at line 166 of file OperationPimpl.hh.
Referenced by addOutput(), clear(), loadState(), and saveState().
|
private |
Flag indicating if Operation reads from memory.
Definition at line 168 of file OperationPimpl.hh.
Referenced by clear(), loadState(), saveState(), and setReadsMemory().
|
private |
Flag indicating if Operation writes to memory.
Definition at line 170 of file OperationPimpl.hh.
Referenced by clear(), loadState(), saveState(), and setWritesMemory().