xref: /freebsd-src/contrib/llvm-project/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.h (revision 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e)
10b57cec5SDimitry Andric //===- PPCInstPrinter.h - Convert PPC MCInst to assembly syntax -*- C++ -*-===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric //
90b57cec5SDimitry Andric // This class prints an PPC MCInst to a .s file.
100b57cec5SDimitry Andric //
110b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
120b57cec5SDimitry Andric 
130b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_POWERPC_MCTARGETDESC_PPCINSTPRINTER_H
140b57cec5SDimitry Andric #define LLVM_LIB_TARGET_POWERPC_MCTARGETDESC_PPCINSTPRINTER_H
150b57cec5SDimitry Andric 
160b57cec5SDimitry Andric #include "llvm/MC/MCInstPrinter.h"
17*06c3fb27SDimitry Andric #include "llvm/TargetParser/Triple.h"
180b57cec5SDimitry Andric 
190b57cec5SDimitry Andric namespace llvm {
200b57cec5SDimitry Andric 
210b57cec5SDimitry Andric class PPCInstPrinter : public MCInstPrinter {
220b57cec5SDimitry Andric   Triple TT;
230b57cec5SDimitry Andric private:
240b57cec5SDimitry Andric   bool showRegistersWithPercentPrefix(const char *RegName) const;
250b57cec5SDimitry Andric   bool showRegistersWithPrefix() const;
260b57cec5SDimitry Andric   const char *getVerboseConditionRegName(unsigned RegNum,
270b57cec5SDimitry Andric                                          unsigned RegEncoding) const;
280b57cec5SDimitry Andric 
290b57cec5SDimitry Andric public:
PPCInstPrinter(const MCAsmInfo & MAI,const MCInstrInfo & MII,const MCRegisterInfo & MRI,Triple T)300b57cec5SDimitry Andric   PPCInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
310b57cec5SDimitry Andric                  const MCRegisterInfo &MRI, Triple T)
320b57cec5SDimitry Andric     : MCInstPrinter(MAI, MII, MRI), TT(T) {}
330b57cec5SDimitry Andric 
34bdd1243dSDimitry Andric   void printRegName(raw_ostream &OS, MCRegister Reg) const override;
35480093f4SDimitry Andric   void printInst(const MCInst *MI, uint64_t Address, StringRef Annot,
36480093f4SDimitry Andric                  const MCSubtargetInfo &STI, raw_ostream &O) override;
370b57cec5SDimitry Andric 
380b57cec5SDimitry Andric   // Autogenerated by tblgen.
39e8d8bef9SDimitry Andric   std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
40e8d8bef9SDimitry Andric   void printInstruction(const MCInst *MI, uint64_t Address,
41e8d8bef9SDimitry Andric                         const MCSubtargetInfo &STI, raw_ostream &O);
42bdd1243dSDimitry Andric   static const char *getRegisterName(MCRegister Reg);
430b57cec5SDimitry Andric 
44e8d8bef9SDimitry Andric   bool printAliasInstr(const MCInst *MI, uint64_t Address,
45e8d8bef9SDimitry Andric                        const MCSubtargetInfo &STI, raw_ostream &OS);
465ffd83dbSDimitry Andric   void printCustomAliasOperand(const MCInst *MI, uint64_t Address,
475ffd83dbSDimitry Andric                                unsigned OpIdx, unsigned PrintMethodIdx,
48e8d8bef9SDimitry Andric                                const MCSubtargetInfo &STI, raw_ostream &OS);
490b57cec5SDimitry Andric 
50e8d8bef9SDimitry Andric   void printOperand(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
515ffd83dbSDimitry Andric                     raw_ostream &O);
52e8d8bef9SDimitry Andric   void printPredicateOperand(const MCInst *MI, unsigned OpNo,
53e8d8bef9SDimitry Andric                              const MCSubtargetInfo &STI, raw_ostream &O,
54e8d8bef9SDimitry Andric                              const char *Modifier = nullptr);
55e8d8bef9SDimitry Andric   void printATBitsAsHint(const MCInst *MI, unsigned OpNo,
56e8d8bef9SDimitry Andric                          const MCSubtargetInfo &STI, raw_ostream &O);
570b57cec5SDimitry Andric 
58e8d8bef9SDimitry Andric   void printU1ImmOperand(const MCInst *MI, unsigned OpNo,
59e8d8bef9SDimitry Andric                          const MCSubtargetInfo &STI, raw_ostream &O);
60e8d8bef9SDimitry Andric   void printU2ImmOperand(const MCInst *MI, unsigned OpNo,
61e8d8bef9SDimitry Andric                          const MCSubtargetInfo &STI, raw_ostream &O);
62e8d8bef9SDimitry Andric   void printU3ImmOperand(const MCInst *MI, unsigned OpNo,
63e8d8bef9SDimitry Andric                          const MCSubtargetInfo &STI, raw_ostream &O);
64e8d8bef9SDimitry Andric   void printU4ImmOperand(const MCInst *MI, unsigned OpNo,
65e8d8bef9SDimitry Andric                          const MCSubtargetInfo &STI, raw_ostream &O);
66e8d8bef9SDimitry Andric   void printS5ImmOperand(const MCInst *MI, unsigned OpNo,
67e8d8bef9SDimitry Andric                          const MCSubtargetInfo &STI, raw_ostream &O);
68e8d8bef9SDimitry Andric   void printU5ImmOperand(const MCInst *MI, unsigned OpNo,
69e8d8bef9SDimitry Andric                          const MCSubtargetInfo &STI, raw_ostream &O);
70e8d8bef9SDimitry Andric   void printU6ImmOperand(const MCInst *MI, unsigned OpNo,
71e8d8bef9SDimitry Andric                          const MCSubtargetInfo &STI, raw_ostream &O);
72e8d8bef9SDimitry Andric   void printU7ImmOperand(const MCInst *MI, unsigned OpNo,
73e8d8bef9SDimitry Andric                          const MCSubtargetInfo &STI, raw_ostream &O);
74e8d8bef9SDimitry Andric   void printU8ImmOperand(const MCInst *MI, unsigned OpNo,
75e8d8bef9SDimitry Andric                          const MCSubtargetInfo &STI, raw_ostream &O);
76e8d8bef9SDimitry Andric   void printU10ImmOperand(const MCInst *MI, unsigned OpNo,
77e8d8bef9SDimitry Andric                           const MCSubtargetInfo &STI, raw_ostream &O);
78e8d8bef9SDimitry Andric   void printU12ImmOperand(const MCInst *MI, unsigned OpNo,
79e8d8bef9SDimitry Andric                           const MCSubtargetInfo &STI, raw_ostream &O);
80e8d8bef9SDimitry Andric   void printS16ImmOperand(const MCInst *MI, unsigned OpNo,
81e8d8bef9SDimitry Andric                           const MCSubtargetInfo &STI, raw_ostream &O);
82e8d8bef9SDimitry Andric   void printS34ImmOperand(const MCInst *MI, unsigned OpNo,
83e8d8bef9SDimitry Andric                           const MCSubtargetInfo &STI, raw_ostream &O);
84e8d8bef9SDimitry Andric   void printU16ImmOperand(const MCInst *MI, unsigned OpNo,
85e8d8bef9SDimitry Andric                           const MCSubtargetInfo &STI, raw_ostream &O);
86e8d8bef9SDimitry Andric   void printImmZeroOperand(const MCInst *MI, unsigned OpNo,
87e8d8bef9SDimitry Andric                            const MCSubtargetInfo &STI, raw_ostream &O);
88e8d8bef9SDimitry Andric   void printBranchOperand(const MCInst *MI, uint64_t Address, unsigned OpNo,
89e8d8bef9SDimitry Andric                           const MCSubtargetInfo &STI, raw_ostream &O);
90e8d8bef9SDimitry Andric   void printAbsBranchOperand(const MCInst *MI, unsigned OpNo,
91e8d8bef9SDimitry Andric                              const MCSubtargetInfo &STI, raw_ostream &O);
92e8d8bef9SDimitry Andric   void printTLSCall(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
93e8d8bef9SDimitry Andric                     raw_ostream &O);
940b57cec5SDimitry Andric 
95e8d8bef9SDimitry Andric   void printcrbitm(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
96e8d8bef9SDimitry Andric                    raw_ostream &O);
97e8d8bef9SDimitry Andric 
98e8d8bef9SDimitry Andric   void printMemRegImm(const MCInst *MI, unsigned OpNo,
99e8d8bef9SDimitry Andric                       const MCSubtargetInfo &STI, raw_ostream &O);
100fe6060f1SDimitry Andric   void printMemRegImmHash(const MCInst *MI, unsigned OpNo,
101fe6060f1SDimitry Andric                           const MCSubtargetInfo &STI, raw_ostream &O);
102e8d8bef9SDimitry Andric   void printMemRegImm34PCRel(const MCInst *MI, unsigned OpNo,
103e8d8bef9SDimitry Andric                              const MCSubtargetInfo &STI, raw_ostream &O);
104e8d8bef9SDimitry Andric   void printMemRegImm34(const MCInst *MI, unsigned OpNo,
105e8d8bef9SDimitry Andric                         const MCSubtargetInfo &STI, raw_ostream &O);
106e8d8bef9SDimitry Andric   void printMemRegReg(const MCInst *MI, unsigned OpNo,
107e8d8bef9SDimitry Andric                       const MCSubtargetInfo &STI, raw_ostream &O);
1080b57cec5SDimitry Andric };
1090b57cec5SDimitry Andric } // end namespace llvm
1100b57cec5SDimitry Andric 
1110b57cec5SDimitry Andric #endif
112