[llvm] [WebAssembly] Handle block and polymorphic stack in AsmTypeCheck (PR #110770)
Derek Schuff via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 2 08:55:49 PDT 2024
================
@@ -0,0 +1,182 @@
+# RUN: llvm-mc -triple=wasm32-unknown-unknown -mattr=+exception-handling < %s | FileCheck %s
+# Check that it converts to .o without errors, but don't check any output:
+# RUN: llvm-mc -triple=wasm32-unknown-unknown -mattr=+exception-handling -filetype=obj -o %t.o < %s
+
+ .tagtype __cpp_exception i32
+
+block_branch_test:
+ .functype block_branch_test () -> ()
+
+ # Block input paramter / return tests
+
+ i32.const 0
+ block (i32) -> (i32)
+ end_block
+ drop
+
+ i32.const 0
+ i64.const 0
+ block (i32, i64) -> (i32, f32)
+ drop
+ f32.const 0.0
+ end_block
+ drop
+ drop
+
+ i32.const 0
+ loop (i32) -> (f32)
+ drop
+ f32.const 0.0
+ end_loop
+ drop
+
+ i32.const 0
+ i32.const 0
+ if (i32) -> (i32)
+ else
+ i32.popcnt
+ end_if
+ drop
+
+ try i32
+ i32.const 0
+ catch __cpp_exception
+ i32.clz
+ catch_all
+ i32.const 5
+ end_try
+ drop
+
+ i32.const 0
+ block (i32) -> (i32)
+ block (i32) -> (f32)
+ drop
+ f32.const 0.0
+ end_block
+ drop
+ i32.const 0
+ end_block
+ drop
+
+ # Branch tests
+
+ block f32
+ f32.const 0.0
+ i32.const 0
+ br_if 0
+ f32.const 1.0
+ br 0
+ # After 'br', we can pop any values from the polymorphic stack
+ i32.add
+ i32.sub
+ i32.mul
+ drop
+ end_block
+ drop
+
+ block () -> (f32, f64)
+ f32.const 0.0
+ f64.const 0.0
+ i32.const 0
+ br_if 0
+ block (f32, f64) -> (f32, f64)
+ i32.const 1
+ br_if 0
+ end_block
+ end_block
+ drop
+ drop
+
+ # Withina loop, branches target the start of the loop
----------------
dschuff wrote:
```suggestion
# Within a loop, branches target the start of the loop
```
https://github.com/llvm/llvm-project/pull/110770
More information about the llvm-commits
mailing list