aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/ELFWriter.cpp21
-rw-r--r--lib/CodeGen/MachineCodeEmitter.cpp131
2 files changed, 7 insertions, 145 deletions
diff --git a/lib/CodeGen/ELFWriter.cpp b/lib/CodeGen/ELFWriter.cpp
index a802c1aa79..c03b6272b5 100644
--- a/lib/CodeGen/ELFWriter.cpp
+++ b/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;
}
//===----------------------------------------------------------------------===//
diff --git a/lib/CodeGen/MachineCodeEmitter.cpp b/lib/CodeGen/MachineCodeEmitter.cpp
deleted file mode 100644
index 301d9afb8a..0000000000
--- a/lib/CodeGen/MachineCodeEmitter.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-//===-- MachineCodeEmitter.cpp - Implement the MachineCodeEmitter itf -----===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements the MachineCodeEmitter interface.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/CodeGen/MachineCodeEmitter.h"
-#include <fstream>
-#include <iostream>
-using namespace llvm;
-
-namespace {
- class FilePrinterEmitter : public MachineCodeEmitter {
- std::ofstream actual;
- std::ostream &o;
- MachineCodeEmitter &MCE;
- unsigned counter;
- unsigned values[4];
-
- public:
- FilePrinterEmitter(MachineCodeEmitter &M, std::ostream &os)
- : o(os), MCE(M), counter(0) {
- openActual();
- }
-
- ~FilePrinterEmitter() {
- o << "\n";
- actual.close();
- }
-
- void openActual() {
- actual.open("lli.actual.obj");
- if (!actual.good()) {
- std::cerr << "Cannot open 'lli.actual.obj' for writing\n";
- abort();
- }
- }
-
- void startFunction(MachineFunction &F) {
- // resolve any outstanding calls
- MCE.startFunction(F);
- }
- void finishFunction(MachineFunction &F) {
- MCE.finishFunction(F);
- }
-
- void emitConstantPool(MachineConstantPool *MCP) {
- MCE.emitConstantPool(MCP);
- }
- void initJumpTableInfo(MachineJumpTableInfo *MJTI) {
- MCE.initJumpTableInfo(MJTI);
- }
- void emitJumpTableInfo(MachineJumpTableInfo *MJTI,
- std::map<MachineBasicBlock*,uint64_t> &MBBM) {
- MCE.emitJumpTableInfo(MJTI, MBBM);
- }
-
- void startFunctionStub(unsigned StubSize) {
- MCE.startFunctionStub(StubSize);
- }
-
- void *finishFunctionStub(const Function *F) {
- return MCE.finishFunctionStub(F);
- }
-
- void emitByte(unsigned char B) {
- MCE.emitByte(B);
- actual << B; actual.flush();
-
- values[counter] = (unsigned int) B;
- if (++counter % 4 == 0 && counter != 0) {
- o << std::hex;
- for (unsigned i=0; i<4; ++i) {
- if (values[i] < 16) o << "0";
- o << values[i] << " ";
- }
-
- o << std::dec << "\t";
- for (unsigned i=0; i<4; ++i) {
- for (int j=7; j>=0; --j) {
- o << ((values[i] >> j) & 1);
- }
- o << " ";
- }
-
- o << "\n";
-
- unsigned instr = 0;
- for (unsigned i=0; i<4; ++i)
- instr |= values[i] << (i*8);
-
- o << "--- * --- * --- * --- * ---\n";
- counter %= 4;
- }
- }
-
- void emitWord(unsigned W) {
- MCE.emitWord(W);
- }
- uint64_t getConstantPoolEntryAddress(unsigned Num) {
- return MCE.getConstantPoolEntryAddress(Num);
- }
- uint64_t getJumpTableEntryAddress(unsigned Num) {
- return MCE.getJumpTableEntryAddress(Num);
- }
- virtual unsigned char* allocateGlobal(unsigned size, unsigned alignment)
- { return MCE.allocateGlobal(size, alignment); }
-
- uint64_t getCurrentPCValue() {
- return MCE.getCurrentPCValue();
- }
- uint64_t getCurrentPCOffset() {
- return MCE.getCurrentPCOffset();
- }
- void addRelocation(const MachineRelocation &MR) {
- return MCE.addRelocation(MR);
- }
- };
-}
-
-MachineCodeEmitter *
-MachineCodeEmitter::createFilePrinterEmitter(MachineCodeEmitter &MCE) {
- return new FilePrinterEmitter(MCE, std::cerr);
-}