xref: /freebsd/contrib/llvm-project/llvm/lib/Target/SystemZ/SystemZAsmPrinter.h (revision 9f23cbd6cae82fd77edfad7173432fa8dccd0a95)
1 //===-- SystemZAsmPrinter.h - SystemZ 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 #ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZASMPRINTER_H
10 #define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZASMPRINTER_H
11 
12 #include "SystemZMCInstLower.h"
13 #include "SystemZTargetMachine.h"
14 #include "SystemZTargetStreamer.h"
15 #include "llvm/CodeGen/AsmPrinter.h"
16 #include "llvm/CodeGen/StackMaps.h"
17 #include "llvm/MC/MCInstBuilder.h"
18 #include "llvm/Support/Compiler.h"
19 
20 namespace llvm {
21 class MCStreamer;
22 class MachineInstr;
23 class Module;
24 class raw_ostream;
25 
26 class LLVM_LIBRARY_VISIBILITY SystemZAsmPrinter : public AsmPrinter {
27 private:
28   MCSymbol *CurrentFnPPA1Sym;     // PPA1 Symbol.
29   MCSymbol *CurrentFnEPMarkerSym; // Entry Point Marker.
30 
31   SystemZTargetStreamer *getTargetStreamer() {
32     MCTargetStreamer *TS = OutStreamer->getTargetStreamer();
33     assert(TS && "do not have a target streamer");
34     return static_cast<SystemZTargetStreamer *>(TS);
35   }
36 
37   /// Call type information for XPLINK.
38   enum class CallType {
39     BASR76 = 0,   // b'x000' == BASR  r7,r6
40     BRAS7 = 1,    // b'x001' == BRAS  r7,ep
41     RESVD_2 = 2,  // b'x010'
42     BRASL7 = 3,   // b'x011' == BRASL r7,ep
43     RESVD_4 = 4,  // b'x100'
44     RESVD_5 = 5,  // b'x101'
45     BALR1415 = 6, // b'x110' == BALR  r14,r15
46     BASR33 = 7,   // b'x111' == BASR  r3,r3
47   };
48 
49   void emitPPA1(MCSymbol *FnEndSym);
50 
51 public:
52   SystemZAsmPrinter(TargetMachine &TM, std::unique_ptr<MCStreamer> Streamer)
53       : AsmPrinter(TM, std::move(Streamer)), CurrentFnPPA1Sym(nullptr),
54         CurrentFnEPMarkerSym(nullptr) {}
55 
56   // Override AsmPrinter.
57   StringRef getPassName() const override { return "SystemZ Assembly Printer"; }
58   void emitInstruction(const MachineInstr *MI) override;
59   void emitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) override;
60   void emitEndOfAsmFile(Module &M) override;
61   bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
62                        const char *ExtraCode, raw_ostream &OS) override;
63   bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
64                              const char *ExtraCode, raw_ostream &OS) override;
65 
66   bool doInitialization(Module &M) override {
67     SM.reset();
68     return AsmPrinter::doInitialization(M);
69   }
70   void emitFunctionEntryLabel() override;
71   void emitFunctionBodyEnd() override;
72 
73 private:
74   void emitCallInformation(CallType CT);
75   void LowerFENTRY_CALL(const MachineInstr &MI, SystemZMCInstLower &MCIL);
76   void LowerSTACKMAP(const MachineInstr &MI);
77   void LowerPATCHPOINT(const MachineInstr &MI, SystemZMCInstLower &Lower);
78   void emitAttributes(Module &M);
79 };
80 } // end namespace llvm
81 
82 #endif
83