From eda6530a187add28f06d9ab84d78b21b5001a6df Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Fri, 12 Jul 2024 16:48:06 -0400 Subject: [threads] ref.i31_shared (#6735) Implement `ref.i31_shared` the new instruction for creating references to shared i31s. Implement binary and text parsing and emitting as well as interpretation. Copy the upstream spec test for i31 and modify it so that all the heap types are shared. Comment out some parts that we do not yet support. --- test/lit/basic/shared-i31.wast | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 test/lit/basic/shared-i31.wast (limited to 'test/lit/basic') diff --git a/test/lit/basic/shared-i31.wast b/test/lit/basic/shared-i31.wast new file mode 100644 index 000000000..b448bcad3 --- /dev/null +++ b/test/lit/basic/shared-i31.wast @@ -0,0 +1,37 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. + +;; RUN: wasm-opt %s -all -S -o - | filecheck %s +;; RUN: wasm-opt %s -all --roundtrip -S -o - | filecheck %s + +(module + ;; CHECK: (type $0 (func (param (ref null (shared i31))) (result i32))) + + ;; CHECK: (type $1 (func (param i32) (result (ref (shared i31))))) + + ;; CHECK: (func $make (type $1) (param $0 i32) (result (ref (shared i31))) + ;; CHECK-NEXT: (ref.i31_shared + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $make (param i32) (result (ref (shared i31))) + (ref.i31_shared (local.get 0)) + ) + + ;; CHECK: (func $get_s (type $0) (param $0 (ref null (shared i31))) (result i32) + ;; CHECK-NEXT: (i31.get_s + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $get_s (param (ref null (shared i31))) (result i32) + (i31.get_s (local.get 0)) + ) + + ;; CHECK: (func $get_u (type $0) (param $0 (ref null (shared i31))) (result i32) + ;; CHECK-NEXT: (i31.get_u + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $get_u (param (ref null (shared i31))) (result i32) + (i31.get_u (local.get 0)) + ) +) -- cgit v1.2.3