Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:12

0001 //===- llvm/Analysis/DDGPrinter.h -------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 //===----------------------------------------------------------------------===//
0010 //
0011 // This file defines the DOT printer for the Data-Dependence Graph (DDG).
0012 //
0013 //===----------------------------------------------------------------------===//
0014 
0015 #ifndef LLVM_ANALYSIS_DDGPRINTER_H
0016 #define LLVM_ANALYSIS_DDGPRINTER_H
0017 
0018 #include "llvm/Analysis/DDG.h"
0019 #include "llvm/Support/DOTGraphTraits.h"
0020 
0021 namespace llvm {
0022 class LPMUpdater;
0023 class Loop;
0024 
0025 //===--------------------------------------------------------------------===//
0026 // Implementation of DDG DOT Printer for a loop.
0027 //===--------------------------------------------------------------------===//
0028 class DDGDotPrinterPass : public PassInfoMixin<DDGDotPrinterPass> {
0029 public:
0030   PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
0031                         LoopStandardAnalysisResults &AR, LPMUpdater &U);
0032   static bool isRequired() { return true; }
0033 };
0034 
0035 //===--------------------------------------------------------------------===//
0036 // Specialization of DOTGraphTraits.
0037 //===--------------------------------------------------------------------===//
0038 template <>
0039 struct DOTGraphTraits<const DataDependenceGraph *>
0040     : public DefaultDOTGraphTraits {
0041 
0042   DOTGraphTraits(bool IsSimple = false) : DefaultDOTGraphTraits(IsSimple) {}
0043 
0044   /// Generate a title for the graph in DOT format
0045   std::string getGraphName(const DataDependenceGraph *G) {
0046     assert(G && "expected a valid pointer to the graph.");
0047     return "DDG for '" + std::string(G->getName()) + "'";
0048   }
0049 
0050   /// Print a DDG node either in concise form (-ddg-dot-only) or
0051   /// verbose mode (-ddg-dot).
0052   std::string getNodeLabel(const DDGNode *Node,
0053                            const DataDependenceGraph *Graph);
0054 
0055   /// Print attributes of an edge in the DDG graph. If the edge
0056   /// is a MemoryDependence edge, then detailed dependence info
0057   /// available from DependenceAnalysis is displayed.
0058   std::string
0059   getEdgeAttributes(const DDGNode *Node,
0060                     GraphTraits<const DDGNode *>::ChildIteratorType I,
0061                     const DataDependenceGraph *G);
0062 
0063   /// Do not print nodes that are part of a pi-block separately. They
0064   /// will be printed when their containing pi-block is being printed.
0065   bool isNodeHidden(const DDGNode *Node, const DataDependenceGraph *G);
0066 
0067 private:
0068   /// Print a DDG node in concise form.
0069   static std::string getSimpleNodeLabel(const DDGNode *Node,
0070                                         const DataDependenceGraph *G);
0071 
0072   /// Print a DDG node with more information including containing instructions
0073   /// and detailed information about the dependence edges.
0074   static std::string getVerboseNodeLabel(const DDGNode *Node,
0075                                          const DataDependenceGraph *G);
0076 
0077   /// Print a DDG edge in concise form.
0078   static std::string getSimpleEdgeAttributes(const DDGNode *Src,
0079                                              const DDGEdge *Edge,
0080                                              const DataDependenceGraph *G);
0081 
0082   /// Print a DDG edge with more information including detailed information
0083   /// about the dependence edges.
0084   static std::string getVerboseEdgeAttributes(const DDGNode *Src,
0085                                               const DDGEdge *Edge,
0086                                               const DataDependenceGraph *G);
0087 };
0088 
0089 using DDGDotGraphTraits = DOTGraphTraits<const DataDependenceGraph *>;
0090 
0091 } // namespace llvm
0092 
0093 #endif // LLVM_ANALYSIS_DDGPRINTER_H