aboutsummaryrefslogtreecommitdiff
path: root/backend/lib/MC/MCAsmBackend.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'backend/lib/MC/MCAsmBackend.cpp')
-rw-r--r--backend/lib/MC/MCAsmBackend.cpp25
1 files changed, 25 insertions, 0 deletions
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<std::vector<MCFixupRelocation>>
+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<MCFixupRelocation>{
+ {.Type = *Type, .Symbol = Value.AddSymbol, .Addend = Value.Addend}};
+}
+
+Expected<MCInst> MCAsmBackend::relaxInstruction(const MCInst &) const {
+ return makeUnexpected(ErrorCode::InstructionEncodingFailed,
+ "target does not support MC instruction relaxation");
+}
+
+} // namespace rcc::mc