blob: 2a10e1c9b71c549cd469d9137d6b9f862f084964 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===-- X86IntelAsmPrinter.h - Convert X86 LLVM code to Intel assembly ----===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
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"
Dan Gohman1e57df32008-02-10 18:45:23 +000019#include "llvm/Target/TargetRegisterInfo.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000020
21namespace llvm {
22
Duncan Sandse73ef972007-10-30 13:14:37 +000023struct VISIBILITY_HIDDEN X86IntelAsmPrinter : public X86SharedAsmPrinter {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000024 X86IntelAsmPrinter(std::ostream &O, X86TargetMachine &TM,
25 const TargetAsmInfo *T)
26 : X86SharedAsmPrinter(O, TM, T) {
27 }
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.
40 void printOperand(const MachineInstr *MI, unsigned OpNo,
41 const char *Modifier = 0) {
42 const MachineOperand &MO = MI->getOperand(OpNo);
43 if (MO.isRegister()) {
Dan Gohman1e57df32008-02-10 18:45:23 +000044 assert(TargetRegisterInfo::isPhysicalRegister(MO.getReg()) &&
45 "Not physreg??");
Bill Wendling8eeb9792008-02-26 21:11:01 +000046 O << TM.getRegisterInfo()->get(MO.getReg()).AsmName;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000047 } else {
48 printOp(MO, Modifier);
49 }
50 }
51
52 void printi8mem(const MachineInstr *MI, unsigned OpNo) {
53 O << "BYTE PTR ";
54 printMemReference(MI, OpNo);
55 }
56 void printi16mem(const MachineInstr *MI, unsigned OpNo) {
57 O << "WORD PTR ";
58 printMemReference(MI, OpNo);
59 }
60 void printi32mem(const MachineInstr *MI, unsigned OpNo) {
61 O << "DWORD PTR ";
62 printMemReference(MI, OpNo);
63 }
64 void printi64mem(const MachineInstr *MI, unsigned OpNo) {
65 O << "QWORD PTR ";
66 printMemReference(MI, OpNo);
67 }
68 void printi128mem(const MachineInstr *MI, unsigned OpNo) {
69 O << "XMMWORD PTR ";
70 printMemReference(MI, OpNo);
71 }
72 void printf32mem(const MachineInstr *MI, unsigned OpNo) {
73 O << "DWORD PTR ";
74 printMemReference(MI, OpNo);
75 }
76 void printf64mem(const MachineInstr *MI, unsigned OpNo) {
77 O << "QWORD PTR ";
78 printMemReference(MI, OpNo);
79 }
Dale Johannesen4ab00bd2007-08-05 18:49:15 +000080 void printf80mem(const MachineInstr *MI, unsigned OpNo) {
81 O << "XWORD PTR ";
82 printMemReference(MI, OpNo);
83 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +000084 void printf128mem(const MachineInstr *MI, unsigned OpNo) {
85 O << "XMMWORD PTR ";
86 printMemReference(MI, OpNo);
87 }
88 void printlea64_32mem(const MachineInstr *MI, unsigned OpNo) {
89 O << "QWORD PTR ";
90 printMemReference(MI, OpNo, "subreg64");
91 }
92
93 bool printAsmMRegister(const MachineOperand &MO, const char Mode);
94 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
95 unsigned AsmVariant, const char *ExtraCode);
96 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
97 unsigned AsmVariant, const char *ExtraCode);
98 void printMachineInstruction(const MachineInstr *MI);
99 void printOp(const MachineOperand &MO, const char *Modifier = 0);
100 void printSSECC(const MachineInstr *MI, unsigned Op);
101 void printMemReference(const MachineInstr *MI, unsigned Op,
102 const char *Modifier=NULL);
Evan Cheng6fb06762007-11-09 01:32:10 +0000103 void printPICJumpTableSetLabel(unsigned uid,
104 const MachineBasicBlock *MBB) const;
105 void printPICJumpTableSetLabel(unsigned uid, unsigned uid2,
106 const MachineBasicBlock *MBB) const {
107 AsmPrinter::printPICJumpTableSetLabel(uid, uid2, MBB);
108 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000109 void printPICLabel(const MachineInstr *MI, unsigned Op);
110 bool runOnMachineFunction(MachineFunction &F);
111 bool doInitialization(Module &M);
112 bool doFinalization(Module &M);
113
114 /// getSectionForFunction - Return the section that we should emit the
115 /// specified function body into.
116 virtual std::string getSectionForFunction(const Function &F) const;
117
118 virtual void EmitString(const ConstantArray *CVA) const;
119};
120
121} // end namespace llvm
122
123#endif