diff options
-rw-r--r-- | include/llvm/MC/MCStreamer.h | 5 | ||||
-rw-r--r-- | lib/MC/MCStreamer.cpp | 9 | ||||
-rw-r--r-- | tools/llvm-mc/AsmParser.cpp | 3 |
3 files changed, 15 insertions, 2 deletions
diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index 5febed7..6e655a5 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -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. /// diff --git a/lib/MC/MCStreamer.cpp b/lib/MC/MCStreamer.cpp index 8a6dcda..e43d941 100644 --- a/lib/MC/MCStreamer.cpp +++ b/lib/MC/MCStreamer.cpp @@ -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); +} diff --git a/tools/llvm-mc/AsmParser.cpp b/tools/llvm-mc/AsmParser.cpp index 0e7c344..3a57953 100644 --- a/tools/llvm-mc/AsmParser.cpp +++ b/tools/llvm-mc/AsmParser.cpp @@ -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; } |