diff options
| author | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-09 18:31:49 +0800 |
|---|---|---|
| committer | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-09 18:31:49 +0800 |
| commit | 379ff50dcc7ccf977379aee68fa9d10f69065d23 (patch) | |
| tree | e0fac3952d46d0bbcaea32bcfc6087c95fff2992 /backend/include/rcc/CodeGen/AsmPrinter.h | |
| parent | 495c675771f43cfa12ab7a426a538be72fec1805 (diff) | |
| download | rcc-project-379ff50dcc7ccf977379aee68fa9d10f69065d23.tar.gz rcc-project-379ff50dcc7ccf977379aee68fa9d10f69065d23.tar.xz | |
[MC] Implement RV64GC assembly emission
Diffstat (limited to 'backend/include/rcc/CodeGen/AsmPrinter.h')
| -rw-r--r-- | backend/include/rcc/CodeGen/AsmPrinter.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/backend/include/rcc/CodeGen/AsmPrinter.h b/backend/include/rcc/CodeGen/AsmPrinter.h new file mode 100644 index 0000000..82bad7d --- /dev/null +++ b/backend/include/rcc/CodeGen/AsmPrinter.h @@ -0,0 +1,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 |
