1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef RCC_CODEGEN_GLOBALISEL_INSTRUCTIONSELECTOR_H
#define RCC_CODEGEN_GLOBALISEL_INSTRUCTIONSELECTOR_H
#include "rcc/CodeGen/GlobalISel/GIMatchTableExecutor.h"
#include "rcc/Support/Error.h"
namespace rcc {
class MachineFunction;
class MachineInstr;
class TargetDescription;
class InstructionSelector : public GIMatchTableExecutor {
public:
virtual ~InstructionSelector() = default;
[[nodiscard]] virtual Expected<void> select(MachineInstr &Instruction, MachineFunction &Function,
const TargetDescription &Target) const = 0;
// Selection matching is read-only and completes before select() mutates MachineIR.
[[nodiscard]] virtual Expected<void> canSelect(const MachineInstr &, const MachineFunction &,
const TargetDescription &) const {
return {};
}
[[nodiscard]] virtual Expected<void>
constrainSelectedInstruction(MachineInstr &, MachineFunction &, const TargetDescription &) const {
return {};
}
[[nodiscard]] Expected<void> propagateSelectionFlags(MachineInstr &Output,
MachineInstrFlags InputFlags,
bool InputMayRaiseFPException,
const TargetDescription &Target) const;
[[nodiscard]] Expected<void> propagateSelectionFlags(MachineInstr &Output,
const MachineInstr &Input,
const TargetDescription &Target) const;
protected:
[[nodiscard]] Expected<void>
finalizeGeneratedInstruction(MachineInstr &Output, MachineFunction &Function,
const TargetDescription &Target, MachineInstrFlags InputFlags,
bool InputMayRaiseFPException) const override;
};
} // namespace rcc
#endif // RCC_CODEGEN_GLOBALISEL_INSTRUCTIONSELECTOR_H
|