1//===- LoongArchAsmPrinter.h - LoongArch LLVM Assembly Printer -*- C++ -*--===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// LoongArch Assembly printer class.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_TARGET_LOONGARCH_LOONGARCHASMPRINTER_H
14#define LLVM_LIB_TARGET_LOONGARCH_LOONGARCHASMPRINTER_H
15
16#include "LoongArchSubtarget.h"
17#include "MCTargetDesc/LoongArchTargetStreamer.h"
18#include "llvm/CodeGen/AsmPrinter.h"
19#include "llvm/CodeGen/StackMaps.h"
20#include "llvm/MC/MCStreamer.h"
21#include "llvm/Support/Compiler.h"
22
23namespace llvm {
24
25class LLVM_LIBRARY_VISIBILITY LoongArchAsmPrinter : public AsmPrinter {
26public:
27 static char ID;
28
29private:
30 const MCSubtargetInfo *STI;
31
32 LoongArchTargetStreamer &getTargetStreamer() const;
33
34public:
35 explicit LoongArchAsmPrinter(TargetMachine &TM,
36 std::unique_ptr<MCStreamer> Streamer)
37 : AsmPrinter(TM, std::move(Streamer), ID), STI(&TM.getMCSubtargetInfo()) {
38 }
39
40 StringRef getPassName() const override {
41 return "LoongArch Assembly Printer";
42 }
43
44 bool runOnMachineFunction(MachineFunction &MF) override;
45
46 void emitInstruction(const MachineInstr *MI) override;
47
48 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
49 const char *ExtraCode, raw_ostream &OS) override;
50 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
51 const char *ExtraCode, raw_ostream &OS) override;
52
53 void LowerSTATEPOINT(const MachineInstr &MI);
54 void LowerPATCHABLE_FUNCTION_ENTER(const MachineInstr &MI);
55 void LowerPATCHABLE_FUNCTION_EXIT(const MachineInstr &MI);
56 void LowerPATCHABLE_TAIL_CALL(const MachineInstr &MI);
57 void emitSled(const MachineInstr &MI, SledKind Kind);
58
59 // tblgen'erated function.
60 bool lowerPseudoInstExpansion(const MachineInstr *MI, MCInst &Inst);
61
62 // Wrapper needed for tblgenned pseudo lowering.
63 bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp) const {
64 return lowerLoongArchMachineOperandToMCOperand(MO, MCOp, AP: *this);
65 }
66 void emitJumpTableInfo() override;
67 void emitDebugValue(const MCExpr *Value, unsigned Size) const override;
68};
69
70} // end namespace llvm
71
72#endif // LLVM_LIB_TARGET_LOONGARCH_LOONGARCHASMPRINTER_H
73