blob: 10932e166ebe83e5fd073297da13fe0556405c06 [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
Dan Gohmanf17a25c2007-07-18 16:29:46 +000017#include "X86ATTAsmPrinter.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000018#include "X86IntelAsmPrinter.h"
Cédric Venet4fce6e22008-08-24 12:30:46 +000019#include "X86Subtarget.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000020using namespace llvm;
21
Dan Gohmanf17a25c2007-07-18 16:29:46 +000022/// createX86CodePrinterPass - Returns a pass that prints the X86 assembly code
23/// for a MachineFunction to the given output stream, using the given target
24/// machine description.
25///
Owen Anderson847b99b2008-08-21 00:14:44 +000026FunctionPass *llvm::createX86CodePrinterPass(raw_ostream &o,
Bill Wendling4f405312009-02-24 08:30:20 +000027 X86TargetMachine &tm,
Bill Wendling5ed22ac2009-04-29 23:29:43 +000028 CodeGenOpt::Level OptLevel,
29 bool verbose) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000030 const X86Subtarget *Subtarget = &tm.getSubtarget<X86Subtarget>();
31
32 if (Subtarget->isFlavorIntel()) {
Bill Wendling58ed5d22009-04-29 00:15:41 +000033 return new X86IntelAsmPrinter(o, tm, tm.getTargetAsmInfo(),
34 OptLevel, verbose);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000035 } else {
Bill Wendling58ed5d22009-04-29 00:15:41 +000036 return new X86ATTAsmPrinter(o, tm, tm.getTargetAsmInfo(),
37 OptLevel, verbose);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000038 }
39}
Anton Korobeynikov9ff5bee2008-08-17 13:53:59 +000040
41namespace {
42 static struct Register {
43 Register() {
44 X86TargetMachine::registerAsmPrinter(createX86CodePrinterPass);
45 }
46 } Registrator;
47}
Oscar Fuentes4f012352008-11-15 21:36:30 +000048
49extern "C" int X86AsmPrinterForceLink;
50int X86AsmPrinterForceLink = 0;
Douglas Gregor1dc5ff42009-06-16 20:12:29 +000051
52// Force static initialization when called from
53// llvm/InitializeAllAsmPrinters.h
54namespace llvm {
55 void InitializeX86AsmPrinter() { }
56}