aboutsummaryrefslogtreecommitdiff
path: root/backend/include/rcc/CodeGen/TargetMCInstLowering.h
diff options
context:
space:
mode:
authorRichard-Qin-X <richard.qin.001@gmail.com>2026-08-09 18:31:49 +0800
committerRichard-Qin-X <richard.qin.001@gmail.com>2026-08-09 18:31:49 +0800
commit379ff50dcc7ccf977379aee68fa9d10f69065d23 (patch)
treee0fac3952d46d0bbcaea32bcfc6087c95fff2992 /backend/include/rcc/CodeGen/TargetMCInstLowering.h
parent495c675771f43cfa12ab7a426a538be72fec1805 (diff)
downloadrcc-project-379ff50dcc7ccf977379aee68fa9d10f69065d23.tar.gz
rcc-project-379ff50dcc7ccf977379aee68fa9d10f69065d23.tar.xz
[MC] Implement RV64GC assembly emission
Diffstat (limited to 'backend/include/rcc/CodeGen/TargetMCInstLowering.h')
-rw-r--r--backend/include/rcc/CodeGen/TargetMCInstLowering.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/backend/include/rcc/CodeGen/TargetMCInstLowering.h b/backend/include/rcc/CodeGen/TargetMCInstLowering.h
new file mode 100644
index 0000000..875d2dd
--- /dev/null
+++ b/backend/include/rcc/CodeGen/TargetMCInstLowering.h
@@ -0,0 +1,69 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#ifndef RCC_CODEGEN_TARGETMCINSTLOWERING_H
+#define RCC_CODEGEN_TARGETMCINSTLOWERING_H
+
+#include "rcc/MC/MCInst.h"
+#include "rcc/MC/MCInstPrinter.h"
+#include "rcc/MC/MCSection.h"
+#include "rcc/MC/MCStreamer.h"
+#include "rcc/Support/Error.h"
+
+namespace rcc {
+
+class MachineConstantPoolEntry;
+class GlobalInitializer;
+struct GlobalObjectDesc;
+class MachineFunction;
+class MachineInstr;
+class MachineJumpTableEntry;
+class MachineMCContext;
+struct GenericConstantData;
+class TargetConstant;
+
+class TargetMCInstLowering {
+public:
+ virtual ~TargetMCInstLowering() = default;
+
+ [[nodiscard]] virtual const mc::MCInstPrinter &instructionPrinter() const noexcept = 0;
+
+ [[nodiscard]] virtual Expected<mc::MCInst> lowerInstruction(const MachineInstr &Instruction,
+ MachineMCContext &Context) const = 0;
+
+ [[nodiscard]] virtual Expected<void> emitTerminalInstruction(const MachineInstr &Instruction,
+ MachineMCContext &Context,
+ mc::MCStreamer &Streamer) const;
+
+ [[nodiscard]] virtual Expected<mc::MCSectionDesc>
+ textSection(const MachineFunction &Function) const = 0;
+ [[nodiscard]] virtual Expected<mc::MCSectionDesc>
+ globalSection(const GlobalObjectDesc &Object, MachineMCContext &Context) const = 0;
+ [[nodiscard]] virtual Expected<mc::MCSectionDesc>
+ constantPoolSection(const MachineFunction &Function,
+ const MachineConstantPoolEntry &Entry) const = 0;
+ [[nodiscard]] virtual Expected<mc::MCSectionDesc>
+ jumpTableSection(const MachineFunction &Function, const MachineJumpTableEntry &Entry) const = 0;
+
+ [[nodiscard]] virtual Expected<void> emitFileHeader(MachineMCContext &Context,
+ mc::MCStreamer &Streamer) const;
+ [[nodiscard]] virtual Expected<void> emitFileTrailer(MachineMCContext &Context,
+ mc::MCStreamer &Streamer) const;
+ [[nodiscard]] virtual Expected<void> emitGenericConstant(const GenericConstantData &Constant,
+ std::uint64_t Size,
+ MachineMCContext &Context,
+ mc::MCStreamer &Streamer) const;
+ [[nodiscard]] virtual Expected<void> emitGlobalInitializer(const GlobalInitializer &Initializer,
+ MachineMCContext &Context,
+ mc::MCStreamer &Streamer) const;
+ [[nodiscard]] virtual Expected<void> emitTargetConstant(const TargetConstant &Constant,
+ MachineMCContext &Context,
+ mc::MCStreamer &Streamer) const;
+ [[nodiscard]] virtual Expected<void> emitTargetJumpTable(const MachineFunction &Function,
+ const MachineJumpTableEntry &Entry,
+ MachineMCContext &Context,
+ mc::MCStreamer &Streamer) const;
+};
+
+} // namespace rcc
+
+#endif // RCC_CODEGEN_TARGETMCINSTLOWERING_H