llvm.org GIT mirror llvm / a22a6f2
[WebAssembly] Add V128 value type to binary format Summary: Adds the necessary support to lib/ObjectYAML and fixes SIMD calls to allow the tests to work. Also removes some dead code that would otherwise have to have been updated. Reviewers: aheejin, dschuff, sbc100 Subscribers: jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D52105 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342689 91177308-0d34-0410-b5e6-96231b3b80d8 Thomas Lively 1 year, 1 month ago
9 changed file(s) with 93 addition(s) and 25 deletion(s). Raw diff Collapse all Expand all
190190 WASM_TYPE_I64 = 0x7E,
191191 WASM_TYPE_F32 = 0x7D,
192192 WASM_TYPE_F64 = 0x7C,
193 WASM_TYPE_V128 = 0x7B,
193194 WASM_TYPE_ANYFUNC = 0x70,
194195 WASM_TYPE_EXCEPT_REF = 0x68,
195196 WASM_TYPE_FUNC = 0x60,
224225 I64 = WASM_TYPE_I64,
225226 F32 = WASM_TYPE_F32,
226227 F64 = WASM_TYPE_F64,
228 V128 = WASM_TYPE_V128,
227229 EXCEPT_REF = WASM_TYPE_EXCEPT_REF,
228230 };
229231
451451 ECase(I64);
452452 ECase(F32);
453453 ECase(F64);
454 ECase(V128);
454455 ECase(ANYFUNC);
455456 ECase(FUNC);
456457 ECase(NORESULT);
257257 llvm_unreachable("unsupported type");
258258 }
259259 }
260
261 const char *llvm::WebAssembly::TypeToString(wasm::ValType Type) {
262 switch (Type) {
263 case wasm::ValType::I32:
264 return "i32";
265 case wasm::ValType::I64:
266 return "i64";
267 case wasm::ValType::F32:
268 return "f32";
269 case wasm::ValType::F64:
270 return "f64";
271 case wasm::ValType::EXCEPT_REF:
272 return "except_ref";
273 }
274 llvm_unreachable("unsupported type");
275 }
5050 namespace WebAssembly {
5151
5252 const char *TypeToString(MVT Ty);
53 const char *TypeToString(wasm::ValType Type);
5453
5554 } // end namespace WebAssembly
5655
132132 return wasm::ValType::F32;
133133 case MVT::f64:
134134 return wasm::ValType::F64;
135 case MVT::v16i8:
136 case MVT::v8i16:
137 case MVT::v4i32:
138 case MVT::v2i64:
139 case MVT::v4f32:
140 case MVT::v2f64:
141 return wasm::ValType::V128;
135142 case MVT::ExceptRef:
136143 return wasm::ValType::EXCEPT_REF;
137144 default:
8888 defm "" : CALL;
8989 defm "" : CALL;
9090 defm "" : CALL;
91 defm "" : SIMD_CALL;
92 defm "" : SIMD_CALL;
93 defm "" : SIMD_CALL;
94 defm "" : SIMD_CALL;
95 defm "" : SIMD_CALL;
96 defm "" : SIMD_CALL2f64, "f64x2.">;
91 defm "" : SIMD_CALL16i8, "v128.">;
92 defm "" : SIMD_CALL;
93 defm "" : SIMD_CALL;
94 defm "" : SIMD_CALL;
95 defm "" : SIMD_CALL;
96 defm "" : SIMD_CALL;
9797
9898 defm CALL_VOID : I<(outs), (ins function32_op:$callee, variable_ops),
9999 (outs), (ins function32_op:$callee),
148148 return wasm::ValType::F32;
149149 if (RC == &WebAssembly::F64RegClass)
150150 return wasm::ValType::F64;
151 if (RC == &WebAssembly::V128RegClass)
152 return wasm::ValType::V128;
151153 llvm_unreachable("Unexpected register class");
152154 }
153155
None ; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers -wasm-temporary-workarounds=false | FileCheck %s
1 ; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers -fast-isel -fast-isel-abort=1 -wasm-temporary-workarounds=false | FileCheck %s
0 ; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers -wasm-temporary-workarounds=false -mattr=+sign-ext,+simd128 | FileCheck %s
1 ; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers -fast-isel -fast-isel-abort=1 -wasm-temporary-workarounds=false -mattr=+sign-ext,+simd128 | FileCheck %s
22
33 ; Test that basic call operations assemble as expected.
44
1111 declare i64 @i64_nullary()
1212 declare float @float_nullary()
1313 declare double @double_nullary()
14 declare <16 x i8> @v128_nullary()
1415 declare void @void_nullary()
1516
1617 ; CHECK-LABEL: call_i32_nullary:
4748 define double @call_double_nullary() {
4849 %r = call double @double_nullary()
4950 ret double %r
51 }
52
53 ; CHECK-LABEL: call_v128_nullary:
54 ; CHECK-NEXT: .result v128{{$}}
55 ; CHECK-NEXT: {{^}} v128.call $push[[NUM:[0-9]+]]=, v128_nullary@FUNCTION{{$}}
56 ; CHECK-NEXT: return $pop[[NUM]]{{$}}
57 define <16 x i8> @call_v128_nullary() {
58 %r = call <16 x i8> @v128_nullary()
59 ret <16 x i8> %r
5060 }
5161
5262 ; CHECK-LABEL: call_void_nullary:
99109 define i32 @call_indirect_i32(i32 ()* %callee) {
100110 %t = call i32 %callee()
101111 ret i32 %t
112 }
113
114 ; CHECK-LABEL: call_indirect_v128:
115 ; CHECK-NEXT: .param i32{{$}}
116 ; CHECK-NEXT: .result v128{{$}}
117 ; CHECK-NEXT: get_local $push[[L0:[0-9]+]]=, 0{{$}}
118 ; CHECK-NEXT: {{^}} v128.call_indirect $push[[NUM:[0-9]+]]=, $pop[[L0]]{{$}}
119 ; CHECK-NEXT: return $pop[[NUM]]{{$}}
120 define <16 x i8> @call_indirect_v128(<16 x i8> ()* %callee) {
121 %t = call <16 x i8> %callee()
122 ret <16 x i8> %t
102123 }
103124
104125 ; CHECK-LABEL: call_indirect_arg:
0 ; RUN: llc -wasm-enable-unimplemented-simd -mattr=+sign-ext,+simd128 -filetype=obj %s -o - | obj2yaml | FileCheck %s
1
2 target triple = "wasm32-unknown-unknown"
3
4 declare i32 @i32()
5 declare i64 @i64()
6 declare float @f32()
7 declare double @f64()
8 declare <16 x i8> @v16i8()
9 declare <8 x i16> @v8i16()
10 declare <4 x i32> @v4i32()
11 declare <2 x i64> @v2i64()
12 declare <4 x float> @v4f32()
13 declare <2 x double> @v2f64()
14
15 define void @f1() {
16 entry:
17 %tmp1 = call i32 @i32()
18 %tmp2 = call i64 @i64()
19 %tmp3 = call float @f32()
20 %tmp4 = call double @f64()
21 %tmp5 = call <16 x i8> @v16i8()
22 %tmp6 = call <8 x i16> @v8i16()
23 %tmp7 = call <4 x i32> @v4i32()
24 %tmp8 = call <2 x i64> @v2i64()
25 %tmp9 = call <4 x float> @v4f32()
26 %tmp10 = call <2 x double> @v2f64()
27 ret void
28 }
29
30 ; CHECK-LABEL: - Type: TYPE
31 ; CHECK-NEXT: Signatures:
32 ; CHECK-NEXT: - Index: 0
33 ; CHECK-NEXT: ReturnType: NORESULT
34 ; CHECK-NEXT: ParamTypes:
35 ; CHECK-NEXT: - Index: 1
36 ; CHECK-NEXT: ReturnType: I32
37 ; CHECK-NEXT: ParamTypes:
38 ; CHECK-NEXT: - Index: 2
39 ; CHECK-NEXT: ReturnType: I64
40 ; CHECK-NEXT: ParamTypes:
41 ; CHECK-NEXT: - Index: 3
42 ; CHECK-NEXT: ReturnType: F32
43 ; CHECK-NEXT: ParamTypes:
44 ; CHECK-NEXT: - Index: 4
45 ; CHECK-NEXT: ReturnType: F64
46 ; CHECK-NEXT: ParamTypes:
47 ; CHECK-NEXT: - Index: 5
48 ; CHECK-NEXT: ReturnType: V128
49 ; CHECK-NEXT: ParamTypes:
50 ; should be no additional types
51 ; CHECK-NOT: ReturnType