Jia Liu | b22310f | 2012-02-18 12:03:15 +0000 | [diff] [blame] | 1 | //===- PPCInstPrinter.h - Convert PPC MCInst to assembly syntax -*- C++ -*-===// |
Chris Lattner | a76eab4 | 2010-11-14 19:40:38 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This class prints an PPC MCInst to a .s file. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef PPCINSTPRINTER_H |
| 15 | #define PPCINSTPRINTER_H |
| 16 | |
| 17 | #include "llvm/MC/MCInstPrinter.h" |
| 18 | |
| 19 | namespace llvm { |
Bill Wendling | 00f0cdd | 2011-03-21 04:13:46 +0000 | [diff] [blame] | 20 | |
| 21 | class MCOperand; |
Chris Lattner | a76eab4 | 2010-11-14 19:40:38 +0000 | [diff] [blame] | 22 | |
| 23 | class PPCInstPrinter : public MCInstPrinter { |
Chris Lattner | 7a5c57e | 2010-11-14 20:02:39 +0000 | [diff] [blame] | 24 | // 0 -> AIX, 1 -> Darwin. |
| 25 | unsigned SyntaxVariant; |
Chris Lattner | a76eab4 | 2010-11-14 19:40:38 +0000 | [diff] [blame] | 26 | public: |
Craig Topper | 54bfde7 | 2012-04-02 06:09:36 +0000 | [diff] [blame^] | 27 | PPCInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII, |
| 28 | const MCRegisterInfo &MRI, unsigned syntaxVariant) |
| 29 | : MCInstPrinter(MAI, MII, MRI), SyntaxVariant(syntaxVariant) {} |
Chris Lattner | 7a5c57e | 2010-11-14 20:02:39 +0000 | [diff] [blame] | 30 | |
| 31 | bool isDarwinSyntax() const { |
| 32 | return SyntaxVariant == 1; |
| 33 | } |
Chris Lattner | a76eab4 | 2010-11-14 19:40:38 +0000 | [diff] [blame] | 34 | |
Rafael Espindola | d686052 | 2011-06-02 02:34:55 +0000 | [diff] [blame] | 35 | virtual void printRegName(raw_ostream &OS, unsigned RegNo) const; |
Owen Anderson | a0c3b97 | 2011-09-15 23:38:46 +0000 | [diff] [blame] | 36 | virtual void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot); |
Chris Lattner | a76eab4 | 2010-11-14 19:40:38 +0000 | [diff] [blame] | 37 | virtual StringRef getOpcodeName(unsigned Opcode) const; |
| 38 | |
| 39 | static const char *getInstructionName(unsigned Opcode); |
| 40 | |
| 41 | // Autogenerated by tblgen. |
| 42 | void printInstruction(const MCInst *MI, raw_ostream &O); |
| 43 | static const char *getRegisterName(unsigned RegNo); |
| 44 | |
| 45 | |
Chris Lattner | 7a5c57e | 2010-11-14 20:02:39 +0000 | [diff] [blame] | 46 | void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O); |
Chris Lattner | a76eab4 | 2010-11-14 19:40:38 +0000 | [diff] [blame] | 47 | void printPredicateOperand(const MCInst *MI, unsigned OpNo, |
Chris Lattner | f2cb69c | 2010-11-14 21:51:37 +0000 | [diff] [blame] | 48 | raw_ostream &O, const char *Modifier); |
Chris Lattner | a76eab4 | 2010-11-14 19:40:38 +0000 | [diff] [blame] | 49 | |
| 50 | |
Chris Lattner | 9488143 | 2010-11-14 20:11:21 +0000 | [diff] [blame] | 51 | void printS5ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O); |
| 52 | void printU5ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O); |
| 53 | void printU6ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O); |
| 54 | void printS16ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O); |
| 55 | void printU16ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O); |
| 56 | void printS16X4ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O); |
Chris Lattner | 3dc9bb2 | 2010-11-14 21:20:46 +0000 | [diff] [blame] | 57 | void printBranchOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O); |
Chris Lattner | f2cb69c | 2010-11-14 21:51:37 +0000 | [diff] [blame] | 58 | void printAbsAddrOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O); |
Chris Lattner | a76eab4 | 2010-11-14 19:40:38 +0000 | [diff] [blame] | 59 | |
Chris Lattner | 0dcd800 | 2010-11-14 20:22:56 +0000 | [diff] [blame] | 60 | void printcrbitm(const MCInst *MI, unsigned OpNo, raw_ostream &O); |
Chris Lattner | a76eab4 | 2010-11-14 19:40:38 +0000 | [diff] [blame] | 61 | |
Chris Lattner | 0dcd800 | 2010-11-14 20:22:56 +0000 | [diff] [blame] | 62 | void printMemRegImm(const MCInst *MI, unsigned OpNo, raw_ostream &O); |
| 63 | void printMemRegImmShifted(const MCInst *MI, unsigned OpNo, raw_ostream &O); |
| 64 | void printMemRegReg(const MCInst *MI, unsigned OpNo, raw_ostream &O); |
Chris Lattner | a76eab4 | 2010-11-14 19:40:38 +0000 | [diff] [blame] | 65 | |
| 66 | // FIXME: Remove |
Chris Lattner | c2ac86e | 2010-11-14 21:33:07 +0000 | [diff] [blame] | 67 | void printSymbolLo(const MCInst *MI, unsigned OpNo, raw_ostream &O); |
| 68 | void printSymbolHi(const MCInst *MI, unsigned OpNo, raw_ostream &O); |
Chris Lattner | a76eab4 | 2010-11-14 19:40:38 +0000 | [diff] [blame] | 69 | }; |
| 70 | } // end namespace llvm |
| 71 | |
| 72 | #endif |