/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/CodeGen/GlobalISel/CombinerInfo.h
Line | Count | Source |
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 | | // |
9 | | /// Interface for Targets to specify which operations are combined how and when. |
10 | | /// |
11 | | //===----------------------------------------------------------------------===// |
12 | | |
13 | | #ifndef LLVM_CODEGEN_GLOBALISEL_COMBINER_INFO_H |
14 | | #define LLVM_CODEGEN_GLOBALISEL_COMBINER_INFO_H |
15 | | |
16 | | #include <cassert> |
17 | | namespace llvm { |
18 | | |
19 | | class GISelChangeObserver; |
20 | | class LegalizerInfo; |
21 | | class MachineInstr; |
22 | | class MachineIRBuilder; |
23 | | class MachineRegisterInfo; |
24 | | |
25 | | // Contains information relevant to enabling/disabling various combines for a |
26 | | // pass. |
27 | | class CombinerInfo { |
28 | | public: |
29 | | CombinerInfo(bool AllowIllegalOps, bool ShouldLegalizeIllegal, |
30 | | LegalizerInfo *LInfo) |
31 | | : IllegalOpsAllowed(AllowIllegalOps), |
32 | 235k | LegalizeIllegalOps(ShouldLegalizeIllegal), LInfo(LInfo) { |
33 | 235k | assert(((AllowIllegalOps || !LegalizeIllegalOps) || LInfo) && |
34 | 235k | "Expecting legalizerInfo when illegalops not allowed"); |
35 | 235k | } |
36 | 235k | virtual ~CombinerInfo() = default; |
37 | | /// If \p IllegalOpsAllowed is false, the CombinerHelper will make use of |
38 | | /// the legalizerInfo to check for legality before each transformation. |
39 | | bool IllegalOpsAllowed; // TODO: Make use of this. |
40 | | |
41 | | /// If \p LegalizeIllegalOps is true, the Combiner will also legalize the |
42 | | /// illegal ops that are created. |
43 | | bool LegalizeIllegalOps; // TODO: Make use of this. |
44 | | const LegalizerInfo *LInfo; |
45 | | |
46 | | /// Attempt to combine instructions using MI as the root. |
47 | | /// |
48 | | /// Use Observer to report the creation, modification, and erasure of |
49 | | /// instructions. GISelChangeObserver will automatically report certain |
50 | | /// kinds of operations. These operations are: |
51 | | /// * Instructions that are newly inserted into the MachineFunction |
52 | | /// * Instructions that are erased from the MachineFunction. |
53 | | /// |
54 | | /// However, it is important to report instruction modification and this is |
55 | | /// not automatic. |
56 | | virtual bool combine(GISelChangeObserver &Observer, MachineInstr &MI, |
57 | | MachineIRBuilder &B) const = 0; |
58 | | }; |
59 | | } // namespace llvm |
60 | | |
61 | | #endif |