blob: ee67f90a39e508c4c7495aa24d599307ed7f0f98 [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//== 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
21namespace llvm {
22
Andrew Scull0372a572018-11-16 15:47:06 +000023class CombinerChangeObserver;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010024class MachineIRBuilder;
25class MachineRegisterInfo;
26class MachineInstr;
27
28class CombinerHelper {
29 MachineIRBuilder &Builder;
30 MachineRegisterInfo &MRI;
Andrew Scull0372a572018-11-16 15:47:06 +000031 CombinerChangeObserver &Observer;
32
33 void eraseInstr(MachineInstr &MI);
34 void scheduleForVisit(MachineInstr &MI);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010035
36public:
Andrew Scull0372a572018-11-16 15:47:06 +000037 CombinerHelper(CombinerChangeObserver &Observer, MachineIRBuilder &B);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010038
39 /// If \p MI is COPY, try to combine it.
40 /// Returns true if MI changed.
41 bool tryCombineCopy(MachineInstr &MI);
42
Andrew Scull0372a572018-11-16 15:47:06 +000043 /// 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 Scull5e1ddfa2018-08-14 10:06:54 +010047 /// 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