2009-06-03 19:47:27 +02:00
|
|
|
//===-- lib/CodeGen/ELFCodeEmitter.h ----------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef ELFCODEEMITTER_H
|
|
|
|
#define ELFCODEEMITTER_H
|
|
|
|
|
2009-07-06 11:26:48 +02:00
|
|
|
#include "llvm/CodeGen/ObjectCodeEmitter.h"
|
2009-06-03 19:47:27 +02:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace llvm {
|
2009-07-02 20:29:24 +02:00
|
|
|
class ELFWriter;
|
|
|
|
class ELFSection;
|
2009-06-03 19:47:27 +02:00
|
|
|
|
|
|
|
/// ELFCodeEmitter - This class is used by the ELFWriter to
|
|
|
|
/// emit the code for functions to the ELF file.
|
2009-07-06 11:26:48 +02:00
|
|
|
class ELFCodeEmitter : public ObjectCodeEmitter {
|
2009-06-03 19:47:27 +02:00
|
|
|
ELFWriter &EW;
|
2009-06-07 23:22:38 +02:00
|
|
|
|
|
|
|
/// Target machine description
|
2009-06-03 19:47:27 +02:00
|
|
|
TargetMachine &TM;
|
2009-06-07 23:22:38 +02:00
|
|
|
|
|
|
|
/// Section containing code for functions
|
|
|
|
ELFSection *ES;
|
|
|
|
|
2009-07-06 11:26:48 +02:00
|
|
|
/// Relocations - Record relocations needed by the current function
|
2009-06-07 23:22:38 +02:00
|
|
|
std::vector<MachineRelocation> Relocations;
|
|
|
|
|
2009-07-22 01:13:26 +02:00
|
|
|
/// JTRelocations - Record relocations needed by the relocation
|
|
|
|
/// section.
|
|
|
|
std::vector<MachineRelocation> JTRelocations;
|
|
|
|
|
2009-07-06 11:26:48 +02:00
|
|
|
/// FnStartPtr - Function offset from the beginning of ELFSection 'ES'
|
|
|
|
uintptr_t FnStartOff;
|
2009-06-03 19:47:27 +02:00
|
|
|
public:
|
2009-07-22 01:13:26 +02:00
|
|
|
explicit ELFCodeEmitter(ELFWriter &ew) : EW(ew), TM(EW.TM) {}
|
2009-06-03 19:47:27 +02:00
|
|
|
|
2009-07-06 11:26:48 +02:00
|
|
|
/// addRelocation - Register new relocations for this function
|
2009-06-03 19:47:27 +02:00
|
|
|
void addRelocation(const MachineRelocation &MR) {
|
2009-06-07 23:22:38 +02:00
|
|
|
Relocations.push_back(MR);
|
2009-06-03 19:47:27 +02:00
|
|
|
}
|
|
|
|
|
2009-07-06 11:26:48 +02:00
|
|
|
/// emitConstantPool - For each constant pool entry, figure out which
|
|
|
|
/// section the constant should live in and emit data to it
|
|
|
|
void emitConstantPool(MachineConstantPool *MCP);
|
2009-06-07 23:22:38 +02:00
|
|
|
|
2009-07-06 11:26:48 +02:00
|
|
|
/// emitJumpTables - Emit all the jump tables for a given jump table
|
|
|
|
/// info and record them to the appropriate section.
|
|
|
|
void emitJumpTables(MachineJumpTableInfo *MJTI);
|
2009-06-25 09:36:24 +02:00
|
|
|
|
2009-07-06 11:26:48 +02:00
|
|
|
void startFunction(MachineFunction &F);
|
|
|
|
bool finishFunction(MachineFunction &F);
|
2009-06-03 19:47:27 +02:00
|
|
|
|
2009-07-06 11:26:48 +02:00
|
|
|
/// emitLabel - Emits a label
|
2010-03-14 02:41:15 +01:00
|
|
|
virtual void emitLabel(MCSymbol *Label) {
|
2009-07-06 11:26:48 +02:00
|
|
|
assert("emitLabel not implemented");
|
2009-06-03 19:47:27 +02:00
|
|
|
}
|
|
|
|
|
2009-07-06 11:26:48 +02:00
|
|
|
/// getLabelAddress - Return the address of the specified LabelID,
|
|
|
|
/// only usable after the LabelID has been emitted.
|
2010-03-14 02:41:15 +01:00
|
|
|
virtual uintptr_t getLabelAddress(MCSymbol *Label) const {
|
2009-07-06 11:26:48 +02:00
|
|
|
assert("getLabelAddress not implemented");
|
2009-06-03 19:47:27 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-07-03 06:36:26 +02:00
|
|
|
virtual void setModuleInfo(llvm::MachineModuleInfo* MMI) {}
|
2009-06-03 19:47:27 +02:00
|
|
|
|
|
|
|
}; // end class ELFCodeEmitter
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|