Improve the implementation of .incbin directive by replacing a loop by using

getStreamer().EmitBytes.  Suggestion by Benjamin Kramer!

llvm-svn: 146599
This commit is contained in:
Kevin Enderby 2011-12-14 22:34:45 +00:00
parent 9c88f32f94
commit bc6d6388c2
2 changed files with 5 additions and 8 deletions

View 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;
}

View 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"