Add virtual dtor, expose a debug impl
[oota-llvm.git] / include / llvm / CodeGen / MachineCodeEmitter.h
1 //===-- llvm/CodeGen/MachineCodeEmitter.h - Code emission -------*- C++ -*-===//
2 //
3 // This file defines an abstract interface that is used by the machine code
4 // emission framework to output the code.  This allows machine code emission to
5 // be seperated from concerns such as resolution of call targets, and where the
6 // machine code will be written (memory or disk, f.e.).
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_CODEGEN_MACHINE_CODE_EMITTER_H
11 #define LLVM_CODEGEN_MACHINE_CODE_EMITTER_H
12
13 class MachineFunction;
14 class MachineBasicBlock;
15 class Value;
16
17 struct MachineCodeEmitter {
18   virtual ~MachineCodeEmitter() {}
19
20   /// startFunction - This callback is invoked when the specified function is
21   /// about to be code generated.
22   ///
23   virtual void startFunction(MachineFunction &F) {}
24   
25   /// finishFunction - This callback is invoked when the specified function has
26   /// finished code generation.
27   ///
28   virtual void finishFunction(MachineFunction &F) {}
29
30   /// startBasicBlock - This callback is invoked when a new basic block is about
31   /// to be emitted.
32   ///
33   virtual void startBasicBlock(MachineBasicBlock &BB) {}
34
35   /// emitByte - This callback is invoked when a byte needs to be written to the
36   /// output stream.
37   ///
38   virtual void emitByte(unsigned char B) {}
39
40   /// emitPCRelativeDisp - This callback is invoked when we need to write out a
41   /// PC relative displacement for the specified Value*.  This is used for call
42   /// and jump instructions typically.
43   ///
44   virtual void emitPCRelativeDisp(Value *V) {}
45
46
47   /// createDebugMachineCodeEmitter - Return a dynamically allocated machine
48   /// code emitter, which just prints the opcodes and fields out the cout.  This
49   /// can be used for debugging users of the MachineCodeEmitter interface.
50   ///
51   static MachineCodeEmitter *createDebugMachineCodeEmitter();
52 };
53
54 #endif