1 | //===- llvm/CodeGen/GlobalISel/InstructionSelector.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 | /// \file This file declares the API for the instruction selector. |
10 | // |
11 | //===----------------------------------------------------------------------===// |
12 | |
13 | #ifndef LLVM_CODEGEN_GLOBALISEL_INSTRUCTIONSELECTOR_H |
14 | #define LLVM_CODEGEN_GLOBALISEL_INSTRUCTIONSELECTOR_H |
15 | |
16 | #include "llvm/CodeGen/GlobalISel/GIMatchTableExecutor.h" |
17 | |
18 | namespace llvm { |
19 | class InstructionSelector : public GIMatchTableExecutor { |
20 | public: |
21 | virtual ~InstructionSelector(); |
22 | |
23 | /// Select the (possibly generic) instruction \p I to only use target-specific |
24 | /// opcodes. It is OK to insert multiple instructions, but they cannot be |
25 | /// generic pre-isel instructions. |
26 | /// |
27 | /// \returns whether selection succeeded. |
28 | /// \pre I.getParent() && I.getParent()->getParent() |
29 | /// \post |
30 | /// if returns true: |
31 | /// for I in all mutated/inserted instructions: |
32 | /// !isPreISelGenericOpcode(I.getOpcode()) |
33 | virtual bool select(MachineInstr &I) = 0; |
34 | |
35 | void setTargetPassConfig(const TargetPassConfig *T) { TPC = T; } |
36 | |
37 | void (MachineOptimizationRemarkEmitter *M) { MORE = M; } |
38 | |
39 | protected: |
40 | const TargetPassConfig *TPC = nullptr; |
41 | MachineOptimizationRemarkEmitter *MORE = nullptr; |
42 | }; |
43 | } // namespace llvm |
44 | |
45 | #endif |
46 | |