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 "llvm/CodeGen/AsmPrinter.h" |
18 | #include "llvm/CodeGen/StackMaps.h" |
19 | #include "llvm/MC/MCStreamer.h" |
20 | #include "llvm/Support/Compiler.h" |
21 | |
22 | namespace llvm { |
23 | |
24 | class LLVM_LIBRARY_VISIBILITY LoongArchAsmPrinter : public AsmPrinter { |
25 | public: |
26 | static char ID; |
27 | |
28 | private: |
29 | const MCSubtargetInfo *STI; |
30 | |
31 | public: |
32 | explicit LoongArchAsmPrinter(TargetMachine &TM, |
33 | std::unique_ptr<MCStreamer> Streamer) |
34 | : AsmPrinter(TM, std::move(Streamer), ID), STI(TM.getMCSubtargetInfo()) {} |
35 | |
36 | StringRef getPassName() const override { |
37 | return "LoongArch Assembly Printer" ; |
38 | } |
39 | |
40 | bool runOnMachineFunction(MachineFunction &MF) override; |
41 | |
42 | void emitInstruction(const MachineInstr *MI) override; |
43 | |
44 | bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, |
45 | const char *, raw_ostream &OS) override; |
46 | bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, |
47 | const char *, raw_ostream &OS) override; |
48 | |
49 | void LowerSTATEPOINT(const MachineInstr &MI); |
50 | void LowerPATCHABLE_FUNCTION_ENTER(const MachineInstr &MI); |
51 | void LowerPATCHABLE_FUNCTION_EXIT(const MachineInstr &MI); |
52 | void LowerPATCHABLE_TAIL_CALL(const MachineInstr &MI); |
53 | void emitSled(const MachineInstr &MI, SledKind Kind); |
54 | |
55 | // tblgen'erated function. |
56 | bool lowerPseudoInstExpansion(const MachineInstr *MI, MCInst &Inst); |
57 | |
58 | // Wrapper needed for tblgenned pseudo lowering. |
59 | bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp) const { |
60 | return lowerLoongArchMachineOperandToMCOperand(MO, MCOp, AP: *this); |
61 | } |
62 | void emitJumpTableInfo() override; |
63 | }; |
64 | |
65 | } // end namespace llvm |
66 | |
67 | #endif // LLVM_LIB_TARGET_LOONGARCH_LOONGARCHASMPRINTER_H |
68 | |