blob: 3ca35c50da94fa9c42a8b6ba9b8aa5520237fbb8 [file] [log] [blame]
Chris Lattnerb9740462005-07-01 22:44:09 +00001//===-- X86AsmPrinter.cpp - Convert X86 LLVM IR to X86 assembly -----------===//
Misha Brukmanc88330a2005-04-21 23:38:14 +00002//
John Criswell482202a2003-10-20 19:43:21 +00003// 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.
Misha Brukmanc88330a2005-04-21 23:38:14 +00007//
John Criswell482202a2003-10-20 19:43:21 +00008//===----------------------------------------------------------------------===//
Chris Lattnerd92fb002002-10-25 22:55:53 +00009//
Chris Lattnerb9740462005-07-01 22:44:09 +000010// This file the shared super class printer that converts from our internal
11// representation of machine-dependent LLVM code to Intel and AT&T format
12// assembly language.
13// This printer is the output mechanism used by `llc'.
Chris Lattnerd92fb002002-10-25 22:55:53 +000014//
15//===----------------------------------------------------------------------===//
16
Daniel Dunbar67038c12009-07-18 23:03:22 +000017#include "X86.h"
Chris Lattnerb9740462005-07-01 22:44:09 +000018#include "X86ATTAsmPrinter.h"
19#include "X86IntelAsmPrinter.h"
Chris Lattner7b26fce2009-08-22 20:48:53 +000020#include "llvm/MC/MCAsmInfo.h"
Daniel Dunbare8338102009-07-15 20:24:03 +000021#include "llvm/Target/TargetRegistry.h"
Chris Lattner9f75a552004-02-14 06:00:36 +000022using namespace llvm;
Brian Gaeke960707c2003-11-11 22:41:34 +000023
Chris Lattner68ab0be2004-10-04 07:24:48 +000024/// createX86CodePrinterPass - Returns a pass that prints the X86 assembly code
25/// for a MachineFunction to the given output stream, using the given target
26/// machine description.
27///
Daniel Dunbar9abdc6c2009-08-13 23:48:47 +000028static AsmPrinter *createX86CodePrinterPass(formatted_raw_ostream &o,
29 TargetMachine &tm,
Chris Lattner7b26fce2009-08-22 20:48:53 +000030 const MCAsmInfo *tai,
Daniel Dunbar9abdc6c2009-08-13 23:48:47 +000031 bool verbose) {
Chris Lattner7b26fce2009-08-22 20:48:53 +000032 if (tm.getMCAsmInfo()->getAssemblerDialect() == 1)
Daniel Dunbar95f58462009-08-13 19:38:51 +000033 return new X86IntelAsmPrinter(o, tm, tai, verbose);
34 return new X86ATTAsmPrinter(o, tm, tai, verbose);
Brian Gaeke259fdbc2003-06-19 19:32:32 +000035}
Anton Korobeynikovc5faeb82008-08-17 13:53:59 +000036
Bob Wilson5a495fe2009-06-23 23:59:40 +000037// Force static initialization.
Daniel Dunbare8338102009-07-15 20:24:03 +000038extern "C" void LLVMInitializeX86AsmPrinter() {
Daniel Dunbare8338102009-07-15 20:24:03 +000039 TargetRegistry::RegisterAsmPrinter(TheX86_32Target, createX86CodePrinterPass);
Daniel Dunbare8338102009-07-15 20:24:03 +000040 TargetRegistry::RegisterAsmPrinter(TheX86_64Target, createX86CodePrinterPass);
41}