LLVM  10.0.0svn
CombinerInfo.h
Go to the documentation of this file.
1 //===- llvm/CodeGen/GlobalISel/CombinerInfo.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 /// Interface for Targets to specify which operations are combined how and when.
10 ///
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CODEGEN_GLOBALISEL_COMBINER_INFO_H
14 #define LLVM_CODEGEN_GLOBALISEL_COMBINER_INFO_H
15 
16 #include <cassert>
17 namespace llvm {
18 
19 class GISelChangeObserver;
20 class LegalizerInfo;
21 class MachineInstr;
22 class MachineIRBuilder;
23 class MachineRegisterInfo;
24 
25 // Contains information relevant to enabling/disabling various combines for a
26 // pass.
27 class CombinerInfo {
28 public:
29  CombinerInfo(bool AllowIllegalOps, bool ShouldLegalizeIllegal,
30  LegalizerInfo *LInfo, bool OptEnabled, bool OptSize,
31  bool MinSize)
32  : IllegalOpsAllowed(AllowIllegalOps),
33  LegalizeIllegalOps(ShouldLegalizeIllegal), LInfo(LInfo),
34  EnableOpt(OptEnabled), EnableOptSize(OptSize), EnableMinSize(MinSize) {
35  assert(((AllowIllegalOps || !LegalizeIllegalOps) || LInfo) &&
36  "Expecting legalizerInfo when illegalops not allowed");
37  }
38  virtual ~CombinerInfo() = default;
39  /// If \p IllegalOpsAllowed is false, the CombinerHelper will make use of
40  /// the legalizerInfo to check for legality before each transformation.
41  bool IllegalOpsAllowed; // TODO: Make use of this.
42 
43  /// If \p LegalizeIllegalOps is true, the Combiner will also legalize the
44  /// illegal ops that are created.
45  bool LegalizeIllegalOps; // TODO: Make use of this.
47 
48  /// Whether optimizations should be enabled. This is to distinguish between
49  /// uses of the combiner unconditionally and only when optimizations are
50  /// specifically enabled/
51  bool EnableOpt;
52  /// Whether we're optimizing for size.
54  /// Whether we're optimizing for minsize (-Oz).
56 
57  /// Attempt to combine instructions using MI as the root.
58  ///
59  /// Use Observer to report the creation, modification, and erasure of
60  /// instructions. GISelChangeObserver will automatically report certain
61  /// kinds of operations. These operations are:
62  /// * Instructions that are newly inserted into the MachineFunction
63  /// * Instructions that are erased from the MachineFunction.
64  ///
65  /// However, it is important to report instruction modification and this is
66  /// not automatic.
67  virtual bool combine(GISelChangeObserver &Observer, MachineInstr &MI,
68  MachineIRBuilder &B) const = 0;
69 };
70 } // namespace llvm
71 
72 #endif
This class represents lattice values for constants.
Definition: AllocatorList.h:23
virtual ~CombinerInfo()=default
virtual bool combine(GISelChangeObserver &Observer, MachineInstr &MI, MachineIRBuilder &B) const =0
Attempt to combine instructions using MI as the root.
const LegalizerInfo * LInfo
Definition: CombinerInfo.h:46
bool EnableOptSize
Whether we&#39;re optimizing for size.
Definition: CombinerInfo.h:53
Abstract class that contains various methods for clients to notify about changes. ...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
bool EnableMinSize
Whether we&#39;re optimizing for minsize (-Oz).
Definition: CombinerInfo.h:55
Helper class to build MachineInstr.
bool IllegalOpsAllowed
If IllegalOpsAllowed is false, the CombinerHelper will make use of the legalizerInfo to check for leg...
Definition: CombinerInfo.h:41
CombinerInfo(bool AllowIllegalOps, bool ShouldLegalizeIllegal, LegalizerInfo *LInfo, bool OptEnabled, bool OptSize, bool MinSize)
Definition: CombinerInfo.h:29
bool LegalizeIllegalOps
If LegalizeIllegalOps is true, the Combiner will also legalize the illegal ops that are created...
Definition: CombinerInfo.h:45
Representation of each machine instruction.
Definition: MachineInstr.h:63
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
IRTranslator LLVM IR MI
bool EnableOpt
Whether optimizations should be enabled.
Definition: CombinerInfo.h:51