Chris Lattner | b36cbd0 | 2005-07-01 22:44:09 +0000 | [diff] [blame] | 1 | //===-- X86IntelAsmPrinter.h - Convert X86 LLVM code to Intel assembly ----===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by the LLVM research group and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // Intel assembly code printer class. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef X86INTELASMPRINTER_H |
| 15 | #define X86INTELASMPRINTER_H |
| 16 | |
| 17 | #include "X86AsmPrinter.h" |
| 18 | #include "llvm/CodeGen/ValueTypes.h" |
Chris Lattner | b36cbd0 | 2005-07-01 22:44:09 +0000 | [diff] [blame] | 19 | #include "llvm/Target/MRegisterInfo.h" |
| 20 | |
| 21 | namespace llvm { |
Chris Lattner | b36cbd0 | 2005-07-01 22:44:09 +0000 | [diff] [blame] | 22 | |
| 23 | struct X86IntelAsmPrinter : public X86SharedAsmPrinter { |
Evan Cheng | c4c6257 | 2006-03-13 23:20:37 +0000 | [diff] [blame] | 24 | X86IntelAsmPrinter(std::ostream &O, X86TargetMachine &TM) |
Chris Lattner | b36cbd0 | 2005-07-01 22:44:09 +0000 | [diff] [blame] | 25 | : X86SharedAsmPrinter(O, TM) { } |
| 26 | |
| 27 | virtual const char *getPassName() const { |
| 28 | return "X86 Intel-Style Assembly Printer"; |
| 29 | } |
| 30 | |
| 31 | /// printInstruction - This method is automatically generated by tablegen |
| 32 | /// from the instruction set description. This method returns true if the |
| 33 | /// machine instruction was sufficiently described to print it, otherwise it |
| 34 | /// returns false. |
| 35 | bool printInstruction(const MachineInstr *MI); |
| 36 | |
| 37 | // This method is used by the tablegen'erated instruction printer. |
Chris Lattner | a3b8c57 | 2006-02-06 23:41:19 +0000 | [diff] [blame] | 38 | void printOperand(const MachineInstr *MI, unsigned OpNo, |
| 39 | const char *Modifier = 0) { |
Chris Lattner | b36cbd0 | 2005-07-01 22:44:09 +0000 | [diff] [blame] | 40 | const MachineOperand &MO = MI->getOperand(OpNo); |
| 41 | if (MO.getType() == MachineOperand::MO_MachineRegister) { |
| 42 | assert(MRegisterInfo::isPhysicalRegister(MO.getReg())&&"Not physref??"); |
Chris Lattner | 99f2632 | 2006-05-01 05:53:50 +0000 | [diff] [blame^] | 43 | O << TM.getRegisterInfo()->get(MO.getReg()).Name; |
Chris Lattner | b36cbd0 | 2005-07-01 22:44:09 +0000 | [diff] [blame] | 44 | } else { |
Chris Lattner | a3b8c57 | 2006-02-06 23:41:19 +0000 | [diff] [blame] | 45 | printOp(MO, Modifier); |
Chris Lattner | b36cbd0 | 2005-07-01 22:44:09 +0000 | [diff] [blame] | 46 | } |
| 47 | } |
| 48 | |
Nate Begeman | 391c5d2 | 2005-11-30 18:54:35 +0000 | [diff] [blame] | 49 | void printi8mem(const MachineInstr *MI, unsigned OpNo) { |
| 50 | O << "BYTE PTR "; |
| 51 | printMemReference(MI, OpNo); |
| 52 | } |
| 53 | void printi16mem(const MachineInstr *MI, unsigned OpNo) { |
| 54 | O << "WORD PTR "; |
| 55 | printMemReference(MI, OpNo); |
| 56 | } |
| 57 | void printi32mem(const MachineInstr *MI, unsigned OpNo) { |
Nate Begeman | 85a168a | 2005-11-30 18:57:39 +0000 | [diff] [blame] | 58 | O << "DWORD PTR "; |
Nate Begeman | 391c5d2 | 2005-11-30 18:54:35 +0000 | [diff] [blame] | 59 | printMemReference(MI, OpNo); |
| 60 | } |
| 61 | void printi64mem(const MachineInstr *MI, unsigned OpNo) { |
Nate Begeman | 85a168a | 2005-11-30 18:57:39 +0000 | [diff] [blame] | 62 | O << "QWORD PTR "; |
Nate Begeman | 391c5d2 | 2005-11-30 18:54:35 +0000 | [diff] [blame] | 63 | printMemReference(MI, OpNo); |
| 64 | } |
Evan Cheng | 470a6ad | 2006-02-22 02:26:30 +0000 | [diff] [blame] | 65 | void printi128mem(const MachineInstr *MI, unsigned OpNo) { |
| 66 | O << "XMMWORD PTR "; |
| 67 | printMemReference(MI, OpNo); |
| 68 | } |
Nate Begeman | 391c5d2 | 2005-11-30 18:54:35 +0000 | [diff] [blame] | 69 | void printf32mem(const MachineInstr *MI, unsigned OpNo) { |
| 70 | O << "DWORD PTR "; |
| 71 | printMemReference(MI, OpNo); |
| 72 | } |
| 73 | void printf64mem(const MachineInstr *MI, unsigned OpNo) { |
| 74 | O << "QWORD PTR "; |
| 75 | printMemReference(MI, OpNo); |
| 76 | } |
Evan Cheng | 223547a | 2006-01-31 22:28:30 +0000 | [diff] [blame] | 77 | void printf128mem(const MachineInstr *MI, unsigned OpNo) { |
| 78 | O << "XMMWORD PTR "; |
Chris Lattner | b36cbd0 | 2005-07-01 22:44:09 +0000 | [diff] [blame] | 79 | printMemReference(MI, OpNo); |
| 80 | } |
| 81 | |
Evan Cheng | 55c25f2 | 2006-04-28 23:19:39 +0000 | [diff] [blame] | 82 | bool printAsmMRegister(const MachineOperand &MO, const char Mode); |
Evan Cheng | 3d48a90 | 2006-04-28 21:19:05 +0000 | [diff] [blame] | 83 | bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, |
| 84 | unsigned AsmVariant, const char *ExtraCode); |
| 85 | bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, |
| 86 | unsigned AsmVariant, const char *ExtraCode); |
| 87 | void printMachineInstruction(const MachineInstr *MI); |
Chris Lattner | a3b8c57 | 2006-02-06 23:41:19 +0000 | [diff] [blame] | 88 | void printOp(const MachineOperand &MO, const char *Modifier = 0); |
Nate Begeman | 391c5d2 | 2005-11-30 18:54:35 +0000 | [diff] [blame] | 89 | void printSSECC(const MachineInstr *MI, unsigned Op); |
Chris Lattner | b36cbd0 | 2005-07-01 22:44:09 +0000 | [diff] [blame] | 90 | void printMemReference(const MachineInstr *MI, unsigned Op); |
Evan Cheng | 7ccced6 | 2006-02-18 00:15:05 +0000 | [diff] [blame] | 91 | void printPICLabel(const MachineInstr *MI, unsigned Op); |
Chris Lattner | b36cbd0 | 2005-07-01 22:44:09 +0000 | [diff] [blame] | 92 | bool runOnMachineFunction(MachineFunction &F); |
| 93 | bool doInitialization(Module &M); |
| 94 | }; |
| 95 | |
Chris Lattner | b36cbd0 | 2005-07-01 22:44:09 +0000 | [diff] [blame] | 96 | } // end namespace llvm |
| 97 | |
| 98 | #endif |