Improve the implementation of .incbin directive by replacing a loop by using
authorKevin Enderby <enderby@apple.com>
Wed, 14 Dec 2011 22:34:45 +0000 (22:34 +0000)
committerKevin Enderby <enderby@apple.com>
Wed, 14 Dec 2011 22:34:45 +0000 (22:34 +0000)
getStreamer().EmitBytes.  Suggestion by Benjamin Kramer!

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

lib/MC/MCParser/AsmParser.cpp
test/MC/AsmParser/directive_incbin.s

index 93492377ff0637815566d813cb062f0e7dbe4a82..4ab60c1cdc1dd145c9bd1ef1a4c42b7a27c83289 100644 (file)
@@ -442,11 +442,11 @@ bool AsmParser::ProcessIncbinFile(const std::string &Filename) {
   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;
 }
index 230573c6488d70a6961643951affafa601916fc0..55f9c7951ffaa6f74d06fc6fc3ed5ec84b64d789 100644 (file)
@@ -3,7 +3,4 @@
 .data
 .incbin "incbin_abcd"
 
-# CHECK: .byte 97
-# CHECK: .byte 98
-# CHECK: .byte 99
-# CHECK: .byte 100
+# CHECK: .ascii         "abcd\n"