Branch data Line data Source code
1 : : // RTL SSA classes related to changing instructions -*- C++ -*-
2 : : // Copyright (C) 2020-2025 Free Software Foundation, Inc.
3 : : //
4 : : // This file is part of GCC.
5 : : //
6 : : // GCC is free software; you can redistribute it and/or modify it under
7 : : // the terms of the GNU General Public License as published by the Free
8 : : // Software Foundation; either version 3, or (at your option) any later
9 : : // version.
10 : : //
11 : : // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 : : // WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 : : // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 : : // for more details.
15 : : //
16 : : // You should have received a copy of the GNU General Public License
17 : : // along with GCC; see the file COPYING3. If not see
18 : : // <http://www.gnu.org/licenses/>.
19 : :
20 : : namespace rtl_ssa {
21 : :
22 : : // A class that describes a change that we're considering making to an
23 : : // instruction. There are three choices:
24 : : //
25 : : // (1) delete the instruction
26 : : // (2) replace the instruction with a new instruction in-place
27 : : // (3) replace the instruction with a new instruction at a different location
28 : : //
29 : : // Anything related to the "new instruction" is irrelevant for (1).
30 : : //
31 : : // The class doesn't actually change anything itself, it simply records
32 : : // something that we might do.
33 : : class insn_change
34 : : {
35 : : friend class function_info;
36 : :
37 : : public:
38 : : enum delete_action { DELETE };
39 : :
40 : : // Construct a possible change to INSN.
41 : : insn_change (insn_info *insn);
42 : :
43 : : // Construct a possible deletion of INSN.
44 : : insn_change (insn_info *insn, delete_action);
45 : :
46 : : // The instruction that we would change.
47 : 297968062 : insn_info *insn () const { return m_insn; }
48 : :
49 : : // The rtx_insn of the instruction that we would change.
50 : 80889161 : rtx_insn *rtl () const { return m_insn->rtl (); }
51 : :
52 : : // The basic block that contains insn ().
53 : 28861211 : bb_info *bb () const { return m_insn->bb (); }
54 : :
55 : : // The extended basic block that contains insn ().
56 : : ebb_info *ebb () const { return m_insn->ebb (); }
57 : :
58 : : // The uid of the instruction that we would change.
59 : 0 : unsigned int insn_uid () const { return m_insn->uid (); }
60 : :
61 : : // The list of things that the original instruction defined and used.
62 : 24612206 : def_array old_defs () const { return m_insn->defs (); }
63 : 12306103 : use_array old_uses () const { return m_insn->uses (); }
64 : :
65 : : // The cost of the original instruction, as calculated by the target.
66 : 27309911 : unsigned int old_cost () const { return m_insn->cost (); }
67 : :
68 : : // Return true if the original instruction would simply be deleted,
69 : : // rather than being replaced by a new instruction.
70 : 96320508 : bool is_deletion () const { return m_is_deletion; }
71 : :
72 : : // Print a description of the change to PP.
73 : : void print (pretty_printer *pp) const;
74 : :
75 : : // Return an insn_change for deleting INSN.
76 : 20332266 : static insn_change delete_insn (insn_info *insn) { return { insn, DELETE }; }
77 : :
78 : : private:
79 : : // The value returned by insn ().
80 : : insn_info *m_insn;
81 : :
82 : : public:
83 : : // The list of things that the new instruction would define and use.
84 : : def_array new_defs;
85 : : use_array new_uses;
86 : :
87 : : // The range of instructions after which the instruction could be placed.
88 : : // The range can include INSN itself: placing the instruction after either
89 : : // INSN or INSN->prev_nondebug_insn () is equivalent to not moving the
90 : : // instruction.
91 : : insn_range_info move_range;
92 : :
93 : : // The cost that the new instruction would have, as calculated by the target.
94 : : unsigned int new_cost;
95 : :
96 : : private:
97 : : // The value returned by is_deletion ().
98 : : bool m_is_deletion;
99 : : };
100 : :
101 : : void pp_insn_change (pretty_printer *, const insn_change &);
102 : :
103 : : }
104 : :
105 : : void dump (FILE *, const rtl_ssa::insn_change &);
106 : :
107 : : void DEBUG_FUNCTION debug (const rtl_ssa::insn_change &);
|