Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions scripts/gen-s-parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,15 +627,12 @@
("i31.get_u", "makeI31Get(false)"),
("ref.test", "makeRefTest()"),
("ref.cast", "makeRefCast(false)"),
("ref.cast_desc", "makeRefCast(true)"), # Deprecated
("ref.cast_desc_eq", "makeRefCast(true)"),
("ref.get_desc", "makeRefGetDesc()"),
("br_on_null", "makeBrOnNull()"),
("br_on_non_null", "makeBrOnNull(true)"),
("br_on_cast", "makeBrOnCast(BrOnCast)"),
("br_on_cast_fail", "makeBrOnCast(BrOnCastFail)"),
("br_on_cast_desc", "makeBrOnCast(BrOnCastDescEq)"), # Deprecated
("br_on_cast_desc_fail", "makeBrOnCast(BrOnCastDescEqFail)"), # Deprecated
("br_on_cast_desc_eq", "makeBrOnCast(BrOnCastDescEq)"),
("br_on_cast_desc_eq_fail", "makeBrOnCast(BrOnCastDescEqFail)"),
("struct.new", "makeStructNew(false, false)"),
Expand Down Expand Up @@ -683,8 +680,6 @@
("array.atomic.rmw.xchg", "makeArrayRMW(RMWXchg)"),
("array.atomic.rmw.cmpxchg", "makeArrayCmpxchg()"),
("ref.as_non_null", "makeRefAs(RefAsNonNull)"),
("extern.internalize", "makeRefAs(AnyConvertExtern)"), # Deprecated
("extern.externalize", "makeRefAs(ExternConvertAny)"), # Deprecated
("any.convert_extern", "makeRefAs(AnyConvertExtern)"),
("extern.convert_any", "makeRefAs(ExternConvertAny)"),
("string.new_lossy_utf8_array", "makeStringNew(StringNewLossyUTF8Array)"),
Expand Down
84 changes: 17 additions & 67 deletions src/gen-s-parser.inc
Original file line number Diff line number Diff line change
Expand Up @@ -273,41 +273,19 @@ switch (buf[0]) {
case '_': {
switch (buf[11]) {
case 'd': {
switch (buf[15]) {
switch (buf[18]) {
case '\0':
if (op == "br_on_cast_desc"sv) {
if (op == "br_on_cast_desc_eq"sv) {
CHECK_ERR(makeBrOnCast(ctx, pos, annotations, BrOnCastDescEq));
return Ok{};
}
goto parse_error;
case '_': {
switch (buf[16]) {
case 'e': {
switch (buf[18]) {
case '\0':
if (op == "br_on_cast_desc_eq"sv) {
CHECK_ERR(makeBrOnCast(ctx, pos, annotations, BrOnCastDescEq));
return Ok{};
}
goto parse_error;
case '_':
if (op == "br_on_cast_desc_eq_fail"sv) {
CHECK_ERR(makeBrOnCast(ctx, pos, annotations, BrOnCastDescEqFail));
return Ok{};
}
goto parse_error;
default: goto parse_error;
}
}
case 'f':
if (op == "br_on_cast_desc_fail"sv) {
CHECK_ERR(makeBrOnCast(ctx, pos, annotations, BrOnCastDescEqFail));
return Ok{};
}
goto parse_error;
default: goto parse_error;
case '_':
if (op == "br_on_cast_desc_eq_fail"sv) {
CHECK_ERR(makeBrOnCast(ctx, pos, annotations, BrOnCastDescEqFail));
return Ok{};
}
}
goto parse_error;
default: goto parse_error;
}
}
Expand Down Expand Up @@ -430,29 +408,12 @@ switch (buf[0]) {
return Ok{};
}
goto parse_error;
case 'x': {
switch (buf[7]) {
case 'c':
if (op == "extern.convert_any"sv) {
CHECK_ERR(makeRefAs(ctx, pos, annotations, ExternConvertAny));
return Ok{};
}
goto parse_error;
case 'e':
if (op == "extern.externalize"sv) {
CHECK_ERR(makeRefAs(ctx, pos, annotations, ExternConvertAny));
return Ok{};
}
goto parse_error;
case 'i':
if (op == "extern.internalize"sv) {
CHECK_ERR(makeRefAs(ctx, pos, annotations, AnyConvertExtern));
return Ok{};
}
goto parse_error;
default: goto parse_error;
case 'x':
if (op == "extern.convert_any"sv) {
CHECK_ERR(makeRefAs(ctx, pos, annotations, ExternConvertAny));
return Ok{};
}
}
goto parse_error;
default: goto parse_error;
}
}
Expand Down Expand Up @@ -5008,23 +4969,12 @@ switch (buf[0]) {
return Ok{};
}
goto parse_error;
case '_': {
switch (buf[13]) {
case '\0':
if (op == "ref.cast_desc"sv) {
CHECK_ERR(makeRefCast(ctx, pos, annotations, true));
return Ok{};
}
goto parse_error;
case '_':
if (op == "ref.cast_desc_eq"sv) {
CHECK_ERR(makeRefCast(ctx, pos, annotations, true));
return Ok{};
}
goto parse_error;
default: goto parse_error;
case '_':
if (op == "ref.cast_desc_eq"sv) {
CHECK_ERR(makeRefCast(ctx, pos, annotations, true));
return Ok{};
}
}
goto parse_error;
default: goto parse_error;
}
}
Expand Down
42 changes: 4 additions & 38 deletions test/lit/extern-conversions.wast
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,16 @@

;; RUN: wasm-opt %s -all -O1 --roundtrip -S -o - | filecheck %s


(module
;; CHECK: (type $0 (func (param externref) (result anyref)))

;; CHECK: (type $1 (func (param (ref any)) (result (ref extern))))
;; CHECK: (type $0 (func (param (ref any)) (result (ref extern))))

;; CHECK: (type $2 (func (param anyref) (result externref)))
;; CHECK: (type $1 (func (param externref) (result anyref)))

;; CHECK: (export "ext" (func $extern.convert_any))

;; CHECK: (export "int" (func $any.convert_extern))

;; CHECK: (export "legacy.1" (func $legacy_notation.1))

;; CHECK: (export "legacy.2" (func $legacy_notation.2))

;; CHECK: (func $extern.convert_any (type $1) (param $0 (ref any)) (result (ref extern))
;; CHECK: (func $extern.convert_any (type $0) (param $0 (ref any)) (result (ref extern))
;; CHECK-NEXT: (extern.convert_any
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: )
Expand All @@ -32,7 +25,7 @@
)
)

;; CHECK: (func $any.convert_extern (type $0) (param $0 externref) (result anyref)
;; CHECK: (func $any.convert_extern (type $1) (param $0 externref) (result anyref)
;; CHECK-NEXT: (any.convert_extern
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: )
Expand All @@ -42,31 +35,4 @@
(local.get $x)
)
)

;; CHECK: (func $legacy_notation.1 (type $0) (param $0 externref) (result anyref)
;; CHECK-NEXT: (ref.as_non_null
;; CHECK-NEXT: (any.convert_extern
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $legacy_notation.1 (export "legacy.1") (param $x (ref null extern)) (result (ref null any))
(extern.internalize
(ref.as_non_null ;; Add this to avoid the entire function being merged with
;; another.
(local.get $x)
)
)
)

;; CHECK: (func $legacy_notation.2 (type $2) (param $0 anyref) (result externref)
;; CHECK-NEXT: (extern.convert_any
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $legacy_notation.2 (export "legacy.2") (param $x (ref null any)) (result (ref null extern))
(extern.externalize
(local.get $x)
)
)
)
62 changes: 0 additions & 62 deletions test/lit/ref-cast-desc.wast

This file was deleted.

Loading