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 MachineBasicBlock;
23 class MachineInstr;
24 class Module;
25 class raw_ostream;
26 
27 class LLVM_LIBRARY_VISIBILITY SystemZAsmPrinter : public AsmPrinter {
28 private:
29   StackMaps SM;
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 public:
38   SystemZAsmPrinter(TargetMachine &TM, std::unique_ptr<MCStreamer> Streamer)
39       : AsmPrinter(TM, std::move(Streamer)), SM(*this) {}
40 
41   // Override AsmPrinter.
42   StringRef getPassName() const override { return "SystemZ Assembly Printer"; }
43   void emitInstruction(const MachineInstr *MI) override;
44   void emitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) override;
45   void emitEndOfAsmFile(Module &M) override;
46   bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
47                        const char *ExtraCode, raw_ostream &OS) override;
48   bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
49                              const char *ExtraCode, raw_ostream &OS) override;
50 
51   bool doInitialization(Module &M) override {
52     SM.reset();
53     return AsmPrinter::doInitialization(M);
54   }
55 
56 private:
57   void LowerFENTRY_CALL(const MachineInstr &MI, SystemZMCInstLower &MCIL);
58   void LowerSTACKMAP(const MachineInstr &MI);
59   void LowerPATCHPOINT(const MachineInstr &MI, SystemZMCInstLower &Lower);
60 };
61 } // end namespace llvm
62 
63 #endif
64