(root)/
gcc-13.2.0/
gcc/
rtl-ssa/
changes.h
       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.
      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  public:
      36    enum delete_action { DELETE };
      37  
      38    // Construct a possible change to INSN.
      39    insn_change (insn_info *insn);
      40  
      41    // Construct a possible deletion of INSN.
      42    insn_change (insn_info *insn, delete_action);
      43  
      44    // The instruction that we would change.
      45    insn_info *insn () const { return m_insn; }
      46  
      47    // The rtx_insn of the instruction that we would change.
      48    rtx_insn *rtl () const { return m_insn->rtl (); }
      49  
      50    // The basic block that contains insn ().
      51    bb_info *bb () const { return m_insn->bb (); }
      52  
      53    // The extended basic block that contains insn ().
      54    ebb_info *ebb () const { return m_insn->ebb (); }
      55  
      56    // The uid of the instruction that we would change.
      57    unsigned int insn_uid () const { return m_insn->uid (); }
      58  
      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 (); }
      62  
      63    // The cost of the original instruction, as calculated by the target.
      64    unsigned int old_cost () const { return m_insn->cost (); }
      65  
      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; }
      69  
      70    // Print a description of the change to PP.
      71    void print (pretty_printer *pp) const;
      72  
      73    // Return an insn_change for deleting INSN.
      74    static insn_change delete_insn (insn_info *insn) { return { insn, DELETE }; }
      75  
      76  private:
      77    // The value returned by insn ().
      78    insn_info *m_insn;
      79  
      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;
      84  
      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;
      90  
      91    // The cost that the new instruction would have, as calculated by the target.
      92    unsigned int new_cost;
      93  
      94  private:
      95    // The value returned by is_deletion ().
      96    bool m_is_deletion;
      97  };
      98  
      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
     103  {
     104  public:
     105    insn_is_changing_closure (array_slice<insn_change *const> changes);
     106    bool operator() (const insn_info *) const;
     107  
     108  private:
     109    array_slice<insn_change *const> m_changes;
     110  };
     111  
     112  void pp_insn_change (pretty_printer *, const insn_change &);
     113  
     114  }
     115  
     116  void dump (FILE *, const rtl_ssa::insn_change &);
     117  
     118  void DEBUG_FUNCTION debug (const rtl_ssa::insn_change &);