diff options
| author | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-09 22:05:14 +0800 |
|---|---|---|
| committer | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-09 22:05:14 +0800 |
| commit | 3a57627e59ba18b6f9f9aae7bb60c390c0d3575a (patch) | |
| tree | 736ca062bfffbd68177a512dfe145b06c16d11b1 /backend/lib/MC/MCAsmBackend.cpp | |
| parent | 379ff50dcc7ccf977379aee68fa9d10f69065d23 (diff) | |
| download | rcc-project-3a57627e59ba18b6f9f9aae7bb60c390c0d3575a.tar.gz rcc-project-3a57627e59ba18b6f9f9aae7bb60c390c0d3575a.tar.xz | |
[MC] Implement RV64GC object emission
Diffstat (limited to 'backend/lib/MC/MCAsmBackend.cpp')
| -rw-r--r-- | backend/lib/MC/MCAsmBackend.cpp | 25 |
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 |
