| Bruno Cardoso Lopes | d51db00 | 2009-06-03 17:47:27 +0000 | [diff] [blame] | 1 | //===-- lib/CodeGen/ELFCodeEmitter.h ----------------------------*- C++ -*-===// | 
|  | 2 | // | 
|  | 3 | //                     The LLVM Compiler Infrastructure | 
|  | 4 | // | 
|  | 5 | // This file is distributed under the University of Illinois Open Source | 
|  | 6 | // License. See LICENSE.TXT for details. | 
|  | 7 | // | 
|  | 8 | //===----------------------------------------------------------------------===// | 
|  | 9 |  | 
|  | 10 | #ifndef ELFCODEEMITTER_H | 
|  | 11 | #define ELFCODEEMITTER_H | 
|  | 12 |  | 
| Bruno Cardoso Lopes | f539f03 | 2009-07-06 09:26:48 +0000 | [diff] [blame] | 13 | #include "llvm/CodeGen/ObjectCodeEmitter.h" | 
| Bruno Cardoso Lopes | d51db00 | 2009-06-03 17:47:27 +0000 | [diff] [blame] | 14 | #include <vector> | 
|  | 15 |  | 
|  | 16 | namespace llvm { | 
| Bruno Cardoso Lopes | 6dca284 | 2009-07-02 18:29:24 +0000 | [diff] [blame] | 17 | class ELFWriter; | 
|  | 18 | class ELFSection; | 
| Bruno Cardoso Lopes | d51db00 | 2009-06-03 17:47:27 +0000 | [diff] [blame] | 19 |  | 
|  | 20 | /// ELFCodeEmitter - This class is used by the ELFWriter to | 
|  | 21 | /// emit the code for functions to the ELF file. | 
| Bruno Cardoso Lopes | f539f03 | 2009-07-06 09:26:48 +0000 | [diff] [blame] | 22 | class ELFCodeEmitter : public ObjectCodeEmitter { | 
| Bruno Cardoso Lopes | d51db00 | 2009-06-03 17:47:27 +0000 | [diff] [blame] | 23 | ELFWriter &EW; | 
| Bruno Cardoso Lopes | e577492 | 2009-06-07 21:22:38 +0000 | [diff] [blame] | 24 |  | 
|  | 25 | /// Target machine description | 
| Bruno Cardoso Lopes | d51db00 | 2009-06-03 17:47:27 +0000 | [diff] [blame] | 26 | TargetMachine &TM; | 
| Bruno Cardoso Lopes | e577492 | 2009-06-07 21:22:38 +0000 | [diff] [blame] | 27 |  | 
|  | 28 | /// Section containing code for functions | 
|  | 29 | ELFSection *ES; | 
|  | 30 |  | 
| Bruno Cardoso Lopes | f539f03 | 2009-07-06 09:26:48 +0000 | [diff] [blame] | 31 | /// Relocations - Record relocations needed by the current function | 
| Bruno Cardoso Lopes | e577492 | 2009-06-07 21:22:38 +0000 | [diff] [blame] | 32 | std::vector<MachineRelocation> Relocations; | 
|  | 33 |  | 
| Bruno Cardoso Lopes | 40ca1f1 | 2009-07-21 23:13:26 +0000 | [diff] [blame] | 34 | /// JTRelocations - Record relocations needed by the relocation | 
|  | 35 | /// section. | 
|  | 36 | std::vector<MachineRelocation> JTRelocations; | 
|  | 37 |  | 
| Bruno Cardoso Lopes | f539f03 | 2009-07-06 09:26:48 +0000 | [diff] [blame] | 38 | /// FnStartPtr - Function offset from the beginning of ELFSection 'ES' | 
|  | 39 | uintptr_t FnStartOff; | 
| Bruno Cardoso Lopes | d51db00 | 2009-06-03 17:47:27 +0000 | [diff] [blame] | 40 | public: | 
| Bruno Cardoso Lopes | 40ca1f1 | 2009-07-21 23:13:26 +0000 | [diff] [blame] | 41 | explicit ELFCodeEmitter(ELFWriter &ew) : EW(ew), TM(EW.TM) {} | 
| Bruno Cardoso Lopes | d51db00 | 2009-06-03 17:47:27 +0000 | [diff] [blame] | 42 |  | 
| Bruno Cardoso Lopes | f539f03 | 2009-07-06 09:26:48 +0000 | [diff] [blame] | 43 | /// addRelocation - Register new relocations for this function | 
| Bruno Cardoso Lopes | d51db00 | 2009-06-03 17:47:27 +0000 | [diff] [blame] | 44 | void addRelocation(const MachineRelocation &MR) { | 
| Bruno Cardoso Lopes | e577492 | 2009-06-07 21:22:38 +0000 | [diff] [blame] | 45 | Relocations.push_back(MR); | 
| Bruno Cardoso Lopes | d51db00 | 2009-06-03 17:47:27 +0000 | [diff] [blame] | 46 | } | 
|  | 47 |  | 
| Bruno Cardoso Lopes | f539f03 | 2009-07-06 09:26:48 +0000 | [diff] [blame] | 48 | /// emitConstantPool - For each constant pool entry, figure out which | 
|  | 49 | /// section the constant should live in and emit data to it | 
| Bruno Cardoso Lopes | e364a23 | 2009-06-25 07:36:24 +0000 | [diff] [blame] | 50 | void emitConstantPool(MachineConstantPool *MCP); | 
|  | 51 |  | 
| Bruno Cardoso Lopes | f539f03 | 2009-07-06 09:26:48 +0000 | [diff] [blame] | 52 | /// emitJumpTables - Emit all the jump tables for a given jump table | 
|  | 53 | /// info and record them to the appropriate section. | 
| Bruno Cardoso Lopes | 95dd865 | 2009-07-03 04:36:26 +0000 | [diff] [blame] | 54 | void emitJumpTables(MachineJumpTableInfo *MJTI); | 
|  | 55 |  | 
| Bruno Cardoso Lopes | f539f03 | 2009-07-06 09:26:48 +0000 | [diff] [blame] | 56 | void startFunction(MachineFunction &F); | 
|  | 57 | bool finishFunction(MachineFunction &F); | 
|  | 58 |  | 
|  | 59 | /// emitLabel - Emits a label | 
|  | 60 | virtual void emitLabel(uint64_t LabelID) { | 
|  | 61 | assert("emitLabel not implemented"); | 
|  | 62 | } | 
|  | 63 |  | 
|  | 64 | /// getLabelAddress - Return the address of the specified LabelID, | 
|  | 65 | /// only usable after the LabelID has been emitted. | 
|  | 66 | virtual uintptr_t getLabelAddress(uint64_t Label) const { | 
|  | 67 | assert("getLabelAddress not implemented"); | 
|  | 68 | return 0; | 
|  | 69 | } | 
|  | 70 |  | 
| Bruno Cardoso Lopes | 95dd865 | 2009-07-03 04:36:26 +0000 | [diff] [blame] | 71 | virtual void setModuleInfo(llvm::MachineModuleInfo* MMI) {} | 
| Bruno Cardoso Lopes | d51db00 | 2009-06-03 17:47:27 +0000 | [diff] [blame] | 72 |  | 
| Bruno Cardoso Lopes | d51db00 | 2009-06-03 17:47:27 +0000 | [diff] [blame] | 73 | };  // end class ELFCodeEmitter | 
|  | 74 |  | 
|  | 75 | } // end namespace llvm | 
|  | 76 |  | 
|  | 77 | #endif | 
|  | 78 |  |