//===----- llvm/CodeGen/GlobalISel/GISelChangeObserver.h --------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// /// \file /// This contains common code to allow clients to notify changes to machine /// instr. /// //===----------------------------------------------------------------------===// #ifndef LLVM_CODEGEN_GLOBALISEL_GISELCHANGEOBSERVER_H #define LLVM_CODEGEN_GLOBALISEL_GISELCHANGEOBSERVER_H #include "llvm/ADT/SmallPtrSet.h" #include "llvm/CodeGen/MachineFunction.h" namespace llvm { class MachineInstr; class MachineRegisterInfo; /// Abstract class that contains various methods for clients to notify about /// changes. This should be the preferred way for APIs to notify changes. /// Typically calling erasingInstr/createdInstr multiple times should not affect /// the result. The observer would likely need to check if it was already /// notified earlier (consider using GISelWorkList). class GISelChangeObserver { … }; /// Simple wrapper observer that takes several observers, and calls /// each one for each event. If there are multiple observers (say CSE, /// Legalizer, Combiner), it's sufficient to register this to the machine /// function as the delegate. class GISelObserverWrapper : public MachineFunction::Delegate, public GISelChangeObserver { … }; /// A simple RAII based Delegate installer. /// Use this in a scope to install a delegate to the MachineFunction and reset /// it at the end of the scope. class RAIIDelegateInstaller { … }; /// A simple RAII based Observer installer. /// Use this in a scope to install the Observer to the MachineFunction and reset /// it at the end of the scope. class RAIIMFObserverInstaller { … }; /// Class to install both of the above. class RAIIMFObsDelInstaller { … }; /// A simple RAII based Observer installer. /// Use this in a scope to install the Observer to the MachineFunction and reset /// it at the end of the scope. class RAIITemporaryObserverInstaller { … }; } // namespace llvm #endif