gccrs: add test case to show our query-type system is working
[official-gcc.git] / gcc / rtl-ssa / changes.h
blobd56e3a646e263820cbeed2c7811174c0731c27ed
1 // RTL SSA classes related to changing instructions -*- C++ -*-
2 // Copyright (C) 2020-2023 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.
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.
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/>.
20 namespace rtl_ssa {
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.
33 class insn_change
35 public:
36 enum delete_action { DELETE };
38 // Construct a possible change to INSN.
39 insn_change (insn_info *insn);
41 // Construct a possible deletion of INSN.
42 insn_change (insn_info *insn, delete_action);
44 // The instruction that we would change.
45 insn_info *insn () const { return m_insn; }
47 // The rtx_insn of the instruction that we would change.
48 rtx_insn *rtl () const { return m_insn->rtl (); }
50 // The basic block that contains insn ().
51 bb_info *bb () const { return m_insn->bb (); }
53 // The extended basic block that contains insn ().
54 ebb_info *ebb () const { return m_insn->ebb (); }
56 // The uid of the instruction that we would change.
57 unsigned int insn_uid () const { return m_insn->uid (); }
59 // The list of things that the original instruction defined and used.
60 def_array old_defs () const { return m_insn->defs (); }
61 use_array old_uses () const { return m_insn->uses (); }
63 // The cost of the original instruction, as calculated by the target.
64 unsigned int old_cost () const { return m_insn->cost (); }
66 // Return true if the original instruction would simply be deleted,
67 // rather than being replaced by a new instruction.
68 bool is_deletion () const { return m_is_deletion; }
70 // Print a description of the change to PP.
71 void print (pretty_printer *pp) const;
73 // Return an insn_change for deleting INSN.
74 static insn_change delete_insn (insn_info *insn) { return { insn, DELETE }; }
76 private:
77 // The value returned by insn ().
78 insn_info *m_insn;
80 public:
81 // The list of things that the new instruction would define and use.
82 def_array new_defs;
83 use_array new_uses;
85 // The range of instructions after which the instruction could be placed.
86 // The range can include INSN itself: placing the instruction after either
87 // INSN or INSN->prev_nondebug_insn () is equivalent to not moving the
88 // instruction.
89 insn_range_info move_range;
91 // The cost that the new instruction would have, as calculated by the target.
92 unsigned int new_cost;
94 private:
95 // The value returned by is_deletion ().
96 bool m_is_deletion;
99 // A class that represents a closure of the two-argument form of
100 // insn_is_changing. See the comment above the one-argument form
101 // for details.
102 class insn_is_changing_closure
104 public:
105 insn_is_changing_closure (array_slice<insn_change *const> changes);
106 bool operator() (const insn_info *) const;
108 private:
109 array_slice<insn_change *const> m_changes;
112 void pp_insn_change (pretty_printer *, const insn_change &);
116 void dump (FILE *, const rtl_ssa::insn_change &);
118 void DEBUG_FUNCTION debug (const rtl_ssa::insn_change &);