Skip to content

Commit 2e39897

Browse files
committedNov 1, 2018
[WebAssembly] Fix signature parsing for 'try' in AsmParser
Summary: Like `block` or `loop`, `try` can take an optional signature which can be omitted. This patch allows `try`'s signature to be omitted. Also added some tests for EH instructions. Reviewers: aardappel Subscribers: dschuff, sbc100, jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D53873 llvm-svn: 345888
1 parent c22b988 commit 2e39897

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed
 

Diff for: ‎llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
303303
// assembly, so we add a dummy one explicitly (since we have no control
304304
// over signature tables here, we assume these will be regenerated when
305305
// the wasm module is generated).
306-
if (BaseName == "block" || BaseName == "loop") {
306+
if (BaseName == "block" || BaseName == "loop" || BaseName == "try") {
307307
Operands.push_back(make_unique<WebAssemblyOperand>(
308308
WebAssemblyOperand::Integer, NameLoc, NameLoc,
309309
WebAssemblyOperand::IntOp{-1}));

Diff for: ‎llvm/test/MC/WebAssembly/basic-assembly.s

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# RUN: llvm-mc -triple=wasm32-unknown-unknown -mattr=+simd128,+nontrapping-fptoint < %s | FileCheck %s
1+
# RUN: llvm-mc -triple=wasm32-unknown-unknown -mattr=+simd128,+nontrapping-fptoint,+exception-handling < %s | FileCheck %s
22

33
.text
44
.type test0,@function
@@ -46,6 +46,13 @@ test0:
4646
# TODO: enable once instruction has been added.
4747
#i32x4.trunc_s/f32x4:sat
4848
i32.trunc_s/f32
49+
try
50+
.LBB0_3:
51+
i32.catch 0
52+
.LBB0_4:
53+
catch_all
54+
.LBB0_5:
55+
end_try
4956
#i32.trunc_s:sat/f32
5057
get_global __stack_pointer@GLOBAL
5158
end_function
@@ -88,5 +95,12 @@ test0:
8895
# CHECK-NEXT: get_local 5
8996
# CHECK-NEXT: f32x4.add
9097
# CHECK-NEXT: i32.trunc_s/f32
98+
# CHECK-NEXT: try
99+
# CHECK-NEXT: .LBB0_3:
100+
# CHECK-NEXT: i32.catch 0
101+
# CHECK-NEXT: .LBB0_4:
102+
# CHECK-NEXT: catch_all
103+
# CHECK-NEXT: .LBB0_5:
104+
# CHECK-NEXT: end_try
91105
# CHECK-NEXT: get_global __stack_pointer@GLOBAL
92106
# CHECK-NEXT: end_function

0 commit comments

Comments
 (0)
Please sign in to comment.