CGRA-ME
OpGraph.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * The software programs comprising "CGRA-ME" and the documentation provided
3  * with them are copyright by its authors and the University of Toronto. Only
4  * non-commercial, not-for-profit use of this software is permitted without ex-
5  * plicit permission. This software is provided "as is" with no warranties or
6  * guarantees of support. See the LICENCE for more details. You should have re-
7  * ceived a copy of the full licence along with this software. If not, see
8  * <http://cgra-me.ece.utoronto.ca/license/>.
9  ******************************************************************************/
10 
11 #ifndef OPGRAPH_H___
12 #define OPGRAPH_H___
13 
14 enum class OpCode : signed char;
16 
17 #include <CGRA/MRRG.h>
18 #include <CGRA/BitSetting.h>
19 
20 #include <iosfwd>
21 #include <map>
22 #include <memory>
23 #include <set>
24 #include <string>
25 #include <unordered_map>
26 #include <utility>
27 #include <vector>
28 
29 enum class OpCode : signed char
30 {
31  NOP = -1,
32  SEXT = 1,
33  ZEXT,
34  TRUNC,
35  INPUT,
36  INPUT_PRED,
38  OUTPUT,
39  PHI,
40  CONST,
41  ADD,
42  SUB,
43  MUL,
44  DIV,
45  AND,
46  OR,
47  XOR,
48  SHL,
49  ASHR,
50  LSHR,
51  LOAD,
52  STORE,
53  GEP,
54  ICMP,
55  CMP,
56  BR,
57  SQRT,
58  FADD,
59  FMUL,
60  FDIV,
61  FP2INT,
62  INT2FP,
75  ADD_FULL,
76  ADD_HALF,
77  ADD_QUART,
78  SELECT
79 };
80 
81 using OperandTag = std::string;
82 
86 namespace Operands {
87  static constexpr auto& UNTAGGED = "";
88  static constexpr auto& PREDICATE = "pred";
89  static constexpr auto& BINARY_LHS = "LHS";
90  static constexpr auto& BINARY_RHS = "RHS";
91  static constexpr auto& BINARY_ANY = "any2input";
92  static constexpr auto& TERNARY_ANY = "any3input";
93  static constexpr auto& MEM_ADDR = "addr";
94  static constexpr auto& MEM_DATA = "data";
95  static constexpr auto& BR_TRUE = "branch_true";
96  static constexpr auto& BR_FALSE = "branch_false";
97 };
98 
99 enum class EdgeKind {
100  kDataFlow,
101  kAlias
102 };
103 
104 std::ostream& operator <<(std::ostream &os, const OpGraphOpCode &opcode);
105 const std::string& to_string(const OpGraphOpCode& opcode);
106 OpGraphOpCode opcode_from_string(const std::string& s);
107 std::istream& operator >>(std::istream &is, OpGraphOpCode &opcode);
108 inline auto operator+(const OpCode& oc) { return static_cast<std::underlying_type_t<OpCode>>(oc); }
109 
110 class MRRG;
111 class MRRGNode;
112 
113 class OpGraphNode {
114  public:
115  OpGraphNode(std::string name)
116  : name(name)
117  { }
118 
119  virtual ~OpGraphNode();
120 
121  const std::string& getName() const { return name; }
122 
123  std::string name;
124 
125  bool operator==(const OpGraphNode& rhs) const { return this->name == rhs.name; }
126  bool operator!=(const OpGraphNode& rhs) const { return not (*this == rhs); }
127 };
128 
129 class OpGraphVal;
130 
131 class OpGraphOp : public OpGraphNode
132 {
133  public:
134  OpGraphOp(std::string name, int bitwidth);
135  OpGraphOp(std::string name, int bitwidth, OpGraphOpCode opcode);
137  OpGraphOp(std::string name, int bitwidth, OpGraphOpCode opcode, std::int64_t constVal);
138  OpGraphOp(std::string name, int bitwidth, OpGraphOpCode opcode, std::string cmpMode, bool cmp);
139  ~OpGraphOp();
140 
141  OpGraphOp(const OpGraphOp&) = delete;
142  OpGraphOp(OpGraphOp&&) = default;
143  OpGraphOp& operator=(const OpGraphOp&) = delete;
144  OpGraphOp& operator=(OpGraphOp&) = default;
145 
150  OpGraphOp propertyClone(std::string new_name) const;
151 
152  std::int64_t getConstValue() const { return constVal; }
153  std::string getCmpMode() const { return cmpMode; }
154  std::string getMemName() const { return memName; }
155 
156  auto getOpCode() const { return opcode; }
157 
159  int bitwidth = 32; // Vlaue of the op bitwidth
160  std::int64_t constVal = 0; // Value of this op if it is const
161  std::string cmpMode = ""; // Value of compare operation
162  std::string memName = ""; // Name of the memory
163 
164  std::vector<OpGraphVal*> input;
165 
167  BitConfig* bitConfig = nullptr;
168  // doesn't compare fanout or fanin -- those are properties of the graph
169  bool operator==(const OpGraphOp& rhs) const;
170  bool operator!=(const OpGraphOp& rhs) const { return !(*this == rhs); }
171 
172  private:
173  friend std::ostream& operator <<(std::ostream& output, const OpGraphOp& op);
174  friend std::ostream& operator <<(std::ostream &os, const OpGraphOpCode &opcode);
175  friend std::istream& operator >>(std::istream &is, OpGraphOpCode &opcode);
176 };
177 
178 class OpGraphVal : public OpGraphNode
179 {
180  public:
181  OpGraphVal(std::string name, int bitwidth, int dist = 0, EdgeKind ek = EdgeKind::kDataFlow);
182  OpGraphVal(std::string name, int bitwidth, OpGraphOp* input_op, int dist = 0, EdgeKind ek = EdgeKind::kDataFlow);
183  ~OpGraphVal();
184 
185  OpGraphVal(const OpGraphVal&) = delete;
186  OpGraphVal(OpGraphVal&&) = default;
187  OpGraphVal& operator=(const OpGraphVal&) = delete;
188  OpGraphVal& operator=(OpGraphVal&) = default;
189 
191  std::string getOperandForOutput(const OpGraphOp*);
192  bool getPredicateForOutput(const OpGraphOp*);
193  EdgeKind getKind() {return kind;}
195  // all fanouts
196  std::vector<OpGraphOp*> output;
197  // this is the operand port that this value feeds to at the downstream Op. Parallel array to the output vector
198  std::vector<std::string> output_operand;
199  int dist = 0;
200  int bitwidth = 0;
201  std::vector<bool> output_predicate;
202 
203  friend std::ostream& operator<<(std::ostream& output, const OpGraphVal& val);
204 
205  // doesn't compare fanout or fanin -- those are properties of the graph
206  bool operator==(const OpGraphVal& rhs) const {
207  return *(const OpGraphNode*)this == rhs;
208  }
209  bool operator!=(const OpGraphVal& rhs) const { return !(*this == rhs); }
210 
211  private:
212 };
213 
214 // Multiple output DFG with val/net nodes between op nodes.
215 class OpGraph
216 {
217  public:
218  using NodeDescriptor = const OpGraphNode*;
219  using OpDescriptor = const OpGraphOp*;
220  using ValDescriptor = const OpGraphVal*;
221 
222  // Uniquely describes a hyper-edge output pin.
223  // Lets you interact with this graph as-if it were a multi-graph
224  struct EdgeDescriptor {
226  explicit operator bool() const { return (bool)val; }
227  friend std::ostream& operator<<(std::ostream& os, const EdgeDescriptor& ed);
228  };
229 
230  // A list of hyper-edge output pins describing a path through this graph
231  using Walk = std::vector<EdgeDescriptor>;
232 
237  OpGraph();
238 
242  OpGraph(const OpGraph&);
243  OpGraph(OpGraph&&) = default;
244  OpGraph& operator=(const OpGraph&);
245  OpGraph& operator=(OpGraph&&) = default;
246 
250  ~OpGraph();
251 
258 
262  template<typename... Args>
263  OpDescriptor emplace(Args&&... args) { return insert(OpGraphOp(std::forward<Args>(args)...)); }
264 
272  };
275  std::string operand_group,
276  int bitwidth = 32,
277  int dist = 0,
279 
286  std::string operand_group,
287  int bitwidth = 32,
288  int dist = 0,
290  bool predicate = false);
291  ValDescriptor link(ValDescriptor val, OpDescriptor fanout, std::string operand_group);
292 
297 
302  void unLink(ValDescriptor driver_val, OpDescriptor fanout);
303 
308  void erase(OpDescriptor op);
309 
313  auto& opNodes() const { return op_nodes; }
314  auto& valNodes() const { return val_nodes; }
315  auto& aliasNodes() const { return alias_nodes; }
316 
322  std::vector<ValDescriptor> outputVals(OpDescriptor op_desc) const;
323  const std::vector<OpGraphVal*>& inputVals(OpDescriptor op) const;
324 
329  const std::vector<OpGraphOp*>& outputOps(ValDescriptor op) const;
330  const std::vector<OpGraphOp*>& outputOps(OpDescriptor op) const;
331  std::vector<OpDescriptor> inputOps(OpDescriptor op) const;
332 
334  const std::vector<OpGraphOp*>& fanout(OpDescriptor op) const { return outputOps(op); };
335 
340 
344  const OperandTag& getOperandTag(EdgeDescriptor edge) const;
345 
346 
350  const int getDist(EdgeDescriptor edge) const;
351  const int getBitwidth(EdgeDescriptor edge) const;
352  const EdgeKind getKind(EdgeDescriptor edge) const;
353 
357  OpDescriptor targetOfEdge(EdgeDescriptor ed) const;
358 
362  std::vector<EdgeDescriptor> outEdges(const OpDescriptor& op) const;
363  std::vector<EdgeDescriptor> inEdges(const OpDescriptor& op) const;
364 
368  decltype(auto) fanout(const EdgeDescriptor& ed) const { return outEdges(targetOfEdge(ed)); }
369  decltype(auto) fanin(const EdgeDescriptor& ed) const { return inEdges(targetOfEdge(ed)); }
370 
376  OpGraphOp& getNodeRef(OpDescriptor ndesc) { return *const_cast<OpGraphOp*>(ndesc); }
377  const OpGraphOp& getNodeRef(OpDescriptor ndesc) const { return *ndesc; }
378  OpGraphVal& getNodeRef(ValDescriptor ndesc) { return *const_cast<OpGraphVal*>(ndesc); }
379  const OpGraphVal& getNodeRef(ValDescriptor ndesc) const { return *ndesc; }
380  OpGraphNode& getNodeRef(NodeDescriptor ndesc) { return *const_cast<OpGraphNode*>(ndesc); }
381  const OpGraphNode& getNodeRef(NodeDescriptor ndesc) const { return *ndesc; }
382 
386  OpDescriptor getOp(const std::string& name) const { return ops_by_name.at(name); }
387  ValDescriptor getVal(const std::string& name) const { return vals_by_name.at(name); }
388  OpGraphOp& getOpRef(const std::string& name) { return getNodeRef( getOp(name)); }
389  const OpGraphOp& getOpRef(const std::string& name) const { return getNodeRef( getOp(name)); }
390  OpGraphVal& getValRef(const std::string& name) { return getNodeRef(getVal(name)); }
391  const OpGraphVal& getValRef(const std::string& name) const { return getNodeRef(getVal(name)); }
392 
397  int getOpIndex (OpGraphOp* op) const;
398  int getValIndex (OpGraphVal* op) const;
399  int getAliasIndex (OpGraphVal* op) const;
403  const OpGraphOp* getOpByIndex (int index) const;
404  const OpGraphVal* getValByIndex (int index) const;
405 
410  OpDescriptor asOp(NodeDescriptor ndesc) const;
411  ValDescriptor asVal(NodeDescriptor ndesc) const;
412 
413  //float getCost(float pfactor);
414  int getMaxCycle();
415 
422  std::map<EdgeDescriptor,int> edgeLatencies() const;
423 
424  void print_dot(std::ostream & s) const;
425  void printDOTwithOps(std::ostream &s) const;
426 
434  void serialize(std::ostream& s) const;
435  void serialize(std::ostream& s, const std::map<OpDescriptor,int>& op_print_ranking) const;
436 
440  void clear();
441 
447  struct VerifyMessage {
448  enum class Type : char { Info, Warning, Error, };
450  std::string message;
451  };
452  std::vector<VerifyMessage> verify() const;
453 
454  friend bool operator==(const OpGraph& lhs, const OpGraph& rhs);
455  friend bool operator!=(const OpGraph& lhs, const OpGraph& rhs) { return not (lhs == rhs); }
456  friend std::ostream& operator<<(std::ostream& os, const OpGraph& og) { og.serialize(os); return os; }
457 
458  private:
459  // list of all nodes & hyper-edges in the graph
460  std::vector<OpGraphOp*> op_nodes;
461  std::vector<OpGraphVal*> val_nodes;
462  std::vector<OpGraphVal*> alias_nodes;
463 
464  // lookups
465  std::unordered_map<std::string, OpDescriptor> ops_by_name;
466  std::unordered_map<std::string, ValDescriptor> vals_by_name;
467 
468  // so we can return const& from fanout/fanin functions
469  static const std::vector<OpGraphOp*> empty_op_vector;
470  static const std::vector<OpGraphVal*> empty_val_vector;
471  static const std::vector<EdgeDescriptor> empty_edge_vector;
472 
473  static constexpr ValDescriptor null_val = nullptr;
474  static constexpr OpDescriptor null_op = nullptr;
475  static constexpr EdgeDescriptor null_edge = {nullptr, -1};
476 
477  // erased nodes are placed here to ensure descriptors are unique
478  std::vector<std::unique_ptr<OpGraphNode>> defunct_nodes = {};
479 };
480 
487 bool verifyAndPrintReport(const OpGraph& opgraph, std::ostream& os, bool silent_on_no_errors, bool throw_if_errors);
488 
492 bool analyzeOpgraphVerifyResults(std::ostream& os, const std::vector<OpGraph::VerifyMessage>& messages, const bool silent_on_no_errors);
493 
494 struct OpSchedule {
495  std::unordered_map<const OpGraphOp*, int> cycle = {};
496  int latency = -1;
497 };
498 
499 OpSchedule computeASAP(const OpGraph& op_graph);
500 OpSchedule computeALAP(const OpGraph& op_graph, unsigned int max_cycles);
501 
504  std::unordered_map<OpGraph::NodeDescriptor, OpGraph::NodeDescriptor> forward_mappings = {};
505  std::unordered_map<OpGraph::NodeDescriptor, OpGraph::NodeDescriptor> reverse_mappings = {};
506 };
507 
512  const OpGraph& src,
513  const std::set<OpGraph::OpDescriptor>& allowed_ops
514 );
515 
523 std::set<OpGraph::OpDescriptor> findNDownstreamOps(
524  const OpGraph& opgraph,
525  const std::vector<OpGraphOp*>& starting_points,
526  const std::ptrdiff_t n_ops
527 );
528 
529 inline std::ostream& operator<<(std::ostream& os, const OpGraph::VerifyMessage::Type& vm_type);
530 
531 inline char operator+(const OpGraph::VerifyMessage::Type& vm_type) { return (char)vm_type; }
532 
533 inline bool operator<(const OpGraph::EdgeDescriptor& lhs, const OpGraph::EdgeDescriptor& rhs) {
534  return std::tie(lhs.val, lhs.output_index) < std::tie(rhs.val, rhs.output_index);
535 }
536 inline bool operator==(const OpGraph::EdgeDescriptor& lhs, const OpGraph::EdgeDescriptor& rhs) {
537  return std::tie(lhs.val, lhs.output_index) == std::tie(rhs.val, rhs.output_index);
538 }
539 
540 #endif
541 
OpGraphVal::kind
EdgeKind kind
Definition: OpGraph.h:194
OpCode::BR
@ BR
OpGraph::OpOpInsertResult
Definition: OpGraph.h:270
OpGraph::empty_val_vector
static const std::vector< OpGraphVal * > empty_val_vector
Definition: OpGraph.h:470
OpGraphVal::output
std::vector< OpGraphOp * > output
Definition: OpGraph.h:196
OpGraphOp::operator>>
friend std::istream & operator>>(std::istream &is, OpGraphOpCode &opcode)
Definition: OpGraph.cpp:140
OpCode::ADD_HALF
@ ADD_HALF
BitConfig
Definition: BitSetting.h:58
OpGraph::getOpRef
OpGraphOp & getOpRef(const std::string &name)
Definition: OpGraph.h:388
OpCode::DIV
@ DIV
OpCode
OpCode
Definition: OpGraph.h:29
OpCode::MULS_HALF_LO
@ MULS_HALF_LO
OpGraph::EdgeDescriptor::val
OpGraph::ValDescriptor val
Definition: OpGraph.h:225
OpGraphOp::output
OpGraphVal * output
Definition: OpGraph.h:166
findNDownstreamOps
std::set< OpGraph::OpDescriptor > findNDownstreamOps(const OpGraph &opgraph, const std::vector< OpGraphOp * > &starting_points, const std::ptrdiff_t n_ops)
Definition: OpGraph.cpp:1246
OpCode::MULS_FULL_LO
@ MULS_FULL_LO
OpGraph::clear
void clear()
Definition: OpGraph.cpp:296
OpGraphNode::~OpGraphNode
virtual ~OpGraphNode()
Definition: OpGraph.cpp:148
OperandTag
std::string OperandTag
Definition: OpGraph.h:81
Operands::BR_TRUE
static constexpr auto & BR_TRUE
Definition: OpGraph.h:95
OpGraphTransformResult::transform_result
OpGraph transform_result
Definition: OpGraph.h:503
OpGraphVal::operator!=
bool operator!=(const OpGraphVal &rhs) const
Definition: OpGraph.h:209
OpCode::SEXT
@ SEXT
to_string
const std::string & to_string(const OpGraphOpCode &opcode)
Definition: OpGraph.cpp:111
OpCode::CONST
@ CONST
OpGraphTransformResult
Definition: OpGraph.h:502
MRRG
Definition: MRRG.h:216
OpCode::PHI
@ PHI
OpGraph::outputVals
std::vector< ValDescriptor > outputVals(OpDescriptor op_desc) const
Definition: OpGraph.cpp:483
OpGraph::ValDescriptor
const OpGraphVal * ValDescriptor
Definition: OpGraph.h:220
OpCode::ADD_QUART
@ ADD_QUART
OpGraph::getDist
const int getDist(EdgeDescriptor edge) const
Definition: OpGraph.cpp:513
OpGraph::getNodeRef
OpGraphNode & getNodeRef(NodeDescriptor ndesc)
Definition: OpGraph.h:380
OpGraph::getNodeRef
OpGraphOp & getNodeRef(OpDescriptor ndesc)
Definition: OpGraph.h:376
Operands::BINARY_LHS
static constexpr auto & BINARY_LHS
Definition: OpGraph.h:89
OpGraph::getOpIndex
int getOpIndex(OpGraphOp *op) const
Definition: OpGraph.cpp:747
OpGraphOp::getMemName
std::string getMemName() const
Definition: OpGraph.h:154
OpCode::ASHR
@ ASHR
OpGraph::targetOfEdge
OpDescriptor targetOfEdge(EdgeDescriptor ed) const
Definition: OpGraph.cpp:525
OpCode::ZEXT
@ ZEXT
OpSchedule::latency
int latency
Definition: OpGraph.h:496
OpGraphOp::operator<<
friend std::ostream & operator<<(std::ostream &output, const OpGraphOp &op)
Definition: OpGraph.cpp:559
OpCode::OR
@ OR
OpGraphOp::getConstValue
std::int64_t getConstValue() const
Definition: OpGraph.h:152
OpGraphVal::dist
int dist
Definition: OpGraph.h:199
OpGraph::asOp
OpDescriptor asOp(NodeDescriptor ndesc) const
Definition: OpGraph.cpp:1275
OpGraph::getNodeRef
OpGraphVal & getNodeRef(ValDescriptor ndesc)
Definition: OpGraph.h:378
OpGraph::getOp
OpDescriptor getOp(const std::string &name) const
Definition: OpGraph.h:386
OpGraph::inputVals
const std::vector< OpGraphVal * > & inputVals(OpDescriptor op) const
Definition: OpGraph.cpp:551
OpGraph::VerifyMessage::Type
Type
Definition: OpGraph.h:448
OpGraph::getBitwidth
const int getBitwidth(EdgeDescriptor edge) const
Definition: OpGraph.cpp:517
OpCode::SELECT
@ SELECT
OpCode::STORE
@ STORE
OpGraph::valNodes
auto & valNodes() const
Definition: OpGraph.h:314
OpGraphVal::OpGraphVal
OpGraphVal(std::string name, int bitwidth, int dist=0, EdgeKind ek=EdgeKind::kDataFlow)
Definition: OpGraph.cpp:252
OpGraph::getOpRef
const OpGraphOp & getOpRef(const std::string &name) const
Definition: OpGraph.h:389
OpSchedule::cycle
std::unordered_map< const OpGraphOp *, int > cycle
Definition: OpGraph.h:495
OpGraph::getValRef
const OpGraphVal & getValRef(const std::string &name) const
Definition: OpGraph.h:391
OpGraph::getAliasIndex
int getAliasIndex(OpGraphVal *op) const
Definition: OpGraph.cpp:765
OpGraph::inputOps
std::vector< OpDescriptor > inputOps(OpDescriptor op) const
Definition: OpGraph.cpp:497
OpGraph::null_val
static constexpr ValDescriptor null_val
Definition: OpGraph.h:473
OpGraph::getOperandTag
const OperandTag & getOperandTag(EdgeDescriptor edge) const
Definition: OpGraph.cpp:509
OpCode::ADD
@ ADD
OpCode::CMP
@ CMP
OpGraph::VerifyMessage::type
Type type
Definition: OpGraph.h:449
OpGraphVal::output_predicate
std::vector< bool > output_predicate
Definition: OpGraph.h:201
OpCode::INT2FP
@ INT2FP
OpGraphOp::operator=
OpGraphOp & operator=(const OpGraphOp &)=delete
OpGraph::edgeLatencies
std::map< EdgeDescriptor, int > edgeLatencies() const
Definition: OpGraph.cpp:906
OpGraph::print_dot
void print_dot(std::ostream &s) const
Definition: OpGraph.cpp:1040
OpGraph::serialize
void serialize(std::ostream &s) const
Definition: OpGraph.cpp:1070
OpGraph::link_like
ValDescriptor link_like(OpDescriptor driver, OpDescriptor fanout, EdgeDescriptor base)
Definition: OpGraph.cpp:418
OpGraph::VerifyMessage::message
std::string message
Definition: OpGraph.h:450
OpGraphOp::constVal
std::int64_t constVal
Definition: OpGraph.h:160
Operands::UNTAGGED
static constexpr auto & UNTAGGED
Definition: OpGraph.h:87
OpGraph::inputOp
OpDescriptor inputOp(ValDescriptor val) const
Definition: OpGraph.cpp:504
OpGraph::operator!=
friend bool operator!=(const OpGraph &lhs, const OpGraph &rhs)
Definition: OpGraph.h:455
OpGraph::operator<<
friend std::ostream & operator<<(std::ostream &os, const OpGraph &og)
Definition: OpGraph.h:456
OpGraph::getNodeRef
const OpGraphVal & getNodeRef(ValDescriptor ndesc) const
Definition: OpGraph.h:379
OpCode::MULU_QUART_LO
@ MULU_QUART_LO
OpGraph::verify
std::vector< VerifyMessage > verify() const
Definition: OpGraph.cpp:684
opcode_from_string
OpGraphOpCode opcode_from_string(const std::string &s)
Definition: OpGraph.cpp:113
OpGraphOpCode
signed char OpCode OpGraphOpCode
Definition: OpGraph.h:15
OpGraphNode::OpGraphNode
OpGraphNode(std::string name)
Definition: OpGraph.h:115
OpGraph::ops_by_name
std::unordered_map< std::string, OpDescriptor > ops_by_name
Definition: OpGraph.h:465
OpGraph::getNodeRef
const OpGraphOp & getNodeRef(OpDescriptor ndesc) const
Definition: OpGraph.h:377
OpCode::LOAD
@ LOAD
OpGraphOp::input
std::vector< OpGraphVal * > input
Definition: OpGraph.h:164
OpCode::MULS_QUART_HI
@ MULS_QUART_HI
OpGraphVal::~OpGraphVal
~OpGraphVal()
Definition: OpGraph.cpp:268
OpGraph::aliasNodes
auto & aliasNodes() const
Definition: OpGraph.h:315
analyzeOpgraphVerifyResults
bool analyzeOpgraphVerifyResults(std::ostream &os, const std::vector< OpGraph::VerifyMessage > &messages, const bool silent_on_no_errors)
Definition: OpGraph.cpp:800
OpCode::MULU_FULL_LO
@ MULU_FULL_LO
OpCode::LSHR
@ LSHR
OpGraph::VerifyMessage::Type::Info
@ Info
OpCode::MULU_HALF_HI
@ MULU_HALF_HI
OpSchedule
Definition: OpGraph.h:494
OpCode::NOP
@ NOP
OpGraph::inEdges
std::vector< EdgeDescriptor > inEdges(const OpDescriptor &op) const
Definition: OpGraph.cpp:540
OpGraphOp::operator==
bool operator==(const OpGraphOp &rhs) const
Definition: OpGraph.cpp:235
OpCode::XOR
@ XOR
OpGraph::getValByIndex
const OpGraphVal * getValByIndex(int index) const
Definition: OpGraph.cpp:782
OpGraphTransformResult::reverse_mappings
std::unordered_map< OpGraph::NodeDescriptor, OpGraph::NodeDescriptor > reverse_mappings
Definition: OpGraph.h:505
Operands::BINARY_RHS
static constexpr auto & BINARY_RHS
Definition: OpGraph.h:90
OpCode::GEP
@ GEP
OpGraph::fanin
decltype(auto) fanin(const EdgeDescriptor &ed) const
Definition: OpGraph.h:369
OpGraph::EdgeDescriptor::output_index
int output_index
Definition: OpGraph.h:225
operator>>
std::istream & operator>>(std::istream &is, OpGraphOpCode &opcode)
Definition: OpGraph.cpp:140
OpGraph::outputOps
const std::vector< OpGraphOp * > & outputOps(ValDescriptor op) const
Definition: OpGraph.cpp:488
operator==
bool operator==(const OpGraph::EdgeDescriptor &lhs, const OpGraph::EdgeDescriptor &rhs)
Definition: OpGraph.h:536
verifyAndPrintReport
bool verifyAndPrintReport(const OpGraph &opgraph, std::ostream &os, bool silent_on_no_errors, bool throw_if_errors)
Definition: OpGraph.cpp:790
OpGraphNode::name
std::string name
Definition: OpGraph.h:123
OpGraph::link
ValDescriptor link(OpDescriptor driver, OpDescriptor fanout, std::string operand_group, int bitwidth=32, int dist=0, EdgeKind kind=EdgeKind::kDataFlow, bool predicate=false)
Definition: OpGraph.cpp:364
OpCode::INPUT
@ INPUT
OpGraph::EdgeDescriptor::operator<<
friend std::ostream & operator<<(std::ostream &os, const EdgeDescriptor &ed)
Definition: OpGraph.cpp:1278
OpCode::MULU_HALF_LO
@ MULU_HALF_LO
OpGraph::opNodes
auto & opNodes() const
Definition: OpGraph.h:313
OpGraph::null_op
static constexpr OpDescriptor null_op
Definition: OpGraph.h:474
operator<
bool operator<(const OpGraph::EdgeDescriptor &lhs, const OpGraph::EdgeDescriptor &rhs)
Definition: OpGraph.h:533
OpGraph::OpOpInsertResult::link
ValDescriptor link
Definition: OpGraph.h:271
OpGraphVal::output_operand
std::vector< std::string > output_operand
Definition: OpGraph.h:198
OpGraphOp::OpGraphOp
OpGraphOp(std::string name, int bitwidth)
OpGraph::fanout
const std::vector< OpGraphOp * > & fanout(OpDescriptor op) const
Definition: OpGraph.h:334
OpGraph::outputVal
ValDescriptor outputVal(OpDescriptor op) const
Definition: OpGraph.cpp:476
OpCode::INPUT_PRED
@ INPUT_PRED
OpGraph::VerifyMessage::Type::Warning
@ Warning
OpGraphVal::getKind
EdgeKind getKind()
Definition: OpGraph.h:193
OpGraphNode
Definition: OpGraph.h:113
OpCode::MULU_FULL_HI
@ MULU_FULL_HI
OpGraphVal::operator=
OpGraphVal & operator=(const OpGraphVal &)=delete
OpGraph::operator==
friend bool operator==(const OpGraph &lhs, const OpGraph &rhs)
Definition: OpGraph.cpp:1159
OpCode::FMUL
@ FMUL
OpGraph::getValRef
OpGraphVal & getValRef(const std::string &name)
Definition: OpGraph.h:390
OpGraphOp::propertyClone
OpGraphOp propertyClone() const
Definition: OpGraph.h:149
OpGraph::OpOpInsertResult::newOp
OpDescriptor newOp
Definition: OpGraph.h:271
OpGraphOp::bitwidth
int bitwidth
Definition: OpGraph.h:159
OpCode::SHL
@ SHL
OpGraph::empty_op_vector
static const std::vector< OpGraphOp * > empty_op_vector
Definition: OpGraph.h:469
OpGraph::getOpByIndex
const OpGraphOp * getOpByIndex(int index) const
Definition: OpGraph.cpp:774
computeALAP
OpSchedule computeALAP(const OpGraph &op_graph, unsigned int max_cycles)
Definition: OpGraph.cpp:629
OpGraph::defunct_nodes
std::vector< std::unique_ptr< OpGraphNode > > defunct_nodes
Definition: OpGraph.h:478
OpGraph::~OpGraph
~OpGraph()
Definition: OpGraph.cpp:294
OpCode::FDIV
@ FDIV
OpCode::TRUNC
@ TRUNC
OpGraphTransformResult::forward_mappings
std::unordered_map< OpGraph::NodeDescriptor, OpGraph::NodeDescriptor > forward_mappings
Definition: OpGraph.h:504
OpGraph::val_nodes
std::vector< OpGraphVal * > val_nodes
Definition: OpGraph.h:461
OpGraphOp::getCmpMode
std::string getCmpMode() const
Definition: OpGraph.h:153
OpGraph::NodeDescriptor
const OpGraphNode * NodeDescriptor
Definition: OpGraph.h:218
OpGraphVal
Definition: OpGraph.h:178
EdgeKind
EdgeKind
Definition: OpGraph.h:99
OpCode::SQRT
@ SQRT
OpGraph::operator=
OpGraph & operator=(const OpGraph &)
Definition: OpGraph.cpp:319
OpGraph::getKind
const EdgeKind getKind(EdgeDescriptor edge) const
Definition: OpGraph.cpp:521
OpGraph::asVal
ValDescriptor asVal(NodeDescriptor ndesc) const
Definition: OpGraph.cpp:1276
OpGraphOp::bitConfig
BitConfig * bitConfig
Definition: OpGraph.h:167
OpGraphOp
Definition: OpGraph.h:131
OpGraphVal::operator==
bool operator==(const OpGraphVal &rhs) const
Definition: OpGraph.h:206
EdgeKind::kAlias
@ kAlias
MRRGNode
Definition: MRRG.h:60
OpGraphOp::getOpCode
auto getOpCode() const
Definition: OpGraph.h:156
OpGraph::VerifyMessage
Definition: OpGraph.h:447
OpGraph::empty_edge_vector
static const std::vector< EdgeDescriptor > empty_edge_vector
Definition: OpGraph.h:471
OpCode::MULS_FULL_HI
@ MULS_FULL_HI
EdgeKind::kDataFlow
@ kDataFlow
OpGraphOp::cmpMode
std::string cmpMode
Definition: OpGraph.h:161
OpCode::OUTPUT
@ OUTPUT
OpCode::ADD_FULL
@ ADD_FULL
OpGraph::VerifyMessage::Type::Error
@ Error
Operands
Definition: OpGraph.h:86
OpGraph::EdgeDescriptor
Definition: OpGraph.h:224
OpCode::AND
@ AND
Operands::BR_FALSE
static constexpr auto & BR_FALSE
Definition: OpGraph.h:96
OpCode::OUTPUT_PRED
@ OUTPUT_PRED
OpGraphNode::operator==
bool operator==(const OpGraphNode &rhs) const
Definition: OpGraph.h:125
OpGraph::insert
OpDescriptor insert(OpGraphOp op)
Definition: OpGraph.cpp:338
OpCode::MULS_QUART_LO
@ MULS_QUART_LO
OpCode::SUB
@ SUB
OpCode::MUL
@ MUL
OpGraph::alias_nodes
std::vector< OpGraphVal * > alias_nodes
Definition: OpGraph.h:462
OpGraphVal::getOperandForOutput
std::string getOperandForOutput(const OpGraphOp *)
Definition: OpGraph.cpp:270
OpGraphVal::input
OpGraphOp * input
Definition: OpGraph.h:190
OpGraphVal::operator<<
friend std::ostream & operator<<(std::ostream &output, const OpGraphVal &val)
Definition: OpGraph.cpp:565
OpCode::ICMP
@ ICMP
OpGraph::getMaxCycle
int getMaxCycle()
Definition: OpGraph.cpp:867
operator+
auto operator+(const OpCode &oc)
Definition: OpGraph.h:108
OpGraph::printDOTwithOps
void printDOTwithOps(std::ostream &s) const
Definition: OpGraph.cpp:1000
OpGraphVal::bitwidth
int bitwidth
Definition: OpGraph.h:200
OpGraph::op_nodes
std::vector< OpGraphOp * > op_nodes
Definition: OpGraph.h:460
OpGraphOp::~OpGraphOp
~OpGraphOp()
Definition: OpGraph.cpp:250
OpGraph::getVal
ValDescriptor getVal(const std::string &name) const
Definition: OpGraph.h:387
OpGraph::vals_by_name
std::unordered_map< std::string, ValDescriptor > vals_by_name
Definition: OpGraph.h:466
Operands::MEM_DATA
static constexpr auto & MEM_DATA
Definition: OpGraph.h:94
computeASAP
OpSchedule computeASAP(const OpGraph &op_graph)
Definition: OpGraph.cpp:572
OpGraph::outEdges
std::vector< EdgeDescriptor > outEdges(const OpDescriptor &op) const
Definition: OpGraph.cpp:530
Operands::BINARY_ANY
static constexpr auto & BINARY_ANY
Definition: OpGraph.h:91
OpGraph::unLink
void unLink(ValDescriptor driver_val, OpDescriptor fanout)
Definition: OpGraph.cpp:422
OpGraph::emplace
OpDescriptor emplace(Args &&... args)
Definition: OpGraph.h:263
OpCode::MULS_HALF_HI
@ MULS_HALF_HI
OpGraphOp::memName
std::string memName
Definition: OpGraph.h:162
OpGraph::erase
void erase(OpDescriptor op)
Definition: OpGraph.cpp:453
OpGraphOp::operator!=
bool operator!=(const OpGraphOp &rhs) const
Definition: OpGraph.h:170
OpCode::FP2INT
@ FP2INT
OpGraph::Walk
std::vector< EdgeDescriptor > Walk
Definition: OpGraph.h:231
Operands::PREDICATE
static constexpr auto & PREDICATE
Definition: OpGraph.h:88
operator<<
std::ostream & operator<<(std::ostream &os, const OpGraphOpCode &opcode)
Definition: OpGraph.cpp:100
OpGraph::OpDescriptor
const OpGraphOp * OpDescriptor
Definition: OpGraph.h:219
OpCode::MULU_QUART_HI
@ MULU_QUART_HI
OpGraphNode::operator!=
bool operator!=(const OpGraphNode &rhs) const
Definition: OpGraph.h:126
OpCode::FADD
@ FADD
OpGraph
Definition: OpGraph.h:215
OpGraphOp::opcode
OpGraphOpCode opcode
Definition: OpGraph.h:158
OpGraphVal::getPredicateForOutput
bool getPredicateForOutput(const OpGraphOp *)
Definition: OpGraph.cpp:276
OpGraph::null_edge
static constexpr EdgeDescriptor null_edge
Definition: OpGraph.h:475
OpGraph::getValIndex
int getValIndex(OpGraphVal *op) const
Definition: OpGraph.cpp:756
OpGraph::getNodeRef
const OpGraphNode & getNodeRef(NodeDescriptor ndesc) const
Definition: OpGraph.h:381
filter
OpGraphTransformResult filter(const OpGraph &src, const std::set< OpGraph::OpDescriptor > &allowed_ops)
Definition: OpGraph.cpp:1212
OpGraph::OpGraph
OpGraph()
Definition: OpGraph.cpp:282
OpGraphNode::getName
const std::string & getName() const
Definition: OpGraph.h:121
Operands::MEM_ADDR
static constexpr auto & MEM_ADDR
Definition: OpGraph.h:93
Operands::TERNARY_ANY
static constexpr auto & TERNARY_ANY
Definition: OpGraph.h:92