blob: 3ca35c50da94fa9c42a8b6ba9b8aa5520237fbb8 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===-- X86AsmPrinter.cpp - Convert X86 LLVM IR to X86 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// 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'.
14//
15//===----------------------------------------------------------------------===//
16
Daniel Dunbar0b0441e2009-07-18 23:03:22 +000017#include "X86.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000018#include "X86ATTAsmPrinter.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000019#include "X86IntelAsmPrinter.h"
Chris Lattner621c44d2009-08-22 20:48:53 +000020#include "llvm/MC/MCAsmInfo.h"
Daniel Dunbarfe5939f2009-07-15 20:24:03 +000021#include "llvm/Target/TargetRegistry.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000022using namespace llvm;
23
Dan Gohmanf17a25c2007-07-18 16:29:46 +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 Dunbar4cb63652009-08-13 23:48:47 +000028static AsmPrinter *createX86CodePrinterPass(formatted_raw_ostream &o,
29 TargetMachine &tm,
Chris Lattner621c44d2009-08-22 20:48:53 +000030 const MCAsmInfo *tai,
Daniel Dunbar4cb63652009-08-13 23:48:47 +000031 bool verbose) {
Chris Lattner621c44d2009-08-22 20:48:53 +000032 if (tm.getMCAsmInfo()->getAssemblerDialect() == 1)
Daniel Dunbaref5abb42009-08-13 19:38:51 +000033 return new X86IntelAsmPrinter(o, tm, tai, verbose);
34 return new X86ATTAsmPrinter(o, tm, tai, verbose);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000035}
Anton Korobeynikov9ff5bee2008-08-17 13:53:59 +000036
Bob Wilsonebbc1c42009-06-23 23:59:40 +000037// Force static initialization.
Daniel Dunbarfe5939f2009-07-15 20:24:03 +000038extern "C" void LLVMInitializeX86AsmPrinter() {
Daniel Dunbarfe5939f2009-07-15 20:24:03 +000039 TargetRegistry::RegisterAsmPrinter(TheX86_32Target, createX86CodePrinterPass);
Daniel Dunbarfe5939f2009-07-15 20:24:03 +000040 TargetRegistry::RegisterAsmPrinter(TheX86_64Target, createX86CodePrinterPass);
41}