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