[PATCH] D44034: Reland "[WebAssembly] More uses of uint8_t for single byte values"

Heejin Ahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 2 11:18:28 PST 2018


aheejin created this revision.
aheejin added a reviewer: ncw.
Herald added subscribers: llvm-commits, sunfish, jgravelle-google, sbc100, dschuff, jfb.

Original change was https://reviews.llvm.org/D43991 (https://reviews.llvm.org/rL326541) and was reverted by https://reviews.llvm.org/rL326571 and
https://reviews.llvm.org/rL326572. This adds also the necessary MCCodeEmitter patch, thanks to @ncw.


Repository:
  rL LLVM

https://reviews.llvm.org/D44034

Files:
  lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp
  lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h


Index: lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h
===================================================================
--- lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h
+++ lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h
@@ -158,19 +158,19 @@
 static const unsigned StoreP2AlignOperandNo = 0;
 
 /// This is used to indicate block signatures.
-enum class ExprType {
-  Void    = -0x40,
-  I32     = -0x01,
-  I64     = -0x02,
-  F32     = -0x03,
-  F64     = -0x04,
-  I8x16   = -0x05,
-  I16x8   = -0x06,
-  I32x4   = -0x07,
-  F32x4   = -0x08,
-  B8x16   = -0x09,
-  B16x8   = -0x0a,
-  B32x4   = -0x0b
+enum class ExprType : unsigned {
+  Void    = 0x40,
+  I32     = 0x7F,
+  I64     = 0x7E,
+  F32     = 0x7D,
+  F64     = 0x7C,
+  I8x16   = 0x7B,
+  I16x8   = 0x7A,
+  I32x4   = 0x79,
+  F32x4   = 0x78,
+  B8x16   = 0x77,
+  B16x8   = 0x76,
+  B32x4   = 0x75
 };
 
 /// Instruction opcodes emitted via means other than CodeGen.
Index: lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp
===================================================================
--- lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp
+++ lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp
@@ -93,7 +93,9 @@
         } else if (Info.OperandType == WebAssembly::OPERAND_GLOBAL) {
           llvm_unreachable("wasm globals should only be accessed symbolicly");
         } else if (Info.OperandType == WebAssembly::OPERAND_SIGNATURE) {
-          encodeSLEB128(int64_t(MO.getImm()), OS);
+          assert(MO.getImm() > 0 && (MO.getImm() & ~0x3f) == 0x40 &&
+                 "Signature must be pre-encoded negative single-byte SLEB");
+          OS << uint8_t(MO.getImm());
         } else {
           encodeULEB128(uint64_t(MO.getImm()), OS);
         }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44034.136813.patch
Type: text/x-patch
Size: 1825 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180302/16021951/attachment.bin>


More information about the llvm-commits mailing list