[llvm-commits] [llvm] r146599 - in /llvm/trunk: lib/MC/MCParser/AsmParser.cpp test/MC/AsmParser/directive_incbin.s

Kevin Enderby enderby at apple.com
Wed Dec 14 14:34:45 PST 2011


Author: enderby
Date: Wed Dec 14 16:34:45 2011
New Revision: 146599

URL: http://llvm.org/viewvc/llvm-project?rev=146599&view=rev
Log:
Improve the implementation of .incbin directive by replacing a loop by using
getStreamer().EmitBytes.  Suggestion by Benjamin Kramer!

Modified:
    llvm/trunk/lib/MC/MCParser/AsmParser.cpp
    llvm/trunk/test/MC/AsmParser/directive_incbin.s

Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=146599&r1=146598&r2=146599&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Wed Dec 14 16:34:45 2011
@@ -442,11 +442,11 @@
   if (NewBuf == -1)
     return true;
 
-  // Loop picking the bytes from the file and emitting them.
+  // Pick up the bytes from the file and emit them.
   const char *BufferStart = SrcMgr.getMemoryBuffer(NewBuf)->getBufferStart();
-  const char *BufferEnd = SrcMgr.getMemoryBuffer(NewBuf)->getBufferEnd();
-  for(const char *p = BufferStart; p < BufferEnd; p++)
-    getStreamer().EmitIntValue(*p, 1, DEFAULT_ADDRSPACE);
+  size_t BufferSize = SrcMgr.getMemoryBuffer(NewBuf)->getBufferSize();
+  std::string Data(BufferStart, BufferSize);
+  getStreamer().EmitBytes(Data, DEFAULT_ADDRSPACE);
 
   return false;
 }

Modified: llvm/trunk/test/MC/AsmParser/directive_incbin.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_incbin.s?rev=146599&r1=146598&r2=146599&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive_incbin.s (original)
+++ llvm/trunk/test/MC/AsmParser/directive_incbin.s Wed Dec 14 16:34:45 2011
@@ -3,7 +3,4 @@
 .data
 .incbin "incbin_abcd"
 
-# CHECK: .byte	97
-# CHECK: .byte	98
-# CHECK: .byte	99
-# CHECK: .byte	100
+# CHECK: .ascii	 "abcd\n"





More information about the llvm-commits mailing list