blob: 02d38092127861c07e31d747279c68b1666ea522 [file] [log] [blame]
Chris Lattnerb9740462005-07-01 22:44:09 +00001//===-- 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"
19#include "llvm/Target/TargetMachine.h"
20#include "llvm/Target/MRegisterInfo.h"
21
22namespace llvm {
23namespace x86 {
24
25struct X86IntelAsmPrinter : public X86SharedAsmPrinter {
26 X86IntelAsmPrinter(std::ostream &O, TargetMachine &TM)
27 : X86SharedAsmPrinter(O, TM) { }
28
29 virtual const char *getPassName() const {
30 return "X86 Intel-Style Assembly Printer";
31 }
32
33 /// printInstruction - This method is automatically generated by tablegen
34 /// from the instruction set description. This method returns true if the
35 /// machine instruction was sufficiently described to print it, otherwise it
36 /// returns false.
37 bool printInstruction(const MachineInstr *MI);
38
39 // This method is used by the tablegen'erated instruction printer.
Nate Begeman6f8c1ac2005-11-30 18:54:35 +000040 void printOperand(const MachineInstr *MI, unsigned OpNo){
Chris Lattnerb9740462005-07-01 22:44:09 +000041 const MachineOperand &MO = MI->getOperand(OpNo);
42 if (MO.getType() == MachineOperand::MO_MachineRegister) {
43 assert(MRegisterInfo::isPhysicalRegister(MO.getReg())&&"Not physref??");
44 // Bug Workaround: See note in Printer::doInitialization about %.
45 O << "%" << TM.getRegisterInfo()->get(MO.getReg()).Name;
46 } else {
47 printOp(MO);
48 }
49 }
50
Nate Begeman6f8c1ac2005-11-30 18:54:35 +000051 void printCallOperand(const MachineInstr *MI, unsigned OpNo) {
Chris Lattnerb9740462005-07-01 22:44:09 +000052 printOp(MI->getOperand(OpNo), true); // Don't print "OFFSET".
53 }
54
Nate Begeman6f8c1ac2005-11-30 18:54:35 +000055 void printi8mem(const MachineInstr *MI, unsigned OpNo) {
56 O << "BYTE PTR ";
57 printMemReference(MI, OpNo);
58 }
59 void printi16mem(const MachineInstr *MI, unsigned OpNo) {
60 O << "WORD PTR ";
61 printMemReference(MI, OpNo);
62 }
63 void printi32mem(const MachineInstr *MI, unsigned OpNo) {
64 O << "WORD PTR ";
65 printMemReference(MI, OpNo);
66 }
67 void printi64mem(const MachineInstr *MI, unsigned OpNo) {
68 O << "DWORD PTR ";
69 printMemReference(MI, OpNo);
70 }
71 void printf32mem(const MachineInstr *MI, unsigned OpNo) {
72 O << "DWORD PTR ";
73 printMemReference(MI, OpNo);
74 }
75 void printf64mem(const MachineInstr *MI, unsigned OpNo) {
76 O << "QWORD PTR ";
77 printMemReference(MI, OpNo);
78 }
79 void printf80mem(const MachineInstr *MI, unsigned OpNo) {
80 O << "XWORD PTR ";
Chris Lattnerb9740462005-07-01 22:44:09 +000081 printMemReference(MI, OpNo);
82 }
83
84 void printMachineInstruction(const MachineInstr *MI);
85 void printOp(const MachineOperand &MO, bool elideOffsetKeyword = false);
Nate Begeman6f8c1ac2005-11-30 18:54:35 +000086 void printSSECC(const MachineInstr *MI, unsigned Op);
Chris Lattnerb9740462005-07-01 22:44:09 +000087 void printMemReference(const MachineInstr *MI, unsigned Op);
88 bool runOnMachineFunction(MachineFunction &F);
89 bool doInitialization(Module &M);
90};
91
92} // end namespace x86
93} // end namespace llvm
94
95#endif