2002-12-02 21:21:36 +00:00
|
|
|
//===-- llvm/CodeGen/MachineCodeEmitter.h - Code emission -------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// This file defines an abstract interface that is used by the machine code
|
|
|
|
// emission framework to output the code. This allows machine code emission to
|
|
|
|
// be seperated from concerns such as resolution of call targets, and where the
|
|
|
|
// machine code will be written (memory or disk, f.e.).
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_CODEGEN_MACHINE_CODE_EMITTER_H
|
|
|
|
#define LLVM_CODEGEN_MACHINE_CODE_EMITTER_H
|
|
|
|
|
2003-01-13 00:14:55 +00:00
|
|
|
#include <string>
|
2002-12-02 21:44:13 +00:00
|
|
|
class MachineFunction;
|
|
|
|
class MachineBasicBlock;
|
2003-01-13 00:14:55 +00:00
|
|
|
class MachineConstantPool;
|
2002-12-02 21:56:28 +00:00
|
|
|
class Value;
|
2002-12-04 06:44:27 +00:00
|
|
|
class GlobalValue;
|
2003-05-08 22:00:52 +00:00
|
|
|
class Function;
|
2002-12-02 21:21:36 +00:00
|
|
|
|
2002-12-02 21:44:13 +00:00
|
|
|
struct MachineCodeEmitter {
|
2002-12-03 20:56:20 +00:00
|
|
|
virtual ~MachineCodeEmitter() {}
|
2002-12-02 21:21:36 +00:00
|
|
|
|
2002-12-02 21:44:13 +00:00
|
|
|
/// startFunction - This callback is invoked when the specified function is
|
|
|
|
/// about to be code generated.
|
|
|
|
///
|
|
|
|
virtual void startFunction(MachineFunction &F) {}
|
2002-12-02 21:21:36 +00:00
|
|
|
|
2002-12-02 21:44:13 +00:00
|
|
|
/// finishFunction - This callback is invoked when the specified function has
|
|
|
|
/// finished code generation.
|
|
|
|
///
|
|
|
|
virtual void finishFunction(MachineFunction &F) {}
|
|
|
|
|
2003-01-13 00:14:55 +00:00
|
|
|
/// emitConstantPool - This callback is invoked to output the constant pool
|
|
|
|
/// for the function.
|
|
|
|
virtual void emitConstantPool(MachineConstantPool *MCP) {}
|
|
|
|
|
2002-12-02 21:44:13 +00:00
|
|
|
/// startBasicBlock - This callback is invoked when a new basic block is about
|
|
|
|
/// to be emitted.
|
|
|
|
///
|
|
|
|
virtual void startBasicBlock(MachineBasicBlock &BB) {}
|
2002-12-02 21:21:36 +00:00
|
|
|
|
2003-05-08 21:53:57 +00:00
|
|
|
/// startFunctionStub - This callback is invoked when the JIT needs the
|
|
|
|
/// 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
|
|
|
|
/// have constant pools, the can only use the other emit* methods.
|
|
|
|
///
|
|
|
|
virtual void startFunctionStub(Function &F, unsigned StubSize) {}
|
|
|
|
|
|
|
|
/// finishFunctionStub - This callback is invoked to terminate a function
|
|
|
|
/// stub.
|
|
|
|
///
|
|
|
|
virtual void finishFunctionStub(Function &F) {}
|
|
|
|
|
2002-12-02 21:44:13 +00:00
|
|
|
/// emitByte - This callback is invoked when a byte needs to be written to the
|
|
|
|
/// output stream.
|
2002-12-02 21:56:28 +00:00
|
|
|
///
|
2002-12-02 21:44:13 +00:00
|
|
|
virtual void emitByte(unsigned char B) {}
|
2002-12-02 21:56:28 +00:00
|
|
|
|
|
|
|
/// emitPCRelativeDisp - This callback is invoked when we need to write out a
|
|
|
|
/// PC relative displacement for the specified Value*. This is used for call
|
|
|
|
/// and jump instructions typically.
|
|
|
|
///
|
|
|
|
virtual void emitPCRelativeDisp(Value *V) {}
|
2002-12-03 20:56:20 +00:00
|
|
|
|
2002-12-04 06:44:27 +00:00
|
|
|
/// emitGlobalAddress - This callback is invoked when we need to write out the
|
|
|
|
/// address of a global value to machine code. This is important for indirect
|
|
|
|
/// calls as well as accessing global variables.
|
|
|
|
///
|
2003-01-13 00:14:55 +00:00
|
|
|
virtual void emitGlobalAddress(GlobalValue *V, bool isPCRelative) {}
|
|
|
|
virtual void emitGlobalAddress(const std::string &Name, bool isPCRelative) {}
|
2002-12-04 06:44:27 +00:00
|
|
|
|
2003-01-13 00:14:55 +00:00
|
|
|
/// emitFunctionConstantValueAddress - This callback is invoked when the
|
|
|
|
/// address of a constant, which was spilled to memory, needs to be addressed.
|
|
|
|
/// This is used for constants which cannot be directly specified as operands
|
|
|
|
/// to instructions, such as large integer values on the sparc, or floating
|
|
|
|
/// point constants on the X86.
|
|
|
|
///
|
|
|
|
virtual void emitFunctionConstantValueAddress(unsigned ConstantNum,
|
|
|
|
int Offset) {}
|
2002-12-03 20:56:20 +00:00
|
|
|
|
|
|
|
/// createDebugMachineCodeEmitter - Return a dynamically allocated machine
|
|
|
|
/// code emitter, which just prints the opcodes and fields out the cout. This
|
|
|
|
/// can be used for debugging users of the MachineCodeEmitter interface.
|
|
|
|
///
|
|
|
|
static MachineCodeEmitter *createDebugMachineCodeEmitter();
|
2002-12-02 21:21:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|