add a "MCStreamer::EmitFill" method, and move the default implementation
authorChris Lattner <sabre@nondot.org>
Tue, 19 Jan 2010 18:45:47 +0000 (18:45 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 19 Jan 2010 18:45:47 +0000 (18:45 +0000)
(which just iteratively emits bytes) to MCStreamer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93888 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCStreamer.h
lib/MC/MCStreamer.cpp
tools/llvm-mc/AsmParser.cpp

index 5febed71b0415100793bffd18939531987b3d578..6e655a59053ecebe1f1ff15f140061cdd63208f2 100644 (file)
@@ -168,6 +168,11 @@ namespace llvm {
     /// match a native machine width.
     virtual void EmitValue(const MCExpr *Value, unsigned Size) = 0;
 
+    /// EmitFill - Emit NumBytes bytes worth of the value specified by
+    /// FillValue.  This implements directives such as '.space'.
+    virtual void EmitFill(uint64_t NumBytes, uint8_t FillValue = 0);
+    
+    
     /// EmitValueToAlignment - Emit some number of copies of @param Value until
     /// the byte alignment @param ByteAlignment is reached.
     ///
index 8a6dcdae7a4072219f8471d07b720059a09373bd..e43d9413093feb8c66de95fe69bfa41670dab3a2 100644 (file)
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/MC/MCStreamer.h"
+#include "llvm/MC/MCExpr.h"
 
 using namespace llvm;
 
@@ -16,3 +17,11 @@ MCStreamer::MCStreamer(MCContext &_Context) : Context(_Context), CurSection(0) {
 
 MCStreamer::~MCStreamer() {
 }
+
+/// EmitFill - Emit NumBytes bytes worth of the value specified by
+/// FillValue.  This implements directives such as '.space'.
+void MCStreamer::EmitFill(uint64_t NumBytes, uint8_t FillValue) {
+  const MCExpr *E = MCConstantExpr::Create(FillValue, getContext());
+  for (uint64_t i = 0, e = NumBytes; i != e; ++i)
+    EmitValue(E, 1);
+}
index 0e7c3443d5a2f64b2d90ce10cc2b02c9df967329..3a57953e65a5220bdf4577d9d2b79fc3455e8cd1 100644 (file)
@@ -1041,8 +1041,7 @@ bool AsmParser::ParseDirectiveSpace() {
     return TokError("invalid number of bytes in '.space' directive");
 
   // FIXME: Sometimes the fill expr is 'nop' if it isn't supplied, instead of 0.
-  for (uint64_t i = 0, e = NumBytes; i != e; ++i)
-    Out.EmitValue(MCConstantExpr::Create(FillExpr, getContext()), 1);
+  Out.EmitFill(NumBytes, FillExpr);
 
   return false;
 }