xref: /freebsd/contrib/llvm-project/llvm/lib/Target/M68k/M68kAsmPrinter.h (revision d4eeb02986980bf33dd56c41ceb9fc5f180c0d47)
1 //===-- M68kAsmPrinter.h - M68k 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 /// \file
10 /// This file contains M68k assembler printer declarations.
11 ///
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_LIB_TARGET_M68K_M68KASMPRINTER_H
15 #define LLVM_LIB_TARGET_M68K_M68KASMPRINTER_H
16 
17 #include "M68kMCInstLower.h"
18 #include "M68kTargetMachine.h"
19 
20 #include "llvm/CodeGen/AsmPrinter.h"
21 #include "llvm/MC/MCStreamer.h"
22 #include "llvm/Support/Compiler.h"
23 #include "llvm/Target/TargetMachine.h"
24 #include <memory>
25 #include <utility>
26 
27 namespace llvm {
28 class MCStreamer;
29 class MachineInstr;
30 class MachineBasicBlock;
31 class Module;
32 class raw_ostream;
33 
34 class M68kSubtarget;
35 class M68kMachineFunctionInfo;
36 
37 class LLVM_LIBRARY_VISIBILITY M68kAsmPrinter : public AsmPrinter {
38 
39   void EmitInstrWithMacroNoAT(const MachineInstr *MI);
40 
41   void printOperand(const MachineInstr *MI, int OpNum, raw_ostream &OS);
42 
43 public:
44   const M68kSubtarget *Subtarget;
45   const M68kMachineFunctionInfo *MMFI;
46   std::unique_ptr<M68kMCInstLower> MCInstLowering;
47 
48   explicit M68kAsmPrinter(TargetMachine &TM,
49                           std::unique_ptr<MCStreamer> Streamer)
50       : AsmPrinter(TM, std::move(Streamer)) {
51     Subtarget = static_cast<M68kTargetMachine &>(TM).getSubtargetImpl();
52   }
53 
54   StringRef getPassName() const override { return "M68k Assembly Printer"; }
55 
56   virtual bool runOnMachineFunction(MachineFunction &MF) override;
57 
58   bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
59                        const char *ExtraCode, raw_ostream &OS) override;
60 
61   void emitInstruction(const MachineInstr *MI) override;
62   void emitFunctionBodyStart() override;
63   void emitFunctionBodyEnd() override;
64   void emitStartOfAsmFile(Module &M) override;
65   void emitEndOfAsmFile(Module &M) override;
66 };
67 } // namespace llvm
68 
69 #endif // LLVM_LIB_TARGET_M68K_M68KASMPRINTER_H
70