[ARM] Better patterns for fp <> predicate vectors
[llvm-core.git] / tools / llvm-xray / xray-graph-diff.h
blob5d12c563f47c497a415ad3c2be55ed10192e57a1
1 //===-- xray-graph-diff.h - XRay Graph Diff Renderer ------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Generate a DOT file to represent the difference between the function call
10 // graph of two differnent traces.
12 //===----------------------------------------------------------------------===//
14 #ifndef XRAY_GRAPH_DIFF_H
15 #define XRAY_GRAPH_DIFF_H
17 #include "xray-graph.h"
18 #include "llvm/ADT/StringMap.h"
19 #include "llvm/XRay/Graph.h"
21 namespace llvm {
22 namespace xray {
24 // This class creates a graph representing the difference between two
25 // xray-graphs And allows you to print it to a dot file, with optional color
26 // coding.
27 class GraphDiffRenderer {
28 static const int N = 2;
30 public:
31 using StatType = GraphRenderer::StatType;
32 using TimeStat = GraphRenderer::TimeStat;
34 using GREdgeValueType = GraphRenderer::GraphT::EdgeValueType;
35 using GRVertexValueType = GraphRenderer::GraphT::VertexValueType;
37 struct EdgeAttribute {
38 std::array<const GREdgeValueType *, N> CorrEdgePtr = {};
41 struct VertexAttribute {
42 std::array<const GRVertexValueType *, N> CorrVertexPtr = {};
45 using GraphT = Graph<VertexAttribute, EdgeAttribute, StringRef>;
47 class Factory {
48 std::array<std::reference_wrapper<const GraphRenderer::GraphT>, N> G;
50 public:
51 template <typename... Ts> Factory(Ts &... Args) : G{{Args...}} {}
53 Expected<GraphDiffRenderer> getGraphDiffRenderer();
56 private:
57 GraphT G;
59 GraphDiffRenderer() = default;
61 public:
62 void exportGraphAsDOT(raw_ostream &OS, StatType EdgeLabel = StatType::NONE,
63 StatType EdgeColor = StatType::NONE,
64 StatType VertexLabel = StatType::NONE,
65 StatType VertexColor = StatType::NONE,
66 int TruncLen = 40);
68 const GraphT &getGraph() { return G; }
70 } // namespace xray
71 } // namespace llvm
73 #endif