Hack up MachineCodeEmitter to actually be target independent.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6514 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2003-06-01 23:20:02 +00:00
parent 63b99f91c9
commit f2e364ad3a

View File

@ -10,10 +10,8 @@
#ifndef LLVM_CODEGEN_MACHINE_CODE_EMITTER_H #ifndef LLVM_CODEGEN_MACHINE_CODE_EMITTER_H
#define LLVM_CODEGEN_MACHINE_CODE_EMITTER_H #define LLVM_CODEGEN_MACHINE_CODE_EMITTER_H
#include <iostream>
#include <string> #include <string>
class BasicBlock; #include "Support/DataTypes.h"
class MachineInstr;
class MachineFunction; class MachineFunction;
class MachineBasicBlock; class MachineBasicBlock;
class MachineConstantPool; class MachineConstantPool;
@ -38,11 +36,6 @@ struct MachineCodeEmitter {
/// for the function. /// for the function.
virtual void emitConstantPool(MachineConstantPool *MCP) {} virtual void emitConstantPool(MachineConstantPool *MCP) {}
/// startBasicBlock - This callback is invoked when a new basic block is about
/// to be emitted.
///
virtual void startBasicBlock(MachineBasicBlock &BB) {}
/// startFunctionStub - This callback is invoked when the JIT needs the /// startFunctionStub - This callback is invoked when the JIT needs the
/// address of a function that has not been code generated yet. The StubSize /// address of a function that has not been code generated yet. The StubSize
/// specifies the total size required by the stub. Stubs are not allowed to /// specifies the total size required by the stub. Stubs are not allowed to
@ -60,45 +53,51 @@ struct MachineCodeEmitter {
/// ///
virtual void emitByte(unsigned char B) {} virtual void emitByte(unsigned char B) {}
/// emitPCRelativeDisp - This callback is invoked when we need to write out a /// emitWord - This callback is invoked when a word needs to be written to the
/// PC relative displacement for the specified Value*. This is used for call /// output stream.
/// and jump instructions typically.
/// ///
virtual void emitPCRelativeDisp(Value *V) {} virtual void emitWord(unsigned W) = 0;
/// emitGlobalAddress - This callback is invoked when we need to write out the /// getGlobalValueAddress - This method is used to get the address of the
/// address of a global value to machine code. This is important for indirect /// specified global value. In some cases, however, the address may not yet
/// calls as well as accessing global variables. /// be known at the point that the method is called (for example, getting the
/// address of a function which has not yet been code generated). If this is
/// the case, the function returns zero, and the callee has to be able to
/// handle the situation.
/// ///
virtual void emitGlobalAddress(GlobalValue *V, bool isPCRelative) {} virtual uint64_t getGlobalValueAddress(GlobalValue *V) = 0;
virtual void emitGlobalAddress(const std::string &Name, bool isPCRelative) {} virtual uint64_t getGlobalValueAddress(const std::string &Name) = 0;
/// emitFunctionConstantValueAddress - This callback is invoked when the // getConstantPoolEntryAddress - Return the address of the 'Index' entry in
/// address of a constant, which was spilled to memory, needs to be addressed. // the constant pool that was last emitted with the 'emitConstantPool' method.
/// This is used for constants which cannot be directly specified as operands //
/// to instructions, such as large integer values on the sparc, or floating virtual uint64_t getConstantPoolEntryAddress(unsigned Index) = 0;
/// point constants on the X86.
///
virtual void emitFunctionConstantValueAddress(unsigned ConstantNum,
int Offset) {}
/// createDebugMachineCodeEmitter - Return a dynamically allocated machine
// getCurrentPCValue - This returns the address that the next emitted byte
// will be output to.
//
virtual uint64_t getCurrentPCValue() = 0;
// forceCompilationOf - Force the compilation of the specified function, and
// return its address, because we REALLY need the address now.
//
// FIXME: This is JIT specific!
//
virtual uint64_t forceCompilationOf(Function *F) = 0;
/// createDebugEmitter - Return a dynamically allocated machine
/// code emitter, which just prints the opcodes and fields out the cout. This /// code emitter, which just prints the opcodes and fields out the cout. This
/// can be used for debugging users of the MachineCodeEmitter interface. /// can be used for debugging users of the MachineCodeEmitter interface.
/// ///
static MachineCodeEmitter *createDebugMachineCodeEmitter(); static MachineCodeEmitter *createDebugEmitter();
/// createFilePrinterMachineCodeEmitter - Return a dynamically allocated /// createFilePrinterEmitter - Return a dynamically allocated
/// machine code emitter, which prints binary code to a file. This /// machine code emitter, which prints binary code to a file. This
/// can be used for debugging users of the MachineCodeEmitter interface. /// can be used for debugging users of the MachineCodeEmitter interface.
/// ///
static MachineCodeEmitter* static MachineCodeEmitter *createFilePrinterEmitter(MachineCodeEmitter&);
createFilePrinterMachineCodeEmitter(MachineCodeEmitter&);
///
virtual void saveBBreference(BasicBlock* BB, MachineInstr &MI) {
std::cerr << "Save BB reference unimplemented\n";
}
}; };
#endif #endif