blob: b5a7f8dc321ad5cd0e42c9ad689bb5257f445f50 [file] [log] [blame]
Chris Lattner5159bbaf2009-09-20 07:41:30 +00001//===-- X86AsmPrinter.h - Convert X86 LLVM code to assembly -----*- C++ -*-===//
Chris Lattnerb9740462005-07-01 22:44:09 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Chris Lattnerb9740462005-07-01 22:44:09 +00007//
8//===----------------------------------------------------------------------===//
9//
10// AT&T assembly code printer class.
11//
12//===----------------------------------------------------------------------===//
13
Chris Lattner5159bbaf2009-09-20 07:41:30 +000014#ifndef X86ASMPRINTER_H
15#define X86ASMPRINTER_H
Chris Lattnerb9740462005-07-01 22:44:09 +000016
Cedric Venet954553c2008-08-17 18:24:26 +000017#include "../X86.h"
18#include "../X86MachineFunctionInfo.h"
19#include "../X86TargetMachine.h"
Anton Korobeynikov016d1d02008-06-28 11:08:27 +000020#include "llvm/ADT/StringSet.h"
21#include "llvm/CodeGen/AsmPrinter.h"
Anton Korobeynikov016d1d02008-06-28 11:08:27 +000022#include "llvm/CodeGen/MachineModuleInfo.h"
Chris Lattnerb9740462005-07-01 22:44:09 +000023#include "llvm/CodeGen/ValueTypes.h"
Anton Korobeynikov016d1d02008-06-28 11:08:27 +000024#include "llvm/Support/Compiler.h"
Chris Lattnerb9740462005-07-01 22:44:09 +000025
26namespace llvm {
Chris Lattnerb9740462005-07-01 22:44:09 +000027
Bill Wendling6b167d62009-05-12 21:55:29 +000028class MachineJumpTableInfo;
Chris Lattner9f40bc22009-06-24 05:46:28 +000029class MCContext;
Chris Lattner3235c382009-06-19 00:47:33 +000030class MCInst;
Chris Lattner9f40bc22009-06-24 05:46:28 +000031class MCStreamer;
Chris Lattner8a4c35d2009-08-16 04:28:14 +000032class MCSymbol;
Anton Korobeynikov016d1d02008-06-28 11:08:27 +000033
Duncan Sands6c5e4352010-05-11 20:16:09 +000034class LLVM_LIBRARY_VISIBILITY X86AsmPrinter : public AsmPrinter {
Anton Korobeynikov016d1d02008-06-28 11:08:27 +000035 const X86Subtarget *Subtarget;
Bill Wendlingc5437ea2009-02-24 08:30:20 +000036 public:
Chris Lattnerd20699b2010-04-04 08:18:47 +000037 explicit X86AsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
38 : AsmPrinter(TM, Streamer) {
Anton Korobeynikov016d1d02008-06-28 11:08:27 +000039 Subtarget = &TM.getSubtarget<X86Subtarget>();
40 }
Chris Lattnerb9740462005-07-01 22:44:09 +000041
42 virtual const char *getPassName() const {
43 return "X86 AT&T-Style Assembly Printer";
44 }
Chris Lattner31722082009-09-12 20:34:57 +000045
46 const X86Subtarget &getSubtarget() const { return *Subtarget; }
Chris Lattnerb9740462005-07-01 22:44:09 +000047
Chris Lattner81fe45d2010-03-13 02:10:00 +000048 virtual void EmitStartOfAsmFile(Module &M);
49
Chris Lattner3a78ce32009-09-18 20:22:52 +000050 virtual void EmitEndOfAsmFile(Module &M);
51
Chris Lattner94a946c2010-01-28 01:02:27 +000052 virtual void EmitInstruction(const MachineInstr *MI);
53
Chris Lattner562e02e2010-04-04 05:19:20 +000054 void printSymbolOperand(const MachineOperand &MO, raw_ostream &O);
Chris Lattnerb9740462005-07-01 22:44:09 +000055
Chris Lattnerd62a3bf2006-02-06 23:41:19 +000056 // These methods are used by the tablegen'erated instruction printer.
Chris Lattner562e02e2010-04-04 05:19:20 +000057 void printOperand(const MachineInstr *MI, unsigned OpNo, raw_ostream &O,
Chris Lattnerfea81da2009-06-27 04:16:01 +000058 const char *Modifier = 0);
Chris Lattner562e02e2010-04-04 05:19:20 +000059 void print_pcrel_imm(const MachineInstr *MI, unsigned OpNo, raw_ostream &O);
Sean Callananf4004422009-09-03 00:04:47 +000060
Chris Lattner562e02e2010-04-04 05:19:20 +000061 bool printAsmMRegister(const MachineOperand &MO, char Mode, raw_ostream &O);
Anton Korobeynikova54216a2008-06-28 11:09:48 +000062 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
Chris Lattner3bb09762010-04-04 05:29:35 +000063 unsigned AsmVariant, const char *ExtraCode,
64 raw_ostream &OS);
Anton Korobeynikova54216a2008-06-28 11:09:48 +000065 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
Chris Lattner3bb09762010-04-04 05:29:35 +000066 unsigned AsmVariant, const char *ExtraCode,
67 raw_ostream &OS);
Anton Korobeynikov016d1d02008-06-28 11:08:27 +000068
Evan Chengb244b802006-04-28 23:11:40 +000069 void printMachineInstruction(const MachineInstr *MI);
Chris Lattner562e02e2010-04-04 05:19:20 +000070 void printSSECC(const MachineInstr *MI, unsigned Op, raw_ostream &O);
71 void printMemReference(const MachineInstr *MI, unsigned Op, raw_ostream &O,
Chris Lattnerfea81da2009-06-27 04:16:01 +000072 const char *Modifier=NULL);
Chris Lattner562e02e2010-04-04 05:19:20 +000073 void printLeaMemReference(const MachineInstr *MI, unsigned Op, raw_ostream &O,
Chris Lattnerfea81da2009-06-27 04:16:01 +000074 const char *Modifier=NULL);
Anton Korobeynikov016d1d02008-06-28 11:08:27 +000075
Chris Lattner562e02e2010-04-04 05:19:20 +000076 void printPICLabel(const MachineInstr *MI, unsigned Op, raw_ostream &O);
Anton Korobeynikovab9ff5a2008-06-28 11:09:32 +000077
Chris Lattner562e02e2010-04-04 05:19:20 +000078 void PrintPICBaseSymbol(raw_ostream &O) const;
Chris Lattner9b4aaef2009-06-24 19:19:16 +000079
Chris Lattnerb9740462005-07-01 22:44:09 +000080 bool runOnMachineFunction(MachineFunction &F);
Chris Lattnerbf43d4b2010-04-04 05:38:19 +000081
82 void PrintDebugValueComment(const MachineInstr *MI, raw_ostream &OS);
Devang Patel50c94312010-04-28 01:39:28 +000083
84 MachineLocation getDebugValueLocation(const MachineInstr *MI) const;
Chris Lattnerb9740462005-07-01 22:44:09 +000085};
86
Chris Lattnerb9740462005-07-01 22:44:09 +000087} // end namespace llvm
88
89#endif