aboutsummaryrefslogtreecommitdiff
path: root/backend/lib/MC/MCAsmBackend.cpp
blob: bc350b75d0c53906d2a3c65e22d08c334995e2c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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