aboutsummaryrefslogtreecommitdiff
path: root/backend/include/rcc/CodeGen/TargetMCInstLowering.h
blob: eacb48e55e28e6266f5f756cdee9d4481555c332 (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
31
32
33
34
35
36
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef RCC_CODEGEN_TARGETMCINSTLOWERING_H
#define RCC_CODEGEN_TARGETMCINSTLOWERING_H

#include "rcc/MC/MCExpr.h"
#include "rcc/MC/MCInst.h"
#include "rcc/MC/MCInstPrinter.h"
#include "rcc/MC/MCStreamer.h"
#include "rcc/Support/Error.h"

namespace rcc {

class MachineInstr;
class MachineMCContext;

class TargetMCInstLowering {
public:
  virtual ~TargetMCInstLowering() = default;

  [[nodiscard]] virtual const mc::MCInstPrinter &instructionPrinter() const noexcept = 0;

  [[nodiscard]] virtual Expected<mc::MCInst> lowerInstruction(const MachineInstr &Instruction,
                                                              MachineMCContext &Context) const = 0;

  [[nodiscard]] virtual Expected<mc::MCExprRef>
  lowerSymbolExpression(mc::MCExprRef Expression, std::uint32_t TargetFlags) const = 0;

  [[nodiscard]] virtual Expected<void> emitTerminalInstruction(const MachineInstr &Instruction,
                                                               MachineMCContext &Context,
                                                               mc::MCStreamer &Streamer) const;
};

} // namespace rcc

#endif // RCC_CODEGEN_TARGETMCINSTLOWERING_H