From c9aa3715e874acbf3fe044154aab01cba90fd8f7 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 2 May 2006 18:27:26 +0000 Subject: Refactor the machine code emitter interface to pull the pointers for the current code emission location into the base class, instead of being in the derived classes. This change means that low-level methods like emitByte/emitWord now are no longer virtual (yaay for speed), and we now have a framework to support growable code segments. This implements feature request #1 of PR469. llvm-svn: 28059 --- llvm/lib/CodeGen/ELFWriter.cpp | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'llvm/lib/CodeGen/ELFWriter.cpp') diff --git a/llvm/lib/CodeGen/ELFWriter.cpp b/llvm/lib/CodeGen/ELFWriter.cpp index a802c1aa793..c03b6272b56 100644 --- a/llvm/lib/CodeGen/ELFWriter.cpp +++ b/llvm/lib/CodeGen/ELFWriter.cpp @@ -56,24 +56,12 @@ namespace llvm { ELFCodeEmitter(ELFWriter &ew) : EW(ew), OutBuffer(0) {} void startFunction(MachineFunction &F); - void finishFunction(MachineFunction &F); + bool finishFunction(MachineFunction &F); void emitConstantPool(MachineConstantPool *MCP) { if (MCP->isEmpty()) return; assert(0 && "unimp"); } - virtual void emitByte(unsigned char B) { - OutBuffer->push_back(B); - } - virtual void emitWord(unsigned W) { - assert(0 && "ni"); - } - virtual uint64_t getCurrentPCValue() { - return OutBuffer->size(); - } - virtual uint64_t getCurrentPCOffset() { - return OutBuffer->size()-FnStart; - } void addRelocation(const MachineRelocation &MR) { assert(0 && "relo not handled yet!"); } @@ -113,6 +101,10 @@ void ELFCodeEmitter::startFunction(MachineFunction &F) { ELFWriter::ELFSection::SHF_EXECINSTR | ELFWriter::ELFSection::SHF_ALLOC); OutBuffer = &ES->SectionData; + std::cerr << "FIXME: This code needs to be updated for changes in the" + << " CodeEmitter interfaces. In particular, this should set " + << "BufferBegin/BufferEnd/CurBufferPtr, not deal with OutBuffer!"; + abort(); // Upgrade the section alignment if required. if (ES->Align < Align) ES->Align = Align; @@ -127,7 +119,7 @@ void ELFCodeEmitter::startFunction(MachineFunction &F) { /// finishFunction - This callback is invoked after the function is completely /// finished. -void ELFCodeEmitter::finishFunction(MachineFunction &F) { +bool ELFCodeEmitter::finishFunction(MachineFunction &F) { // We now know the size of the function, add a symbol to represent it. ELFWriter::ELFSym FnSym(F.getFunction()); @@ -157,6 +149,7 @@ void ELFCodeEmitter::finishFunction(MachineFunction &F) { // Finally, add it to the symtab. EW.SymbolTable.push_back(FnSym); + return false; } //===----------------------------------------------------------------------===// -- cgit v1.2.3