46c46420301bcc7ca74e83fdb65dc675542d06a6
[oota-llvm.git] / lib / Target / X86 / X86ELFWriter.cpp
1 //===-- X86ELFWriter.cpp - Emit an ELF file for the X86 backend -----------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements an ELF writer for the X86 backend.  The public interface
11 // to this file is the createX86ELFObjectWriterPass function.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #include "X86.h"
16 #include "X86TargetMachine.h"
17 #include "llvm/PassManager.h"
18 #include "llvm/CodeGen/ELFWriter.h"
19 #include "llvm/Support/Visibility.h"
20 using namespace llvm;
21
22 namespace {
23   class VISIBILITY_HIDDEN X86ELFWriter : public ELFWriter {
24   public:
25     X86ELFWriter(std::ostream &O, X86TargetMachine &TM) : ELFWriter(O, TM) {
26       e_machine = 3;   // EM_386
27     }
28   };
29 }
30
31 /// addX86ELFObjectWriterPass - Returns a pass that outputs the generated code
32 /// as an ELF object file.
33 ///
34 void llvm::addX86ELFObjectWriterPass(PassManager &FPM,
35                                      std::ostream &O, X86TargetMachine &TM) {
36   X86ELFWriter *EW = new X86ELFWriter(O, TM);
37   FPM.add(EW);
38   FPM.add(createX86CodeEmitterPass(TM, EW->getMachineCodeEmitter()));
39 }