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
63
64
65
66
67
68
69
|
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef RCC_CODEGEN_TARGETMCINSTLOWERING_H
#define RCC_CODEGEN_TARGETMCINSTLOWERING_H
#include "rcc/MC/MCInst.h"
#include "rcc/MC/MCInstPrinter.h"
#include "rcc/MC/MCSection.h"
#include "rcc/MC/MCStreamer.h"
#include "rcc/Support/Error.h"
namespace rcc {
class MachineConstantPoolEntry;
class GlobalInitializer;
struct GlobalObjectDesc;
class MachineFunction;
class MachineInstr;
class MachineJumpTableEntry;
class MachineMCContext;
struct GenericConstantData;
class TargetConstant;
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<void> emitTerminalInstruction(const MachineInstr &Instruction,
MachineMCContext &Context,
mc::MCStreamer &Streamer) const;
[[nodiscard]] virtual Expected<mc::MCSectionDesc>
textSection(const MachineFunction &Function) const = 0;
[[nodiscard]] virtual Expected<mc::MCSectionDesc>
globalSection(const GlobalObjectDesc &Object, MachineMCContext &Context) const = 0;
[[nodiscard]] virtual Expected<mc::MCSectionDesc>
constantPoolSection(const MachineFunction &Function,
const MachineConstantPoolEntry &Entry) const = 0;
[[nodiscard]] virtual Expected<mc::MCSectionDesc>
jumpTableSection(const MachineFunction &Function, const MachineJumpTableEntry &Entry) const = 0;
[[nodiscard]] virtual Expected<void> emitFileHeader(MachineMCContext &Context,
mc::MCStreamer &Streamer) const;
[[nodiscard]] virtual Expected<void> emitFileTrailer(MachineMCContext &Context,
mc::MCStreamer &Streamer) const;
[[nodiscard]] virtual Expected<void> emitGenericConstant(const GenericConstantData &Constant,
std::uint64_t Size,
MachineMCContext &Context,
mc::MCStreamer &Streamer) const;
[[nodiscard]] virtual Expected<void> emitGlobalInitializer(const GlobalInitializer &Initializer,
MachineMCContext &Context,
mc::MCStreamer &Streamer) const;
[[nodiscard]] virtual Expected<void> emitTargetConstant(const TargetConstant &Constant,
MachineMCContext &Context,
mc::MCStreamer &Streamer) const;
[[nodiscard]] virtual Expected<void> emitTargetJumpTable(const MachineFunction &Function,
const MachineJumpTableEntry &Entry,
MachineMCContext &Context,
mc::MCStreamer &Streamer) const;
};
} // namespace rcc
#endif // RCC_CODEGEN_TARGETMCINSTLOWERING_H
|