]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/CodeGen/GlobalISel/CombinerInfo.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / CodeGen / GlobalISel / CombinerInfo.h
1 //===- llvm/CodeGen/GlobalISel/CombinerInfo.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 /// Interface for Targets to specify which operations are combined how and when.
11 ///
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_CODEGEN_GLOBALISEL_COMBINER_INFO_H
15 #define LLVM_CODEGEN_GLOBALISEL_COMBINER_INFO_H
16
17 #include <cassert>
18 namespace llvm {
19
20 class GISelChangeObserver;
21 class LegalizerInfo;
22 class MachineInstr;
23 class MachineIRBuilder;
24 class MachineRegisterInfo;
25
26 // Contains information relevant to enabling/disabling various combines for a
27 // pass.
28 class CombinerInfo {
29 public:
30   CombinerInfo(bool AllowIllegalOps, bool ShouldLegalizeIllegal,
31                LegalizerInfo *LInfo)
32       : IllegalOpsAllowed(AllowIllegalOps),
33         LegalizeIllegalOps(ShouldLegalizeIllegal), LInfo(LInfo) {
34     assert(((AllowIllegalOps || !LegalizeIllegalOps) || LInfo) &&
35            "Expecting legalizerInfo when illegalops not allowed");
36   }
37   virtual ~CombinerInfo() = default;
38   /// If \p IllegalOpsAllowed is false, the CombinerHelper will make use of
39   /// the legalizerInfo to check for legality before each transformation.
40   bool IllegalOpsAllowed; // TODO: Make use of this.
41
42   /// If \p LegalizeIllegalOps is true, the Combiner will also legalize the
43   /// illegal ops that are created.
44   bool LegalizeIllegalOps; // TODO: Make use of this.
45   const LegalizerInfo *LInfo;
46
47   /// Attempt to combine instructions using MI as the root.
48   ///
49   /// Use Observer to report the creation, modification, and erasure of
50   /// instructions. GISelChangeObserver will automatically report certain
51   /// kinds of operations. These operations are:
52   /// * Instructions that are newly inserted into the MachineFunction
53   /// * Instructions that are erased from the MachineFunction.
54   ///
55   /// However, it is important to report instruction modification and this is
56   /// not automatic.
57   virtual bool combine(GISelChangeObserver &Observer, MachineInstr &MI,
58                        MachineIRBuilder &B) const = 0;
59 };
60 } // namespace llvm
61
62 #endif