Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 1 | //== llvm/CodeGen/GlobalISel/CombinerHelper.h -------------- -*- C++ -*-==// |
| 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 combine transformations that may be used in a combine |
| 11 | /// pass,or by the target elsewhere. |
| 12 | /// Targets can pick individual opcode transformations from the helper or use |
| 13 | /// tryCombine which invokes all transformations. All of the transformations |
| 14 | /// return true if the MachineInstruction changed and false otherwise. |
| 15 | // |
| 16 | //===--------------------------------------------------------------------===// |
| 17 | |
| 18 | #ifndef LLVM_CODEGEN_GLOBALISEL_COMBINER_HELPER_H |
| 19 | #define LLVM_CODEGEN_GLOBALISEL_COMBINER_HELPER_H |
| 20 | |
| 21 | namespace llvm { |
| 22 | |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame^] | 23 | class CombinerChangeObserver; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 24 | class MachineIRBuilder; |
| 25 | class MachineRegisterInfo; |
| 26 | class MachineInstr; |
| 27 | |
| 28 | class CombinerHelper { |
| 29 | MachineIRBuilder &Builder; |
| 30 | MachineRegisterInfo &MRI; |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame^] | 31 | CombinerChangeObserver &Observer; |
| 32 | |
| 33 | void eraseInstr(MachineInstr &MI); |
| 34 | void scheduleForVisit(MachineInstr &MI); |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 35 | |
| 36 | public: |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame^] | 37 | CombinerHelper(CombinerChangeObserver &Observer, MachineIRBuilder &B); |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 38 | |
| 39 | /// If \p MI is COPY, try to combine it. |
| 40 | /// Returns true if MI changed. |
| 41 | bool tryCombineCopy(MachineInstr &MI); |
| 42 | |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame^] | 43 | /// If \p MI is extend that consumes the result of a load, try to combine it. |
| 44 | /// Returns true if MI changed. |
| 45 | bool tryCombineExtendingLoads(MachineInstr &MI); |
| 46 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 47 | /// Try to transform \p MI by using all of the above |
| 48 | /// combine functions. Returns true if changed. |
| 49 | bool tryCombine(MachineInstr &MI); |
| 50 | }; |
| 51 | } // namespace llvm |
| 52 | |
| 53 | #endif |