Skip to content

Commit c9c711a

Browse files
committedAug 14, 2018
[WebAssembly] Fix encoding of non-SIMD vector-typed instructions
Previously SIMD_I was the same as a normal instruction except for the addition of a HasSIM128 predicate. However, rL339186 changed the encoding of SIMD_I instructions to automatically contain the SIMD prefix byte. This broke the encoding of non-SIMD vector-typed instructions, which had instantiated SIMD_I. This CL corrects this error. Reviewers: aheejin Subscribers: sunfish, jgravelle-google, sbc100, llvm-commits Differential Revision: https://reviews.llvm.org/D50682 Patch by Thomas Lively (tlively) llvm-svn: 339710
1 parent a1e55d2 commit c9c711a

File tree

2 files changed

+32
-29
lines changed

2 files changed

+32
-29
lines changed
 

‎llvm/lib/Target/WebAssembly/WebAssemblyInstrCall.td

+25-24
Original file line numberDiff line numberDiff line change
@@ -52,34 +52,35 @@ multiclass CALL<WebAssemblyRegClass vt, string prefix> {
5252
}
5353

5454
multiclass SIMD_CALL<ValueType vt, string prefix> {
55-
defm CALL_#vt : SIMD_I<(outs V128:$dst), (ins function32_op:$callee,
56-
variable_ops),
57-
(outs), (ins function32_op:$callee),
58-
[(set (vt V128:$dst),
59-
(WebAssemblycall1 (i32 imm:$callee)))],
60-
!strconcat(prefix, "call\t$dst, $callee"),
61-
!strconcat(prefix, "call\t$callee"),
62-
0x10>;
55+
56+
defm CALL_#vt : I<(outs V128:$dst), (ins function32_op:$callee, variable_ops),
57+
(outs), (ins function32_op:$callee),
58+
[(set (vt V128:$dst),
59+
(WebAssemblycall1 (i32 imm:$callee)))],
60+
!strconcat(prefix, "call\t$dst, $callee"),
61+
!strconcat(prefix, "call\t$callee"),
62+
0x10>,
63+
Requires<[HasSIMD128]>;
6364

6465
let isCodeGenOnly = 1 in {
65-
defm PCALL_INDIRECT_#vt : SIMD_I<(outs V128:$dst),
66-
(ins I32:$callee, variable_ops),
67-
(outs), (ins I32:$callee),
68-
[(set (vt V128:$dst),
69-
(WebAssemblycall1 I32:$callee))],
70-
"PSEUDO CALL INDIRECT\t$callee",
71-
"PSEUDO CALL INDIRECT\t$callee">;
66+
defm PCALL_INDIRECT_#vt : I<(outs V128:$dst),
67+
(ins I32:$callee, variable_ops),
68+
(outs), (ins I32:$callee),
69+
[(set (vt V128:$dst),
70+
(WebAssemblycall1 I32:$callee))],
71+
"PSEUDO CALL INDIRECT\t$callee",
72+
"PSEUDO CALL INDIRECT\t$callee">,
73+
Requires<[HasSIMD128]>;
7274
} // isCodeGenOnly = 1
7375

74-
defm CALL_INDIRECT_#vt : SIMD_I<(outs V128:$dst),
75-
(ins TypeIndex:$type, i32imm:$flags,
76-
variable_ops),
77-
(outs), (ins TypeIndex:$type, i32imm:$flags),
78-
[],
79-
!strconcat(prefix,
80-
"call_indirect\t$dst"),
81-
!strconcat(prefix, "call_indirect\t$type"),
82-
0x11>;
76+
defm CALL_INDIRECT_#vt : I<(outs V128:$dst),
77+
(ins TypeIndex:$type, i32imm:$flags, variable_ops),
78+
(outs), (ins TypeIndex:$type, i32imm:$flags),
79+
[],
80+
!strconcat(prefix, "call_indirect\t$dst"),
81+
!strconcat(prefix, "call_indirect\t$type"),
82+
0x11>,
83+
Requires<[HasSIMD128]>;
8384
}
8485

8586
let Uses = [SP32, SP64], isCall = 1 in {

‎llvm/lib/Target/WebAssembly/WebAssemblyInstrControl.td

+7-5
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,16 @@ multiclass RETURN<WebAssemblyRegClass vt> {
103103
}
104104

105105
multiclass SIMD_RETURN<ValueType vt> {
106-
defm RETURN_#vt : SIMD_I<(outs), (ins V128:$val), (outs), (ins),
107-
[(WebAssemblyreturn (vt V128:$val))],
108-
"return \t$val", "return", 0x0f>;
106+
defm RETURN_#vt : I<(outs), (ins V128:$val), (outs), (ins),
107+
[(WebAssemblyreturn (vt V128:$val))],
108+
"return \t$val", "return", 0x0f>,
109+
Requires<[HasSIMD128]>;
109110
// Equivalent to RETURN_#vt, for use at the end of a function when wasm
110111
// semantics return by falling off the end of the block.
111112
let isCodeGenOnly = 1 in
112-
defm FALLTHROUGH_RETURN_#vt : SIMD_I<(outs), (ins V128:$val), (outs), (ins),
113-
[]>;
113+
defm FALLTHROUGH_RETURN_#vt : I<(outs), (ins V128:$val), (outs), (ins),
114+
[]>,
115+
Requires<[HasSIMD128]>;
114116
}
115117

116118
let isTerminator = 1, hasCtrlDep = 1, isBarrier = 1 in {

0 commit comments

Comments
 (0)
Please sign in to comment.