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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef RCC_TARGET_RISCV_RISCVMCTARGETLOWERING_H
#define RCC_TARGET_RISCV_RISCVMCTARGETLOWERING_H
#include "rcc/CodeGen/TargetMCInstLowering.h"
#include "rcc/Target/RISCV/RISCVInstPrinter.h"
namespace rcc::riscv {
class RISCVMCTargetLowering final : public TargetMCInstLowering {
public:
explicit RISCVMCTargetLowering(const TargetDescription &Target) noexcept
: Target(&Target), Printer(Target) {}
[[nodiscard]] const mc::MCInstPrinter &instructionPrinter() const noexcept override {
return Printer;
}
[[nodiscard]] Expected<mc::MCInst> lowerInstruction(const MachineInstr &Instruction,
MachineMCContext &Context) const override;
[[nodiscard]] Expected<void> emitTerminalInstruction(const MachineInstr &Instruction,
MachineMCContext &Context,
mc::MCStreamer &Streamer) const override;
[[nodiscard]] Expected<mc::MCSectionDesc>
textSection(const MachineFunction &Function) const override;
[[nodiscard]] Expected<mc::MCSectionDesc> globalSection(const GlobalObjectDesc &Object,
MachineMCContext &Context) const override;
[[nodiscard]] Expected<mc::MCSectionDesc>
constantPoolSection(const MachineFunction &Function,
const MachineConstantPoolEntry &Entry) const override;
[[nodiscard]] Expected<mc::MCSectionDesc>
jumpTableSection(const MachineFunction &Function,
const MachineJumpTableEntry &Entry) const override;
[[nodiscard]] Expected<void> emitFileHeader(MachineMCContext &Context,
mc::MCStreamer &Streamer) const override;
[[nodiscard]] Expected<void> emitFileTrailer(MachineMCContext &Context,
mc::MCStreamer &Streamer) const override;
[[nodiscard]] Expected<void> emitGenericConstant(const GenericConstantData &Constant,
std::uint64_t Size, MachineMCContext &Context,
mc::MCStreamer &Streamer) const override;
[[nodiscard]] Expected<void> emitGlobalInitializer(const GlobalInitializer &Initializer,
MachineMCContext &Context,
mc::MCStreamer &Streamer) const override;
[[nodiscard]] Expected<void> emitTargetConstant(const TargetConstant &Constant,
MachineMCContext &Context,
mc::MCStreamer &Streamer) const override;
[[nodiscard]] Expected<void> emitTargetJumpTable(const MachineFunction &Function,
const MachineJumpTableEntry &Entry,
MachineMCContext &Context,
mc::MCStreamer &Streamer) const override;
private:
const TargetDescription *Target;
RISCVInstPrinter Printer;
};
} // namespace rcc::riscv
#endif // RCC_TARGET_RISCV_RISCVMCTARGETLOWERING_H
|