[llvm-commits] CVS: llvm/lib/CodeGen/ELFWriter.cpp MachineCodeEmitter.cpp

Chris Lattner lattner at cs.uiuc.edu
Tue May 2 11:27:42 PDT 2006



Changes in directory llvm/lib/CodeGen:

ELFWriter.cpp updated: 1.19 -> 1.20
MachineCodeEmitter.cpp (r1.28) removed
---
Log message:

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: http://llvm.cs.uiuc.edu/PR469 .


---
Diffs of the changes:  (+7 -14)

 ELFWriter.cpp |   21 +++++++--------------
 1 files changed, 7 insertions(+), 14 deletions(-)


Index: llvm/lib/CodeGen/ELFWriter.cpp
diff -u llvm/lib/CodeGen/ELFWriter.cpp:1.19 llvm/lib/CodeGen/ELFWriter.cpp:1.20
--- llvm/lib/CodeGen/ELFWriter.cpp:1.19	Tue May  2 12:17:47 2006
+++ llvm/lib/CodeGen/ELFWriter.cpp	Tue May  2 13:27:26 2006
@@ -56,24 +56,12 @@
     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 @@
                       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 @@
 
 /// 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 @@
 
   // Finally, add it to the symtab.
   EW.SymbolTable.push_back(FnSym);
+  return false;
 }
 
 //===----------------------------------------------------------------------===//






More information about the llvm-commits mailing list