xref: /freebsd/contrib/llvm-project/llvm/lib/Target/M68k/M68kAsmPrinter.h (revision 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e)
104eeddc0SDimitry Andric //===-- M68kAsmPrinter.h - M68k LLVM Assembly Printer -----------*- C++ -*-===//
2fe6060f1SDimitry Andric //
3fe6060f1SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4fe6060f1SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5fe6060f1SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6fe6060f1SDimitry Andric //
7fe6060f1SDimitry Andric //===----------------------------------------------------------------------===//
8fe6060f1SDimitry Andric ///
9fe6060f1SDimitry Andric /// \file
10fe6060f1SDimitry Andric /// This file contains M68k assembler printer declarations.
11fe6060f1SDimitry Andric ///
12fe6060f1SDimitry Andric //===----------------------------------------------------------------------===//
13fe6060f1SDimitry Andric 
14fe6060f1SDimitry Andric #ifndef LLVM_LIB_TARGET_M68K_M68KASMPRINTER_H
15fe6060f1SDimitry Andric #define LLVM_LIB_TARGET_M68K_M68KASMPRINTER_H
16fe6060f1SDimitry Andric 
17fe6060f1SDimitry Andric #include "M68kMCInstLower.h"
18fe6060f1SDimitry Andric #include "M68kTargetMachine.h"
19*06c3fb27SDimitry Andric #include "MCTargetDesc/M68kMemOperandPrinter.h"
20fe6060f1SDimitry Andric 
21fe6060f1SDimitry Andric #include "llvm/CodeGen/AsmPrinter.h"
22fe6060f1SDimitry Andric #include "llvm/MC/MCStreamer.h"
23fe6060f1SDimitry Andric #include "llvm/Support/Compiler.h"
24fe6060f1SDimitry Andric #include "llvm/Target/TargetMachine.h"
25fe6060f1SDimitry Andric #include <memory>
26fe6060f1SDimitry Andric #include <utility>
27fe6060f1SDimitry Andric 
28fe6060f1SDimitry Andric namespace llvm {
29fe6060f1SDimitry Andric class MCStreamer;
30fe6060f1SDimitry Andric class MachineInstr;
31fe6060f1SDimitry Andric class MachineBasicBlock;
32fe6060f1SDimitry Andric class Module;
33fe6060f1SDimitry Andric class raw_ostream;
34fe6060f1SDimitry Andric 
35fe6060f1SDimitry Andric class M68kSubtarget;
36fe6060f1SDimitry Andric class M68kMachineFunctionInfo;
37fe6060f1SDimitry Andric 
38*06c3fb27SDimitry Andric class LLVM_LIBRARY_VISIBILITY M68kAsmPrinter
39*06c3fb27SDimitry Andric     : public AsmPrinter,
40*06c3fb27SDimitry Andric       public M68kMemOperandPrinter<M68kAsmPrinter, MachineInstr> {
41*06c3fb27SDimitry Andric 
42*06c3fb27SDimitry Andric   friend class M68kMemOperandPrinter;
43fe6060f1SDimitry Andric 
44fe6060f1SDimitry Andric   void EmitInstrWithMacroNoAT(const MachineInstr *MI);
45fe6060f1SDimitry Andric 
46fe6060f1SDimitry Andric   void printOperand(const MachineInstr *MI, int OpNum, raw_ostream &OS);
47fe6060f1SDimitry Andric 
48*06c3fb27SDimitry Andric   void printDisp(const MachineInstr *MI, unsigned OpNum, raw_ostream &OS);
49*06c3fb27SDimitry Andric   void printAbsMem(const MachineInstr *MI, unsigned OpNum, raw_ostream &OS);
50*06c3fb27SDimitry Andric 
51fe6060f1SDimitry Andric public:
52fe6060f1SDimitry Andric   const M68kSubtarget *Subtarget;
53fe6060f1SDimitry Andric   const M68kMachineFunctionInfo *MMFI;
54fe6060f1SDimitry Andric   std::unique_ptr<M68kMCInstLower> MCInstLowering;
55fe6060f1SDimitry Andric 
M68kAsmPrinter(TargetMachine & TM,std::unique_ptr<MCStreamer> Streamer)56fe6060f1SDimitry Andric   explicit M68kAsmPrinter(TargetMachine &TM,
57fe6060f1SDimitry Andric                           std::unique_ptr<MCStreamer> Streamer)
58fe6060f1SDimitry Andric       : AsmPrinter(TM, std::move(Streamer)) {
59fe6060f1SDimitry Andric     Subtarget = static_cast<M68kTargetMachine &>(TM).getSubtargetImpl();
60fe6060f1SDimitry Andric   }
61fe6060f1SDimitry Andric 
getPassName()62fe6060f1SDimitry Andric   StringRef getPassName() const override { return "M68k Assembly Printer"; }
63fe6060f1SDimitry Andric 
64fe6060f1SDimitry Andric   virtual bool runOnMachineFunction(MachineFunction &MF) override;
65fe6060f1SDimitry Andric 
66fe6060f1SDimitry Andric   bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
67fe6060f1SDimitry Andric                        const char *ExtraCode, raw_ostream &OS) override;
68*06c3fb27SDimitry Andric   bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
69*06c3fb27SDimitry Andric                              const char *ExtraCode, raw_ostream &OS) override;
70fe6060f1SDimitry Andric 
71fe6060f1SDimitry Andric   void emitInstruction(const MachineInstr *MI) override;
72fe6060f1SDimitry Andric   void emitFunctionBodyStart() override;
73fe6060f1SDimitry Andric   void emitFunctionBodyEnd() override;
74fe6060f1SDimitry Andric   void emitStartOfAsmFile(Module &M) override;
75fe6060f1SDimitry Andric   void emitEndOfAsmFile(Module &M) override;
76fe6060f1SDimitry Andric };
77fe6060f1SDimitry Andric } // namespace llvm
78fe6060f1SDimitry Andric 
7904eeddc0SDimitry Andric #endif // LLVM_LIB_TARGET_M68K_M68KASMPRINTER_H
80