Skip to content

Commit 20efebc

Browse files
tlivelyarichardson
authored andcommitted
[WebAssembly] Renumber SIMD opcodes
Summary: As described in WebAssembly/simd#209. This is the final reorganization of the SIMD opcode space before standardization. It has been landed in concert with corresponding changes in other projects in the WebAssembly SIMD ecosystem. Reviewers: aheejin Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D79224
2 parents 547112a + e0f5284 commit 20efebc

File tree

10 files changed

+392
-495
lines changed

10 files changed

+392
-495
lines changed

clang/include/clang/Basic/BuiltinsWebAssembly.def

-2
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@ TARGET_BUILTIN(__builtin_wasm_qfms_f64x2, "V2dV2dV2dV2d", "nc", "unimplemented-s
153153

154154
TARGET_BUILTIN(__builtin_wasm_trunc_saturate_s_i32x4_f32x4, "V4iV4f", "nc", "simd128")
155155
TARGET_BUILTIN(__builtin_wasm_trunc_saturate_u_i32x4_f32x4, "V4iV4f", "nc", "simd128")
156-
TARGET_BUILTIN(__builtin_wasm_trunc_saturate_s_i64x2_f64x2, "V2LLiV2d", "nc", "unimplemented-simd128")
157-
TARGET_BUILTIN(__builtin_wasm_trunc_saturate_u_i64x2_f64x2, "V2LLiV2d", "nc", "unimplemented-simd128")
158156

159157
TARGET_BUILTIN(__builtin_wasm_narrow_s_i8x16_i16x8, "V16cV8sV8s", "nc", "simd128")
160158
TARGET_BUILTIN(__builtin_wasm_narrow_u_i8x16_i16x8, "V16cV8sV8s", "nc", "simd128")

clang/lib/CodeGen/CGBuiltin.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -15876,8 +15876,7 @@ Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
1587615876
case WebAssembly::BI__builtin_wasm_trunc_saturate_s_i32_f64:
1587715877
case WebAssembly::BI__builtin_wasm_trunc_saturate_s_i64_f32:
1587815878
case WebAssembly::BI__builtin_wasm_trunc_saturate_s_i64_f64:
15879-
case WebAssembly::BI__builtin_wasm_trunc_saturate_s_i32x4_f32x4:
15880-
case WebAssembly::BI__builtin_wasm_trunc_saturate_s_i64x2_f64x2: {
15879+
case WebAssembly::BI__builtin_wasm_trunc_saturate_s_i32x4_f32x4: {
1588115880
Value *Src = EmitScalarExpr(E->getArg(0));
1588215881
llvm::Type *ResT = ConvertType(E->getType());
1588315882
Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_trunc_saturate_signed,
@@ -15888,8 +15887,7 @@ Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
1588815887
case WebAssembly::BI__builtin_wasm_trunc_saturate_u_i32_f64:
1588915888
case WebAssembly::BI__builtin_wasm_trunc_saturate_u_i64_f32:
1589015889
case WebAssembly::BI__builtin_wasm_trunc_saturate_u_i64_f64:
15891-
case WebAssembly::BI__builtin_wasm_trunc_saturate_u_i32x4_f32x4:
15892-
case WebAssembly::BI__builtin_wasm_trunc_saturate_u_i64x2_f64x2: {
15890+
case WebAssembly::BI__builtin_wasm_trunc_saturate_u_i32x4_f32x4: {
1589315891
Value *Src = EmitScalarExpr(E->getArg(0));
1589415892
llvm::Type *ResT = ConvertType(E->getType());
1589515893
Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_trunc_saturate_unsigned,

clang/lib/Headers/wasm_simd128.h

-28
Original file line numberDiff line numberDiff line change
@@ -1007,20 +1007,6 @@ wasm_u32x4_trunc_saturate_f32x4(v128_t __a) {
10071007
return (v128_t)__builtin_wasm_trunc_saturate_u_i32x4_f32x4((__f32x4)__a);
10081008
}
10091009

1010-
#ifdef __wasm_unimplemented_simd128__
1011-
1012-
static __inline__ v128_t __DEFAULT_FN_ATTRS
1013-
wasm_i64x2_trunc_saturate_f64x2(v128_t __a) {
1014-
return (v128_t)__builtin_wasm_trunc_saturate_s_i64x2_f64x2((__f64x2)__a);
1015-
}
1016-
1017-
static __inline__ v128_t __DEFAULT_FN_ATTRS
1018-
wasm_u64x2_trunc_saturate_f64x2(v128_t __a) {
1019-
return (v128_t)__builtin_wasm_trunc_saturate_s_i64x2_f64x2((__f64x2)__a);
1020-
}
1021-
1022-
#endif // __wasm_unimplemented_simd128__
1023-
10241010
static __inline__ v128_t __DEFAULT_FN_ATTRS
10251011
wasm_f32x4_convert_i32x4(v128_t __a) {
10261012
return (v128_t) __builtin_convertvector((__i32x4)__a, __f32x4);
@@ -1031,20 +1017,6 @@ wasm_f32x4_convert_u32x4(v128_t __a) {
10311017
return (v128_t) __builtin_convertvector((__u32x4)__a, __f32x4);
10321018
}
10331019

1034-
#ifdef __wasm_unimplemented_simd128__
1035-
1036-
static __inline__ v128_t __DEFAULT_FN_ATTRS
1037-
wasm_f64x2_convert_i64x2(v128_t __a) {
1038-
return (v128_t) __builtin_convertvector((__i64x2)__a, __f64x2);
1039-
}
1040-
1041-
static __inline__ v128_t __DEFAULT_FN_ATTRS
1042-
wasm_f64x2_convert_u64x2(v128_t __a) {
1043-
return (v128_t) __builtin_convertvector((__u64x2)__a, __f64x2);
1044-
}
1045-
1046-
#endif // __wasm_unimplemented_simd128__
1047-
10481020
#define wasm_v8x16_shuffle(__a, __b, __c0, __c1, __c2, __c3, __c4, __c5, __c6, \
10491021
__c7, __c8, __c9, __c10, __c11, __c12, __c13, \
10501022
__c14, __c15) \

clang/test/CodeGen/builtins-wasm.c

-12
Original file line numberDiff line numberDiff line change
@@ -645,18 +645,6 @@ i32x4 trunc_saturate_u_i32x4_f32x4(f32x4 f) {
645645
// WEBASSEMBLY-NEXT: ret
646646
}
647647

648-
i64x2 trunc_saturate_s_i64x2_f64x2(f64x2 f) {
649-
return __builtin_wasm_trunc_saturate_s_i64x2_f64x2(f);
650-
// WEBASSEMBLY: call <2 x i64> @llvm.wasm.trunc.saturate.signed.v2i64.v2f64(<2 x double> %f)
651-
// WEBASSEMBLY-NEXT: ret
652-
}
653-
654-
i64x2 trunc_saturate_u_i64x2_f64x2(f64x2 f) {
655-
return __builtin_wasm_trunc_saturate_u_i64x2_f64x2(f);
656-
// WEBASSEMBLY: call <2 x i64> @llvm.wasm.trunc.saturate.unsigned.v2i64.v2f64(<2 x double> %f)
657-
// WEBASSEMBLY-NEXT: ret
658-
}
659-
660648
i8x16 narrow_s_i8x16_i16x8(i16x8 low, i16x8 high) {
661649
return __builtin_wasm_narrow_s_i8x16_i16x8(low, high);
662650
// WEBASSEMBLY: call <16 x i8> @llvm.wasm.narrow.signed.v16i8.v8i16(

llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,10 @@ WebAssemblyTargetLowering::WebAssemblyTargetLowering(
183183
setCondCodeAction(static_cast<ISD::CondCode>(CC), MVT::v2i64, Custom);
184184

185185
// 64x2 conversions are not in the spec
186-
if (!Subtarget->hasUnimplementedSIMD128())
187-
for (auto Op :
188-
{ISD::SINT_TO_FP, ISD::UINT_TO_FP, ISD::FP_TO_SINT, ISD::FP_TO_UINT})
189-
for (auto T : {MVT::v2i64, MVT::v2f64})
190-
setOperationAction(Op, T, Expand);
186+
for (auto Op :
187+
{ISD::SINT_TO_FP, ISD::UINT_TO_FP, ISD::FP_TO_SINT, ISD::FP_TO_UINT})
188+
for (auto T : {MVT::v2i64, MVT::v2f64})
189+
setOperationAction(Op, T, Expand);
191190
}
192191

193192
// As a special case, these operators use the type to mean the type to

0 commit comments

Comments
 (0)