1 //===- llvm/CodeGen/GlobalISel/CombinerInfo.h ------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 /// Interface for Targets to specify which operations are combined how and when.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CODEGEN_GLOBALISEL_COMBINER_INFO_H
15 #define LLVM_CODEGEN_GLOBALISEL_COMBINER_INFO_H
20 class GISelChangeObserver;
23 class MachineIRBuilder;
24 class MachineRegisterInfo;
26 // Contains information relevant to enabling/disabling various combines for a
30 CombinerInfo(bool AllowIllegalOps, bool ShouldLegalizeIllegal,
32 : IllegalOpsAllowed(AllowIllegalOps),
33 LegalizeIllegalOps(ShouldLegalizeIllegal), LInfo(LInfo) {
34 assert(((AllowIllegalOps || !LegalizeIllegalOps) || LInfo) &&
35 "Expecting legalizerInfo when illegalops not allowed");
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.
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;
47 /// Attempt to combine instructions using MI as the root.
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.
55 /// However, it is important to report instruction modification and this is
57 virtual bool combine(GISelChangeObserver &Observer, MachineInstr &MI,
58 MachineIRBuilder &B) const = 0;