[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
This commit is contained in:
Heejin Ahn 2018-11-01 20:32:15 +00:00
parent 2a4a060cab
commit dfc0a29e32
2 changed files with 16 additions and 2 deletions

View File

@ -303,7 +303,7 @@ public:
// assembly, so we add a dummy one explicitly (since we have no control // assembly, so we add a dummy one explicitly (since we have no control
// over signature tables here, we assume these will be regenerated when // over signature tables here, we assume these will be regenerated when
// the wasm module is generated). // the wasm module is generated).
if (BaseName == "block" || BaseName == "loop") { if (BaseName == "block" || BaseName == "loop" || BaseName == "try") {
Operands.push_back(make_unique<WebAssemblyOperand>( Operands.push_back(make_unique<WebAssemblyOperand>(
WebAssemblyOperand::Integer, NameLoc, NameLoc, WebAssemblyOperand::Integer, NameLoc, NameLoc,
WebAssemblyOperand::IntOp{-1})); WebAssemblyOperand::IntOp{-1}));

View File

@ -1,4 +1,4 @@
# RUN: llvm-mc -triple=wasm32-unknown-unknown -mattr=+simd128,+nontrapping-fptoint < %s | FileCheck %s # RUN: llvm-mc -triple=wasm32-unknown-unknown -mattr=+simd128,+nontrapping-fptoint,+exception-handling < %s | FileCheck %s
.text .text
.type test0,@function .type test0,@function
@ -46,6 +46,13 @@ test0:
# TODO: enable once instruction has been added. # TODO: enable once instruction has been added.
#i32x4.trunc_s/f32x4:sat #i32x4.trunc_s/f32x4:sat
i32.trunc_s/f32 i32.trunc_s/f32
try
.LBB0_3:
i32.catch 0
.LBB0_4:
catch_all
.LBB0_5:
end_try
#i32.trunc_s:sat/f32 #i32.trunc_s:sat/f32
get_global __stack_pointer@GLOBAL get_global __stack_pointer@GLOBAL
end_function end_function
@ -88,5 +95,12 @@ test0:
# CHECK-NEXT: get_local 5 # CHECK-NEXT: get_local 5
# CHECK-NEXT: f32x4.add # CHECK-NEXT: f32x4.add
# CHECK-NEXT: i32.trunc_s/f32 # CHECK-NEXT: i32.trunc_s/f32
# CHECK-NEXT: try
# CHECK-NEXT: .LBB0_3:
# CHECK-NEXT: i32.catch 0
# CHECK-NEXT: .LBB0_4:
# CHECK-NEXT: catch_all
# CHECK-NEXT: .LBB0_5:
# CHECK-NEXT: end_try
# CHECK-NEXT: get_global __stack_pointer@GLOBAL # CHECK-NEXT: get_global __stack_pointer@GLOBAL
# CHECK-NEXT: end_function # CHECK-NEXT: end_function