aboutsummaryrefslogtreecommitdiff
path: root/backend/include/rcc/CodeGen/GlobalISel/InstructionSelector.h
diff options
context:
space:
mode:
Diffstat (limited to 'backend/include/rcc/CodeGen/GlobalISel/InstructionSelector.h')
-rw-r--r--backend/include/rcc/CodeGen/GlobalISel/InstructionSelector.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/backend/include/rcc/CodeGen/GlobalISel/InstructionSelector.h b/backend/include/rcc/CodeGen/GlobalISel/InstructionSelector.h
new file mode 100644
index 0000000..8e5b56d
--- /dev/null
+++ b/backend/include/rcc/CodeGen/GlobalISel/InstructionSelector.h
@@ -0,0 +1,45 @@
+// 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:
+ ~InstructionSelector() override = default;
+
+ [[nodiscard]] virtual Expected<void> select(MachineInstr &Instruction, MachineFunction &Function,
+ const TargetDescription &Target) const = 0;
+
+ [[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