LLVM 22.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/// Option class for Targets to specify which operations are combined how and
10/// when.
11///
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CODEGEN_GLOBALISEL_COMBINERINFO_H
15#define LLVM_CODEGEN_GLOBALISEL_COMBINERINFO_H
16
17#include <cassert>
18namespace llvm {
19
20class LegalizerInfo;
21
22// Contains information relevant to enabling/disabling various combines for a
23// pass.
25 CombinerInfo(bool AllowIllegalOps, bool ShouldLegalizeIllegal,
26 const LegalizerInfo *LInfo, bool OptEnabled, bool OptSize,
27 bool MinSize)
28 : IllegalOpsAllowed(AllowIllegalOps),
29 LegalizeIllegalOps(ShouldLegalizeIllegal), LInfo(LInfo),
30 EnableOpt(OptEnabled), EnableOptSize(OptSize), EnableMinSize(MinSize) {
31 assert(((AllowIllegalOps || !LegalizeIllegalOps) || LInfo) &&
32 "Expecting legalizerInfo when illegalops not allowed");
33 }
34 virtual ~CombinerInfo() = default;
35 /// If \p IllegalOpsAllowed is false, the CombinerHelper will make use of
36 /// the legalizerInfo to check for legality before each transformation.
37 bool IllegalOpsAllowed; // TODO: Make use of this.
38
39 /// If \p LegalizeIllegalOps is true, the Combiner will also legalize the
40 /// illegal ops that are created.
41 bool LegalizeIllegalOps; // TODO: Make use of this.
43
44 /// Whether optimizations should be enabled. This is to distinguish between
45 /// uses of the combiner unconditionally and only when optimizations are
46 /// specifically enabled/
48 /// Whether we're optimizing for size.
50 /// Whether we're optimizing for minsize (-Oz).
52
53 /// The maximum number of times the Combiner will iterate over the
54 /// MachineFunction. Setting this to 0 enables fixed-point iteration.
55 unsigned MaxIterations = 0;
56
57 enum class ObserverLevel {
58 /// Only retry combining created/changed instructions.
59 /// This replicates the legacy default Observer behavior for use with
60 /// fixed-point iteration.
62 /// Enables Observer-based detection of dead instructions. This can save
63 /// some compile-time if full disabling of fixed-point iteration is not
64 /// desired. If the input IR doesn't contain dead instructions, consider
65 /// disabling \p EnableFullDCE.
67 /// Enables Observer-based DCE and additional heuristics that retry
68 /// combining defined and used instructions of modified instructions.
69 /// This provides a good balance between compile-time and completeness of
70 /// combining without needing fixed-point iteration.
72 };
73
74 /// Select how the Combiner acts on MIR changes.
76
77 /// Whether dead code elimination is performed before each Combiner iteration.
78 /// If Observer-based DCE is enabled, this controls if a full DCE pass is
79 /// performed before the first Combiner iteration.
80 bool EnableFullDCE = true;
81};
82} // namespace llvm
83
84#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This is an optimization pass for GlobalISel generic memory operations.
bool EnableMinSize
Whether we're optimizing for minsize (-Oz).
unsigned MaxIterations
The maximum number of times the Combiner will iterate over the MachineFunction.
CombinerInfo(bool AllowIllegalOps, bool ShouldLegalizeIllegal, const LegalizerInfo *LInfo, bool OptEnabled, bool OptSize, bool MinSize)
ObserverLevel ObserverLvl
Select how the Combiner acts on MIR changes.
const LegalizerInfo * LInfo
bool EnableFullDCE
Whether dead code elimination is performed before each Combiner iteration.
bool LegalizeIllegalOps
If LegalizeIllegalOps is true, the Combiner will also legalize the illegal ops that are created.
bool IllegalOpsAllowed
If IllegalOpsAllowed is false, the CombinerHelper will make use of the legalizerInfo to check for leg...
virtual ~CombinerInfo()=default
bool EnableOptSize
Whether we're optimizing for size.
bool EnableOpt
Whether optimizations should be enabled.
@ DCE
Enables Observer-based detection of dead instructions.
@ Basic
Only retry combining created/changed instructions.
@ SinglePass
Enables Observer-based DCE and additional heuristics that retry combining defined and used instructio...