blob: 82bad7da7bd88c1fa36f3635c00edf8108d46757 (
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef RCC_CODEGEN_ASMPRINTER_H
#define RCC_CODEGEN_ASMPRINTER_H
#include "rcc/Support/Error.h"
namespace rcc {
class CompilationUnit;
class MachineFunction;
class MachineMCContext;
class TargetDescription;
class TargetMCInstLowering;
namespace mc {
class MCStreamer;
} // namespace mc
struct AsmPrinterOptions final {
bool EmitFunctionDirectives = true;
bool EmitCFI = true;
bool EmitBlockLabels = true;
bool EmitInstructionSymbols = true;
bool VerifyInput = true;
};
class AsmPrinter final {
public:
AsmPrinter(const TargetDescription &Target, const TargetMCInstLowering &Lowering,
MachineMCContext &Context, mc::MCStreamer &Streamer,
AsmPrinterOptions Options = {}) noexcept
: Target(&Target), Lowering(&Lowering), Context(&Context), Streamer(&Streamer),
Options(Options) {}
[[nodiscard]] Expected<void> emitCompilationUnit(const CompilationUnit &Unit);
[[nodiscard]] Expected<void> emitFunction(const MachineFunction &Function);
private:
[[nodiscard]] Expected<void> verifyFunction(const MachineFunction &Function) const;
[[nodiscard]] Expected<void> emitGlobalObjects(const CompilationUnit &Unit);
[[nodiscard]] Expected<void> emitFunctionBody(const MachineFunction &Function);
[[nodiscard]] Expected<void> emitConstantPool(const MachineFunction &Function);
[[nodiscard]] Expected<void> emitJumpTables(const MachineFunction &Function);
const TargetDescription *Target;
const TargetMCInstLowering *Lowering;
MachineMCContext *Context;
mc::MCStreamer *Streamer;
AsmPrinterOptions Options;
bool UnitEmissionStarted = false;
bool UnitEmissionFinished = false;
};
} // namespace rcc
#endif // RCC_CODEGEN_ASMPRINTER_H
|