diff options
author | Sam Clegg <sbc@chromium.org> | 2017-09-15 20:34:47 +0000 |
---|---|---|
committer | Sam Clegg <sbc@chromium.org> | 2017-09-15 20:34:47 +0000 |
commit | 66a99e41cdc8d1ddd67860f7d97d861f654f1dbd (patch) | |
tree | 1a16a1862c0a527303792304cab8c61e1041cf7c /llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp | |
parent | 04370d3a820f65ac91faae9eb026ddea33b4f16e (diff) | |
download | bcm5719-llvm-66a99e41cdc8d1ddd67860f7d97d861f654f1dbd.tar.gz bcm5719-llvm-66a99e41cdc8d1ddd67860f7d97d861f654f1dbd.zip |
Change encodeU/SLEB128 to pad to certain number of bytes
Previously the 'Padding' argument was the number of padding
bytes to add. However most callers that use 'Padding' know
how many overall bytes they need to write. With the previous
code this would mean encoding the LEB once to find out how
many bytes it would occupy and then using this to calulate
the 'Padding' value.
See: https://reviews.llvm.org/D36595
Differential Revision: https://reviews.llvm.org/D37494
llvm-svn: 313393
Diffstat (limited to 'llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp')
-rw-r--r-- | llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp index 3e3b52fca56..10f787c3f7d 100644 --- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp +++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp @@ -116,10 +116,9 @@ void WebAssemblyMCCodeEmitter::encodeInstruction( } else if (MO.isExpr()) { const MCOperandInfo &Info = Desc.OpInfo[i]; llvm::MCFixupKind FixupKind; - size_t PaddedSize; + size_t PaddedSize = 5; if (Info.OperandType == WebAssembly::OPERAND_I32IMM) { FixupKind = MCFixupKind(WebAssembly::fixup_code_sleb128_i32); - PaddedSize = 5; } else if (Info.OperandType == WebAssembly::OPERAND_I64IMM) { FixupKind = MCFixupKind(WebAssembly::fixup_code_sleb128_i64); PaddedSize = 10; @@ -127,10 +126,8 @@ void WebAssemblyMCCodeEmitter::encodeInstruction( Info.OperandType == WebAssembly::OPERAND_OFFSET32 || Info.OperandType == WebAssembly::OPERAND_TYPEINDEX) { FixupKind = MCFixupKind(WebAssembly::fixup_code_uleb128_i32); - PaddedSize = 5; } else if (Info.OperandType == WebAssembly::OPERAND_GLOBAL) { FixupKind = MCFixupKind(WebAssembly::fixup_code_global_index); - PaddedSize = 5; } else { llvm_unreachable("unexpected symbolic operand kind"); } @@ -138,7 +135,7 @@ void WebAssemblyMCCodeEmitter::encodeInstruction( OS.tell() - Start, MO.getExpr(), FixupKind, MI.getLoc())); ++MCNumFixups; - encodeULEB128(0, OS, PaddedSize - 1); + encodeULEB128(0, OS, PaddedSize); } else { llvm_unreachable("unexpected operand kind"); } |