[PATCH] D45280: WebAssembly: Never write more than 32-bits for WebAssembly::OPERAND_OFFSET32
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 4 15:31:13 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329238: [WebAssembly] Only write 32-bits for WebAssembly::OPERAND_OFFSET32 (authored by sbc, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D45280?vs=141025&id=141074#toc
Repository:
rL LLVM
https://reviews.llvm.org/D45280
Files:
llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp
llvm/trunk/test/MC/WebAssembly/offset.ll
Index: llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp
===================================================================
--- llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp
+++ llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp
@@ -23,9 +23,11 @@
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/MCSymbol.h"
+#include "llvm/Support/Debug.h"
#include "llvm/Support/EndianStream.h"
#include "llvm/Support/LEB128.h"
#include "llvm/Support/raw_ostream.h"
+
using namespace llvm;
#define DEBUG_TYPE "mccodeemitter"
@@ -86,8 +88,11 @@
assert(Desc.TSFlags == 0 &&
"WebAssembly non-variable_ops don't use TSFlags");
const MCOperandInfo &Info = Desc.OpInfo[i];
+ DEBUG(dbgs() << "Encoding immediate: type=" << int(Info.OperandType) << "\n");
if (Info.OperandType == WebAssembly::OPERAND_I32IMM) {
encodeSLEB128(int32_t(MO.getImm()), OS);
+ } else if (Info.OperandType == WebAssembly::OPERAND_OFFSET32) {
+ encodeULEB128(uint32_t(MO.getImm()), OS);
} else if (Info.OperandType == WebAssembly::OPERAND_I64IMM) {
encodeSLEB128(int64_t(MO.getImm()), OS);
} else if (Info.OperandType == WebAssembly::OPERAND_GLOBAL) {
Index: llvm/trunk/test/MC/WebAssembly/offset.ll
===================================================================
--- llvm/trunk/test/MC/WebAssembly/offset.ll
+++ llvm/trunk/test/MC/WebAssembly/offset.ll
@@ -0,0 +1,21 @@
+; RUN: llc -filetype=obj %s -o - | obj2yaml | FileCheck %s
+
+target triple = "wasm32-unknown-unknown-wasm"
+
+; CHECK: - Type: CODE
+; CHECK-NEXT: Functions:
+; CHECK-NEXT: - Index: 0
+; CHECK-NEXT: Locals:
+; CHECK-NEXT: Body: 41002802FFFFFFFF0F0B
+define i32 @load_i32_from_negative_address() {
+ %t = load i32, i32* inttoptr (i32 -1 to i32*)
+ ret i32 %t
+}
+
+; CHECK-NEXT: - Index: 1
+; CHECK-NEXT: Locals:
+; CHECK-NEXT: Body: 41002802030B
+define i32 @load_i32_from_wrapped_address() {
+ %t = load i32, i32* inttoptr (i32 4294967299 to i32*)
+ ret i32 %t
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45280.141074.patch
Type: text/x-patch
Size: 2257 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180404/b81185ca/attachment.bin>
More information about the llvm-commits
mailing list