LLVM 17.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>
17namespace llvm {
18
19class GISelChangeObserver;
20class LegalizerInfo;
21class MachineInstr;
22class MachineIRBuilder;
23
24// Contains information relevant to enabling/disabling various combines for a
25// pass.
27public:
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/
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
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
IRTranslator LLVM IR MI
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
virtual bool combine(GISelChangeObserver &Observer, MachineInstr &MI, MachineIRBuilder &B) const =0
Attempt to combine instructions using MI as the root.
bool EnableMinSize
Whether we're optimizing for minsize (-Oz).
Definition: CombinerInfo.h:54
CombinerInfo(bool AllowIllegalOps, bool ShouldLegalizeIllegal, const LegalizerInfo *LInfo, bool OptEnabled, bool OptSize, bool MinSize)
Definition: CombinerInfo.h:28
const LegalizerInfo * LInfo
Definition: CombinerInfo.h:45
bool LegalizeIllegalOps
If LegalizeIllegalOps is true, the Combiner will also legalize the illegal ops that are created.
Definition: CombinerInfo.h:44
bool IllegalOpsAllowed
If IllegalOpsAllowed is false, the CombinerHelper will make use of the legalizerInfo to check for leg...
Definition: CombinerInfo.h:40
virtual ~CombinerInfo()=default
bool EnableOptSize
Whether we're optimizing for size.
Definition: CombinerInfo.h:52
bool EnableOpt
Whether optimizations should be enabled.
Definition: CombinerInfo.h:50
Abstract class that contains various methods for clients to notify about changes.
Helper class to build MachineInstr.
Representation of each machine instruction.
Definition: MachineInstr.h:68
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18