blob: e61be66c75a2e4cf1be3998ea1a332c226dffe17 [file] [log] [blame]
Chris Lattner0dc32ea2009-09-20 07:41:30 +00001//===-- X86AsmPrinter.h - Convert X86 LLVM code to assembly -----*- C++ -*-===//
Chris Lattnerb36cbd02005-07-01 22:44:09 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-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 Lattnerb36cbd02005-07-01 22:44:09 +00007//
8//===----------------------------------------------------------------------===//
9//
10// AT&T assembly code printer class.
11//
12//===----------------------------------------------------------------------===//
13
Chris Lattner0dc32ea2009-09-20 07:41:30 +000014#ifndef X86ASMPRINTER_H
15#define X86ASMPRINTER_H
Chris Lattnerb36cbd02005-07-01 22:44:09 +000016
Chris Lattneraef40352010-07-19 23:41:57 +000017#include "X86.h"
18#include "X86MachineFunctionInfo.h"
19#include "X86TargetMachine.h"
Anton Korobeynikov75b68822008-06-28 11:08:27 +000020#include "llvm/ADT/StringSet.h"
21#include "llvm/CodeGen/AsmPrinter.h"
Anton Korobeynikov75b68822008-06-28 11:08:27 +000022#include "llvm/CodeGen/MachineModuleInfo.h"
Chris Lattnerb36cbd02005-07-01 22:44:09 +000023#include "llvm/CodeGen/ValueTypes.h"
Anton Korobeynikov75b68822008-06-28 11:08:27 +000024#include "llvm/Support/Compiler.h"
Chris Lattnerb36cbd02005-07-01 22:44:09 +000025
26namespace llvm {
Chris Lattnerb36cbd02005-07-01 22:44:09 +000027
Bill Wendlingb877a1f2009-05-12 21:55:29 +000028class MachineJumpTableInfo;
Chris Lattner40e3c7a2009-06-24 05:46:28 +000029class MCContext;
Chris Lattner475370b2009-06-19 00:47:33 +000030class MCInst;
Chris Lattner40e3c7a2009-06-24 05:46:28 +000031class MCStreamer;
Chris Lattner9b60e042009-08-16 04:28:14 +000032class MCSymbol;
Anton Korobeynikov75b68822008-06-28 11:08:27 +000033
Duncan Sands16d8f8b2010-05-11 20:16:09 +000034class LLVM_LIBRARY_VISIBILITY X86AsmPrinter : public AsmPrinter {
Anton Korobeynikov75b68822008-06-28 11:08:27 +000035 const X86Subtarget *Subtarget;
Bill Wendling57f0db82009-02-24 08:30:20 +000036 public:
Chris Lattnerb23569a2010-04-04 08:18:47 +000037 explicit X86AsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
38 : AsmPrinter(TM, Streamer) {
Anton Korobeynikov75b68822008-06-28 11:08:27 +000039 Subtarget = &TM.getSubtarget<X86Subtarget>();
40 }
Chris Lattnerb36cbd02005-07-01 22:44:09 +000041
42 virtual const char *getPassName() const {
43 return "X86 AT&T-Style Assembly Printer";
44 }
Chris Lattner8fea32f2009-09-12 20:34:57 +000045
46 const X86Subtarget &getSubtarget() const { return *Subtarget; }
Chris Lattnerb36cbd02005-07-01 22:44:09 +000047
Chris Lattner1bd1e6d2010-03-13 02:10:00 +000048 virtual void EmitStartOfAsmFile(Module &M);
49
Chris Lattner228252f2009-09-18 20:22:52 +000050 virtual void EmitEndOfAsmFile(Module &M);
51
Chris Lattner14c38ec2010-01-28 01:02:27 +000052 virtual void EmitInstruction(const MachineInstr *MI);
53
Chris Lattner88db7862010-04-04 05:19:20 +000054 void printSymbolOperand(const MachineOperand &MO, raw_ostream &O);
Chris Lattnerb36cbd02005-07-01 22:44:09 +000055
Chris Lattnera3b8c572006-02-06 23:41:19 +000056 // These methods are used by the tablegen'erated instruction printer.
Chris Lattner88db7862010-04-04 05:19:20 +000057 void printOperand(const MachineInstr *MI, unsigned OpNo, raw_ostream &O,
Chris Lattner18c59872009-06-27 04:16:01 +000058 const char *Modifier = 0);
Chris Lattner88db7862010-04-04 05:19:20 +000059 void print_pcrel_imm(const MachineInstr *MI, unsigned OpNo, raw_ostream &O);
Sean Callanan9947bbb2009-09-03 00:04:47 +000060
Chris Lattner88db7862010-04-04 05:19:20 +000061 bool printAsmMRegister(const MachineOperand &MO, char Mode, raw_ostream &O);
Anton Korobeynikovf0302cd2008-06-28 11:09:48 +000062 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
Chris Lattnerc75c0282010-04-04 05:29:35 +000063 unsigned AsmVariant, const char *ExtraCode,
64 raw_ostream &OS);
Anton Korobeynikovf0302cd2008-06-28 11:09:48 +000065 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
Chris Lattnerc75c0282010-04-04 05:29:35 +000066 unsigned AsmVariant, const char *ExtraCode,
67 raw_ostream &OS);
Anton Korobeynikov75b68822008-06-28 11:08:27 +000068
Evan Cheng62f27002006-04-28 23:11:40 +000069 void printMachineInstruction(const MachineInstr *MI);
Chris Lattner88db7862010-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 Lattner18c59872009-06-27 04:16:01 +000072 const char *Modifier=NULL);
Chris Lattner88db7862010-04-04 05:19:20 +000073 void printLeaMemReference(const MachineInstr *MI, unsigned Op, raw_ostream &O,
Chris Lattner18c59872009-06-27 04:16:01 +000074 const char *Modifier=NULL);
Anton Korobeynikov75b68822008-06-28 11:08:27 +000075
Chris Lattner88db7862010-04-04 05:19:20 +000076 void printPICLabel(const MachineInstr *MI, unsigned Op, raw_ostream &O);
Anton Korobeynikove51ab442008-06-28 11:09:32 +000077
Chris Lattner88db7862010-04-04 05:19:20 +000078 void PrintPICBaseSymbol(raw_ostream &O) const;
Chris Lattnerb5299dd2009-06-24 19:19:16 +000079
Chris Lattnerb36cbd02005-07-01 22:44:09 +000080 bool runOnMachineFunction(MachineFunction &F);
Chris Lattnerbfbab352010-04-04 05:38:19 +000081
82 void PrintDebugValueComment(const MachineInstr *MI, raw_ostream &OS);
Devang Patel28ff35d2010-04-28 01:39:28 +000083
84 MachineLocation getDebugValueLocation(const MachineInstr *MI) const;
Chris Lattnerb36cbd02005-07-01 22:44:09 +000085};
86
Chris Lattnerb36cbd02005-07-01 22:44:09 +000087} // end namespace llvm
88
89#endif