]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/print-rtl.h
print-rtl: Change return type of two print functions from int to void
[thirdparty/gcc.git] / gcc / print-rtl.h
CommitLineData
d8a2d370 1/* Print RTL for GCC.
aeee4812 2 Copyright (C) 1987-2023 Free Software Foundation, Inc.
d8a2d370
DN
3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
8Software Foundation; either version 3, or (at your option) any later
9version.
10
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14for more details.
15
16You should have received a copy of the GNU General Public License
17along with GCC; see the file COPYING3. If not see
18<http://www.gnu.org/licenses/>. */
19
20#ifndef GCC_PRINT_RTL_H
21#define GCC_PRINT_RTL_H
22
00439aef
DM
23#ifndef GENERATOR_FILE
24#include "bitmap.h"
25#endif /* #ifndef GENERATOR_FILE */
26
27class rtx_reuse_manager;
28
36cd856f
DM
29/* A class for writing rtx to a FILE *. */
30
31class rtx_writer
32{
33 public:
00439aef
DM
34 rtx_writer (FILE *outfile, int ind, bool simple, bool compact,
35 rtx_reuse_manager *reuse_manager);
36cd856f
DM
36
37 void print_rtx (const_rtx in_rtx);
38 void print_rtl (const_rtx rtx_first);
8e1e1fc4 39 void print_rtl_single_with_indent (const_rtx x, int ind);
36cd856f 40
677aa9b4
DM
41 void finish_directive ();
42
36cd856f
DM
43 private:
44 void print_rtx_operand_code_0 (const_rtx in_rtx, int idx);
45 void print_rtx_operand_code_e (const_rtx in_rtx, int idx);
46 void print_rtx_operand_codes_E_and_V (const_rtx in_rtx, int idx);
47 void print_rtx_operand_code_i (const_rtx in_rtx, int idx);
48 void print_rtx_operand_code_r (const_rtx in_rtx);
49 void print_rtx_operand_code_u (const_rtx in_rtx, int idx);
50 void print_rtx_operand (const_rtx in_rtx, int idx);
b5fbe716 51 bool operand_has_default_value_p (const_rtx in_rtx, int idx);
36cd856f
DM
52
53 private:
54 FILE *m_outfile;
36cd856f 55 int m_indent;
8e1e1fc4 56 bool m_sawclose;
36cd856f
DM
57 bool m_in_call_function_usage;
58
59 /* True means use simplified format without flags, modes, etc. */
60 bool m_simple;
61
62 /* If true, use compact dump format:
7574cfd4 63 - PREV/NEXT_INSN UIDs are omitted
36cd856f
DM
64 - INSN_CODEs are omitted,
65 - register numbers are omitted for hard and virtual regs, and
66 non-virtual pseudos are offset relative to the first such reg, and
67 printed with a '%' sigil e.g. "%0" for (LAST_VIRTUAL_REGISTER + 1),
68 - insn names are prefixed with "c" (e.g. "cinsn", "cnote", etc). */
69 bool m_compact;
00439aef 70
0dc0947d 71#ifndef GENERATOR_FILE
00439aef
DM
72 /* An optional instance of rtx_reuse_manager. */
73 rtx_reuse_manager *m_rtx_reuse_manager;
0dc0947d 74#endif
36cd856f 75};
e2ce9e83 76
d8a2d370
DN
77#ifdef BUFSIZ
78extern void print_rtl (FILE *, const_rtx);
79#endif
e4dbabfe 80extern void print_rtx_insn_vec (FILE *file, const vec<rtx_insn *> &vec);
d8a2d370 81
013a8899
JL
82extern void dump_value_slim (FILE *, const_rtx, int);
83extern void dump_insn_slim (FILE *, const rtx_insn *);
84extern void dump_rtl_slim (FILE *, const rtx_insn *, const rtx_insn *,
85 int, int);
86extern void print_value (pretty_printer *, const_rtx, int);
87extern void print_pattern (pretty_printer *, const_rtx, int);
cdb0d947 88extern void print_insn (pretty_printer *pp, const rtx_insn *x, int verbose);
d6c9781e 89extern void print_insn_with_notes (pretty_printer *, const rtx_insn *);
cdb0d947 90
013a8899
JL
91extern void rtl_dump_bb_for_graph (pretty_printer *, basic_block);
92extern const char *str_pattern_slim (const_rtx);
93
7810c4eb 94extern void print_rtx_function (FILE *file, function *fn, bool compact);
dd4b238a 95
00439aef
DM
96#ifndef GENERATOR_FILE
97
98/* For some rtx codes (such as SCRATCH), instances are defined to only be
99 equal for pointer equality: two distinct SCRATCH instances are non-equal.
100 copy_rtx preserves this equality by reusing the SCRATCH instance.
101
102 For example, in this x86 instruction:
103
104 (cinsn (set (mem/v:BLK (scratch:DI) [0 A8])
105 (unspec:BLK [
106 (mem/v:BLK (scratch:DI) [0 A8])
107 ] UNSPEC_MEMORY_BLOCKAGE)) "test.c":2
108 (nil))
109
110 the two instances of "(scratch:DI)" are actually the same underlying
111 rtx pointer (and thus "equal"), and the insn will only be recognized
112 (as "*memory_blockage") if this pointer-equality is preserved.
113
114 To be able to preserve this pointer-equality when round-tripping
115 through dumping/loading the rtl, we need some syntax. The first
116 time a reused rtx is encountered in the dump, we prefix it with
117 a reuse ID:
118
119 (0|scratch:DI)
120
121 Subsequent references to the rtx in the dump can be expressed using
122 "reuse_rtx" e.g.:
123
124 (reuse_rtx 0)
125
126 This class is responsible for tracking a set of reuse IDs during a dump.
127
128 Dumping with reuse-support is done in two passes:
129
130 (a) a first pass in which "preprocess" is called on each top-level rtx
131 to be seen in the dump. This traverses the rtx and its descendents,
132 identifying rtx that will be seen more than once in the actual dump,
133 and assigning them reuse IDs.
134
135 (b) the actual dump, via print_rtx etc. print_rtx detect the presence
136 of a live rtx_reuse_manager and uses it if there is one. Any rtx
137 that were assigned reuse IDs will be printed with it the first time
138 that they are seen, and then printed as "(reuse_rtx ID)" subsequently.
139
140 The first phase is needed since otherwise there would be no way to tell
141 if an rtx will be reused when first encountering it. */
142
143class rtx_reuse_manager
144{
145 public:
146 rtx_reuse_manager ();
147
148 /* The first pass. */
149 void preprocess (const_rtx x);
150
151 /* The second pass (within print_rtx). */
152 bool has_reuse_id (const_rtx x, int *out);
153 bool seen_def_p (int reuse_id);
154 void set_seen_def (int reuse_id);
155
156 private:
157 hash_map<const_rtx, int> m_rtx_occurrence_count;
158 hash_map<const_rtx, int> m_rtx_reuse_ids;
8f9b31f7 159 auto_bitmap m_defs_seen;
00439aef
DM
160 int m_next_id;
161};
162
163#endif /* #ifndef GENERATOR_FILE */
164
d8a2d370 165#endif // GCC_PRINT_RTL_H