CGRAOmp  0.1
CGRADataFlowGraph.hpp
Go to the documentation of this file.
1 /*
2 * MIT License
3 *
4 * Copyright (c) 2021 Amano laboratory, Keio University & Processor Research Team, RIKEN Center for Computational Science
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy of
7 * this software and associated documentation files (the "Software"), to deal in
8 * the Software without restriction, including without limitation the rights to
9 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
10 * of the Software, and to permit persons to whom the Software is furnished to do
11 * so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * 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 THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 *
24 * File: /include/CGRADataFlowGraph.hpp
25 * Project: CGRAOmp
26 * Author: Takuya Kojima in The University of Tokyo (tkojima@hal.ipc.i.u-tokyo.ac.jp)
27 * Created Date: 27-08-2021 15:03:28
28 * Last Modified: 20-07-2022 13:48:25
29 */
30 #ifndef CGRADataFlowGraph_H
31 #define CGRADataFlowGraph_H
32 
33 #include "llvm/Support/DOTGraphTraits.h"
34 #include "llvm/ADT/DirectedGraph.h"
35 #include "llvm/Support/FormatVariadic.h"
36 #include "llvm/ADT/StringRef.h"
37 #include "llvm/ADT/StringMap.h"
38 #include "llvm/IR/Constant.h"
39 #include "llvm/IR/Instruction.h"
40 #include "llvm/ADT/APFloat.h"
41 #include "llvm/Support/JSON.h"
42 
43 #include "CGRAInstMap.hpp"
44 #include "OptionPlugin.hpp"
45 #include "Utils.hpp"
46 
47 #include <string>
48 #include <utility>
49 #include <stdint.h>
50 
51 using namespace CGRAOmp;
52 using namespace std;
53 
54 #define VROOT_NODE_ID (-1)
55 
56 
57 namespace llvm {
58  class DFGNode;
59  class DFGEdge;
60  class CGRADFG;
61  using DFGNodeBase = DGNode<DFGNode, DFGEdge>;
62  using DFGEdgeBase = DGEdge<DFGNode, DFGEdge>;
63  using CGRADFGBase = DirectedGraph<DFGNode, DFGEdge>;
64 
69  class DFGNode : public DFGNodeBase {
70  public:
71  friend CGRADFG;
72  enum class NodeKind {
73  Compute,
74  MemLoad,
75  MemStore,
76  Compare,
77  Constant,
78  GlobalData,
79  VirtualRoot,
80  };
81 
82  DFGNode(int ID, NodeKind kind, Value *val) :
83  DFGNodeBase(), ID(ID), kind(kind), val(val) {};
84 
85  DFGNode(NodeKind kind, Value* val) :
86  DFGNode((std::uintptr_t)(val), kind, val) {}
87 
88  DFGNode(const DFGNode &N) {
89  *this = N;
90  }
92  *this = std::move(N);
93  }
94 
95  DFGNode &operator=(const DFGNode &N) {
96  DGNode::operator=(N);
97  return *this;
98  }
99 
101  DGNode::operator=(std::move(N));
102  return *this;
103  }
104 
105  NodeKind getKind() const {
106  return kind;
107  }
108 
109  int getID() const { return ID; }
110 
111  Value* getValue() const { return val; }
112 
113  virtual string getUniqueName() const = 0;
114  virtual string getNodeAttr() const = 0;
115  virtual string getExtraAttr() const { return ""; };
116 
117  bool isEqualTo(const DFGNode &N) const {
118  return this->ID == N.ID;
119  }
120 
121  void setExtraInfo(StringRef key, json::Value V) {
122  extra_info[key] = new json::Value(std::move(V));
123  }
124 
125  bool hasExtraInfo() const {
126  return !extra_info.empty();
127  }
128 
129  json::Value getExtraInfoAsJSONObject() {
130  if (!hasExtraInfo()) {
131  return json::Object({});
132  } else {
133  json::Object json_obj;
134  for (auto &item : extra_info) {
135  json_obj[item.getKey()] = *(item.getValue());
136  }
137  return json::Value(std::move(json_obj));
138  }
139 
140  }
141 
142  protected:
144  int ID;
145  Value *val;
146  StringMap<json::Value*> extra_info;
147 
148  };
149 
154  class VirtualRootNode : public DFGNode {
155  public:
158  DFGNode::NodeKind::VirtualRoot, nullptr) {}
159  string getUniqueName() const {
160  return "__VROOT";
161  }
162  string getNodeAttr() const {
163  return "";
164  }
165  };
166 
171  class ComputeNode : public DFGNode {
172  public:
173  ComputeNode(Instruction* inst, std::string opcode) :
174  DFGNode(DFGNode::NodeKind::Compute, inst), opcode(opcode) {}
175 
176  string getUniqueName() const {
177  return opcode + "_" + to_string(getID());
178  }
179  string getNodeAttr() const {
180  return formatv("type=op,{0}={1}", OptDFGOpKey, opcode);
181  }
182  static bool classof(const DFGNode* N) {
183  return N->getKind() == NodeKind::Compute;
184  }
185  Instruction* getInst() const {
186  return dyn_cast<Instruction>(val);
187  }
188  private:
189  std::string opcode;
190  };
191 
192  class MemAccessNode : public DFGNode {
193  public:
194  MemAccessNode(LoadInst *load) :
195  DFGNode(DFGNode::NodeKind::MemLoad, load) {
196  is_load = true;
197  addr = load->getOperand(0);
198  }
199 
200  MemAccessNode(StoreInst *store) :
201  DFGNode(DFGNode::NodeKind::MemStore, store) {
202  is_load = false;
203  addr = store->getOperand(1);
204  }
205 
206  inline bool isLoad() { return is_load;}
207 
208  string getUniqueName() const {
209  if (is_load) {
210  return "Load_" + to_string(getID());
211  } else {
212  return "Store_" + to_string(getID());
213  }
214  }
215 
216  string getNodeAttr() const {
217  string type = (is_load) ? "input" : "output";
218  return formatv("type={0},data={1}", type, getSymbol());
219  }
220 
226  string getSymbol() const {
227  if (auto gep = dyn_cast<GetElementPtrInst>(addr)) {
228  auto *ptr = gep->getPointerOperand();
229  if (isa<Argument>(*ptr)) {
230  if (ptr->hasName()) {
231  return string(ptr->getName());
232  }
233  } else if (auto load = dyn_cast<LoadInst>(ptr)) {
234  auto child_ptr = load->getPointerOperand();
235  if (isa<Argument>(*child_ptr)) {
236  if (child_ptr->hasName()) {
237  return string(child_ptr->getName());
238  }
239  }
240  } else if (auto *alloc_inst = dyn_cast<AllocaInst>(ptr)) {
241  return string(alloc_inst->getName());
242  }
243  return "unknown";
244  } else {
245  return "unknown";
246  }
247  }
248 
249  static bool classof(const DFGNode* N) {
250  return N->getKind() == NodeKind::MemLoad ||
251  N->getKind() == NodeKind::MemStore;
252  }
253  private:
254  bool is_load;
255  Value *addr;
256  };
257 
258  template <DFGNode::NodeKind DrivedKind>
259  class DataNode : public DFGNode {
260  public:
261  using SkipSeq = SmallVector<Value*>;
262 
263  explicit DataNode(Value *v) :
264  DataNode(v, nullptr) {};
265 
266  // constructor used if it has skipped nodes
267  DataNode(Value *v, SkipSeq* seq) :
268  DFGNode(DrivedKind, v), skip_seq(seq) {};
269 
270  DataNode(Value *v, SkipSeq* seq, int ID) :
271  DFGNode(ID, DrivedKind, v), skip_seq(seq) {};
272 
273 
274  protected:
275 
276  string getTypeName(Type* ty) const {
277  Type *ele_ty = ty;
278  string format_str = "{0}", type_str;
279 
280  while (ele_ty->isPointerTy()) {
281  ele_ty = ty->getPointerElementType();
282  }
283  while (ele_ty->isArrayTy()) {
284  int size = dyn_cast<ArrayType>(ele_ty)->getArrayNumElements();
285  format_str += formatv("[{0}]", size);
286  ele_ty = ele_ty->getArrayElementType();
287  }
288 
289  if (ele_ty->isFloatingPointTy()) {
290  type_str = "float" + to_string(Utils::getDataWidth(ele_ty));
291  } else if (ele_ty->isIntegerTy()) {
292  type_str = "int" + to_string(Utils::getDataWidth(ele_ty));
293  } else {
294  type_str = "unknown";
295  }
296 
297  return formatv(format_str.c_str(), type_str);
298  }
299 
300  string getSkipSeq() const {
301  #define DEBUG_TYPE "cgraomp"
302  string str = "";
303  if (skip_seq) {
304  SmallVector<string> opcode_vec;
305  for (auto it = ++(skip_seq->rbegin()); it != skip_seq->rend(); it++) {
306  if (auto inst = dyn_cast<Instruction>(*it)) {
307  opcode_vec.emplace_back(inst->getOpcodeName());
308  } else {
309  LLVM_DEBUG(dbgs() << ERR_DEBUG_PREFIX
310  << " Unexpected skip instruction: ";
311  (*it)->print(dbgs());
312  dbgs() << "\n"
313  );
314  }
315  }
316  str = formatv("skipped=\"({0})\",", make_range(opcode_vec.begin(), opcode_vec.end()));
317  }
318  return str;
319  #undef DEBUG_TYPE
320  }
321 
323  };
324 
325  class ConstantNode : public DataNode<DFGNode::NodeKind::Constant> {
326  public:
327  explicit ConstantNode(Value *v) :
328  ConstantNode(v, nullptr) {};
329 
330  ConstantNode(Value *v, int ID) :
331  ConstantNode(v, nullptr, ID) {};
332 
333 
334  // constructor used if it has skipped nodes
335  ConstantNode(Value *v, SkipSeq* seq) :
336  DataNode<DFGNode::NodeKind::Constant>(v, seq) {};
337 
338  ConstantNode(Value *v, SkipSeq* seq, int ID) :
339  DataNode<DFGNode::NodeKind::Constant>(v, seq, ID) {};
340 
341  string getUniqueName() const {
342  return "Const_" + to_string(getID());
343  }
344  virtual string getNodeAttr() const;
345 
346  virtual string getExtraAttr() const {
347  return getConstStr();
348  }
349  static bool classof(const DFGNode *N) {
350  return N->getKind() == NodeKind::Constant;
351  }
352  private:
353  string getConstStr() const;
354 
355  };
356 
357  class GlobalDataNode : public DataNode<DFGNode::NodeKind::GlobalData> {
358  public:
359  explicit GlobalDataNode(Value *v) :
360  GlobalDataNode(v, nullptr) {};
361 
362  // constructor used if it has skipped nodes
363  GlobalDataNode(Value *v, SkipSeq* seq) :
364  DataNode<DFGNode::NodeKind::GlobalData>(v, seq) {};
365 
366  string getUniqueName() const {
367  return "GlobalData_" + to_string(getID());
368  }
369  string getNodeAttr() const;
370 
371  string getExtraAttr() const {
372  return getDataStr();
373  }
374  static bool classof(const DFGNode *N) {
375  return N->getKind() == NodeKind::GlobalData;
376  }
377  private:
378  string getDataStr() const;
379 
380  };
381 
382 
383  template<char const* OPCODE_STR>
384  class GEPNode : public DFGNode {
385  public:
386  GEPNode(GetElementPtrInst *gep, int ID) :
387  DFGNode(ID, DFGNode::NodeKind::Compute, gep), opcode(OPCODE_STR) {}
388 
389  string getUniqueName() const {
390  return opcode + "_" + to_string(getID());
391  }
392  string getNodeAttr() const {
393  return formatv("type=op,{0}={1}", OptDFGOpKey, opcode);
394  }
395  static bool classof(const DFGNode* N) {
396  return N->getKind() == NodeKind::Compute;
397  }
398  Instruction* getInst() const {
399  return dyn_cast<Instruction>(val);
400  }
401  private:
402  std::string opcode;
403  };
404 
405  class GEPConstantNode : public ConstantNode {
406  public:
407  explicit GEPConstantNode(Value *v, int ID, int const_value) :
408  ConstantNode(v, ID), const_value(const_value) {};
409 
410  virtual string getExtraAttr() const {
411  return formatv("datatype=int,value={0}", const_value);
412  }
413  virtual string getNodeAttr() const {
414  return formatv("type=const,{0}", getExtraAttr());
415  }
416 
417  private:
419  };
420 
421 
426  class DFGEdge : public DFGEdgeBase {
427  public:
428  enum class EdgeKind {
429  Normal,
430  LoopCarried,
431  Init
432  };
433  DFGEdge(DFGNode &N, int operand = 0, EdgeKind Kind = EdgeKind::Normal)
434  : DFGEdgeBase(N), operand(operand), Kind(Kind) {}
435 
436  DFGEdge(const DFGEdge &E) : DFGEdgeBase(E) {
437  *this = E;
438  };
439  DFGEdge(DFGEdge &&E) : DFGEdgeBase(std::move(E)) {
440  *this = std::move(E);
441  };
442 
443  DFGEdge &operator=(const DFGEdge &E) {
444  DFGEdgeBase::operator=(E);
445  return *this;
446  };
447 
449  DFGEdgeBase::operator=(std::move(E));
450  return *this;
451  };
452 
453  virtual string getEdgeAttr() const {
454  return formatv("operand={0}", operand);
455  }
456 
457  EdgeKind getKind() const { return Kind; }
458 
459  protected:
460  int operand;
462  };
463 
464  class LoopDependencyEdge : public DFGEdge {
465  public:
466  LoopDependencyEdge(DFGNode &N, int operand, int distance) :
467  DFGEdge(N, operand, EdgeKind::LoopCarried), distance(distance) {}
468 
469 
470  virtual string getEdgeAttr() const {
471  // add distance info
472  return formatv("operand={0},dir=back,distance={1},label={1}", operand ,distance);
473  }
474 
475  static bool classof(const DFGEdge* E) {
476  return E->getKind() == EdgeKind::LoopCarried;
477  }
478 
479  private:
480  int distance;
481  };
482 
483  class InitDataEdge : public DFGEdge {
484  public:
485  InitDataEdge(DFGNode &N, int operand) :
486  DFGEdge(N, operand, EdgeKind::Init) {}
487 
488  virtual string getEdgeAttr() const {
489  return formatv("operand={0},type=init,label=init", operand);
490  }
491 
492  static bool classof(const DFGEdge* E) {
493  return E->getKind() == EdgeKind::Init;
494  }
495  private:
496 
497  };
498 
505  class CGRADFG : public CGRADFGBase {
506  public:
507  using NodeType = DFGNode;
508  using EdgeType = DFGEdge;
509  using EdgeInfoType = std::pair<NodeType*, EdgeListTy>;
510 
511  CGRADFG() = delete;
518  CGRADFG(Function *F, Loop *L) : CGRADFGBase(),
519  F(F), L(L) {
520  createVirtualRoot();
521  };
522  CGRADFG(const CGRADFG &G) = delete;
524  CGRADFG(CGRADFG &&G) : CGRADFGBase(std::move(G)) {
525  virtual_root = G.virtual_root;
526  G.virtual_root = nullptr;
527  };
528 
531  createVirtualRoot();
532  auto E = new DFGEdge(N);
533  connect(getRoot(), N, *E);
534  };
535 
538  delete virtual_root;
539  Nodes.clear();
540  }
541 
547  NodeType &getRoot() const {
548  return *virtual_root;
549  }
550 
560  NodeType* addNode(NodeType &N);
561 
571  bool connect(NodeType &Src, NodeType &Dst, EdgeType &E);
572 
586  SmallVectorImpl<EdgeInfoType> &EL,
587  bool ignore_vroot = false) const {
588  assert(EL.empty() && "Expected the list of edges to be empty.");
589  EdgeListTy TempList;
590  for (auto *Node : Nodes) {
591  if (*Node == N)
592  continue;
593  if (ignore_vroot && *Node == getRoot()) continue;
594  if (Node->findEdgesTo(N, TempList)) {
595  EL.push_back(std::make_pair(Node,TempList));
596  }
597  TempList.clear();
598  }
599  return !EL.empty();
600  }
601 
602  bool hasExtraInfo() const {
603  bool find = false;
604  for (auto *Node : Nodes) {
605  if (Node->hasExtraInfo()) {
606  find = true;
607  break;
608  }
609  }
610  return find;
611  }
612 
619  string convertToReadableNodeName(const string dot_string) const;
620 
627  Error saveAsDotGraph(StringRef filepath);
628 
629  Error saveExtraInfo(StringRef filepath);
630 
636  void setName(const string graph_name) {
637  name = graph_name;
638  }
639 
645  string getName() const {
646  return name;
647  }
648 
649  void makeSequentialNodeID();
650 
651  Function* getFunction() {
652  return F;
653  }
654 
655  Loop* getLoop() {
656  return L;
657  }
658 
659  private:
660 
662  virtual_root = new VirtualRootNode();
663  CGRADFGBase::addNode(*virtual_root);
664  }
665  NodeType *virtual_root = nullptr;
666 
667  string name = "";
668 
669  Function *F;
670  Loop *L;
671  };
672 
677  template <>
678  struct GraphTraits<DFGNode *> {
679  using NodeRef = DFGNode *;
680 
682  return &P->getTargetNode();
683  }
684 
685  using ChildIteratorType =
686  mapped_iterator<DFGNode::iterator, decltype(&DDGGetTargetNode)>;
687  using ChildEdgeIteratorType = DFGNode::iterator;
688 
690  return ChildIteratorType(N->begin(), &DDGGetTargetNode);
691  }
693  return ChildIteratorType(N->end(), &DDGGetTargetNode);
694  }
695 
697  return N->begin();
698  }
699 
701  return N->end();
702  }
703  };
704 
709  template <>
710  struct GraphTraits<CGRADFG *> : public GraphTraits<DFGNode*> {
711  using nodes_iterator = CGRADFG::iterator;
713  return &G->getRoot();
714  }
716  return G->begin();
717  }
719  return G->end();
720  }
721  };
722 
727  template <>
728  struct GraphTraits<const DFGNode *> {
729  using NodeRef = const DFGNode *;
730 
731  static const DFGNode *DDGGetTargetNode(const DFGEdge *P) {
732  return &P->getTargetNode();
733  }
734 
735  using ChildIteratorType =
736  mapped_iterator<DFGNode::iterator, decltype(&DDGGetTargetNode)>;
737  using ChildEdgeIteratorType = DFGNode::iterator;
738 
740  return ChildIteratorType(N->begin(), &DDGGetTargetNode);
741  }
743  return ChildIteratorType(N->end(), &DDGGetTargetNode);
744  }
745 
747  return N->begin();
748  }
749 
751  return N->end();
752  }
753  };
754 
759  template <>
760  struct GraphTraits<const CGRADFG *> : public GraphTraits<DFGNode*> {
761  using nodes_iterator = CGRADFG::const_iterator;
762  static NodeRef getEntryNode(const CGRADFG *G) {
763  return &G->getRoot();
764  }
765  static nodes_iterator nodes_begin(const CGRADFG *G) {
766  return G->begin();
767  }
768  static nodes_iterator nodes_end(const CGRADFG *G) {
769  return G->end();
770  }
771  };
772 
778  template<>
779  struct DOTGraphTraits<const CGRADFG *> : public DefaultDOTGraphTraits {
780  public:
781  DOTGraphTraits(bool isSimple) : DefaultDOTGraphTraits(isSimple) {};
782  DOTGraphTraits() : DefaultDOTGraphTraits(false) {};
783 
784  string getGraphName(const CGRADFG *G) {
785  return G->getName();
786  }
787 
788  static string getGraphProperties(const CGRADFG *G);
789 
790  static bool isNodeHidden(const DFGNode *Node,
791  const CGRADFG *G) {
792  return *Node == G->getRoot();
793  }
794 
795  static string getNodeLabel(const DFGNode *Node,
796  const CGRADFG *G) {
797  return Node->getUniqueName();
798  }
799 
800  static string getNodeIdentifierLabel(const DFGNode *Node,
801  const CGRADFG *G) {
802  return Node->getExtraAttr();
803  }
804 
805  static string getNodeDescription(const DFGNode *Node,
806  const CGRADFG *G) {
807  return "";
808  }
809 
810  static string getNodeAttributes(const DFGNode *Node,
811  const CGRADFG *G) {
812  return Node->getNodeAttr();
813  }
814 
815  static string getEdgeAttributes(const DFGNode *Node,
816  GraphTraits<DFGNode *>::ChildIteratorType I,
817  const CGRADFG *G);
818  private:
822  static StringMap<StringRef> default_graph_prop;
826  static StringMap<StringRef> default_node_prop;
830  static StringMap<StringRef> default_edge_prop;
831 
832  };
833 
835 
836 };
837 
838 #endif //CGRADataFlowGraph_H
llvm::CGRADFG::createVirtualRoot
void createVirtualRoot()
Definition: CGRADataFlowGraph.hpp:661
llvm::CGRADFG::hasExtraInfo
bool hasExtraInfo() const
Definition: CGRADataFlowGraph.hpp:602
llvm::DFGNode::extra_info
StringMap< json::Value * > extra_info
Definition: CGRADataFlowGraph.hpp:146
llvm::DataNode::getSkipSeq
string getSkipSeq() const
Definition: CGRADataFlowGraph.hpp:300
llvm
Definition: OptionPlugin.cpp:128
llvm::GEPNode
Definition: CGRADataFlowGraph.hpp:384
llvm::GlobalDataNode::getExtraAttr
string getExtraAttr() const
Definition: CGRADataFlowGraph.hpp:371
llvm::DOTGraphTraits< const CGRADFG * >::getGraphName
string getGraphName(const CGRADFG *G)
Definition: CGRADataFlowGraph.hpp:784
llvm::CGRADFG::L
Loop * L
Definition: CGRADataFlowGraph.hpp:670
llvm::GraphTraits< CGRADFG * >::getEntryNode
static NodeRef getEntryNode(CGRADFG *G)
Definition: CGRADataFlowGraph.hpp:712
llvm::DOTGraphTraits< const CGRADFG * >::getNodeAttributes
static string getNodeAttributes(const DFGNode *Node, const CGRADFG *G)
Definition: CGRADataFlowGraph.hpp:810
llvm::ComputeNode::getNodeAttr
string getNodeAttr() const
Definition: CGRADataFlowGraph.hpp:179
llvm::MemAccessNode::is_load
bool is_load
Definition: CGRADataFlowGraph.hpp:254
llvm::VirtualRootNode
A concrete class for virtual root node, connected to all the primary input node.
Definition: CGRADataFlowGraph.hpp:154
llvm::VirtualRootNode::VirtualRootNode
VirtualRootNode()
Definition: CGRADataFlowGraph.hpp:156
llvm::MemAccessNode::MemAccessNode
MemAccessNode(LoadInst *load)
Definition: CGRADataFlowGraph.hpp:194
llvm::CGRADFG::getLoop
Loop * getLoop()
Definition: CGRADataFlowGraph.hpp:655
llvm::DOTGraphTraits< const CGRADFG * >
Specilized template of DotGraphTraits for CGRADFG This is needed to save CGRADFG as DOT graph file.
Definition: CGRADataFlowGraph.hpp:779
llvm::GEPConstantNode
Definition: CGRADataFlowGraph.hpp:405
llvm::MemAccessNode::getSymbol
string getSymbol() const
Get a symbol name to be accessed.
Definition: CGRADataFlowGraph.hpp:226
llvm::DOTGraphTraits< const CGRADFG * >::default_node_prop
static StringMap< StringRef > default_node_prop
a default node propterties for DOT graph
Definition: CGRADataFlowGraph.hpp:826
llvm::CGRADFG::setName
void setName(const string graph_name)
Set the Name object.
Definition: CGRADataFlowGraph.hpp:636
llvm::InitDataEdge::classof
static bool classof(const DFGEdge *E)
Definition: CGRADataFlowGraph.hpp:492
llvm::GraphTraits< const DFGNode * >::ChildEdgeIteratorType
DFGNode::iterator ChildEdgeIteratorType
Definition: CGRADataFlowGraph.hpp:737
llvm::DFGNode::DFGNode
DFGNode(int ID, NodeKind kind, Value *val)
Definition: CGRADataFlowGraph.hpp:82
llvm::DOTGraphTraits< const CGRADFG * >::DOTGraphTraits
DOTGraphTraits(bool isSimple)
Definition: CGRADataFlowGraph.hpp:781
llvm::ComputeNode::getUniqueName
string getUniqueName() const
Definition: CGRADataFlowGraph.hpp:176
llvm::DFGNode::DFGNode
DFGNode(NodeKind kind, Value *val)
Definition: CGRADataFlowGraph.hpp:85
llvm::DataNode::skip_seq
SkipSeq * skip_seq
Definition: CGRADataFlowGraph.hpp:322
llvm::GlobalDataNode::GlobalDataNode
GlobalDataNode(Value *v)
Definition: CGRADataFlowGraph.hpp:359
llvm::DFGNode::operator=
DFGNode & operator=(DFGNode &&N)
Definition: CGRADataFlowGraph.hpp:100
llvm::ComputeNode::ComputeNode
ComputeNode(Instruction *inst, std::string opcode)
Definition: CGRADataFlowGraph.hpp:173
llvm::CGRADFG::CGRADFG
CGRADFG(NodeType &N)
constructor with an initial node
Definition: CGRADataFlowGraph.hpp:530
llvm::CGRADFG::CGRADFG
CGRADFG(Function *F, Loop *L)
Constructor.
Definition: CGRADataFlowGraph.hpp:518
llvm::DataNode::DataNode
DataNode(Value *v, SkipSeq *seq)
Definition: CGRADataFlowGraph.hpp:267
llvm::GEPNode::getInst
Instruction * getInst() const
Definition: CGRADataFlowGraph.hpp:398
llvm::GEPConstantNode::getNodeAttr
virtual string getNodeAttr() const
Definition: CGRADataFlowGraph.hpp:413
llvm::DFGEdge::Kind
EdgeKind Kind
Definition: CGRADataFlowGraph.hpp:461
llvm::DFGNode::DFGNode
DFGNode(DFGNode &&N)
Definition: CGRADataFlowGraph.hpp:91
llvm::ConstantNode::getExtraAttr
virtual string getExtraAttr() const
Definition: CGRADataFlowGraph.hpp:346
llvm::GraphTraits< CGRADFG * >::nodes_iterator
CGRADFG::iterator nodes_iterator
Definition: CGRADataFlowGraph.hpp:711
llvm::ConstantNode::classof
static bool classof(const DFGNode *N)
Definition: CGRADataFlowGraph.hpp:349
llvm::DOTGraphTraits< const CGRADFG * >::DOTGraphTraits
DOTGraphTraits()
Definition: CGRADataFlowGraph.hpp:782
llvm::DFGNode::CGRADFG
friend CGRADFG
Definition: CGRADataFlowGraph.hpp:71
llvm::DFGEdge
Class of DFG edge derived from DGEdge.
Definition: CGRADataFlowGraph.hpp:426
llvm::VirtualRootNode::getNodeAttr
string getNodeAttr() const
Definition: CGRADataFlowGraph.hpp:162
llvm::CGRADFG::getRoot
NodeType & getRoot() const
Get the virtual route node object.
Definition: CGRADataFlowGraph.hpp:547
llvm::DOTGraphTraits< const CGRADFG * >::getNodeLabel
static string getNodeLabel(const DFGNode *Node, const CGRADFG *G)
Definition: CGRADataFlowGraph.hpp:795
llvm::DFGNode::DFGNode
DFGNode(const DFGNode &N)
Definition: CGRADataFlowGraph.hpp:88
llvm::DOTGraphTraits< const CGRADFG * >::default_edge_prop
static StringMap< StringRef > default_edge_prop
a default edge propterties for DOT graph
Definition: CGRADataFlowGraph.hpp:830
llvm::DOTGraphTraits< const CGRADFG * >::getNodeIdentifierLabel
static string getNodeIdentifierLabel(const DFGNode *Node, const CGRADFG *G)
Definition: CGRADataFlowGraph.hpp:800
llvm::DFGNode::getNodeAttr
virtual string getNodeAttr() const =0
llvm::DFGNode::NodeKind
NodeKind
Definition: CGRADataFlowGraph.hpp:72
llvm::GEPNode::getUniqueName
string getUniqueName() const
Definition: CGRADataFlowGraph.hpp:389
llvm::GraphTraits< const DFGNode * >::child_end
static ChildIteratorType child_end(const NodeRef N)
Definition: CGRADataFlowGraph.hpp:742
llvm::GlobalDataNode
Definition: CGRADataFlowGraph.hpp:357
llvm::DFGEdge::DFGEdge
DFGEdge(DFGNode &N, int operand=0, EdgeKind Kind=EdgeKind::Normal)
Definition: CGRADataFlowGraph.hpp:433
llvm::MemAccessNode::classof
static bool classof(const DFGNode *N)
Definition: CGRADataFlowGraph.hpp:249
llvm::GraphTraits< DFGNode * >::DDGGetTargetNode
static DFGNode * DDGGetTargetNode(DFGEdge *P)
Definition: CGRADataFlowGraph.hpp:681
llvm::GraphTraits< DFGNode * >::ChildIteratorType
mapped_iterator< DFGNode::iterator, decltype(&DDGGetTargetNode)> ChildIteratorType
Definition: CGRADataFlowGraph.hpp:686
llvm::LoopDependencyEdge::distance
int distance
Definition: CGRADataFlowGraph.hpp:480
llvm::DFGEdge::getKind
EdgeKind getKind() const
Definition: CGRADataFlowGraph.hpp:457
llvm::GraphTraits< DFGNode * >::child_edge_begin
static ChildEdgeIteratorType child_edge_begin(NodeRef N)
Definition: CGRADataFlowGraph.hpp:696
llvm::GraphTraits< const CGRADFG * >::getEntryNode
static NodeRef getEntryNode(const CGRADFG *G)
Definition: CGRADataFlowGraph.hpp:762
CGRAOmp::Utils::getDataWidth
int getDataWidth(const Type *T)
Definition: Utils.cpp:137
llvm::MemAccessNode::getUniqueName
string getUniqueName() const
Definition: CGRADataFlowGraph.hpp:208
llvm::DFGNode::kind
NodeKind kind
Definition: CGRADataFlowGraph.hpp:143
OptionPlugin.hpp
llvm::VirtualRootNode::getUniqueName
string getUniqueName() const
Definition: CGRADataFlowGraph.hpp:159
llvm::LoopDependencyEdge::classof
static bool classof(const DFGEdge *E)
Definition: CGRADataFlowGraph.hpp:475
llvm::GraphTraits< const CGRADFG * >::nodes_begin
static nodes_iterator nodes_begin(const CGRADFG *G)
Definition: CGRADataFlowGraph.hpp:765
llvm::DFGNode::getUniqueName
virtual string getUniqueName() const =0
llvm::GEPConstantNode::const_value
int const_value
Definition: CGRADataFlowGraph.hpp:418
llvm::DataNode::getTypeName
string getTypeName(Type *ty) const
Definition: CGRADataFlowGraph.hpp:276
CGRAOmp
Definition: AGVerifyPass.hpp:50
llvm::GraphTraits< const CGRADFG * >::nodes_end
static nodes_iterator nodes_end(const CGRADFG *G)
Definition: CGRADataFlowGraph.hpp:768
llvm::DFGEdgeBase
DGEdge< DFGNode, DFGEdge > DFGEdgeBase
Definition: CGRADataFlowGraph.hpp:62
llvm::GlobalDataNode::getUniqueName
string getUniqueName() const
Definition: CGRADataFlowGraph.hpp:366
llvm::MemAccessNode::MemAccessNode
MemAccessNode(StoreInst *store)
Definition: CGRADataFlowGraph.hpp:200
llvm::ConstantNode::ConstantNode
ConstantNode(Value *v, SkipSeq *seq, int ID)
Definition: CGRADataFlowGraph.hpp:338
llvm::GraphTraits< CGRADFG * >::nodes_begin
static nodes_iterator nodes_begin(CGRADFG *G)
Definition: CGRADataFlowGraph.hpp:715
llvm::InitDataEdge::InitDataEdge
InitDataEdge(DFGNode &N, int operand)
Definition: CGRADataFlowGraph.hpp:485
llvm::LoopDependencyEdge::getEdgeAttr
virtual string getEdgeAttr() const
Definition: CGRADataFlowGraph.hpp:470
llvm::GEPNode::opcode
std::string opcode
Definition: CGRADataFlowGraph.hpp:402
llvm::DFGNode::getKind
NodeKind getKind() const
Definition: CGRADataFlowGraph.hpp:105
llvm::LoopDependencyEdge::LoopDependencyEdge
LoopDependencyEdge(DFGNode &N, int operand, int distance)
Definition: CGRADataFlowGraph.hpp:466
llvm::DFGEdge::getEdgeAttr
virtual string getEdgeAttr() const
Definition: CGRADataFlowGraph.hpp:453
VROOT_NODE_ID
#define VROOT_NODE_ID
Definition: CGRADataFlowGraph.hpp:54
llvm::CGRADFG::EdgeInfoType
std::pair< NodeType *, EdgeListTy > EdgeInfoType
Definition: CGRADataFlowGraph.hpp:509
llvm::ComputeNode::classof
static bool classof(const DFGNode *N)
Definition: CGRADataFlowGraph.hpp:182
ERR_DEBUG_PREFIX
#define ERR_DEBUG_PREFIX
Definition: common.hpp:41
llvm::ConstantNode
Definition: CGRADataFlowGraph.hpp:325
CGRAOmp::OptDFGOpKey
cl::opt< string > OptDFGOpKey
key string for opcode in DOT graph
llvm::ConstantNode::ConstantNode
ConstantNode(Value *v, int ID)
Definition: CGRADataFlowGraph.hpp:330
llvm::GraphTraits< const CGRADFG * >::nodes_iterator
CGRADFG::const_iterator nodes_iterator
Definition: CGRADataFlowGraph.hpp:761
llvm::DOTGraphTraits< const CGRADFG * >::isNodeHidden
static bool isNodeHidden(const DFGNode *Node, const CGRADFG *G)
Definition: CGRADataFlowGraph.hpp:790
llvm::GraphTraits< DFGNode * >::child_edge_end
static ChildEdgeIteratorType child_edge_end(NodeRef N)
Definition: CGRADataFlowGraph.hpp:700
llvm::GraphTraits< const DFGNode * >::ChildIteratorType
mapped_iterator< DFGNode::iterator, decltype(&DDGGetTargetNode)> ChildIteratorType
Definition: CGRADataFlowGraph.hpp:736
Utils.hpp
llvm::CGRADFG
A graph class for CGRA kernel DFG derived from llvm::DirectedGraph.
Definition: CGRADataFlowGraph.hpp:505
llvm::LoopDependencyEdge
Definition: CGRADataFlowGraph.hpp:464
llvm::CGRADFG::findIncomingEdgesToNode
bool findIncomingEdgesToNode(const NodeType &N, SmallVectorImpl< EdgeInfoType > &EL, bool ignore_vroot=false) const
find in-coming edges and get the list of them Unlike the same name method in llvm::DirectedGraph,...
Definition: CGRADataFlowGraph.hpp:585
llvm::MemAccessNode::addr
Value * addr
Definition: CGRADataFlowGraph.hpp:255
llvm::CGRADFG::CGRADFG
CGRADFG(CGRADFG &&G)
move constructor
Definition: CGRADataFlowGraph.hpp:524
llvm::GraphTraits< const DFGNode * >::child_begin
static ChildIteratorType child_begin(const NodeRef N)
Definition: CGRADataFlowGraph.hpp:739
llvm::DataNode
Definition: CGRADataFlowGraph.hpp:259
llvm::DFGNode::getExtraInfoAsJSONObject
json::Value getExtraInfoAsJSONObject()
Definition: CGRADataFlowGraph.hpp:129
llvm::CGRADFG::~CGRADFG
~CGRADFG()
Destructor.
Definition: CGRADataFlowGraph.hpp:537
llvm::InitDataEdge::getEdgeAttr
virtual string getEdgeAttr() const
Definition: CGRADataFlowGraph.hpp:488
llvm::CGRADFG::getName
string getName() const
Get the Name object.
Definition: CGRADataFlowGraph.hpp:645
llvm::DFGNode::setExtraInfo
void setExtraInfo(StringRef key, json::Value V)
Definition: CGRADataFlowGraph.hpp:121
llvm::GEPNode::GEPNode
GEPNode(GetElementPtrInst *gep, int ID)
Definition: CGRADataFlowGraph.hpp:386
llvm::GlobalDataNode::classof
static bool classof(const DFGNode *N)
Definition: CGRADataFlowGraph.hpp:374
llvm::GraphTraits< const DFGNode * >::child_edge_begin
static ChildEdgeIteratorType child_edge_begin(const NodeRef N)
Definition: CGRADataFlowGraph.hpp:746
llvm::ComputeNode
A concrete class for computational nodes.
Definition: CGRADataFlowGraph.hpp:171
llvm::DFGNode::operator=
DFGNode & operator=(const DFGNode &N)
Definition: CGRADataFlowGraph.hpp:95
llvm::DataNode< DFGNode::NodeKind::Constant >::SkipSeq
SmallVector< Value * > SkipSeq
Definition: CGRADataFlowGraph.hpp:261
llvm::ConstantNode::ConstantNode
ConstantNode(Value *v, SkipSeq *seq)
Definition: CGRADataFlowGraph.hpp:335
llvm::CGRADFG::getFunction
Function * getFunction()
Definition: CGRADataFlowGraph.hpp:651
llvm::DOTGraphTraits< const CGRADFG * >::getNodeDescription
static string getNodeDescription(const DFGNode *Node, const CGRADFG *G)
Definition: CGRADataFlowGraph.hpp:805
llvm::DFGEdge::EdgeKind
EdgeKind
Definition: CGRADataFlowGraph.hpp:428
llvm::DataNode::DataNode
DataNode(Value *v, SkipSeq *seq, int ID)
Definition: CGRADataFlowGraph.hpp:270
llvm::DFGEdge::DFGEdge
DFGEdge(const DFGEdge &E)
Definition: CGRADataFlowGraph.hpp:436
llvm::GraphTraits< CGRADFG * >::nodes_end
static nodes_iterator nodes_end(CGRADFG *G)
Definition: CGRADataFlowGraph.hpp:718
llvm::MemAccessNode::getNodeAttr
string getNodeAttr() const
Definition: CGRADataFlowGraph.hpp:216
llvm::ComputeNode::opcode
std::string opcode
Definition: CGRADataFlowGraph.hpp:189
llvm::DFGNode
An abstract class for DFG node derived from DGNode.
Definition: CGRADataFlowGraph.hpp:69
llvm::DFGNode::isEqualTo
bool isEqualTo(const DFGNode &N) const
Definition: CGRADataFlowGraph.hpp:117
llvm::GraphTraits< const DFGNode * >::child_edge_end
static ChildEdgeIteratorType child_edge_end(const NodeRef N)
Definition: CGRADataFlowGraph.hpp:750
llvm::GraphTraits< DFGNode * >
Specilized template of GraphTraits for DFNode.
Definition: CGRADataFlowGraph.hpp:678
llvm::DFGEdge::operator=
DFGEdge & operator=(DFGEdge &&E)
Definition: CGRADataFlowGraph.hpp:448
llvm::GraphTraits< DFGNode * >::child_begin
static ChildIteratorType child_begin(NodeRef N)
Definition: CGRADataFlowGraph.hpp:689
llvm::MemAccessNode::isLoad
bool isLoad()
Definition: CGRADataFlowGraph.hpp:206
llvm::DFGNode::getValue
Value * getValue() const
Definition: CGRADataFlowGraph.hpp:111
llvm::GraphTraits< const DFGNode * >::DDGGetTargetNode
static const DFGNode * DDGGetTargetNode(const DFGEdge *P)
Definition: CGRADataFlowGraph.hpp:731
llvm::CGRADFGBase
DirectedGraph< DFGNode, DFGEdge > CGRADFGBase
Definition: CGRADataFlowGraph.hpp:63
llvm::ConstantNode::getUniqueName
string getUniqueName() const
Definition: CGRADataFlowGraph.hpp:341
llvm::MemAccessNode
Definition: CGRADataFlowGraph.hpp:192
llvm::DFGNode::getExtraAttr
virtual string getExtraAttr() const
Definition: CGRADataFlowGraph.hpp:115
llvm::DFGEdge::DFGEdge
DFGEdge(DFGEdge &&E)
Definition: CGRADataFlowGraph.hpp:439
llvm::DFGNodeBase
DGNode< DFGNode, DFGEdge > DFGNodeBase
Definition: CGRADataFlowGraph.hpp:61
llvm::GlobalDataNode::GlobalDataNode
GlobalDataNode(Value *v, SkipSeq *seq)
Definition: CGRADataFlowGraph.hpp:363
llvm::ComputeNode::getInst
Instruction * getInst() const
Definition: CGRADataFlowGraph.hpp:185
llvm::DFGEdge::operator=
DFGEdge & operator=(const DFGEdge &E)
Definition: CGRADataFlowGraph.hpp:443
CGRAInstMap.hpp
llvm::DFGEdge::operand
int operand
Definition: CGRADataFlowGraph.hpp:460
llvm::GEPConstantNode::GEPConstantNode
GEPConstantNode(Value *v, int ID, int const_value)
Definition: CGRADataFlowGraph.hpp:407
llvm::DOTGraphTraits< const CGRADFG * >::default_graph_prop
static StringMap< StringRef > default_graph_prop
a default graph properties for DOT graph
Definition: CGRADataFlowGraph.hpp:822
llvm::InitDataEdge
Definition: CGRADataFlowGraph.hpp:483
llvm::CGRADFG::F
Function * F
Definition: CGRADataFlowGraph.hpp:669
llvm::GraphTraits< DFGNode * >::ChildEdgeIteratorType
DFGNode::iterator ChildEdgeIteratorType
Definition: CGRADataFlowGraph.hpp:687
llvm::GEPConstantNode::getExtraAttr
virtual string getExtraAttr() const
Definition: CGRADataFlowGraph.hpp:410
llvm::ConstantNode::ConstantNode
ConstantNode(Value *v)
Definition: CGRADataFlowGraph.hpp:327
llvm::DFGNode::getID
int getID() const
Definition: CGRADataFlowGraph.hpp:109
llvm::DFGNode::val
Value * val
Definition: CGRADataFlowGraph.hpp:145
llvm::GEPNode::getNodeAttr
string getNodeAttr() const
Definition: CGRADataFlowGraph.hpp:392
llvm::GraphTraits< DFGNode * >::child_end
static ChildIteratorType child_end(NodeRef N)
Definition: CGRADataFlowGraph.hpp:692
llvm::GEPNode::classof
static bool classof(const DFGNode *N)
Definition: CGRADataFlowGraph.hpp:395
llvm::DFGNode::ID
int ID
Definition: CGRADataFlowGraph.hpp:144
llvm::DFGNode::hasExtraInfo
bool hasExtraInfo() const
Definition: CGRADataFlowGraph.hpp:125
llvm::DataNode::DataNode
DataNode(Value *v)
Definition: CGRADataFlowGraph.hpp:263