Go to the documentation of this file.
50 #include "boost/assign.hpp"
51 using namespace boost::assign;
68 behavior_(&behavior), name_(
StringTools::stringToUpper(name)),
70 inputs_(0), outputs_(0), readsMemory_(
false), writesMemory_(
false),
90 for (
int i = 0; i <
dagCount(); i++) {
145 dags_.push_back(newDag);
155 DAGContainer::iterator i =
dags_.begin() + index;
157 if (!i->dag->isNull()) {
195 dags_[index].compilationFailed =
false;
196 dags_[index].error =
"";
201 dags_[index].compilationFailed =
true;
206 dags_[index].compilationFailed =
true;
210 return *
dags_[index].dag;
221 return dags_[index].code;
233 dags_[index].code = code;
235 delete dags_[index].dag;
238 dags_[index].compilationFailed =
false;
249 return dags_[index].error;
367 string method =
"OperationPimpl::affects()";
368 string msg =
"Index out of range.";
369 throw OutOfRange(__FILE__, __LINE__, method, msg);
372 set<string>::const_iterator it =
affects_.begin();
373 unsigned int count = 0;
392 string method =
"OperationPimpl::affectedBy()";
393 string msg =
"Index out of range.";
394 throw OutOfRange(__FILE__, __LINE__, method, msg);
397 set<string>::const_iterator it =
affectedBy_.begin();
398 unsigned int count = 0;
414 set<string>::const_iterator it =
affects_.find(op.
name());
457 string method =
"OperationPimpl::loadState()";
477 for (
int i = 0; i < state->
childCount(); i++) {
484 string msg =
"Input operand index illegal";
485 throw Exception(__FILE__, __LINE__, method, msg);
494 string msg =
"Output operand index illegal";
495 throw Exception(__FILE__, __LINE__, method, msg);
500 for (
int j = 0; j < child->
childCount(); j++) {
508 for (
int j = 0; j < child->
childCount(); j++) {
520 string msg =
"Unknown child: " + child->
name();
521 throw Exception(__FILE__, __LINE__, method, msg);
529 for (
int i = 1; i <=
inputs_; ++i) {
544 string msg =
"Problems loading Operation: " + e.
errorMessage();
576 set<string>::const_iterator it =
affectedBy_.begin();
588 set<string>::const_iterator it =
affects_.begin();
592 affects->addChild(affectsChild);
610 for (
int i = 0; i <
dagCount(); i++) {
677 for (std::vector<Operand*>::const_iterator i = ops.begin(); i != ops.end();
679 if ((*i)->index() ==
id) {
725 vector<Operand*>::iterator it = ops.begin();
726 bool inserted =
false;
727 while (it != ops.end()) {
820 std::string functionName;
822 functionName =
"__emulate_" + std::string(
name()) +
std::set< std::string > affects_
Operations that affects this Operation.
bool hasSideEffects() const
void setBranch(bool setting)
virtual bool canBeSimulated() const
TCEString dagError(int index) const
int affectedByCount() const
std::string stringAttribute(const std::string &name) const
void loadState(const ObjectState *state)
void addInput(Operand *operand)
static const char * OPRN_IN
Object state name for input operand.
OperationDAG * dag
DAG presentation of code. set to NullOperationDAG if could not be created.
bool isControlFlowOperation() const
void setCall(bool setting)
int inputs_
The number of inputs of the Operation.
static const char * OPRN_NAME
Object state name for name.
void setCause(const Exception &cause)
static NullOperand & instance()
static const char * OPRN_AFFECTS
Object state name for affects.
void addOutput(Operand *operand)
std::set< std::string > affectedBy_
Operations that are affected by this Operation.
TCEString emulationFunctionName() const
virtual TCEString name() const
bool canTrap_
Flag indicating if Operation can trap.
static const char * OPRN_AFFECTED_BY
Object state name for affected by.
static std::string toString(const T &source)
virtual void createState(OperationContext &context) const
int outputs_
The number of outputs of the Operation.
std::string name_
Name of the Operation.
TCEString dagCode(int index) const
virtual bool simulateTrigger(SimValue **io, OperationContext &context) const =0
std::vector< Operand * > outputOperands_
Output Operands of the Operation.
int numberOfOutputs() const
#define assert(condition)
static const char * OPRN_CONTROL_FLOW
Object state name for control flow property.
void setControlFlowOperation(bool setting)
bool isClocked_
Flag indicating if Operation is clocked and needs AdvanceClock.
static const char * OPRN_DESCRIPTION
Object state name for description.
ObjectState * saveState() const
void setBehavior(OperationBehavior &behavior)
static const char * OPRN_TRAP
Object state name for trap.
static const char * OPRN_TRIGGER
Object state name for trigger semantics.
virtual bool canSwap(const Operand &op) const
Operand & output(int index) const
std::string code
Source code for creating DAG for operation.
static const char * OPRN_OPERATION
Object state name for operation.
static const char * OPRN_CLOCKED
Object state name for clockedness.
static const char * OPRN_ISCALL
Object state name for call property.
virtual int index() const
std::string llvmOperandType(Operand::OperandType type)
bool writesMemory_
Flag indicating if Operation writes to memory.
ObjectState * child(int index) const
bool simulateTrigger(SimValue **, OperationContext &context) const
void addChild(ObjectState *child)
TCEString affects(unsigned int i) const
void setReadsMemory(bool setting)
static const char * OPRN_WRITES_MEMORY
Object state name for writes memory.
Operand & operand(int id) const
static const char * OPRN_READS_MEMORY
Object state name for reads memory.
void createState(OperationContext &context) const
OperationBehavior & behavior() const
static const char * OPRN_OUT
Object state name for output operand.
std::string errorMessage() const
static const char * OPRN_INPUTS
Object state name for inputs.
DAGContainer dags_
Table of DAGs and their source codes of an operation.
void insertOperand(Operand *operand, std::vector< Operand * > &ops)
static const char * OPRN_SIDE_EFFECTS
Object state name for side effects.
virtual OperandType type() const
find Finds info of the inner loops in the false
virtual void deleteState(OperationContext &context) const
bool boolAttribute(const std::string &name) const
Operand & fetchOperand(int id, const std::vector< Operand * > &ops) const
OperationBehavior * behavior_
The behavior of the Operation.
void removeDag(int index)
bool isBranch_
Flag indicating if Operation is branch changing control flow.
std::string stringValue() const
std::vector< Operand * > inputOperands_
Input Operands of the Operation.
int intAttribute(const std::string &name) const
bool dependsOn(const Operation &op) const
OperationDAG & dag(int index) const
bool canSwap(int id1, int id2) const
TCEString affectedBy(unsigned int i) const
bool compilationFailed
If code was already tried to compile and it did not succeed.
bool readsMemory_
Flag indicating if Operation reads from memory.
bool canBeSimulated() const
std::string description_
Description of the Operation.
bool hasSideEffects_
Flag indicating if Operation has side effects.
void addDag(const TCEString &code)
void setValue(const std::string &value)
static const char * OPRN_ISBRANCH
Object state name for branch property.
static const char * OPRN_OUTPUTS
Object state name for outputs.
bool controlFlowOperation_
Flag indicating if the Operation can change program flow.
TCEString description() const
void setWritesMemory(bool setting)
void setAttribute(const std::string &name, const std::string &value)
static OperationDAG * createDAG(const OperationPimpl &operation, std::string sourceCode)
virtual void loadState(const ObjectState *state)
void deleteState(OperationContext &context) const
bool isCall_
Flag indicating if Operation is call.
void setDagCode(int index, const TCEString &code)
int numberOfInputs() const