xref: /freebsd/contrib/llvm-project/llvm/lib/Target/M68k/M68kAsmPrinter.h (revision f126890ac5386406dadf7c4cfa9566cbb56537c5)
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 #include "MCTargetDesc/M68kMemOperandPrinter.h"
20 
21 #include "llvm/CodeGen/AsmPrinter.h"
22 #include "llvm/MC/MCStreamer.h"
23 #include "llvm/Support/Compiler.h"
24 #include "llvm/Target/TargetMachine.h"
25 #include <memory>
26 #include <utility>
27 
28 namespace llvm {
29 class MCStreamer;
30 class MachineInstr;
31 class MachineBasicBlock;
32 class Module;
33 class raw_ostream;
34 
35 class M68kSubtarget;
36 class M68kMachineFunctionInfo;
37 
38 class LLVM_LIBRARY_VISIBILITY M68kAsmPrinter
39     : public AsmPrinter,
40       public M68kMemOperandPrinter<M68kAsmPrinter, MachineInstr> {
41 
42   friend class M68kMemOperandPrinter;
43 
44   void EmitInstrWithMacroNoAT(const MachineInstr *MI);
45 
46   void printOperand(const MachineInstr *MI, int OpNum, raw_ostream &OS);
47 
48   void printDisp(const MachineInstr *MI, unsigned OpNum, raw_ostream &OS);
49   void printAbsMem(const MachineInstr *MI, unsigned OpNum, raw_ostream &OS);
50 
51 public:
52   const M68kSubtarget *Subtarget;
53   const M68kMachineFunctionInfo *MMFI;
54   std::unique_ptr<M68kMCInstLower> MCInstLowering;
55 
56   explicit M68kAsmPrinter(TargetMachine &TM,
57                           std::unique_ptr<MCStreamer> Streamer)
58       : AsmPrinter(TM, std::move(Streamer)) {
59     Subtarget = static_cast<M68kTargetMachine &>(TM).getSubtargetImpl();
60   }
61 
62   StringRef getPassName() const override { return "M68k Assembly Printer"; }
63 
64   virtual bool runOnMachineFunction(MachineFunction &MF) override;
65 
66   bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
67                        const char *ExtraCode, raw_ostream &OS) override;
68   bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
69                              const char *ExtraCode, raw_ostream &OS) override;
70 
71   void emitInstruction(const MachineInstr *MI) override;
72   void emitFunctionBodyStart() override;
73   void emitFunctionBodyEnd() override;
74   void emitStartOfAsmFile(Module &M) override;
75   void emitEndOfAsmFile(Module &M) override;
76 };
77 } // namespace llvm
78 
79 #endif // LLVM_LIB_TARGET_M68K_M68KASMPRINTER_H
80