OpenASIP 2.2
Loading...
Searching...
No Matches
ProgramOperation.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 ProgramOperation.hh
26 *
27 * Declaration of ProgramOperation class.
28 *
29 * @author Heikki Kultala 2006 (hkultala-no.spam-cs.tut.fi)
30 * @author Vladimir Guzma 2006 (vladimir.guzma-no.spam-tut.fi)
31 * @note rating: red
32 */
33
34#ifndef TCE_PROGRAM_OPERATION_HH
35#define TCE_PROGRAM_OPERATION_HH
36
37#include <string>
38#include <map>
39#include <vector>
40#include <memory>
41
42#include "Exception.hh"
43
44class MoveNode;
45class MoveNodeSet;
46class Operation;
48
49namespace llvm {
50 class MachineInstr;
51}
52namespace TTAProgram {
53 class Move;
54}
55
56namespace TTAMachine {
57 class Unit;
58 class PortGuard;
59 class FunctionUnit;
60 class HWOperation;
61}
62
63// use this smart_ptr type to point to POs to allow more safe sharing of
64// POs between POM and DDG, etc.
65typedef std::shared_ptr<ProgramOperation> ProgramOperationPtr;
66
67/**
68 * Represents a single execution of an operation in a program.
69 */
71public:
73 const Operation &operation,
74 const llvm::MachineInstr* instr=NULL);
77
78 void addNode(MoveNode& node);
79 void addInputNode(MoveNode& node);
80 void addOutputNode(MoveNode& node, int outputIndex);
81 void addOutputNode(MoveNode& node);
82 void addGuardOutputNode(MoveNode& node);
83
84 int outputIndexFromGuardOfMove(const MoveNode& node) const;
86
87 static int outputIndexFromGuard(
88 const TTAMachine::PortGuard& pg, const Operation& op);
89
90 int outputIndexOfMove(const MoveNode& mn) const;
93 const MoveNode& outputNode) const;
94
96 const MoveNode& outputNode) const;
97
98 void removeOutputNode(MoveNode& node, int outputIndex);
99 void removeOutputNode(MoveNode& node);
101 void removeInputNode(MoveNode& node);
102
103 bool isComplete();
104 bool isReady();
105 bool isMultinode();
106 bool isAssigned();
107 bool isAnyNodeAssigned();
108 bool isAnyInputAssigned();
109 bool isAnyOutputAssigned();
110 bool areInputsAssigned();
111 bool areOutputsAssigned();
112
114 MoveNodeSet& inputNode(int in) const;
115 MoveNodeSet& outputNode(int out) const;
116
117 bool hasOutputNode(int out) const;
118 bool hasInputNode(int in) const;
119
120 const Operation& operation() const;
121 void setOperation(const Operation& op);
122
123 int inputMoveCount() const;
124 int outputMoveCount() const;
125
126 bool hasMoveNodeForMove(const TTAProgram::Move& move) const;
127 MoveNode& moveNode(const TTAProgram::Move& move) const;
128 MoveNode& inputMove(int index) const;
129 MoveNode& outputMove(int index) const;
130
131 MoveNode* triggeringMove() const;
132
134 bool isLegalFU(const TTAMachine::FunctionUnit& fu) const;
135
136 const llvm::MachineInstr* machineInstr() const { return mInstr_; }
137
138 void switchInputs(int idx1 = 1, int idx2 = 2);
139
140 std::string toString() const;
141
142 unsigned int poId() const;
143
144 bool hasConstantOperand() const;
145 // Comparator for maps and sets
146
147 bool operator==(const ProgramOperation& po) { return poId() == po.poId(); }
149 public:
150 bool operator()(
151 const ProgramOperation* po1, const ProgramOperation* po2) const;
152 bool operator()(
153 const ProgramOperationPtr &po1, const ProgramOperationPtr &po2) const;
154
155 };
156
157private:
158 typedef std::vector<MoveNode*> MoveVector;
159 // copying forbidden
161 // assignment forbidden
163 // OSAL Operation this program operation is executing.
165 // map from operand index to MoveNodeSet
166 std::map<int,MoveNodeSet*> inputMoves_;
167 // map from operand index to MoveNodeSet
168 std::map<int,MoveNodeSet*> outputMoves_;
169 // all input moves
171 // all output moves
173 unsigned int poId_;
174 static unsigned int idCounter;
175 // Reference to original LLVM MachineInstruction
176 const llvm::MachineInstr* mInstr_;
177};
178
180public:
182 const ProgramOperationPtr po1, const ProgramOperationPtr po2) const {
183 return ProgramOperation::Comparator()(po1.get(), po2.get());
184 }
185};
186
187
188#endif
std::shared_ptr< ProgramOperation > ProgramOperationPtr
bool operator()(const ProgramOperationPtr po1, const ProgramOperationPtr po2) const
bool operator()(const ProgramOperation *po1, const ProgramOperation *po2) const
const TTAMachine::HWOperation * hwopFromOutMove(const MoveNode &outputNode) const
std::map< int, MoveNodeSet * > inputMoves_
void addGuardOutputNode(MoveNode &node)
bool hasOutputNode(int out) const
int outputMoveCount() const
const Operation & operation() const
int outputIndexFromGuard(const TTAMachine::PortGuard &pg) const
void addOutputNode(MoveNode &node, int outputIndex)
MoveNode * findTriggerFromUnit(const TTAMachine::Unit &unit) const
unsigned int poId() const
const TTAMachine::FunctionUnit * scheduledFU() const
const llvm::MachineInstr * machineInstr() const
int outputIndexFromGuardOfMove(const MoveNode &node) const
int inputMoveCount() const
std::vector< MoveNode * > MoveVector
MoveNode & moveNode(const TTAProgram::Move &move) const
MoveNode * triggeringMove() const
bool hasInputNode(int in) const
MoveNode & opcodeSettingNode()
void addNode(MoveNode &node)
ProgramOperation()
TODO: this better go, just for testing with empty operation...
std::map< int, MoveNodeSet * > outputMoves_
MoveNodeSet & inputNode(int in) const
std::string toString() const
MoveNode & inputMove(int index) const
bool hasMoveNodeForMove(const TTAProgram::Move &move) const
void removeInputNode(MoveNode &node)
void removeGuardOutputNode(MoveNode &node)
void switchInputs(int idx1=1, int idx2=2)
const TTAMachine::FunctionUnit * fuFromOutMove(const MoveNode &outputNode) const
void removeOutputNode(MoveNode &node, int outputIndex)
bool isLegalFU(const TTAMachine::FunctionUnit &fu) const
ProgramOperation & operator=(const ProgramOperation &)
void addInputNode(MoveNode &node)
MoveNode & outputMove(int index) const
int outputIndexOfMove(const MoveNode &mn) const
bool operator==(const ProgramOperation &po)
static unsigned int idCounter
MoveNodeSet & outputNode(int out) const
void setOperation(const Operation &op)
const Operation * operation_
const llvm::MachineInstr * mInstr_
ProgramOperation(const ProgramOperation &)
bool hasConstantOperand() const