Chris Lattner | cae05cb | 2009-09-13 19:30:11 +0000 | [diff] [blame] | 1 | //===-- X86ATTInstPrinter.h - Convert X86 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 X86 MCInst to AT&T style .s file syntax. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef X86_ATT_INST_PRINTER_H |
| 15 | #define X86_ATT_INST_PRINTER_H |
| 16 | |
Chris Lattner | c493fb2 | 2009-09-14 01:49:26 +0000 | [diff] [blame] | 17 | #include "llvm/MC/MCInstPrinter.h" |
Chris Lattner | 05af261 | 2009-09-13 20:08:00 +0000 | [diff] [blame] | 18 | |
Chris Lattner | c493fb2 | 2009-09-14 01:49:26 +0000 | [diff] [blame] | 19 | namespace llvm { |
Bill Wendling | a5c177e | 2011-03-21 04:13:46 +0000 | [diff] [blame] | 20 | |
| 21 | class MCOperand; |
Bill Wendling | 44dcfd3 | 2011-04-07 21:20:06 +0000 | [diff] [blame] | 22 | class X86Subtarget; |
Bill Wendling | a5c177e | 2011-03-21 04:13:46 +0000 | [diff] [blame] | 23 | class TargetMachine; |
Chris Lattner | c493fb2 | 2009-09-14 01:49:26 +0000 | [diff] [blame] | 24 | |
| 25 | class X86ATTInstPrinter : public MCInstPrinter { |
| 26 | public: |
Bill Wendling | 44dcfd3 | 2011-04-07 21:20:06 +0000 | [diff] [blame] | 27 | X86ATTInstPrinter(TargetMachine &TM, const MCAsmInfo &MAI); |
Chris Lattner | c493fb2 | 2009-09-14 01:49:26 +0000 | [diff] [blame] | 28 | |
Rafael Espindola | 6e03294 | 2011-05-30 20:20:15 +0000 | [diff] [blame] | 29 | StringRef getRegName(unsigned RegNo) const; |
Chris Lattner | d374087 | 2010-04-04 05:04:31 +0000 | [diff] [blame] | 30 | virtual void printInst(const MCInst *MI, raw_ostream &OS); |
Chris Lattner | 0d7b0aa | 2010-02-11 22:57:32 +0000 | [diff] [blame] | 31 | virtual StringRef getOpcodeName(unsigned Opcode) const; |
| 32 | |
Bill Wendling | 44dcfd3 | 2011-04-07 21:20:06 +0000 | [diff] [blame] | 33 | // Methods used to print the alias of an instruction. |
| 34 | unsigned ComputeAvailableFeatures(const X86Subtarget *Subtarget) const; |
Eric Christopher | 721ef66 | 2011-04-18 21:28:11 +0000 | [diff] [blame] | 35 | // Autogenerated by tblgen, returns true if we successfully printed an |
| 36 | // alias. |
Bill Wendling | 44dcfd3 | 2011-04-07 21:20:06 +0000 | [diff] [blame] | 37 | bool printAliasInstr(const MCInst *MI, raw_ostream &OS); |
| 38 | |
Chris Lattner | 05af261 | 2009-09-13 20:08:00 +0000 | [diff] [blame] | 39 | // Autogenerated by tblgen. |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 40 | void printInstruction(const MCInst *MI, raw_ostream &OS); |
Chris Lattner | d95148f | 2009-09-13 20:19:22 +0000 | [diff] [blame] | 41 | static const char *getRegisterName(unsigned RegNo); |
Chris Lattner | 0d7b0aa | 2010-02-11 22:57:32 +0000 | [diff] [blame] | 42 | static const char *getInstructionName(unsigned Opcode); |
Chris Lattner | cae05cb | 2009-09-13 19:30:11 +0000 | [diff] [blame] | 43 | |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 44 | void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &OS); |
| 45 | void printMemReference(const MCInst *MI, unsigned Op, raw_ostream &OS); |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 46 | void printSSECC(const MCInst *MI, unsigned Op, raw_ostream &OS); |
| 47 | void print_pcrel_imm(const MCInst *MI, unsigned OpNo, raw_ostream &OS); |
Chris Lattner | cae05cb | 2009-09-13 19:30:11 +0000 | [diff] [blame] | 48 | |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 49 | void printopaquemem(const MCInst *MI, unsigned OpNo, raw_ostream &O) { |
| 50 | printMemReference(MI, OpNo, O); |
Chris Lattner | cae05cb | 2009-09-13 19:30:11 +0000 | [diff] [blame] | 51 | } |
| 52 | |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 53 | void printi8mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) { |
| 54 | printMemReference(MI, OpNo, O); |
Chris Lattner | cae05cb | 2009-09-13 19:30:11 +0000 | [diff] [blame] | 55 | } |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 56 | void printi16mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) { |
| 57 | printMemReference(MI, OpNo, O); |
Chris Lattner | cae05cb | 2009-09-13 19:30:11 +0000 | [diff] [blame] | 58 | } |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 59 | void printi32mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) { |
| 60 | printMemReference(MI, OpNo, O); |
Chris Lattner | cae05cb | 2009-09-13 19:30:11 +0000 | [diff] [blame] | 61 | } |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 62 | void printi64mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) { |
| 63 | printMemReference(MI, OpNo, O); |
Chris Lattner | cae05cb | 2009-09-13 19:30:11 +0000 | [diff] [blame] | 64 | } |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 65 | void printi128mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) { |
| 66 | printMemReference(MI, OpNo, O); |
Chris Lattner | cae05cb | 2009-09-13 19:30:11 +0000 | [diff] [blame] | 67 | } |
Bruno Cardoso Lopes | 94143ee | 2010-07-19 23:32:44 +0000 | [diff] [blame] | 68 | void printi256mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) { |
| 69 | printMemReference(MI, OpNo, O); |
| 70 | } |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 71 | void printf32mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) { |
| 72 | printMemReference(MI, OpNo, O); |
Chris Lattner | cae05cb | 2009-09-13 19:30:11 +0000 | [diff] [blame] | 73 | } |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 74 | void printf64mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) { |
| 75 | printMemReference(MI, OpNo, O); |
Chris Lattner | cae05cb | 2009-09-13 19:30:11 +0000 | [diff] [blame] | 76 | } |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 77 | void printf80mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) { |
| 78 | printMemReference(MI, OpNo, O); |
Chris Lattner | cae05cb | 2009-09-13 19:30:11 +0000 | [diff] [blame] | 79 | } |
Chris Lattner | 35c33bd | 2010-04-04 04:47:45 +0000 | [diff] [blame] | 80 | void printf128mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) { |
| 81 | printMemReference(MI, OpNo, O); |
Chris Lattner | cae05cb | 2009-09-13 19:30:11 +0000 | [diff] [blame] | 82 | } |
Bruno Cardoso Lopes | e86b01c | 2010-07-09 18:27:43 +0000 | [diff] [blame] | 83 | void printf256mem(const MCInst *MI, unsigned OpNo, raw_ostream &O) { |
| 84 | printMemReference(MI, OpNo, O); |
| 85 | } |
Chris Lattner | cae05cb | 2009-09-13 19:30:11 +0000 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | } |
| 89 | |
| 90 | #endif |