LLVM API Documentation

ELFCodeEmitter.h

Go to the documentation of this file.
00001 //===-- lib/CodeGen/ELFCodeEmitter.h ----------------------------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 
00010 #ifndef ELFCODEEMITTER_H
00011 #define ELFCODEEMITTER_H
00012 
00013 #include "llvm/CodeGen/ObjectCodeEmitter.h"
00014 #include <vector>
00015 
00016 namespace llvm {
00017   class ELFWriter;
00018   class ELFSection;
00019 
00020   /// ELFCodeEmitter - This class is used by the ELFWriter to 
00021   /// emit the code for functions to the ELF file.
00022   class ELFCodeEmitter : public ObjectCodeEmitter {
00023     ELFWriter &EW;
00024 
00025     /// Target machine description
00026     TargetMachine &TM;
00027 
00028     /// Section containing code for functions
00029     ELFSection *ES;
00030 
00031     /// Relocations - Record relocations needed by the current function 
00032     std::vector<MachineRelocation> Relocations;
00033 
00034     /// JTRelocations - Record relocations needed by the relocation
00035     /// section.
00036     std::vector<MachineRelocation> JTRelocations;
00037 
00038     /// FnStartPtr - Function offset from the beginning of ELFSection 'ES'
00039     uintptr_t FnStartOff;
00040   public:
00041     explicit ELFCodeEmitter(ELFWriter &ew) : EW(ew), TM(EW.TM) {}
00042 
00043     /// addRelocation - Register new relocations for this function
00044     void addRelocation(const MachineRelocation &MR) {
00045       Relocations.push_back(MR);
00046     }
00047 
00048     /// emitConstantPool - For each constant pool entry, figure out which
00049     /// section the constant should live in and emit data to it
00050     void emitConstantPool(MachineConstantPool *MCP);
00051 
00052     /// emitJumpTables - Emit all the jump tables for a given jump table
00053     /// info and record them to the appropriate section.
00054     void emitJumpTables(MachineJumpTableInfo *MJTI);
00055 
00056     void startFunction(MachineFunction &F);
00057     bool finishFunction(MachineFunction &F);
00058 
00059     /// emitLabel - Emits a label
00060     virtual void emitLabel(uint64_t LabelID) {
00061       assert("emitLabel not implemented");
00062     }
00063 
00064     /// getLabelAddress - Return the address of the specified LabelID, 
00065     /// only usable after the LabelID has been emitted.
00066     virtual uintptr_t getLabelAddress(uint64_t Label) const {
00067       assert("getLabelAddress not implemented");
00068       return 0;
00069     }
00070 
00071     virtual void setModuleInfo(llvm::MachineModuleInfo* MMI) {}
00072 
00073 };  // end class ELFCodeEmitter
00074 
00075 } // end namespace llvm
00076 
00077 #endif
00078