xref: /freebsd/contrib/llvm-project/llvm/lib/Target/SystemZ/SystemZAsmPrinter.h (revision 3078531de10dcae44b253a35125c949ff4235284)
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   StackMaps SM;
29 
30   SystemZTargetStreamer *getTargetStreamer() {
31     MCTargetStreamer *TS = OutStreamer->getTargetStreamer();
32     assert(TS && "do not have a target streamer");
33     return static_cast<SystemZTargetStreamer *>(TS);
34   }
35 
36 public:
37   SystemZAsmPrinter(TargetMachine &TM, std::unique_ptr<MCStreamer> Streamer)
38       : AsmPrinter(TM, std::move(Streamer)), SM(*this) {}
39 
40   // Override AsmPrinter.
41   StringRef getPassName() const override { return "SystemZ Assembly Printer"; }
42   void emitInstruction(const MachineInstr *MI) override;
43   void emitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) override;
44   void emitEndOfAsmFile(Module &M) override;
45   bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
46                        const char *ExtraCode, raw_ostream &OS) override;
47   bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
48                              const char *ExtraCode, raw_ostream &OS) override;
49 
50   bool doInitialization(Module &M) override {
51     SM.reset();
52     return AsmPrinter::doInitialization(M);
53   }
54   void emitFunctionEntryLabel() override;
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