]> granicus.if.org Git - llvm/commitdiff
[WebAssembly] Allow multivalue signatures in object files
authorThomas Lively <tlively@google.com>
Fri, 18 Oct 2019 20:27:30 +0000 (20:27 +0000)
committerThomas Lively <tlively@google.com>
Fri, 18 Oct 2019 20:27:30 +0000 (20:27 +0000)
Summary:
Also changes the wasm YAML format to reflect the possibility of having
multiple return types and to put the returns after the params for
consistency with the binary encoding.

Reviewers: aheejin, sbc100

Subscribers: dschuff, jgravelle-google, hiraditya, sunfish, arphaman, rupprecht, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D69156

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@375283 91177308-0d34-0410-b5e6-96231b3b80d8

35 files changed:
include/llvm/ObjectYAML/WasmYAML.h
lib/Object/WasmObjectFile.cpp
lib/ObjectYAML/WasmEmitter.cpp
lib/ObjectYAML/WasmYAML.cpp
test/CodeGen/WebAssembly/multivalue.ll
test/CodeGen/WebAssembly/tailcall.ll
test/MC/WebAssembly/assembler-binary.ll
test/MC/WebAssembly/comdat.ll
test/MC/WebAssembly/data-section.s
test/MC/WebAssembly/event-section.ll
test/MC/WebAssembly/external-func-address.ll
test/MC/WebAssembly/libcall.ll
test/MC/WebAssembly/reloc-pic.s
test/MC/WebAssembly/type-index.s
test/MC/WebAssembly/types.ll
test/MC/WebAssembly/weak-alias.ll
test/Object/wasm-duplicate-name.test
test/Object/wasm-relocs-and-producers.yaml
test/ObjectYAML/wasm/code_section.yaml
test/ObjectYAML/wasm/event_section.yaml
test/ObjectYAML/wasm/export_section.yaml
test/ObjectYAML/wasm/function_section.yaml
test/ObjectYAML/wasm/import_memory_shared.yaml
test/ObjectYAML/wasm/import_section.yaml
test/ObjectYAML/wasm/invalid_section_order.yaml
test/ObjectYAML/wasm/linking_section.yaml
test/ObjectYAML/wasm/name_section.yaml
test/ObjectYAML/wasm/start_section.yaml
test/ObjectYAML/wasm/type_section.yaml
test/ObjectYAML/wasm/weak_symbols.yaml
test/tools/llvm-nm/wasm/exports.yaml
test/tools/llvm-nm/wasm/imports.yaml
test/tools/llvm-nm/wasm/weak-symbols.yaml
test/tools/llvm-readobj/wasm-imports.test
tools/obj2yaml/wasm2yaml.cpp

index 2411dc7ac17d8420420dbc878804e9814509950d..15a8cc215020b2797c4f906603d9e897c24b3fbc 100644 (file)
@@ -145,7 +145,7 @@ struct Signature {
   uint32_t Index;
   SignatureForm Form = wasm::WASM_TYPE_FUNC;
   std::vector<ValueType> ParamTypes;
-  ValueType ReturnType;
+  std::vector<ValueType> ReturnTypes;
 };
 
 struct SymbolInfo {
index 470283efb294d326284c351c48323c52230762d5..014b403556df5497e281e4e04bbe4f9561713e65 100644 (file)
@@ -881,12 +881,9 @@ Error WasmObjectFile::parseTypeSection(ReadContext &Ctx) {
       Sig.Params.push_back(wasm::ValType(ParamType));
     }
     uint32_t ReturnCount = readVaruint32(Ctx);
-    if (ReturnCount) {
-      if (ReturnCount != 1) {
-        return make_error<GenericBinaryError>(
-            "Multiple return types not supported", object_error::parse_failed);
-      }
-      Sig.Returns.push_back(wasm::ValType(readUint8(Ctx)));
+    while (ReturnCount--) {
+      uint32_t ReturnType = readUint8(Ctx);
+      Sig.Returns.push_back(wasm::ValType(ReturnType));
     }
     Signatures.push_back(std::move(Sig));
   }
index 42c57d42ad786085da50f35e9fa037bad06d9b94..debc040587a87fa9c9a625eeb608ce43bf52e65a 100644 (file)
@@ -334,12 +334,9 @@ void WasmWriter::writeSectionContent(raw_ostream &OS,
     encodeULEB128(Sig.ParamTypes.size(), OS);
     for (auto ParamType : Sig.ParamTypes)
       writeUint8(OS, ParamType);
-    if (Sig.ReturnType == wasm::WASM_TYPE_NORESULT) {
-      encodeULEB128(0, OS);
-    } else {
-      encodeULEB128(1, OS);
-      writeUint8(OS, Sig.ReturnType);
-    }
+    encodeULEB128(Sig.ReturnTypes.size(), OS);
+    for (auto ReturnType : Sig.ReturnTypes)
+      writeUint8(OS, ReturnType);
   }
 }
 
index 04f569479592fd33596ce382d3d054412ae552a0..232d5122004a7c6fcc00c3e30042a294e9b62d2b 100644 (file)
@@ -295,8 +295,8 @@ void ScalarEnumerationTraits<WasmYAML::SectionType>::enumeration(
 void MappingTraits<WasmYAML::Signature>::mapping(
     IO &IO, WasmYAML::Signature &Signature) {
   IO.mapRequired("Index", Signature.Index);
-  IO.mapRequired("ReturnType", Signature.ReturnType);
   IO.mapRequired("ParamTypes", Signature.ParamTypes);
+  IO.mapRequired("ReturnTypes", Signature.ReturnTypes);
 }
 
 void MappingTraits<WasmYAML::Table>::mapping(IO &IO, WasmYAML::Table &Table) {
@@ -560,7 +560,6 @@ void ScalarEnumerationTraits<WasmYAML::ValueType>::enumeration(
   ECase(V128);
   ECase(FUNCREF);
   ECase(FUNC);
-  ECase(NORESULT);
 #undef ECase
 }
 
index 877851f6a3621ded6fd42dd2e5389594dc6ef749..ee32852ef5791c2ee192c76272ee0448d7a6b934 100644 (file)
@@ -1,4 +1,5 @@
 ; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+multivalue | FileCheck %s
+; RUN: llc < %s --filetype=obj -mattr=+multivalue | obj2yaml | FileCheck %s --check-prefix OBJ
 
 ; Test that the multivalue returns, function types, and block types
 ; work as expected.
@@ -42,3 +43,19 @@ loop:
 ; CHECK-NEXT: .int8 43
 ; CHECK-NEXT: .int8 10
 ; CHECK-NEXT: .ascii "multivalue"
+
+; OBJ-LABEL:  - Type:            TYPE
+; OBJ-NEXT:     Signatures:
+; OBJ-NEXT:       - Index:           0
+; OBJ-NEXT:         ParamTypes:
+; OBJ-NEXT:           - I32
+; OBJ-NEXT:           - I32
+; OBJ-NEXT:         ReturnTypes:
+; OBJ-NEXT:           - I32
+; OBJ-NEXT:           - I32
+; OBJ-NEXT:       - Index:           1
+; OBJ-NEXT:         ParamTypes:
+; OBJ-NEXT:           - I32
+; OBJ-NEXT:         ReturnTypes:
+; OBJ-NEXT:           - I32
+; OBJ-NEXT:           - I64
index a277b4f7bc2087e7bf022edc1b0f2c2be422a977..f4d4499bcef7e2f87957613d6a6f264095fd1b97 100644 (file)
@@ -215,12 +215,13 @@ define i1 @mismatched_return_trunc() {
 ; return-called functions include the proper return types
 
 ; YAML-LABEL: - Index:           8
-; YAML-NEXT:    ReturnType:      I32
 ; YAML-NEXT:    ParamTypes:
 ; YAML-NEXT:      - I32
 ; YAML-NEXT:      - F32
 ; YAML-NEXT:      - I64
 ; YAML-NEXT:      - F64
+; YAML-NEXT:    ReturnTypes:
+; YAML-NEXT:      - I32
 define i32 @unique_caller(i32 (i32, float, i64, double)** %p) {
   %f = load i32 (i32, float, i64, double)*, i32 (i32, float, i64, double)** %p
   %v = tail call i32 %f(i32 0, float 0., i64 0, double 0.)
index 3683d63e435bf3e0940022e785101b9eec3c5c66..35fa4111117b74b9c9319347ac3a81ed5c24a5b8 100644 (file)
@@ -38,12 +38,12 @@ entry:
 ; CHECK-NEXT:   - Type:            TYPE
 ; CHECK-NEXT:     Signatures:
 ; CHECK-NEXT:       - Index:           0
-; CHECK-NEXT:         ReturnType:      NORESULT
 ; CHECK-NEXT:         ParamTypes:
 ; CHECK-NEXT:           - I32
+; CHECK-NEXT:         ReturnTypes:     []
 ; CHECK-NEXT:       - Index:           1
-; CHECK-NEXT:         ReturnType:      NORESULT
 ; CHECK-NEXT:         ParamTypes:      []
+; CHECK-NEXT:         ReturnTypes:     []
 ; CHECK-NEXT:   - Type:            IMPORT
 ; CHECK-NEXT:     Imports:
 ; CHECK-NEXT:       - Module:          env
index ecc5e5be27a49f8e85623ee66fb26991a028634c..e50f5bf1cc96af0bcc5470382c8c889379650ded 100644 (file)
@@ -28,8 +28,9 @@ define linkonce_odr i32 @sharedFn() #1 comdat($sharedComdat) {
 ; CHECK-NEXT:   - Type:            TYPE
 ; CHECK-NEXT:     Signatures:
 ; CHECK-NEXT:       - Index:           0
-; CHECK-NEXT:         ReturnType:      I32
-; CHECK-NEXT:         ParamTypes:
+; CHECK-NEXT:         ParamTypes:      []
+; CHECK-NEXT:         ReturnTypes:
+; CHECK-NEXT:           - I32
 ; CHECK-NEXT:   - Type:            IMPORT
 ; CHECK-NEXT:     Imports:
 ; CHECK-NEXT:       - Module:          env
index 70d9de2bb934133c25042abaf3a0b4707e254b9b..52e60f6d4a7d1efb5f09ef6d9c9a5c0a6e94aeda 100644 (file)
@@ -35,8 +35,9 @@ test0:
 # BIN-NEXT:   - Type:            TYPE
 # BIN-NEXT:     Signatures:
 # BIN-NEXT:       - Index:           0
-# BIN-NEXT:         ReturnType:      I32
 # BIN-NEXT:         ParamTypes:      []
+# BIN-NEXT:         ReturnTypes:
+# BIN-NEXT:           - I32
 # BIN-NEXT:   - Type:            IMPORT
 # BIN-NEXT:     Imports:
 # BIN-NEXT:       - Module:          env
index 2b5b5bba9fe6b3eda32eb343172f110c042ed97d..b662c290d3c7e0b4f4f1d1e45445bd34744eb721 100644 (file)
@@ -19,13 +19,14 @@ define i32 @test_throw1(i8* %p) {
 ; CHECK-NEXT:   - Type:            TYPE
 ; CHECK-NEXT:     Signatures:
 ; CHECK-NEXT:       - Index:           0
-; CHECK-NEXT:         ReturnType:      I32
 ; CHECK-NEXT:         ParamTypes:
 ; CHECK-NEXT:           - I32
+; CHECK-NEXT:         ReturnTypes:
+; CHECK-NEXT:           - I32
 ; CHECK-NEXT:       - Index:           1
-; CHECK-NEXT:         ReturnType:      NORESULT
 ; CHECK-NEXT:         ParamTypes:
 ; CHECK-NEXT:           - I32
+; CHECK-NEXT:         ReturnTypes:      []
 
 ; CHECK:        - Type:            EVENT
 ; CHECK-NEXT:     Events:
index 9d3b33592e0b98f36ee6876da5e3171cda6b5659..9c16c02a4a0f42c41e0ee4c273d4d244ae4225fd 100644 (file)
@@ -27,15 +27,16 @@ define void @call(i32) {
 ; CHECK-NEXT:   - Type:            TYPE
 ; CHECK-NEXT:     Signatures:
 ; CHECK-NEXT:       - Index:           0
-; CHECK-NEXT:         ReturnType:      NORESULT
 ; CHECK-NEXT:         ParamTypes:
 ; CHECK-NEXT:           - I32
+; CHECK-NEXT:         ReturnTypes:     []
 ; CHECK-NEXT:       - Index:           1
-; CHECK-NEXT:         ReturnType:      I32
 ; CHECK-NEXT:         ParamTypes:
 ; CHECK-NEXT:           - I32
 ; CHECK-NEXT:           - I32
 ; CHECK-NEXT:           - I32
+; CHECK-NEXT:         ReturnTypes:
+; CHECK-NEXT:           - I32
 ; CHECK:        - Type:            IMPORT
 ; CHECK-NEXT:     Imports:
 ; CHECK:            - Module:          env
index b2253583898fc44d10ba19a9d29afa65b852c77b..9f8abba70c0e029f60a541361d6c707735dfbca6 100644 (file)
@@ -17,14 +17,15 @@ declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture writeonly, i8* nocapture r
 ; CHECK-NEXT:   - Type:            TYPE
 ; CHECK-NEXT:     Signatures:
 ; CHECK-NEXT:       - Index:           0
-; CHECK-NEXT:         ReturnType:      NORESULT
 ; CHECK-NEXT:         ParamTypes:
 ; CHECK-NEXT:           - I32
 ; CHECK-NEXT:           - I32
+; CHECK-NEXT:         ReturnTypes:     []
 ; CHECK-NEXT:       - Index:           1
-; CHECK-NEXT:         ReturnType:      I32
 ; CHECK-NEXT:         ParamTypes:
 ; CHECK-NEXT:           - I32
 ; CHECK-NEXT:           - I32
 ; CHECK-NEXT:           - I32
+; CHECK-NEXT:         ReturnTypes:
+; CHECK-NEXT:           - I32
 ; CHECK-NEXT:   - Type:            IMPORT
index 2b7ef54a3a5b70cb430fe1ccf5ce8d5ee8738d47..626f8d993e3c6543036372a02edadde8c4ca1a55 100644 (file)
@@ -52,8 +52,9 @@ hidden_func:
 # CHECK-NEXT:   - Type:            TYPE
 # CHECK-NEXT:     Signatures:
 # CHECK-NEXT:       - Index:           0
-# CHECK-NEXT:         ReturnType:      I32
 # CHECK-NEXT:         ParamTypes:      []
+# CHECK-NEXT:         ReturnTypes:
+# CHECK-NEXT:           - I32
 # CHECK-NEXT:   - Type:            IMPORT
 # CHECK-NEXT:     Imports:
 # CHECK-NEXT:       - Module:          env
index 707f6aa98943800ae375ef16beab19861051dcef..9c77434589f58eccb5118547e427da0831e2de3b 100644 (file)
@@ -22,13 +22,15 @@ test0:
 # BIN-NEXT:   - Type:            TYPE
 # BIN-NEXT:     Signatures:
 # BIN-NEXT:       - Index:           0
-# BIN-NEXT:         ReturnType:      I32
 # BIN-NEXT:         ParamTypes:
 # BIN-NEXT:           - I32
+# BIN-NEXT:         ReturnTypes:
+# BIN-NEXT:           - I32
 # BIN-NEXT:       - Index:           1
-# BIN-NEXT:         ReturnType:      F64
 # BIN-NEXT:         ParamTypes:
 # BIN-NEXT:           - F64
+# BIN-NEXT:         ReturnTypes:
+# BIN-NEXT:           - F64
 # BIN-NEXT:   - Type:            IMPORT
 # BIN-NEXT:     Imports:
 # BIN-NEXT:       - Module:          env
@@ -64,4 +66,3 @@ test0:
 # BIN-NEXT:         Flags:           [ BINDING_LOCAL ]
 # BIN-NEXT:         Function:        0
 # BIN-NEXT: ...
-
index 6eeeef2f5311d6f1614d6547c32a04d755c7a20a..c049d3ce0e82d7661df3586a1b28ad890390366e 100644 (file)
@@ -37,32 +37,37 @@ define void @vararg(i32, i32, ...) {
 ; CHECK-LABEL: - Type: TYPE
 ; CHECK-NEXT:    Signatures:
 ; CHECK-NEXT:       - Index: 0
-; CHECK-NEXT:         ReturnType: NORESULT
 ; CHECK-NEXT:         ParamTypes:
+; CHECK-NEXT:         ReturnTypes: []
 ; CHECK-NEXT:       - Index: 1
-; CHECK-NEXT:         ReturnType: I32
 ; CHECK-NEXT:         ParamTypes:
+; CHECK-NEXT:         ReturnTypes:
+; CHECK-NEXT:           - I32
 ; CHECK-NEXT:       - Index: 2
-; CHECK-NEXT:         ReturnType: I64
 ; CHECK-NEXT:         ParamTypes:
+; CHECK-NEXT:         ReturnTypes:
+; CHECK-NEXT:           - I64
 ; CHECK-NEXT:       - Index: 3
-; CHECK-NEXT:         ReturnType: F32
 ; CHECK-NEXT:         ParamTypes:
+; CHECK-NEXT:         ReturnTypes:
+; CHECK-NEXT:           - F32
 ; CHECK-NEXT:       - Index: 4
-; CHECK-NEXT:         ReturnType: F64
 ; CHECK-NEXT:         ParamTypes:
+; CHECK-NEXT:         ReturnTypes:
+; CHECK-NEXT:           - F64
 ; CHECK-NEXT:       - Index: 5
-; CHECK-NEXT:         ReturnType: V128
 ; CHECK-NEXT:         ParamTypes:
+; CHECK-NEXT:         ReturnTypes:
+; CHECK-NEXT:           - V128
 ; CHECK-NEXT:       - Index: 6
-; CHECK-NEXT:         ReturnType: NORESULT
 ; CHECK-NEXT:         ParamTypes:
 ; CHECK-NEXT:           - I32
+; CHECK-NEXT:         ReturnTypes: []
 ; CHECK-NEXT:       - Index: 7
-; CHECK-NEXT:         ReturnType: NORESULT
 ; CHECK-NEXT:         ParamTypes:
 ; CHECK-NEXT:           - I32
 ; CHECK-NEXT:           - I32
 ; CHECK-NEXT:           - I32
+; CHECK-NEXT:         ReturnTypes: []
 ; should be no additional types
-; CHECK-NOT: ReturnType
+; CHECK-NOT: ReturnTypes
index 20a27edd343a204393acb9b41771513e0bbb5517..c9c707e69e2a3e9f51055fb6783623349a133119 100644 (file)
@@ -49,8 +49,9 @@ entry:
 ; CHECK:        - Type:            TYPE
 ; CHECK-NEXT:     Signatures:
 ; CHECK-NEXT:       - Index:           0
-; CHECK-NEXT:         ReturnType:      I32
 ; CHECK-NEXT:         ParamTypes:
+; CHECK-NEXT:         ReturnTypes:
+; CHECK-NEXT:           - I32
 ; CHECK-NEXT:   - Type:            IMPORT
 ; CHECK-NEXT:     Imports:
 ; CHECK-NEXT:       - Module:          env
index 1bf20778028001944dc54150f33c8cf963674a09..666291c9524086d78855695d78b5ddf3f0cc25d0 100644 (file)
@@ -7,9 +7,10 @@ Sections:
   - Type:            TYPE
     Signatures:
       - Index:           0
-        ReturnType:      I32
         ParamTypes:
           - I32
+        ReturnTypes:
+          - I32
   - Type:            IMPORT
     Imports:
       - Module:          foo
index 01ad2bb89fbf4abc5a764d8f18395c908179e34b..2bdc12e4619d6ab42c02e5883e66bce1f2eb1418 100644 (file)
@@ -16,8 +16,8 @@ Sections:
   - Type:            TYPE
     Signatures:
       - Index:           0
-        ReturnType:      NORESULT
         ParamTypes:      []
+        ReturnTypes:     []
   - Type:            IMPORT
     Imports:
       - Module:          env
index 0171938a6a30437fdf8015d4be3fb2e5ad363a3c..dad75e081ea794ee1c057a4caa5f500c13e21cb4 100644 (file)
@@ -6,14 +6,15 @@ Sections:
   - Type:            TYPE
     Signatures:
       - Index:           0
-        ReturnType:      F32
         ParamTypes:
           - I32
+        ReturnTypes:
+          - F32
       - Index:           1
-        ReturnType:      NORESULT
         ParamTypes:
           - I32
           - I64
+        ReturnTypes:     []
   - Type:            FUNCTION
     FunctionTypes:
       - 0
@@ -59,14 +60,15 @@ Sections:
 # CHECK:  - Type:            TYPE
 # CHECK:    Signatures:
 # CHECK:      - Index:           0
-# CHECK:        ReturnType:      F32
 # CHECK:        ParamTypes:
 # CHECK:          - I32
+# CHECK:        ReturnTypes:
+# CHECK:          - F32
 # CHECK:      - Index:           1
-# CHECK:        ReturnType:      NORESULT
 # CHECK:        ParamTypes:
 # CHECK:          - I32
 # CHECK:          - I64
+# CHECK:        ReturnTypes:     []
 # CHECK:  - Type:            CODE
 # CHECK:    Relocations:
 # CHECK:      - Type:            R_WASM_TABLE_INDEX_SLEB
index 91683bd3da4c72ca66672348f1ba6d1e274dec84..5c64cc815529f865e8796a8148734ac44c0c4209 100644 (file)
@@ -7,13 +7,14 @@ Sections:
   - Type:            TYPE
     Signatures:
       - Index:           0
-        ReturnType:      I32
         ParamTypes:
           - I32
+        ReturnTypes:
+          - I32
       - Index:           1
-        ReturnType:      NORESULT
         ParamTypes:
           - I32
+        ReturnTypes:      []
   - Type:            FUNCTION
     FunctionTypes:   [ 0 ]
   - Type:            EVENT
@@ -53,13 +54,14 @@ Sections:
 # CHECK-NEXT:   - Type:            TYPE
 # CHECK-NEXT:     Signatures:
 # CHECK-NEXT:       - Index:           0
-# CHECK-NEXT:         ReturnType:      I32
 # CHECK-NEXT:         ParamTypes:
 # CHECK-NEXT:           - I32
+# CHECK-NEXT:         ReturnTypes:
+# CHECK-NEXT:           - I32
 # CHECK-NEXT:       - Index:           1
-# CHECK-NEXT:         ReturnType:      NORESULT
 # CHECK-NEXT:         ParamTypes:
 # CHECK-NEXT:           - I32
+# CHECK-NEXT:         ReturnTypes:     []
 # CHECK-NEXT:   - Type:            FUNCTION
 # CHECK-NEXT:     FunctionTypes:   [ 0 ]
 # CHECK-NEXT:   - Type:            EVENT
index af72f1368110fd7daceff5632e9c96d72f3ea7a9..4b3487cec5a555b3949718dea6e81040c3d111ab 100644 (file)
@@ -6,8 +6,8 @@ Sections:
   - Type:            TYPE
     Signatures:
       - Index:           0
-        ReturnType:      NORESULT
         ParamTypes:
+        ReturnTypes:     []
   - Type:            FUNCTION
     FunctionTypes: [ 0, 0 ]
   - Type:            GLOBAL
@@ -25,7 +25,7 @@ Sections:
           Opcode:          I64_CONST
           Value:           64
   - Type:            EXPORT
-    Exports:         
+    Exports:
       - Name:            function_export
         Kind:            FUNCTION
         Index:           1
@@ -52,7 +52,7 @@ Sections:
 # CHECK:   Version:           0x00000001
 # CHECK: Sections:
 # CHECK:   - Type:            EXPORT
-# CHECK:     Exports:         
+# CHECK:     Exports:
 # CHECK:       - Name:            function_export
 # CHECK:         Kind:            FUNCTION
 # CHECK:         Index:           1
index d31614452952451f6e7875e137313a97980daa54..8bfe4fa7f58a4fe9205f9919a5429f7e0186924b 100644 (file)
@@ -6,12 +6,12 @@ Sections:
   - Type:            TYPE
     Signatures:
       - Index:           0
-        ReturnType:      NORESULT
         ParamTypes:
+        ReturnTypes:     []
       - Index:           1
-        ReturnType:      NORESULT
         ParamTypes:
           - I32
+        ReturnTypes:     []
   - Type:            FUNCTION
     FunctionTypes: [ 1, 0 ]
   - Type:            CODE
index 849bdc5314d1b1b7270fb5f67ca3e50027272d5c..b6ca9fa44f96ce51c34a202d167055a1ed3c7518 100644 (file)
@@ -6,9 +6,10 @@ Sections:
   - Type:            TYPE
     Signatures:
       - Index:           0
-        ReturnType:      I32
         ParamTypes:
           - I32
+        ReturnTypes:
+          - I32
   - Type:            IMPORT
     Imports:
       - Module:          foo
@@ -25,7 +26,7 @@ Sections:
 # CHECK:   Version:           0x00000001
 # CHECK: Sections:
 # CHECK:   - Type:            IMPORT
-# CHECK:     Imports:         
+# CHECK:     Imports:
 # CHECK:       - Module:          foo
 # CHECK:         Field:           imported_memory
 # CHECK:         Kind:            MEMORY
index 90de6f0fec7f0db3f559af67928fd32a0564375b..2df2f3928ecb07e3d08c40c552cda90df0794f32 100644 (file)
@@ -6,9 +6,10 @@ Sections:
   - Type:            TYPE
     Signatures:
       - Index:           0
-        ReturnType:      I32
         ParamTypes:
           - I32
+        ReturnTypes:
+          - I32
   - Type:            IMPORT
     Imports:
       - Module:          foo
@@ -42,7 +43,7 @@ Sections:
 # CHECK:   Version:           0x00000001
 # CHECK: Sections:
 # CHECK:   - Type:            IMPORT
-# CHECK:     Imports:         
+# CHECK:     Imports:
 # CHECK:       - Module:          foo
 # CHECK:         Field:           imported_function
 # CHECK:         Kind:            FUNCTION
index 4e3581ec5ebe3298b5293b49a02cc8fc7be98a43..71767576979b0a305073e7c811d873d05c2cc4a1 100644 (file)
@@ -7,8 +7,8 @@ Sections:
   - Type:            TYPE
     Signatures:
       - Index:           0
-        ReturnType:      NORESULT
         ParamTypes:      []
+        ReturnTypes:     []
   - Type:            CODE
     Functions:
       - Index:           0
index 39827410b0ecb2cb627b795c30278b7ed3c629b9..2e3da8791c7bb67a84bd902390de687b1acf7d5b 100644 (file)
@@ -6,9 +6,10 @@ Sections:
   - Type:            TYPE
     Signatures:
       - Index:           0
-        ReturnType:      I32
         ParamTypes:
           - I32
+        ReturnTypes:
+          - I32
   - Type:            IMPORT
     Imports:
       - Module:          foo
index f7a489d75426e2a961ff96224c02216f15aaef7f..a22b25771e15ced80a8be1e0af0a6f8cc9c169ee 100644 (file)
@@ -6,9 +6,10 @@ Sections:
   - Type:            TYPE
     Signatures:
       - Index:           0
-        ReturnType:      I32
         ParamTypes:
           - I32
+        ReturnTypes:
+          - I32
   - Type:            IMPORT
     Imports:
       - Module:          foo
index 5d57c1b7a05115136e7ed599efa65d86c5aaa0e7..754adea5a18bc024e11f05a22af9fb96b189b785 100644 (file)
@@ -7,8 +7,8 @@ Sections:
   - Type:            TYPE
     Signatures:
       - Index:           0
-        ReturnType:      NORESULT
-        ParamTypes:
+        ParamTypes:      []
+        ReturnTypes:     []
   - Type:            FUNCTION
     FunctionTypes: [ 0, 0, 0 ]
   - Type:            START
index a87949fed06b5f0e5c9200eaebc57dd055ddc6fb..beb3a16e766aadecccd2991402a825579050453c 100644 (file)
@@ -6,15 +6,17 @@ Sections:
   - Type:            TYPE
     Signatures:
       - Index:           0
-        ReturnType:      I32
         ParamTypes:
           - F32
           - F32
+        ReturnTypes:
+          - I32
       - Index:           1
-        ReturnType:      I64
         ParamTypes:
           - F64
           - F64
+        ReturnTypes:
+          - I64
 ...
 # CHECK: --- !WASM
 # CHECK: FileHeader:
@@ -23,13 +25,15 @@ Sections:
 # CHECK:  - Type:            TYPE
 # CHECK:    Signatures:
 # CHECK:      - Index:           0
-# CHECK:        ReturnType:      I32
 # CHECK:        ParamTypes:
 # CHECK:          - F32
 # CHECK:          - F32
+# CHECK:        ReturnTypes:
+# CHECK:          - I32
 # CHECK:      - Index:           1
-# CHECK:        ReturnType:      I64
 # CHECK:        ParamTypes:
 # CHECK:          - F64
 # CHECK:          - F64
+# CHECK:        ReturnTypes:
+# CHECK:          - I64
 # CHECK: ...
index fb85b829a371b9de95adb73a5cfbfcfacfc59ab2..82bc70c244f497f8cf896bec43807ad5fd762377 100644 (file)
@@ -6,12 +6,13 @@ Sections:
   - Type:            TYPE
     Signatures:
       - Index:           0
-        ReturnType:      I32
-        ParamTypes:
+        ParamTypes:      []
+        ReturnTypes:
+          - I32
   - Type:            FUNCTION
     FunctionTypes:   [ 0, 0 ]
   - Type:            GLOBAL
-    Globals:         
+    Globals:
       - Index:       0
         Type:        I32
         Mutable:     false
@@ -19,7 +20,7 @@ Sections:
           Opcode:          I32_CONST
           Value:           1
   - Type:            EXPORT
-    Exports:         
+    Exports:
       - Name:            function_export
         Kind:            FUNCTION
         Index:           1
@@ -54,7 +55,7 @@ Sections:
 # CHECK:   Version:           0x00000001
 # CHECK: Sections:
 # CHECK:   - Type:            EXPORT
-# CHECK:     Exports:         
+# CHECK:     Exports:
 # CHECK:       - Name:            function_export
 # CHECK:         Kind:            FUNCTION
 # CHECK:         Index:           1
index eddcbc22c1f17933f1e04d195b8631c734a02a85..15c98ae2bf4a22142db7a326a81cb67cbb08a8d3 100644 (file)
@@ -9,9 +9,10 @@ Sections:
   - Type:            TYPE
     Signatures:
       - Index:           0
-        ReturnType:      I32
         ParamTypes:
           - I32
+        ReturnTypes:
+          - I32
   - Type:            FUNCTION
     FunctionTypes: [ 0 ]
   - Type:            GLOBAL
index 2ea0d0f13fe34fd52fda8a9483a7ac8616762477..37b0ce486c35912aea171bdb313214335a73d878 100644 (file)
@@ -9,9 +9,10 @@ Sections:
   - Type:            TYPE
     Signatures:
       - Index:           0
-        ReturnType:      I32
         ParamTypes:
           - I32
+        ReturnTypes:
+          - I32
   - Type:            IMPORT
     Imports:
       - Module:          env
index a81559402dc62c95982190f4e2caf6b031a17c80..d8e4cece0fef775cdc268b5af88bf0c51a392969 100644 (file)
@@ -9,9 +9,10 @@ Sections:
   - Type:            TYPE
     Signatures:
       - Index:           0
-        ReturnType:      I32
         ParamTypes:
           - I32
+        ReturnTypes:
+          - I32
   - Type:            IMPORT
     Imports:
       - Module:          env
index fd1e5c8e641dea7a1a7d14a1e6d95133dfcd5027..6eb19673d99b3b9da3a33fe0e0331bf5fcd2bf8a 100644 (file)
@@ -9,11 +9,12 @@ Sections:
   - Type:            TYPE
     Signatures:      
       - Index:           0
-        ReturnType:      I32
         ParamTypes:      []
+        ReturnTypes:
+          - I32
       - Index:           1
-        ReturnType:      NORESULT
         ParamTypes:      []
+        ReturnTypes:     []
   - Type:            IMPORT
     Imports:         
       - Module:          env
index 7a540974d500380c67b75f73a9b73b34c9cbf7f5..ea7a1e983bd43c6eac9bb033c26aaefeacb1e310 100644 (file)
@@ -198,13 +198,10 @@ ErrorOr<WasmYAML::Object *> WasmDumper::dump() {
       for (const auto &FunctionSig : Obj.types()) {
         WasmYAML::Signature Sig;
         Sig.Index = Index++;
-        Sig.ReturnType = wasm::WASM_TYPE_NORESULT;
-        assert(FunctionSig.Returns.size() <= 1 &&
-               "Functions with multiple returns are not supported");
-        if (FunctionSig.Returns.size())
-          Sig.ReturnType = static_cast<uint32_t>(FunctionSig.Returns[0]);
         for (const auto &ParamType : FunctionSig.Params)
           Sig.ParamTypes.emplace_back(static_cast<uint32_t>(ParamType));
+        for (const auto &ReturnType : FunctionSig.Returns)
+          Sig.ReturnTypes.emplace_back(static_cast<uint32_t>(ReturnType));
         TypeSec->Signatures.push_back(Sig);
       }
       S = std::move(TypeSec);