LLVM  9.0.0svn
CombinerHelper.h
Go to the documentation of this file.
1 //===-- llvm/CodeGen/GlobalISel/CombinerHelper.h --------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===--------------------------------------------------------------------===//
8 //
9 /// This contains common combine transformations that may be used in a combine
10 /// pass,or by the target elsewhere.
11 /// Targets can pick individual opcode transformations from the helper or use
12 /// tryCombine which invokes all transformations. All of the transformations
13 /// return true if the MachineInstruction changed and false otherwise.
14 //
15 //===--------------------------------------------------------------------===//
16 
17 #ifndef LLVM_CODEGEN_GLOBALISEL_COMBINER_HELPER_H
18 #define LLVM_CODEGEN_GLOBALISEL_COMBINER_HELPER_H
19 
21 
22 namespace llvm {
23 
24 class GISelChangeObserver;
25 class MachineIRBuilder;
26 class MachineRegisterInfo;
27 class MachineInstr;
28 class MachineOperand;
29 
31  LLT Ty; // The result type of the extend.
32  unsigned ExtendOpcode; // G_ANYEXT/G_SEXT/G_ZEXT
34 };
35 
37  MachineIRBuilder &Builder;
39  GISelChangeObserver &Observer;
40 
41 public:
43 
44  /// MachineRegisterInfo::replaceRegWith() and inform the observer of the changes
45  void replaceRegWith(MachineRegisterInfo &MRI, unsigned FromReg, unsigned ToReg) const;
46 
47  /// Replace a single register operand with a new register and inform the
48  /// observer of the changes.
49  void replaceRegOpWith(MachineRegisterInfo &MRI, MachineOperand &FromRegOp,
50  unsigned ToReg) const;
51 
52  /// If \p MI is COPY, try to combine it.
53  /// Returns true if MI changed.
54  bool tryCombineCopy(MachineInstr &MI);
55  bool matchCombineCopy(MachineInstr &MI);
56  void applyCombineCopy(MachineInstr &MI);
57 
58  /// If \p MI is extend that consumes the result of a load, try to combine it.
59  /// Returns true if MI changed.
60  bool tryCombineExtendingLoads(MachineInstr &MI);
61  bool matchCombineExtendingLoads(MachineInstr &MI, PreferredTuple &MatchInfo);
62  void applyCombineExtendingLoads(MachineInstr &MI, PreferredTuple &MatchInfo);
63 
64  /// Try to transform \p MI by using all of the above
65  /// combine functions. Returns true if changed.
66  bool tryCombine(MachineInstr &MI);
67 };
68 } // namespace llvm
69 
70 #endif
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Abstract class that contains various methods for clients to notify about changes. ...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
unsigned const MachineRegisterInfo * MRI
Helper class to build MachineInstr.
MachineOperand class - Representation of each machine instruction operand.
MachineInstr * MI
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
Representation of each machine instruction.
Definition: MachineInstr.h:63