LLVM 19.0.0git
Combiner.h
Go to the documentation of this file.
1//== ----- llvm/CodeGen/GlobalISel/Combiner.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/// This contains the base class for all Combiners generated by TableGen.
10/// Backends need to create class that inherits from "Combiner" and put all of
11/// the TableGen-erated code in there, as it implements the virtual functions.
12///
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_CODEGEN_GLOBALISEL_COMBINER_H
16#define LLVM_CODEGEN_GLOBALISEL_COMBINER_H
17
21
22namespace llvm {
23class MachineRegisterInfo;
24struct CombinerInfo;
25class GISelCSEInfo;
26class TargetPassConfig;
27class MachineFunction;
28class MachineIRBuilder;
29
30/// Combiner implementation. This is per-function, so passes need to recreate
31/// one of these each time they enter a new function.
32///
33/// TODO: Is it worth making this module-wide?
35private:
37 GISelWorkList<512> WorkList;
38
39 // We have a little hack here where keep the owned pointers private, and only
40 // expose a reference. This has two purposes:
41 // - Avoid derived classes messing with those pointers.
42 // - Keep the API consistent. CInfo, MF, MRI, etc. are all accessed as
43 // references. Accessing Observer/B as pointers unnecessarily leaks
44 // implementation details into derived classes.
45 std::unique_ptr<MachineIRBuilder> Builder;
46 std::unique_ptr<WorkListMaintainer> WLObserver;
47 std::unique_ptr<GISelObserverWrapper> ObserverWrapper;
48
49 bool HasSetupMF = false;
50
51public:
52 /// If CSEInfo is not null, then the Combiner will use CSEInfo as the observer
53 /// and also create a CSEMIRBuilder. Pass nullptr if CSE is not needed.
56 GISelCSEInfo *CSEInfo = nullptr);
57 virtual ~Combiner();
58
59 virtual bool tryCombineAll(MachineInstr &I) const = 0;
60
62
63protected:
70
73};
74
75} // End namespace llvm.
76
77#endif // LLVM_CODEGEN_GLOBALISEL_COMBINER_H
This contains common code to allow clients to notify changes to machine instr.
#define I(x, y, z)
Definition: MD5.cpp:58
This file declares the MachineIRBuilder class.
This class acts as the glue the joins the CombinerHelper to the overall Combine algorithm.
Definition: Combiner.cpp:50
Combiner implementation.
Definition: Combiner.h:34
GISelCSEInfo * CSEInfo
Definition: Combiner.h:72
bool combineMachineInstrs()
Definition: Combiner.cpp:117
MachineRegisterInfo & MRI
Definition: Combiner.h:68
const TargetPassConfig * TPC
Definition: Combiner.h:71
virtual ~Combiner()
MachineIRBuilder & B
Definition: Combiner.h:66
GISelKnownBits * KB
Definition: Combiner.h:69
MachineFunction & MF
Definition: Combiner.h:67
CombinerInfo & CInfo
Definition: Combiner.h:64
GISelChangeObserver & Observer
Definition: Combiner.h:65
virtual bool tryCombineAll(MachineInstr &I) const =0
Provides the logic to execute GlobalISel match tables, which are used by the instruction selector and...
The CSE Analysis object.
Definition: CSEInfo.h:69
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:69
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Target-Independent Code Generator Pass Configuration Options.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18