LLVM API Documentation
00001 //===-- X86ELFWriter.cpp - Emit an ELF file for the X86 backend -----------===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file was developed by the LLVM research group and is distributed under 00006 // the University of Illinois Open Source License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file implements an ELF writer for the X86 backend. The public interface 00011 // to this file is the createX86ELFObjectWriterPass function. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #include "X86.h" 00016 #include "X86TargetMachine.h" 00017 #include "llvm/PassManager.h" 00018 #include "llvm/CodeGen/ELFWriter.h" 00019 using namespace llvm; 00020 00021 namespace { 00022 class X86ELFWriter : public ELFWriter { 00023 public: 00024 X86ELFWriter(std::ostream &O, X86TargetMachine &TM) : ELFWriter(O, TM) { 00025 e_machine = 3; // EM_386 00026 } 00027 }; 00028 } 00029 00030 /// addX86ELFObjectWriterPass - Returns a pass that outputs the generated code 00031 /// as an ELF object file. 00032 /// 00033 void llvm::addX86ELFObjectWriterPass(PassManager &FPM, 00034 std::ostream &O, X86TargetMachine &TM) { 00035 X86ELFWriter *EW = new X86ELFWriter(O, TM); 00036 FPM.add(EW); 00037 FPM.add(createX86CodeEmitterPass(EW->getMachineCodeEmitter())); 00038 }