blob: a39203b19c24b224f70986898c1c735bb0384ef6 [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
Chris Lattner63c41092009-06-18 23:33:13 +000032 if (Subtarget->isFlavorIntel())
Bill Wendling58ed5d22009-04-29 00:15:41 +000033 return new X86IntelAsmPrinter(o, tm, tm.getTargetAsmInfo(),
34 OptLevel, verbose);
Chris Lattner63c41092009-06-18 23:33:13 +000035 return new X86ATTAsmPrinter(o, tm, tm.getTargetAsmInfo(),
36 OptLevel, verbose);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000037}
Anton Korobeynikov9ff5bee2008-08-17 13:53:59 +000038
39namespace {
40 static struct Register {
41 Register() {
42 X86TargetMachine::registerAsmPrinter(createX86CodePrinterPass);
43 }
44 } Registrator;
45}
Oscar Fuentes4f012352008-11-15 21:36:30 +000046
47extern "C" int X86AsmPrinterForceLink;
48int X86AsmPrinterForceLink = 0;
Douglas Gregor1dc5ff42009-06-16 20:12:29 +000049
50// Force static initialization when called from
51// llvm/InitializeAllAsmPrinters.h
52namespace llvm {
53 void InitializeX86AsmPrinter() { }
54}