1 //===-- X86AsmPrinter.h - Convert X86 LLVM code to assembly -----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // AT&T assembly code printer class.
12 //===----------------------------------------------------------------------===//
14 #ifndef X86ASMPRINTER_H
15 #define X86ASMPRINTER_H
18 #include "../X86MachineFunctionInfo.h"
19 #include "../X86TargetMachine.h"
20 #include "llvm/ADT/StringSet.h"
21 #include "llvm/CodeGen/AsmPrinter.h"
22 #include "llvm/CodeGen/DwarfWriter.h"
23 #include "llvm/CodeGen/MachineModuleInfo.h"
24 #include "llvm/CodeGen/ValueTypes.h"
25 #include "llvm/Support/Compiler.h"
29 class MachineJumpTableInfo;
35 class VISIBILITY_HIDDEN X86AsmPrinter : public AsmPrinter {
36 const X86Subtarget *Subtarget;
38 explicit X86AsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
39 MCContext &Ctx, MCStreamer &Streamer,
41 : AsmPrinter(O, TM, Ctx, Streamer, T) {
42 Subtarget = &TM.getSubtarget<X86Subtarget>();
45 virtual const char *getPassName() const {
46 return "X86 AT&T-Style Assembly Printer";
49 const X86Subtarget &getSubtarget() const { return *Subtarget; }
51 void getAnalysisUsage(AnalysisUsage &AU) const {
53 AU.addRequired<MachineModuleInfo>();
54 AU.addRequired<DwarfWriter>();
55 AsmPrinter::getAnalysisUsage(AU);
59 virtual void EmitEndOfAsmFile(Module &M);
61 virtual void EmitInstruction(const MachineInstr *MI);
63 void printSymbolOperand(const MachineOperand &MO);
64 virtual MCSymbol *GetGlobalValueSymbol(const GlobalValue *GV) const;
66 // These methods are used by the tablegen'erated instruction printer.
67 void printOperand(const MachineInstr *MI, unsigned OpNo,
68 const char *Modifier = 0);
69 void print_pcrel_imm(const MachineInstr *MI, unsigned OpNo);
71 void printopaquemem(const MachineInstr *MI, unsigned OpNo) {
72 printMemReference(MI, OpNo);
75 void printi8mem(const MachineInstr *MI, unsigned OpNo) {
76 printMemReference(MI, OpNo);
78 void printi16mem(const MachineInstr *MI, unsigned OpNo) {
79 printMemReference(MI, OpNo);
81 void printi32mem(const MachineInstr *MI, unsigned OpNo) {
82 printMemReference(MI, OpNo);
84 void printi64mem(const MachineInstr *MI, unsigned OpNo) {
85 printMemReference(MI, OpNo);
87 void printi128mem(const MachineInstr *MI, unsigned OpNo) {
88 printMemReference(MI, OpNo);
90 void printf32mem(const MachineInstr *MI, unsigned OpNo) {
91 printMemReference(MI, OpNo);
93 void printf64mem(const MachineInstr *MI, unsigned OpNo) {
94 printMemReference(MI, OpNo);
96 void printf80mem(const MachineInstr *MI, unsigned OpNo) {
97 printMemReference(MI, OpNo);
99 void printf128mem(const MachineInstr *MI, unsigned OpNo) {
100 printMemReference(MI, OpNo);
102 void printlea32mem(const MachineInstr *MI, unsigned OpNo) {
103 printLeaMemReference(MI, OpNo);
105 void printlea64mem(const MachineInstr *MI, unsigned OpNo) {
106 printLeaMemReference(MI, OpNo);
108 void printlea64_32mem(const MachineInstr *MI, unsigned OpNo) {
109 printLeaMemReference(MI, OpNo, "subreg64");
112 bool printAsmMRegister(const MachineOperand &MO, char Mode);
113 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
114 unsigned AsmVariant, const char *ExtraCode);
115 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
116 unsigned AsmVariant, const char *ExtraCode);
118 void printMachineInstruction(const MachineInstr *MI);
119 void printSSECC(const MachineInstr *MI, unsigned Op);
120 void printMemReference(const MachineInstr *MI, unsigned Op,
121 const char *Modifier=NULL);
122 void printLeaMemReference(const MachineInstr *MI, unsigned Op,
123 const char *Modifier=NULL);
125 void printPICLabel(const MachineInstr *MI, unsigned Op);
127 void PrintPICBaseSymbol() const;
129 bool runOnMachineFunction(MachineFunction &F);
132 } // end namespace llvm