From 3a57627e59ba18b6f9f9aae7bb60c390c0d3575a Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Sun, 9 Aug 2026 22:05:14 +0800 Subject: [MC] Implement RV64GC object emission --- backend/lib/MC/MCAsmBackend.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 backend/lib/MC/MCAsmBackend.cpp (limited to 'backend/lib/MC/MCAsmBackend.cpp') diff --git a/backend/lib/MC/MCAsmBackend.cpp b/backend/lib/MC/MCAsmBackend.cpp new file mode 100644 index 0000000..bc350b7 --- /dev/null +++ b/backend/lib/MC/MCAsmBackend.cpp @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "rcc/MC/MCAsmBackend.h" + +namespace rcc::mc { + +Expected> +MCAsmBackend::relocationsForFixup(const MCFixup &Fixup, const MCValue &Value) const { + if (!Value.AddSymbol || Value.SubtractSymbol) { + return makeUnexpected(ErrorCode::RelocationFailed, + "MC backend cannot represent this expression as one relocation"); + } + auto Type = relocationType(Fixup, Value); + if (!Type) + return std::unexpected(Type.error()); + return std::vector{ + {.Type = *Type, .Symbol = Value.AddSymbol, .Addend = Value.Addend}}; +} + +Expected MCAsmBackend::relaxInstruction(const MCInst &) const { + return makeUnexpected(ErrorCode::InstructionEncodingFailed, + "target does not support MC instruction relaxation"); +} + +} // namespace rcc::mc -- cgit v1.2.3