Chris Lattner | 60d5b5f | 2010-11-14 19:40:38 +0000 | [diff] [blame] | 1 | //===-- PPCInstPrinter.h - Convert PPC MCInst to assembly syntax ----------===// |
| 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 | a5c177e | 2011-03-21 04:13:46 +0000 | [diff] [blame] | 20 | |
| 21 | class MCOperand; |
Chris Lattner | 60d5b5f | 2010-11-14 19:40:38 +0000 | [diff] [blame] | 22 | |
| 23 | class PPCInstPrinter : public MCInstPrinter { |
Chris Lattner | 0d1b7d9 | 2010-11-14 20:02:39 +0000 | [diff] [blame] | 24 | // 0 -> AIX, 1 -> Darwin. |
| 25 | unsigned SyntaxVariant; |
Chris Lattner | 60d5b5f | 2010-11-14 19:40:38 +0000 | [diff] [blame] | 26 | public: |
Evan Cheng | b262799 | 2011-07-06 19:45:42 +0000 | [diff] [blame] | 27 | PPCInstPrinter(const MCAsmInfo &MAI, unsigned syntaxVariant) |
Chris Lattner | 0d1b7d9 | 2010-11-14 20:02:39 +0000 | [diff] [blame] | 28 | : MCInstPrinter(MAI), SyntaxVariant(syntaxVariant) {} |
| 29 | |
| 30 | bool isDarwinSyntax() const { |
| 31 | return SyntaxVariant == 1; |
| 32 | } |
Chris Lattner | 60d5b5f | 2010-11-14 19:40:38 +0000 | [diff] [blame] | 33 | |
Rafael Espindola | cde4ce4 | 2011-06-02 02:34:55 +0000 | [diff] [blame] | 34 | virtual void printRegName(raw_ostream &OS, unsigned RegNo) const; |
Chris Lattner | 60d5b5f | 2010-11-14 19:40:38 +0000 | [diff] [blame] | 35 | virtual void printInst(const MCInst *MI, raw_ostream &O); |
| 36 | virtual StringRef getOpcodeName(unsigned Opcode) const; |
| 37 | |
| 38 | static const char *getInstructionName(unsigned Opcode); |
| 39 | |
| 40 | // Autogenerated by tblgen. |
| 41 | void printInstruction(const MCInst *MI, raw_ostream &O); |
| 42 | static const char *getRegisterName(unsigned RegNo); |
| 43 | |
| 44 | |
Chris Lattner | 0d1b7d9 | 2010-11-14 20:02:39 +0000 | [diff] [blame] | 45 | void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O); |
Chris Lattner | 60d5b5f | 2010-11-14 19:40:38 +0000 | [diff] [blame] | 46 | void printPredicateOperand(const MCInst *MI, unsigned OpNo, |
Chris Lattner | b2e477f | 2010-11-14 21:51:37 +0000 | [diff] [blame] | 47 | raw_ostream &O, const char *Modifier); |
Chris Lattner | 60d5b5f | 2010-11-14 19:40:38 +0000 | [diff] [blame] | 48 | |
| 49 | |
Chris Lattner | 9988913 | 2010-11-14 20:11:21 +0000 | [diff] [blame] | 50 | void printS5ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O); |
| 51 | void printU5ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O); |
| 52 | void printU6ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O); |
| 53 | void printS16ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O); |
| 54 | void printU16ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O); |
| 55 | void printS16X4ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O); |
Chris Lattner | 1520fd6 | 2010-11-14 21:20:46 +0000 | [diff] [blame] | 56 | void printBranchOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O); |
Chris Lattner | b2e477f | 2010-11-14 21:51:37 +0000 | [diff] [blame] | 57 | void printAbsAddrOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O); |
Chris Lattner | 60d5b5f | 2010-11-14 19:40:38 +0000 | [diff] [blame] | 58 | |
Chris Lattner | fdb2ded | 2010-11-14 20:22:56 +0000 | [diff] [blame] | 59 | void printcrbitm(const MCInst *MI, unsigned OpNo, raw_ostream &O); |
Chris Lattner | 60d5b5f | 2010-11-14 19:40:38 +0000 | [diff] [blame] | 60 | |
Chris Lattner | fdb2ded | 2010-11-14 20:22:56 +0000 | [diff] [blame] | 61 | void printMemRegImm(const MCInst *MI, unsigned OpNo, raw_ostream &O); |
| 62 | void printMemRegImmShifted(const MCInst *MI, unsigned OpNo, raw_ostream &O); |
| 63 | void printMemRegReg(const MCInst *MI, unsigned OpNo, raw_ostream &O); |
Chris Lattner | 60d5b5f | 2010-11-14 19:40:38 +0000 | [diff] [blame] | 64 | |
| 65 | // FIXME: Remove |
Chris Lattner | 58d014f | 2010-11-14 21:33:07 +0000 | [diff] [blame] | 66 | void printSymbolLo(const MCInst *MI, unsigned OpNo, raw_ostream &O); |
| 67 | void printSymbolHi(const MCInst *MI, unsigned OpNo, raw_ostream &O); |
Chris Lattner | 60d5b5f | 2010-11-14 19:40:38 +0000 | [diff] [blame] | 68 | }; |
| 69 | } // end namespace llvm |
| 70 | |
| 71 | #endif |