1 // RTL SSA classes related to changing instructions -*- C++ -*-
2 // Copyright (C) 2020-2025 Free Software Foundation, Inc.
4 // This file is part of GCC.
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
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
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/>.
22 // A class that describes a change that we're considering making to an
23 // instruction. There are three choices:
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
29 // Anything related to the "new instruction" is irrelevant for (1).
31 // The class doesn't actually change anything itself, it simply records
32 // something that we might do.
35 friend class function_info
;
38 enum delete_action
{ DELETE
};
40 // Construct a possible change to INSN.
41 insn_change (insn_info
*insn
);
43 // Construct a possible deletion of INSN.
44 insn_change (insn_info
*insn
, delete_action
);
46 // The instruction that we would change.
47 insn_info
*insn () const { return m_insn
; }
49 // The rtx_insn of the instruction that we would change.
50 rtx_insn
*rtl () const { return m_insn
->rtl (); }
52 // The basic block that contains insn ().
53 bb_info
*bb () const { return m_insn
->bb (); }
55 // The extended basic block that contains insn ().
56 ebb_info
*ebb () const { return m_insn
->ebb (); }
58 // The uid of the instruction that we would change.
59 unsigned int insn_uid () const { return m_insn
->uid (); }
61 // The list of things that the original instruction defined and used.
62 def_array
old_defs () const { return m_insn
->defs (); }
63 use_array
old_uses () const { return m_insn
->uses (); }
65 // The cost of the original instruction, as calculated by the target.
66 unsigned int old_cost () const { return m_insn
->cost (); }
68 // Return true if the original instruction would simply be deleted,
69 // rather than being replaced by a new instruction.
70 bool is_deletion () const { return m_is_deletion
; }
72 // Print a description of the change to PP.
73 void print (pretty_printer
*pp
) const;
75 // Return an insn_change for deleting INSN.
76 static insn_change
delete_insn (insn_info
*insn
) { return { insn
, DELETE
}; }
79 // The value returned by insn ().
83 // The list of things that the new instruction would define and use.
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
91 insn_range_info move_range
;
93 // The cost that the new instruction would have, as calculated by the target.
94 unsigned int new_cost
;
97 // The value returned by is_deletion ().
101 void pp_insn_change (pretty_printer
*, const insn_change
&);
105 void dump (FILE *, const rtl_ssa::insn_change
&);
107 void DEBUG_FUNCTION
debug (const rtl_ssa::insn_change
&);