aboutsummaryrefslogtreecommitdiff
path: root/backend/include/rcc/Target/RISCV/RISCVAsmBackend.h
blob: 11dcb774b1337e2d55809de4fdb27f1317a37ce2 (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
26
27
28
29
30
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef RCC_TARGET_RISCV_RISCVASMBACKEND_H
#define RCC_TARGET_RISCV_RISCVASMBACKEND_H

#include "rcc/MC/MCAsmBackend.h"

namespace rcc::riscv {

class RISCVAsmBackend final : public mc::MCAsmBackend {
public:
  [[nodiscard]] Expected<mc::MCFixupKindInfo> fixupKindInfo(mc::MCFixupKind Kind) const override;
  [[nodiscard]] Expected<void> applyFixup(mc::MCFixupKind Kind, std::span<std::uint8_t> Data,
                                          std::uint64_t Offset, std::int64_t Value) const override;
  [[nodiscard]] Expected<std::uint32_t> relocationType(const mc::MCFixup &Fixup,
                                                       const mc::MCValue &Value) const override;
  [[nodiscard]] Expected<std::vector<mc::MCFixupRelocation>>
  relocationsForFixup(const mc::MCFixup &Fixup, const mc::MCValue &Value) const override;

  [[nodiscard]] bool mayNeedRelaxation(const mc::MCInst &Instruction) const noexcept override;
  [[nodiscard]] Expected<bool> fixupNeedsRelaxation(const mc::MCFixup &Fixup,
                                                    std::int64_t Value) const override;
  [[nodiscard]] Expected<mc::MCInst> relaxInstruction(const mc::MCInst &Instruction) const override;

  [[nodiscard]] std::uint32_t objectFlags() const noexcept override;
};

} // namespace rcc::riscv

#endif // RCC_TARGET_RISCV_RISCVASMBACKEND_H