Initial support for carrying MachineInstrs in SUnits.
[oota-llvm.git] / include / llvm / CodeGen / MachineCodeEmitter.h
index 86684d7b9e4f4d788be976909e276ac7ebbf9b96..a14e4c13fb6f37202803b4f1dab15c335e49e2bb 100644 (file)
@@ -75,19 +75,16 @@ public:
   ///
   virtual bool finishFunction(MachineFunction &F) = 0;
   
-  /// 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 emitByte*/emitWord*
-  /// methods.
+  /// startGVStub - This callback is invoked when the JIT needs the
+  /// address of a GV (e.g. function) that has not been code generated yet.
+  /// The StubSize specifies the total size required by the stub.
   ///
-  virtual void startFunctionStub(const GlobalValue* F, unsigned StubSize,
-                                 unsigned Alignment = 1) = 0;
+  virtual void startGVStub(const GlobalValue* GV, unsigned StubSize,
+                           unsigned Alignment = 1) = 0;
 
-  /// finishFunctionStub - This callback is invoked to terminate a function
-  /// stub.
+  /// finishGVStub - This callback is invoked to terminate a GV stub.
   ///
-  virtual void *finishFunctionStub(const GlobalValue* F) = 0;
+  virtual void *finishGVStub(const GlobalValue* F) = 0;
 
   /// emitByte - This callback is invoked when a byte needs to be written to the
   /// output stream.
@@ -125,6 +122,42 @@ public:
     }
   }
 
+  /// emitDWordLE - This callback is invoked when a 64-bit word needs to be
+  /// written to the output stream in little-endian format.
+  ///
+  void emitDWordLE(uint64_t W) {
+    if (CurBufferPtr+8 <= BufferEnd) {
+      *CurBufferPtr++ = (unsigned char)(W >>  0);
+      *CurBufferPtr++ = (unsigned char)(W >>  8);
+      *CurBufferPtr++ = (unsigned char)(W >> 16);
+      *CurBufferPtr++ = (unsigned char)(W >> 24);
+      *CurBufferPtr++ = (unsigned char)(W >> 32);
+      *CurBufferPtr++ = (unsigned char)(W >> 40);
+      *CurBufferPtr++ = (unsigned char)(W >> 48);
+      *CurBufferPtr++ = (unsigned char)(W >> 56);
+    } else {
+      CurBufferPtr = BufferEnd;
+    }
+  }
+  
+  /// emitDWordBE - This callback is invoked when a 64-bit word needs to be
+  /// written to the output stream in big-endian format.
+  ///
+  void emitDWordBE(uint64_t W) {
+    if (CurBufferPtr+8 <= BufferEnd) {
+      *CurBufferPtr++ = (unsigned char)(W >> 56);
+      *CurBufferPtr++ = (unsigned char)(W >> 48);
+      *CurBufferPtr++ = (unsigned char)(W >> 40);
+      *CurBufferPtr++ = (unsigned char)(W >> 32);
+      *CurBufferPtr++ = (unsigned char)(W >> 24);
+      *CurBufferPtr++ = (unsigned char)(W >> 16);
+      *CurBufferPtr++ = (unsigned char)(W >>  8);
+      *CurBufferPtr++ = (unsigned char)(W >>  0);
+    } else {
+      CurBufferPtr = BufferEnd;
+    }
+  }
+
   /// emitAlignment - Move the CurBufferPtr pointer up the the specified
   /// alignment (saturated to BufferEnd of course).
   void emitAlignment(unsigned Alignment) {
@@ -207,7 +240,7 @@ public:
   /// allocateSpace - Allocate a block of space in the current output buffer,
   /// returning null (and setting conditions to indicate buffer overflow) on
   /// failure.  Alignment is the alignment in bytes of the buffer desired.
-  void *allocateSpace(intptr_t Size, unsigned Alignment) {
+  virtual void *allocateSpace(intptr_t Size, unsigned Alignment) {
     emitAlignment(Alignment);
     void *Result = CurBufferPtr;