Jlm
print.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2017 Nico Reißmann <nico.reissmann@gmail.com>
3  * See COPYING for terms of redistribution.
4  */
5 
6 #ifndef JLM_JLM_LLVM_IR_PRINT_HPP
7 #define JLM_JLM_LLVM_IR_PRINT_HPP
8 
9 /* FIXME: I would rather like to forward declare AnnotationMap and demand_set */
12 
13 #include <string>
14 
15 namespace jlm::llvm
16 {
17 
18 class ControlFlowGraph;
19 class InterProceduralGraph;
20 class InterProceduralGraphModule;
21 
22 /* control flow graph */
23 
24 std::string
25 to_dot(const ControlFlowGraph & cfg);
26 
27 static inline void
28 print_dot(const ControlFlowGraph & cfg, FILE * out)
29 {
30  fputs(to_dot(cfg).c_str(), out);
31  fflush(out);
32 }
33 
34 /* inter-procedural graph */
35 
36 std::string
37 to_str(const InterProceduralGraph & ipg);
38 
39 std::string
40 to_dot(const InterProceduralGraph & ipg);
41 
42 static inline void
43 print_ascii(const InterProceduralGraph & ipg, FILE * out)
44 {
45  fputs(to_str(ipg).c_str(), out);
46  fflush(out);
47 }
48 
49 static inline void
50 print_dot(const InterProceduralGraph & ipg, FILE * out)
51 {
52  fputs(to_dot(ipg).c_str(), out);
53  fflush(out);
54 }
55 
56 /* ipgraph module */
57 
58 static inline std::string
60 {
61  return to_str(im.ipgraph());
62 }
63 
64 static inline void
65 print(const InterProceduralGraphModule & im, FILE * out)
66 {
67  fputs(to_str(im).c_str(), out);
68  fflush(out);
69 }
70 
71 /* aggregation tree */
72 
73 std::string
74 to_str(const AggregationNode & n, const AnnotationMap & dm);
75 
76 static inline std::string
78 {
79  return to_str(n, {});
80 }
81 
82 void
83 print(const AggregationNode & n, const AnnotationMap & dm, FILE * out);
84 
85 static inline void
86 print(const AggregationNode & n, FILE * out)
87 {
88  print(n, {}, out);
89 }
90 
91 }
92 
93 #endif
InterProceduralGraph & ipgraph() noexcept
Global memory state passed between functions.
std::string to_dot(const ControlFlowGraph &cfg)
Definition: print.cpp:171
static void print_ascii(const InterProceduralGraph &ipg, FILE *out)
Definition: print.hpp:43
void print(const AggregationNode &n, const AnnotationMap &dm, FILE *out)
Definition: print.cpp:255
std::string to_str(const InterProceduralGraph &clg)
Definition: print.cpp:80
static void print_dot(const ControlFlowGraph &cfg, FILE *out)
Definition: print.hpp:28