Finish support for Microsoft ML/MASM. May still be a few rough edges.
[oota-llvm.git] / include / llvm / CodeGen / MachineCodeEmitter.h
index 8b61c7c5d0a411f22c038546581ed51381e9dbec..eba7bae8acc55c4100334b1f5c1e2c0a548ca74f 100644 (file)
@@ -1,10 +1,10 @@
 //===-- llvm/CodeGen/MachineCodeEmitter.h - Code emission -------*- C++ -*-===//
-// 
+//
 //                     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 defines an abstract interface that is used by the machine code
 #define LLVM_CODEGEN_MACHINECODEEMITTER_H
 
 #include "llvm/Support/DataTypes.h"
+#include <map>
 
 namespace llvm {
 
 class MachineBasicBlock;
 class MachineConstantPool;
+class MachineJumpTableInfo;
 class MachineFunction;
 class MachineRelocation;
 class Value;
@@ -37,7 +39,7 @@ public:
   /// about to be code generated.
   ///
   virtual void startFunction(MachineFunction &F) {}
-  
+
   /// finishFunction - This callback is invoked when the specified function has
   /// finished code generation.
   ///
@@ -47,17 +49,28 @@ public:
   /// for the function.
   virtual void emitConstantPool(MachineConstantPool *MCP) {}
 
+  /// initJumpTableInfo - This callback is invoked by the JIT to allocate the
+  /// necessary memory to hold the jump tables.
+  virtual void initJumpTableInfo(MachineJumpTableInfo *MJTI) {}
+  
+  /// emitJumpTableInfo - This callback is invoked to output the jump tables
+  /// for the function.  In addition to a pointer to the MachineJumpTableInfo,
+  /// this function also takes a map of MBBs to addresses, so that the final
+  /// addresses of the MBBs can be written to the jump tables.
+  virtual void emitJumpTableInfo(MachineJumpTableInfo *MJTI,
+                                 std::map<MachineBasicBlock*,uint64_t> &MBBM) {}
+  
   /// 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(const Function &F, unsigned StubSize) {}
+  virtual void startFunctionStub(unsigned StubSize) {}
 
   /// finishFunctionStub - This callback is invoked to terminate a function
   /// stub.
   ///
-  virtual void *finishFunctionStub(const Function &F) { return 0; }
+  virtual void *finishFunctionStub(const Function *F) { return 0; }
 
   /// emitByte - This callback is invoked when a byte needs to be written to the
   /// output stream.
@@ -75,33 +88,33 @@ public:
   ///
   virtual void emitWord(unsigned W) = 0;
 
-  /// getGlobalValueAddress - This method is used to get the address of the
-  /// specified global value.  In some cases, however, the address may not yet
-  /// 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.
+  /// getCurrentPCValue - This returns the address that the next emitted byte
+  /// will be output to.
   ///
-  virtual uint64_t getGlobalValueAddress(GlobalValue *V) = 0;
-  virtual uint64_t getGlobalValueAddress(const char *SymName) = 0;
+  virtual uint64_t getCurrentPCValue() = 0;
 
-  // getConstantPoolEntryAddress - Return the address of the 'Index' entry in
-  // the constant pool that was last emitted with the 'emitConstantPool' method.
-  //
-  virtual uint64_t getConstantPoolEntryAddress(unsigned Index) = 0;
 
-  // getCurrentPCValue - This returns the address that the next emitted byte
-  // will be output to.
-  //
-  virtual uint64_t getCurrentPCValue() = 0;
+  /// getCurrentPCOffset - Return the offset from the start of the emitted
+  /// buffer that we are currently writing to.
+  virtual uint64_t getCurrentPCOffset() = 0;
+
+  /// addRelocation - Whenever a relocatable address is needed, it should be
+  /// noted with this interface.
+  virtual void addRelocation(const MachineRelocation &MR) = 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;
+  /// getConstantPoolEntryAddress - Return the address of the 'Index' entry in
+  /// the constant pool that was last emitted with the emitConstantPool method.
+  ///
+  virtual uint64_t getConstantPoolEntryAddress(unsigned Index) = 0;
+
+  /// getJumpTableEntryAddress - Return the address of the jump table with index
+  /// 'Index' in the function that last called initJumpTableInfo.
+  ///
+  virtual uint64_t getJumpTableEntryAddress(unsigned Index) = 0;
   
+  // allocateGlobal - Allocate some space for a global variable.
+  virtual unsigned char* allocateGlobal(unsigned size, unsigned alignment) = 0;
+
   /// createDebugEmitter - 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.