blob: 14156828f8b9b88977392c33c3a7c777d9b5aeff [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 Lattner2c048f22009-08-11 23:01:09 +000020#include "llvm/Target/TargetAsmInfo.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 Dunbarc680b012009-07-25 06:49:55 +000028static FunctionPass *createX86CodePrinterPass(formatted_raw_ostream &o,
29 TargetMachine &tm,
30 bool verbose) {
Chris Lattner2c048f22009-08-11 23:01:09 +000031 if (tm.getTargetAsmInfo()->getAssemblerDialect() == 1)
Daniel Dunbarb10d2222009-07-01 01:48:54 +000032 return new X86IntelAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
33 return new X86ATTAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000034}
Anton Korobeynikov9ff5bee2008-08-17 13:53:59 +000035
Bob Wilsonebbc1c42009-06-23 23:59:40 +000036// Force static initialization.
Daniel Dunbarfe5939f2009-07-15 20:24:03 +000037extern "C" void LLVMInitializeX86AsmPrinter() {
Daniel Dunbarfe5939f2009-07-15 20:24:03 +000038 TargetRegistry::RegisterAsmPrinter(TheX86_32Target, createX86CodePrinterPass);
Daniel Dunbarfe5939f2009-07-15 20:24:03 +000039 TargetRegistry::RegisterAsmPrinter(TheX86_64Target, createX86CodePrinterPass);
40}