Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 1 | //== ----- llvm/CodeGen/GlobalISel/Combiner.h --------------------- == // |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | /// This contains common code to drive combines. Combiner Passes will need to |
| 11 | /// setup a CombinerInfo and call combineMachineFunction. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef LLVM_CODEGEN_GLOBALISEL_COMBINER_H |
| 16 | #define LLVM_CODEGEN_GLOBALISEL_COMBINER_H |
| 17 | |
| 18 | #include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h" |
| 19 | #include "llvm/CodeGen/MachineFunctionPass.h" |
| 20 | |
| 21 | namespace llvm { |
| 22 | class MachineRegisterInfo; |
| 23 | class CombinerInfo; |
| 24 | class TargetPassConfig; |
| 25 | class MachineFunction; |
| 26 | |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame^] | 27 | class CombinerChangeObserver { |
| 28 | public: |
| 29 | virtual ~CombinerChangeObserver() {} |
| 30 | |
| 31 | /// An instruction was erased. |
| 32 | virtual void erasedInstr(MachineInstr &MI) = 0; |
| 33 | /// An instruction was created and inseerted into the function. |
| 34 | virtual void createdInstr(MachineInstr &MI) = 0; |
| 35 | }; |
| 36 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 37 | class Combiner { |
| 38 | public: |
| 39 | Combiner(CombinerInfo &CombinerInfo, const TargetPassConfig *TPC); |
| 40 | |
| 41 | bool combineMachineInstrs(MachineFunction &MF); |
| 42 | |
| 43 | protected: |
| 44 | CombinerInfo &CInfo; |
| 45 | |
| 46 | MachineRegisterInfo *MRI = nullptr; |
| 47 | const TargetPassConfig *TPC; |
| 48 | MachineIRBuilder Builder; |
| 49 | }; |
| 50 | |
| 51 | } // End namespace llvm. |
| 52 | |
| 53 | #endif // LLVM_CODEGEN_GLOBALISEL_GICOMBINER_H |