OpenASIP 2.2
Loading...
Searching...
No Matches
OperationPimpl.hh
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2009 Tampere University.
3
4 This file is part of TTA-Based Codesign Environment (TCE).
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 */
24/**
25 * @file OperationPimpl.hh
26 *
27 * Declaration of OperationPimpl (private implementation) class.
28 *
29 * @author Viljami Korhonen 2008 (viljami.korhonen-no.spam-tut.fi)
30 * @note rating: red
31 */
32
33#ifndef OPERATION_PIMPL_HH
34#define OPERATION_PIMPL_HH
35
36#include <string>
37#include <set>
38#include <vector>
39#include <map>
40
41#include "TCEString.hh"
42
43class Operation;
44class OperationDAG;
46class Operand;
47class ObjectState;
48class SimValue;
50
51/**
52 * A private implementation class for Operation
53 */
55public:
56 friend class Operation;
58
59 inline int numberOfInputs() const;
60 inline int numberOfOutputs() const;
61 TCEString name() const;
62 void setCall(bool setting);
63 void setBranch(bool setting);
64 void setControlFlowOperation(bool setting);
65
66 Operand& operand(int id) const;
67private:
69 const TCEString& name,
72
73 /// Copying not allowed.
75 /// Assignment not allowed.
77
78 TCEString description() const;
79
80 void addDag(const TCEString& code);
81 void removeDag(int index);
82 int dagCount() const;
83 OperationDAG& dag(int index) const;
84 TCEString dagCode(int index) const;
85 void setDagCode(int index, const TCEString& code);
86 TCEString dagError(int index) const;
87
88 inline bool usesMemory() const;
89 inline bool readsMemory() const;
90 inline bool writesMemory() const;
91 bool canTrap() const;
92 bool hasSideEffects() const;
93 bool isClocked() const;
94 bool isControlFlowOperation() const;
95 bool isCall() const;
96 bool isBranch() const;
97 bool dependsOn(const Operation& op) const;
98 void setReadsMemory(bool setting);
99 void setWritesMemory(bool setting);
100 int affectsCount() const;
101 int affectedByCount() const;
102 TCEString affects(unsigned int i) const;
103 TCEString affectedBy(unsigned int i) const;
104 bool canSwap(int id1, int id2) const;
105
106 inline Operand& input(int index) const;
107 void addInput(Operand* operand);
108 Operand& output(int index) const;
110
113
114 void loadState(const ObjectState* state);
115 ObjectState* saveState() const;
116
117 bool simulateTrigger(
118 SimValue**,
119 OperationContext& context) const;
120
121 void createState(OperationContext& context) const;
122 void deleteState(OperationContext& context) const;
123
124 bool canBeSimulated() const;
125
126 bool isNull() const;
127
129
130 /**
131 * Internal container for information of one DAG.
132 */
134 /// Source code for creating DAG for operation.
135 std::string code;
136 /// Error message if creating DAG failed.
137 std::string error;
138 /// If code was already tried to compile and it did not succeed.
140 /// DAG presentation of code. set to
141 /// NullOperationDAG if could not be created.
143
144 };
145
146 typedef std::vector<OperationDAGInfo> DAGContainer;
147
148 void clear();
149
150 Operand& fetchOperand(int id, const std::vector<Operand*>& ops) const;
151 Operand& fetchOperand(int id) const;
152 void insertOperand(Operand* operand, std::vector<Operand*>& ops);
153
154 /// The behavior of the Operation.
156 /// Name of the Operation.
157 std::string name_;
158 /// Description of the Operation.
159 std::string description_;
160 /// Table of DAGs and their source codes of an operation.
162
163 /// The number of inputs of the Operation.
165 /// The number of outputs of the Operation.
167 /// Flag indicating if Operation reads from memory.
169 /// Flag indicating if Operation writes to memory.
171 /// Flag indicating if Operation can trap.
173 /// Flag indicating if Operation has side effects.
175 /// Flag indicating if Operation is clocked and needs AdvanceClock.
177 /// Flag indicating if the Operation can change program flow.
179 /// Operations that affects this Operation.
180 std::set<std::string> affects_;
181 /// Operations that are affected by this Operation.
182 std::set<std::string> affectedBy_;
183 /// Input Operands of the Operation.
184 std::vector<Operand*> inputOperands_;
185 /// Output Operands of the Operation.
186 std::vector<Operand*> outputOperands_;
187 /// Flag indicating if Operation is call.
189 /// Flag indicating if Operation is branch changing control flow.
191
192};
193
194#include "OperationPimpl.icc"
195
196#endif
197
void loadState(const ObjectState *state)
bool isClocked() const
void createState(OperationContext &context) const
OperationBehavior * behavior_
The behavior of the Operation.
TCEString description() const
bool dependsOn(const Operation &op) const
std::string name_
Name of the Operation.
DAGContainer dags_
Table of DAGs and their source codes of an operation.
std::string description_
Description of the Operation.
std::vector< Operand * > inputOperands_
Input Operands of the Operation.
std::vector< OperationDAGInfo > DAGContainer
void setDagCode(int index, const TCEString &code)
bool isCall() const
bool hasSideEffects() const
Operand & operand(int id) const
TCEString emulationFunctionName() const
bool canSwap(int id1, int id2) const
bool writesMemory_
Flag indicating if Operation writes to memory.
Operand & output(int index) const
void insertOperand(Operand *operand, std::vector< Operand * > &ops)
bool writesMemory() const
bool isBranch() const
std::set< std::string > affectedBy_
Operations that are affected by this Operation.
int inputs_
The number of inputs of the Operation.
ObjectState * saveState() const
int dagCount() const
std::set< std::string > affects_
Operations that affects this Operation.
int affectedByCount() const
bool usesMemory() const
bool isControlFlowOperation() const
bool isNull() const
bool controlFlowOperation_
Flag indicating if the Operation can change program flow.
void setBranch(bool setting)
bool readsMemory() const
int numberOfOutputs() const
OperationDAG & dag(int index) const
OperationPimpl & operator=(const OperationPimpl &)
Assignment not allowed.
TCEString name() const
bool hasSideEffects_
Flag indicating if Operation has side effects.
void addInput(Operand *operand)
int numberOfInputs() const
void setReadsMemory(bool setting)
TCEString dagCode(int index) const
void removeDag(int index)
Operand & input(int index) const
Operand & fetchOperand(int id, const std::vector< Operand * > &ops) const
TCEString affectedBy(unsigned int i) const
OperationPimpl(const OperationPimpl &)
Copying not allowed.
int outputs_
The number of outputs of the Operation.
std::vector< Operand * > outputOperands_
Output Operands of the Operation.
TCEString affects(unsigned int i) const
void setCall(bool setting)
bool canBeSimulated() const
bool canTrap() const
void addOutput(Operand *operand)
void setBehavior(OperationBehavior &behavior)
void addDag(const TCEString &code)
void deleteState(OperationContext &context) const
int affectsCount() const
TCEString dagError(int index) const
bool simulateTrigger(SimValue **, OperationContext &context) const
bool isCall_
Flag indicating if Operation is call.
void setWritesMemory(bool setting)
bool readsMemory_
Flag indicating if Operation reads from memory.
OperationBehavior & behavior() const
void setControlFlowOperation(bool setting)
bool canTrap_
Flag indicating if Operation can trap.
bool isClocked_
Flag indicating if Operation is clocked and needs AdvanceClock.
bool isBranch_
Flag indicating if Operation is branch changing control flow.
std::string code
Source code for creating DAG for operation.
OperationDAG * dag
DAG presentation of code. set to NullOperationDAG if could not be created.
std::string error
Error message if creating DAG failed.
bool compilationFailed
If code was already tried to compile and it did not succeed.