Clean up code, no functionality changes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22382 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2005-07-11 06:34:30 +00:00
parent c569d79a2a
commit 0e18050797

View File

@@ -40,7 +40,13 @@
#include "llvm/Support/Mangler.h"
using namespace llvm;
//===----------------------------------------------------------------------===//
// ELFCodeEmitter Implementation
//===----------------------------------------------------------------------===//
namespace llvm {
/// ELFCodeEmitter - This class is used by the ELFWriter to emit the code for
/// functions to the ELF file.
class ELFCodeEmitter : public MachineCodeEmitter {
ELFWriter &EW;
std::vector<unsigned char> &OutputBuffer;
@@ -48,7 +54,51 @@ namespace llvm {
public:
ELFCodeEmitter(ELFWriter &ew) : EW(ew), OutputBuffer(EW.OutputBuffer) {}
void startFunction(MachineFunction &F) {
void startFunction(MachineFunction &F);
void finishFunction(MachineFunction &F);
void emitConstantPool(MachineConstantPool *MCP) {
if (MCP->isEmpty()) return;
assert(0 && "unimp");
}
virtual void emitByte(unsigned char B) {
OutputBuffer.push_back(B);
}
virtual void emitWordAt(unsigned W, unsigned *Ptr) {
assert(0 && "ni");
}
virtual void emitWord(unsigned W) {
assert(0 && "ni");
}
virtual uint64_t getCurrentPCValue() {
return OutputBuffer.size();
}
virtual uint64_t getCurrentPCOffset() {
return OutputBuffer.size()-FnStart;
}
void addRelocation(const MachineRelocation &MR) {
assert(0 && "relo not handled yet!");
}
virtual uint64_t getConstantPoolEntryAddress(unsigned Index) {
assert(0 && "CP not implementated yet!");
}
/// JIT SPECIFIC FUNCTIONS - DO NOT IMPLEMENT THESE HERE!
void startFunctionStub(unsigned StubSize) {
assert(0 && "JIT specific function called!");
abort();
}
void *finishFunctionStub(const Function *F) {
assert(0 && "JIT specific function called!");
abort();
return 0;
}
};
}
/// startFunction - This callback is invoked when a new machine function is
/// about to be emitted.
void ELFCodeEmitter::startFunction(MachineFunction &F) {
// Align the output buffer to the appropriate alignment.
unsigned Align = 16; // FIXME: GENERICIZE!!
ELFWriter::ELFSection &TextSection = EW.SectionList.back();
@@ -67,7 +117,10 @@ namespace llvm {
FnStart = OutputBuffer.size();
}
void finishFunction(MachineFunction &F) {
/// finishFunction - This callback is invoked after the function is completely
/// finished.
void ELFCodeEmitter::finishFunction(MachineFunction &F) {
// We now know the size of the function, add a symbol to represent it.
ELFWriter::ELFSym FnSym(F.getFunction());
@@ -98,44 +151,9 @@ namespace llvm {
EW.SymbolTable.push_back(FnSym);
}
void emitConstantPool(MachineConstantPool *MCP) {
if (MCP->isEmpty()) return;
assert(0 && "unimp");
}
virtual void emitByte(unsigned char B) {
OutputBuffer.push_back(B);
}
virtual void emitWordAt(unsigned W, unsigned *Ptr) {
assert(0 && "ni");
}
virtual void emitWord(unsigned W) {
assert(0 && "ni");
}
virtual uint64_t getCurrentPCValue() {
return OutputBuffer.size();
}
virtual uint64_t getCurrentPCOffset() {
return OutputBuffer.size()-FnStart;
}
void addRelocation(const MachineRelocation &MR) {
assert(0 && "relo not handled yet!");
}
virtual uint64_t getConstantPoolEntryAddress(unsigned Index) {
assert(0 && "CP not implementated yet!");
}
/// JIT SPECIFIC FUNCTIONS
void startFunctionStub(unsigned StubSize) {
assert(0 && "JIT specific function called!");
abort();
}
void *finishFunctionStub(const Function *F) {
assert(0 && "JIT specific function called!");
abort();
return 0;
}
};
}
//===----------------------------------------------------------------------===//
// ELFWriter Implementation
//===----------------------------------------------------------------------===//
ELFWriter::ELFWriter(std::ostream &o, TargetMachine &tm) : O(o), TM(tm) {
e_machine = 0; // e_machine defaults to 'No Machine'