Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove (attr 0) from tag text format #3946

Merged
merged 1 commit into from
Jun 20, 2021
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
4 changes: 2 additions & 2 deletions src/passes/Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2685,7 +2685,7 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> {
emitImportHeader(curr);
o << "(tag ";
printName(curr->name, o);
o << maybeSpace << "(attr " << curr->attribute << ')' << maybeSpace;
o << maybeSpace;
printParamType(o, curr->sig.params, currModule);
o << "))";
o << maybeNewLine;
Expand All @@ -2695,7 +2695,7 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> {
o << '(';
printMedium(o, "tag ");
printName(curr->name, o);
o << maybeSpace << "(attr " << curr->attribute << ')' << maybeSpace;
o << maybeSpace;
printParamType(o, curr->sig.params, currModule);
o << ")" << maybeNewLine;
}
Expand Down
1 change: 0 additions & 1 deletion src/shared-constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ extern Name PRINT;
extern Name EXIT;
extern Name SHARED;
extern Name TAG;
extern Name ATTR;

} // namespace wasm

Expand Down
22 changes: 0 additions & 22 deletions src/wasm/wasm-s-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3109,14 +3109,6 @@ void SExpressionWasmBuilder::parseImport(Element& s) {
}
} else if (kind == ExternalKind::Tag) {
auto tag = make_unique<Tag>();
if (j >= inner.size()) {
throw ParseException("tag does not have an attribute", s.line, s.col);
}
auto& attrElem = *inner[j++];
if (!elementStartsWith(attrElem, ATTR) || attrElem.size() != 2) {
throw ParseException("invalid attribute", attrElem.line, attrElem.col);
}
tag->attribute = atoi(attrElem[1]->c_str());
j = parseTypeUse(inner, j, tag->sig);
tag->setName(name, hasExplicitName);
tag->module = module;
Expand Down Expand Up @@ -3498,20 +3490,6 @@ void SExpressionWasmBuilder::parseTag(Element& s, bool preParseImport) {
ex->kind = ExternalKind::Tag;
}

// Parse attribute
if (i >= s.size()) {
throw ParseException("tag does not have an attribute", s.line, s.col);
}
auto& attrElem = *s[i++];
if (!elementStartsWith(attrElem, ATTR) || attrElem.size() != 2) {
throw ParseException("invalid attribute", attrElem.line, attrElem.col);
}
if (!attrElem[1]->isStr()) {
throw ParseException(
"invalid attribute", attrElem[1]->line, attrElem[1]->col);
}
tag->attribute = atoi(attrElem[1]->c_str());

// Parse typeuse
i = parseTypeUse(s, i, tag->sig);

Expand Down
1 change: 0 additions & 1 deletion src/wasm/wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ Name PRINT("print");
Name EXIT("exit");
Name SHARED("shared");
Name TAG("tag");
Name ATTR("attr");

// Expressions

Expand Down
2 changes: 1 addition & 1 deletion test/binaryen.js/exception-handling.js.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(module
(type $i32_=>_none (func (param i32)))
(type $none_=>_none (func))
(tag $e (attr 0) (param i32))
(tag $e (param i32))
(func $test
(try $l0
(do
Expand Down
14 changes: 7 additions & 7 deletions test/binaryen.js/kitchen-sink.js.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7}
(import "module" "base" (global $a-global-imp i32))
(import "module" "base" (global $a-mut-global-imp (mut i32)))
(import "module" "base" (func $an-imported (param i32 f64) (result f32)))
(import "module" "base" (tag $a-tag-imp (attr 0) (param i32)))
(import "module" "base" (tag $a-tag-imp (param i32)))
(global $a-global i32 (i32.const 1))
(memory $0 (shared 1 256))
(data (i32.const 10) "hello, world")
(data "I am passive")
(table $t0 1 funcref)
(elem $e0 (i32.const 0) "$kitchen()sinker")
(tag $a-tag (attr 0) (param i32))
(tag $a-tag (param i32))
(export "kitchen_sinker" (func "$kitchen()sinker"))
(export "a-global-exp" (global $a-global))
(export "a-tag-exp" (tag $a-tag))
Expand Down Expand Up @@ -2220,14 +2220,14 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7}
(import "module" "base" (global $a-global-imp i32))
(import "module" "base" (global $a-mut-global-imp (mut i32)))
(import "module" "base" (func $an-imported (param i32 f64) (result f32)))
(import "module" "base" (tag $a-tag-imp (attr 0) (param i32)))
(import "module" "base" (tag $a-tag-imp (param i32)))
(global $a-global i32 (i32.const 1))
(memory $0 (shared 1 256))
(data (i32.const 10) "hello, world")
(data "I am passive")
(table $t0 1 funcref)
(elem $e0 (i32.const 0) "$kitchen()sinker")
(tag $a-tag (attr 0) (param i32))
(tag $a-tag (param i32))
(export "kitchen_sinker" (func "$kitchen()sinker"))
(export "a-global-exp" (global $a-global))
(export "a-tag-exp" (tag $a-tag))
Expand Down Expand Up @@ -4779,7 +4779,7 @@ module loaded from binary form:
(type $i32_i32_=>_none (func (param i32 i32)))
(type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
(global $a-global i32 (i32.const 3))
(tag $tag$0 (attr 0) (param i32 i32))
(tag $tag$0 (param i32 i32))
(func $adder (param $0 i32) (param $1 i32) (result i32)
(i32.add
(local.get $0)
Expand Down Expand Up @@ -4821,7 +4821,7 @@ test_parsing text:
(type $i32_=>_none (func (param i32)))
(type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
(global $a-global i32 (i32.const 3))
(tag $a-tag (attr 0) (param i32))
(tag $a-tag (param i32))
(func $adder (param $0 i32) (param $1 i32) (result i32)
(i32.add
(local.get $0)
Expand All @@ -4835,7 +4835,7 @@ module loaded from text form:
(type $i32_=>_none (func (param i32)))
(type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
(global $a-global i32 (i32.const 3))
(tag $a-tag (attr 0) (param i32))
(tag $a-tag (param i32))
(func $ADD_ER (param $0 i32) (param $1 i32) (result i32)
(i32.add
(local.get $0)
Expand Down
6 changes: 3 additions & 3 deletions test/binaryen.js/tag.js.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ getTagInfo={"name":"a-tag","module":"","base":"","attribute":0,"params":2,"resul
(module
(type $i32_=>_none (func (param i32)))
(type $i32_f32_=>_none (func (param i32 f32)))
(import "module" "base" (tag $a-tag-imp (attr 0) (param i32 f32)))
(tag $a-tag (attr 0) (param i32))
(import "module" "base" (tag $a-tag-imp (param i32 f32)))
(tag $a-tag (param i32))
(export "a-tag-exp" (tag $a-tag))
)

(module
(type $i32_f32_=>_none (func (param i32 f32)))
(import "module" "base" (tag $a-tag-imp (attr 0) (param i32 f32)))
(import "module" "base" (tag $a-tag-imp (param i32 f32)))
)

2 changes: 1 addition & 1 deletion test/br_to_try.wasm.fromBinary
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(module
(type $i32_=>_none (func (param i32)))
(type $none_=>_none (func))
(tag $tag$0 (attr 0) (param i32))
(tag $tag$0 (param i32))
(func $0
(try $label$3
(do
Expand Down
2 changes: 1 addition & 1 deletion test/break-within-catch.wasm.fromBinary
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(module
(type $i32_=>_none (func (param i32)))
(type $none_=>_none (func))
(tag $tag$0 (attr 0) (param i32))
(tag $tag$0 (param i32))
(func $0
(block $label$2
(try $label$3
Expand Down
2 changes: 1 addition & 1 deletion test/example/c-api-kitchen-sink.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ BinaryenFeatureAll: 16383
(table $0 1 1 funcref)
(elem $0 (table $0) (i32.const 0) func "$kitchen()sinker")
(elem $passive func "$kitchen()sinker")
(tag $a-tag (attr 0) (param i32))
(tag $a-tag (param i32))
(export "kitchen_sinker" (func "$kitchen()sinker"))
(export "mem" (memory $0))
(start $starter)
Expand Down
6 changes: 3 additions & 3 deletions test/example/module-splitting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ int main() {
(memory $mem (shared 3 42))
(table $tab 3 42 funcref)
(global $glob (mut i32) (i32.const 7))
(tag $e (attr 0) (param i32))
(tag $e (param i32))
))");

// Imported global stuff
Expand All @@ -85,7 +85,7 @@ int main() {
(import "env" "mem" (memory $mem (shared 3 42)))
(import "env" "tab" (table $tab 3 42 funcref))
(import "env" "glob" (global $glob (mut i32)))
(import "env" "e" (tag $e (attr 0) (param i32)))
(import "env" "e" (tag $e (param i32)))
))");

// Exported global stuff
Expand All @@ -94,7 +94,7 @@ int main() {
(memory $mem (shared 3 42))
(table $tab 3 42 funcref)
(global $glob (mut i32) (i32.const 7))
(tag $e (attr 0) (param i32))
(tag $e (param i32))
(export "mem" (memory $mem))
(export "tab" (table $tab))
(export "glob" (global $glob))
Expand Down
18 changes: 9 additions & 9 deletions test/example/module-splitting.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Before:
(global $glob (mut i32) (i32.const 7))
(memory $mem (shared 3 42))
(table $tab 3 42 funcref)
(tag $e (attr 0) (param i32))
(tag $e (param i32))
)
Keeping: <none>
After:
Expand All @@ -25,7 +25,7 @@ After:
(global $glob (mut i32) (i32.const 7))
(memory $mem (shared 3 42))
(table $tab 3 42 funcref)
(tag $e (attr 0) (param i32))
(tag $e (param i32))
(export "%memory" (memory $mem))
(export "%table" (table $tab))
(export "%global" (global $glob))
Expand All @@ -37,7 +37,7 @@ Secondary:
(import "primary" "%memory" (memory $mem (shared 3 42)))
(import "primary" "%table" (table $tab 3 42 funcref))
(import "primary" "%global" (global $glob (mut i32)))
(import "primary" "%tag" (tag $e (attr 0) (param i32)))
(import "primary" "%tag" (tag $e (param i32)))
)


Expand All @@ -47,7 +47,7 @@ Before:
(import "env" "mem" (memory $mem (shared 3 42)))
(import "env" "tab" (table $tab 3 42 funcref))
(import "env" "glob" (global $glob (mut i32)))
(import "env" "e" (tag $e (attr 0) (param i32)))
(import "env" "e" (tag $e (param i32)))
)
Keeping: <none>
After:
Expand All @@ -56,7 +56,7 @@ After:
(import "env" "mem" (memory $mem (shared 3 42)))
(import "env" "tab" (table $tab 3 42 funcref))
(import "env" "glob" (global $glob (mut i32)))
(import "env" "e" (tag $e (attr 0) (param i32)))
(import "env" "e" (tag $e (param i32)))
(export "%memory" (memory $mem))
(export "%table" (table $tab))
(export "%global" (global $glob))
Expand All @@ -68,7 +68,7 @@ Secondary:
(import "primary" "%memory" (memory $mem (shared 3 42)))
(import "primary" "%table" (table $tab 3 42 funcref))
(import "primary" "%global" (global $glob (mut i32)))
(import "primary" "%tag" (tag $e (attr 0) (param i32)))
(import "primary" "%tag" (tag $e (param i32)))
)


Expand All @@ -78,7 +78,7 @@ Before:
(global $glob (mut i32) (i32.const 7))
(memory $mem (shared 3 42))
(table $tab 3 42 funcref)
(tag $e (attr 0) (param i32))
(tag $e (param i32))
(export "mem" (memory $mem))
(export "tab" (table $tab))
(export "glob" (global $glob))
Expand All @@ -91,7 +91,7 @@ After:
(global $glob (mut i32) (i32.const 7))
(memory $mem (shared 3 42))
(table $tab 3 42 funcref)
(tag $e (attr 0) (param i32))
(tag $e (param i32))
(export "mem" (memory $mem))
(export "tab" (table $tab))
(export "glob" (global $glob))
Expand All @@ -103,7 +103,7 @@ Secondary:
(import "primary" "mem" (memory $mem (shared 3 42)))
(import "primary" "tab" (table $tab 3 42 funcref))
(import "primary" "glob" (global $glob (mut i32)))
(import "primary" "e" (tag $e (attr 0) (param i32)))
(import "primary" "e" (tag $e (param i32)))
)


Expand Down
8 changes: 4 additions & 4 deletions test/exception-handling.wast
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(module
(tag $e-i32 (attr 0) (param i32))
(tag $e-i64 (attr 0) (param i64))
(tag $e-i32-i64 (attr 0) (param i32 i64))
(tag $e-empty (attr 0))
(tag $e-i32 (param i32))
(tag $e-i64 (param i64))
(tag $e-i32-i64 (param i32 i64))
(tag $e-empty)

(func $foo)
(func $bar)
Expand Down
8 changes: 4 additions & 4 deletions test/exception-handling.wast.from-wast
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
(type $i32_=>_none (func (param i32)))
(type $i64_=>_none (func (param i64)))
(type $i32_i64_=>_none (func (param i32 i64)))
(tag $e-i32 (attr 0) (param i32))
(tag $e-i64 (attr 0) (param i64))
(tag $e-i32-i64 (attr 0) (param i32 i64))
(tag $e-empty (attr 0) (param))
(tag $e-i32 (param i32))
(tag $e-i64 (param i64))
(tag $e-i32-i64 (param i32 i64))
(tag $e-empty (param))
(func $foo
(nop)
)
Expand Down
8 changes: 4 additions & 4 deletions test/exception-handling.wast.fromBinary
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
(type $i32_=>_none (func (param i32)))
(type $i64_=>_none (func (param i64)))
(type $i32_i64_=>_none (func (param i32 i64)))
(tag $tag$0 (attr 0) (param i32))
(tag $tag$1 (attr 0) (param i64))
(tag $tag$2 (attr 0) (param i32 i64))
(tag $tag$3 (attr 0) (param))
(tag $tag$0 (param i32))
(tag $tag$1 (param i64))
(tag $tag$2 (param i32 i64))
(tag $tag$3 (param))
(func $foo
(nop)
)
Expand Down
8 changes: 4 additions & 4 deletions test/exception-handling.wast.fromBinary.noDebugInfo
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
(type $i32_=>_none (func (param i32)))
(type $i64_=>_none (func (param i64)))
(type $i32_i64_=>_none (func (param i32 i64)))
(tag $tag$0 (attr 0) (param i32))
(tag $tag$1 (attr 0) (param i64))
(tag $tag$2 (attr 0) (param i32 i64))
(tag $tag$3 (attr 0) (param))
(tag $tag$0 (param i32))
(tag $tag$1 (param i64))
(tag $tag$2 (param i32 i64))
(tag $tag$3 (param))
(func $0
(nop)
)
Expand Down
2 changes: 1 addition & 1 deletion test/lit/passes/coalesce-locals-eh.wast
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
(i32.const 1984)
)

(tag $e (attr 0))
(tag $e)
;; CHECK: (func $bug-cfg-traversal (param $0 i32) (result i32)
;; CHECK-NEXT: (try $try
;; CHECK-NEXT: (do
Expand Down
2 changes: 1 addition & 1 deletion test/lit/passes/code-folding-eh.wast
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
;; RUN: | filecheck %s

(module
(tag $e-i32 (attr 0) (param i32))
(tag $e-i32 (param i32))

;; CHECK: (func $pop-test
;; CHECK-NEXT: (block $folding-inner0
Expand Down
2 changes: 1 addition & 1 deletion test/lit/passes/code-pushing-eh.wast
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
;; RUN: wasm-opt %s --code-pushing -all -S -o - | filecheck %s

(module
(tag $e (attr 0) (param i32))
(tag $e (param i32))

;; CHECK: (func $cant-push-past-call
;; CHECK-NEXT: (local $x i32)
Expand Down
2 changes: 1 addition & 1 deletion test/lit/passes/dce-eh.wast
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
;; reachable
(module
(func $foo)
(tag $e (attr 0))
(tag $e)

;; CHECK: (func $try_unreachable
;; CHECK-NEXT: (try $try
Expand Down
2 changes: 1 addition & 1 deletion test/lit/passes/inlining-eh.wast
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
(module
;; ---------------------------------------------------------------------------
(import "a" "b" (func $foo (result i32)))
(tag $tag$0 (attr 0) (param i32))
(tag $tag$0 (param i32))
(func $callee-with-label
(try $label
(do)
Expand Down
Loading