diff --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def b/clang/include/clang/Basic/BuiltinsWebAssembly.def --- a/clang/include/clang/Basic/BuiltinsWebAssembly.def +++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def @@ -158,8 +158,8 @@ TARGET_BUILTIN(__builtin_wasm_narrow_s_i16x8_i32x4, "V8sV4iV4i", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_narrow_u_i16x8_i32x4, "V8UsV4iV4i", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_trunc_sat_zero_s_f64x2_i32x4, "V4iV2d", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_trunc_sat_zero_u_f64x2_i32x4, "V4UiV2d", "nc", "simd128") +TARGET_BUILTIN(__builtin_wasm_trunc_sat_s_zero_f64x2_i32x4, "V4iV2d", "nc", "simd128") +TARGET_BUILTIN(__builtin_wasm_trunc_sat_u_zero_f64x2_i32x4, "V4UiV2d", "nc", "simd128") // Relaxed SIMD builtins (experimental) TARGET_BUILTIN(__builtin_wasm_fma_f32x4, "V4fV4fV4fV4f", "nc", "relaxed-simd") @@ -181,8 +181,8 @@ TARGET_BUILTIN(__builtin_wasm_relaxed_trunc_s_i32x4_f32x4, "V4iV4f", "nc", "relaxed-simd") TARGET_BUILTIN(__builtin_wasm_relaxed_trunc_u_i32x4_f32x4, "V4UiV4f", "nc", "relaxed-simd") -TARGET_BUILTIN(__builtin_wasm_relaxed_trunc_zero_s_i32x4_f64x2, "V4iV2d", "nc", "relaxed-simd") -TARGET_BUILTIN(__builtin_wasm_relaxed_trunc_zero_u_i32x4_f64x2, "V4UiV2d", "nc", "relaxed-simd") +TARGET_BUILTIN(__builtin_wasm_relaxed_trunc_s_zero_i32x4_f64x2, "V4iV2d", "nc", "relaxed-simd") +TARGET_BUILTIN(__builtin_wasm_relaxed_trunc_u_zero_i32x4_f64x2, "V4UiV2d", "nc", "relaxed-simd") #undef BUILTIN #undef TARGET_BUILTIN diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -18411,15 +18411,15 @@ CGM.getIntrinsic(IntNo, {ConvertType(E->getType()), Low->getType()}); return Builder.CreateCall(Callee, {Low, High}); } - case WebAssembly::BI__builtin_wasm_trunc_sat_zero_s_f64x2_i32x4: - case WebAssembly::BI__builtin_wasm_trunc_sat_zero_u_f64x2_i32x4: { + case WebAssembly::BI__builtin_wasm_trunc_sat_s_zero_f64x2_i32x4: + case WebAssembly::BI__builtin_wasm_trunc_sat_u_zero_f64x2_i32x4: { Value *Vec = EmitScalarExpr(E->getArg(0)); unsigned IntNo; switch (BuiltinID) { - case WebAssembly::BI__builtin_wasm_trunc_sat_zero_s_f64x2_i32x4: + case WebAssembly::BI__builtin_wasm_trunc_sat_s_zero_f64x2_i32x4: IntNo = Intrinsic::fptosi_sat; break; - case WebAssembly::BI__builtin_wasm_trunc_sat_zero_u_f64x2_i32x4: + case WebAssembly::BI__builtin_wasm_trunc_sat_u_zero_f64x2_i32x4: IntNo = Intrinsic::fptoui_sat; break; default: @@ -18510,8 +18510,8 @@ } case WebAssembly::BI__builtin_wasm_relaxed_trunc_s_i32x4_f32x4: case WebAssembly::BI__builtin_wasm_relaxed_trunc_u_i32x4_f32x4: - case WebAssembly::BI__builtin_wasm_relaxed_trunc_zero_s_i32x4_f64x2: - case WebAssembly::BI__builtin_wasm_relaxed_trunc_zero_u_i32x4_f64x2: { + case WebAssembly::BI__builtin_wasm_relaxed_trunc_s_zero_i32x4_f64x2: + case WebAssembly::BI__builtin_wasm_relaxed_trunc_u_zero_i32x4_f64x2: { Value *Vec = EmitScalarExpr(E->getArg(0)); unsigned IntNo; switch (BuiltinID) { @@ -18521,11 +18521,11 @@ case WebAssembly::BI__builtin_wasm_relaxed_trunc_u_i32x4_f32x4: IntNo = Intrinsic::wasm_relaxed_trunc_unsigned; break; - case WebAssembly::BI__builtin_wasm_relaxed_trunc_zero_s_i32x4_f64x2: - IntNo = Intrinsic::wasm_relaxed_trunc_zero_signed; + case WebAssembly::BI__builtin_wasm_relaxed_trunc_s_zero_i32x4_f64x2: + IntNo = Intrinsic::wasm_relaxed_trunc_signed_zero; break; - case WebAssembly::BI__builtin_wasm_relaxed_trunc_zero_u_i32x4_f64x2: - IntNo = Intrinsic::wasm_relaxed_trunc_zero_unsigned; + case WebAssembly::BI__builtin_wasm_relaxed_trunc_u_zero_i32x4_f64x2: + IntNo = Intrinsic::wasm_relaxed_trunc_unsigned_zero; break; default: llvm_unreachable("unexpected builtin ID"); diff --git a/clang/lib/Headers/wasm_simd128.h b/clang/lib/Headers/wasm_simd128.h --- a/clang/lib/Headers/wasm_simd128.h +++ b/clang/lib/Headers/wasm_simd128.h @@ -1405,12 +1405,12 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_trunc_sat_f64x2_zero(v128_t __a) { - return (v128_t)__builtin_wasm_trunc_sat_zero_s_f64x2_i32x4((__f64x2)__a); + return (v128_t)__builtin_wasm_trunc_sat_s_zero_f64x2_i32x4((__f64x2)__a); } static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_trunc_sat_f64x2_zero(v128_t __a) { - return (v128_t)__builtin_wasm_trunc_sat_zero_u_f64x2_i32x4((__f64x2)__a); + return (v128_t)__builtin_wasm_trunc_sat_u_zero_f64x2_i32x4((__f64x2)__a); } static __inline__ v128_t __DEFAULT_FN_ATTRS diff --git a/clang/test/CodeGen/builtins-wasm.c b/clang/test/CodeGen/builtins-wasm.c --- a/clang/test/CodeGen/builtins-wasm.c +++ b/clang/test/CodeGen/builtins-wasm.c @@ -636,15 +636,15 @@ // WEBASSEMBLY: ret } -i32x4 trunc_sat_zero_s_f64x2_i32x4(f64x2 x) { - return __builtin_wasm_trunc_sat_zero_s_f64x2_i32x4(x); +i32x4 trunc_sat_s_zero_f64x2_i32x4(f64x2 x) { + return __builtin_wasm_trunc_sat_s_zero_f64x2_i32x4(x); // WEBASSEMBLY: %0 = tail call <2 x i32> @llvm.fptosi.sat.v2i32.v2f64(<2 x double> %x) // WEBASSEMBLY: %1 = shufflevector <2 x i32> %0, <2 x i32> zeroinitializer, <4 x i32> // WEBASSEMBLY: ret <4 x i32> %1 } -u32x4 trunc_sat_zero_u_f64x2_i32x4(f64x2 x) { - return __builtin_wasm_trunc_sat_zero_u_f64x2_i32x4(x); +u32x4 trunc_sat_u_zero_f64x2_i32x4(f64x2 x) { + return __builtin_wasm_trunc_sat_u_zero_f64x2_i32x4(x); // WEBASSEMBLY: %0 = tail call <2 x i32> @llvm.fptoui.sat.v2i32.v2f64(<2 x double> %x) // WEBASSEMBLY: %1 = shufflevector <2 x i32> %0, <2 x i32> zeroinitializer, <4 x i32> // WEBASSEMBLY: ret <4 x i32> %1 @@ -766,14 +766,14 @@ // WEBASSEMBLY-NEXT: ret } -i32x4 relaxed_trunc_zero_s_i32x4_f64x2(f64x2 x) { - return __builtin_wasm_relaxed_trunc_zero_s_i32x4_f64x2(x); - // WEBASSEMBLY: call <4 x i32> @llvm.wasm.relaxed.trunc.zero.signed(<2 x double> %x) +i32x4 relaxed_trunc_s_zero_i32x4_f64x2(f64x2 x) { + return __builtin_wasm_relaxed_trunc_s_zero_i32x4_f64x2(x); + // WEBASSEMBLY: call <4 x i32> @llvm.wasm.relaxed.trunc.signed.zero(<2 x double> %x) // WEBASSEMBLY-NEXT: ret } -u32x4 relaxed_trunc_zero_u_i32x4_f64x2(f64x2 x) { - return __builtin_wasm_relaxed_trunc_zero_u_i32x4_f64x2(x); - // WEBASSEMBLY: call <4 x i32> @llvm.wasm.relaxed.trunc.zero.unsigned(<2 x double> %x) +u32x4 relaxed_trunc_u_zero_i32x4_f64x2(f64x2 x) { + return __builtin_wasm_relaxed_trunc_u_zero_i32x4_f64x2(x); + // WEBASSEMBLY: call <4 x i32> @llvm.wasm.relaxed.trunc.unsigned.zero(<2 x double> %x) // WEBASSEMBLY-NEXT: ret } diff --git a/llvm/include/llvm/IR/IntrinsicsWebAssembly.td b/llvm/include/llvm/IR/IntrinsicsWebAssembly.td --- a/llvm/include/llvm/IR/IntrinsicsWebAssembly.td +++ b/llvm/include/llvm/IR/IntrinsicsWebAssembly.td @@ -256,12 +256,12 @@ [llvm_v4f32_ty], [IntrNoMem, IntrSpeculatable]>; -def int_wasm_relaxed_trunc_zero_signed: +def int_wasm_relaxed_trunc_signed_zero: Intrinsic<[llvm_v4i32_ty], [llvm_v2f64_ty], [IntrNoMem, IntrSpeculatable]>; -def int_wasm_relaxed_trunc_zero_unsigned: +def int_wasm_relaxed_trunc_unsigned_zero: Intrinsic<[llvm_v4i32_ty], [llvm_v2f64_ty], [IntrNoMem, IntrSpeculatable]>; diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td b/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td --- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td +++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td @@ -1229,9 +1229,9 @@ SDNode<"WebAssemblyISD::TRUNC_SAT_ZERO_S", trunc_sat_zero_t>; def trunc_sat_zero_u : SDNode<"WebAssemblyISD::TRUNC_SAT_ZERO_U", trunc_sat_zero_t>; -defm "" : SIMDConvert; -defm "" : SIMDConvert; // Integer to floating point: convert @@ -1307,7 +1307,7 @@ def demote_t : SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisVec<1>]>; def demote_zero : SDNode<"WebAssemblyISD::DEMOTE_ZERO", demote_t>; defm "" : SIMDConvert; + "demote_f64x2_zero", 0x5e>; def promote_t : SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisVec<1>]>; def promote_low : SDNode<"WebAssemblyISD::PROMOTE_LOW", promote_t>; @@ -1415,5 +1415,5 @@ defm "" : SIMD_RELAXED_CONVERT; defm "" : SIMD_RELAXED_CONVERT; -defm "" : SIMD_RELAXED_CONVERT; -defm "" : SIMD_RELAXED_CONVERT; +defm "" : SIMD_RELAXED_CONVERT; +defm "" : SIMD_RELAXED_CONVERT; diff --git a/llvm/test/CodeGen/WebAssembly/simd-conversions.ll b/llvm/test/CodeGen/WebAssembly/simd-conversions.ll --- a/llvm/test/CodeGen/WebAssembly/simd-conversions.ll +++ b/llvm/test/CodeGen/WebAssembly/simd-conversions.ll @@ -211,7 +211,7 @@ ; CHECK: .functype demote_zero_v4f32 (v128) -> (v128) ; CHECK-NEXT: # %bb.0: ; CHECK-NEXT: local.get 0 -; CHECK-NEXT: f32x4.demote_zero_f64x2 +; CHECK-NEXT: f32x4.demote_f64x2_zero ; CHECK-NEXT: # fallthrough-return %v = shufflevector <2 x double> %x, <2 x double> zeroinitializer, <4 x i32> @@ -224,7 +224,7 @@ ; CHECK: .functype demote_zero_v4f32_2 (v128) -> (v128) ; CHECK-NEXT: # %bb.0: ; CHECK-NEXT: local.get 0 -; CHECK-NEXT: f32x4.demote_zero_f64x2 +; CHECK-NEXT: f32x4.demote_f64x2_zero ; CHECK-NEXT: # fallthrough-return %v = fptrunc <2 x double> %x to <2 x float> %a = shufflevector <2 x float> %v, <2 x float> zeroinitializer, diff --git a/llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll b/llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll --- a/llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll +++ b/llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll @@ -466,48 +466,48 @@ ret <4 x i32> %a } -; CHECK-LABEL: trunc_sat_zero_s_v4i32: -; CHECK-NEXT: .functype trunc_sat_zero_s_v4i32 (v128) -> (v128){{$}} -; CHECK-NEXT: i32x4.trunc_sat_zero_f64x2_s $push[[R:[0-9]+]]=, $0{{$}} +; CHECK-LABEL: trunc_sat_s_zero_v4i32: +; CHECK-NEXT: .functype trunc_sat_s_zero_v4i32 (v128) -> (v128){{$}} +; CHECK-NEXT: i32x4.trunc_sat_f64x2_s_zero $push[[R:[0-9]+]]=, $0{{$}} ; CHECK-NEXT: return $pop[[R]]{{$}} declare <2 x i32> @llvm.fptosi.sat.v2i32.v2f64(<2 x double>) -define <4 x i32> @trunc_sat_zero_s_v4i32(<2 x double> %x) { +define <4 x i32> @trunc_sat_s_zero_v4i32(<2 x double> %x) { %v = call <2 x i32> @llvm.fptosi.sat.v2i32.v2f64(<2 x double> %x) %a = shufflevector <2 x i32> %v, <2 x i32> , <4 x i32> ret <4 x i32> %a } -; CHECK-LABEL: trunc_sat_zero_s_v4i32_2: -; CHECK-NEXT: .functype trunc_sat_zero_s_v4i32_2 (v128) -> (v128){{$}} -; SLOW-NEXT: i32x4.trunc_sat_zero_f64x2_s $push[[R:[0-9]+]]=, $0{{$}} +; CHECK-LABEL: trunc_sat_s_zero_v4i32_2: +; CHECK-NEXT: .functype trunc_sat_s_zero_v4i32_2 (v128) -> (v128){{$}} +; SLOW-NEXT: i32x4.trunc_sat_f64x2_s_zero $push[[R:[0-9]+]]=, $0{{$}} ; SLOW-NEXT: return $pop[[R]]{{$}} declare <4 x i32> @llvm.fptosi.sat.v4i32.v4f64(<4 x double>) -define <4 x i32> @trunc_sat_zero_s_v4i32_2(<2 x double> %x) { +define <4 x i32> @trunc_sat_s_zero_v4i32_2(<2 x double> %x) { %v = shufflevector <2 x double> %x, <2 x double> zeroinitializer, <4 x i32> %a = call <4 x i32> @llvm.fptosi.sat.v4i32.v4f64(<4 x double> %v) ret <4 x i32> %a } -; CHECK-LABEL: trunc_sat_zero_u_v4i32: -; CHECK-NEXT: .functype trunc_sat_zero_u_v4i32 (v128) -> (v128){{$}} -; CHECK-NEXT: i32x4.trunc_sat_zero_f64x2_u $push[[R:[0-9]+]]=, $0{{$}} +; CHECK-LABEL: trunc_sat_u_zero_v4i32: +; CHECK-NEXT: .functype trunc_sat_u_zero_v4i32 (v128) -> (v128){{$}} +; CHECK-NEXT: i32x4.trunc_sat_f64x2_u_zero $push[[R:[0-9]+]]=, $0{{$}} ; CHECK-NEXT: return $pop[[R]]{{$}} declare <2 x i32> @llvm.fptoui.sat.v2i32.v2f64(<2 x double>) -define <4 x i32> @trunc_sat_zero_u_v4i32(<2 x double> %x) { +define <4 x i32> @trunc_sat_u_zero_v4i32(<2 x double> %x) { %v = call <2 x i32> @llvm.fptoui.sat.v2i32.v2f64(<2 x double> %x) %a = shufflevector <2 x i32> %v, <2 x i32> , <4 x i32> ret <4 x i32> %a } -; CHECK-LABEL: trunc_sat_zero_u_v4i32_2: -; CHECK-NEXT: .functype trunc_sat_zero_u_v4i32_2 (v128) -> (v128){{$}} -; SLOW-NEXT: i32x4.trunc_sat_zero_f64x2_u $push[[R:[0-9]+]]=, $0{{$}} +; CHECK-LABEL: trunc_sat_u_zero_v4i32_2: +; CHECK-NEXT: .functype trunc_sat_u_zero_v4i32_2 (v128) -> (v128){{$}} +; SLOW-NEXT: i32x4.trunc_sat_f64x2_u_zero $push[[R:[0-9]+]]=, $0{{$}} ; SLOW-NEXT: return $pop[[R]]{{$}} declare <4 x i32> @llvm.fptoui.sat.v4i32.v4f64(<4 x double>) -define <4 x i32> @trunc_sat_zero_u_v4i32_2(<2 x double> %x) { +define <4 x i32> @trunc_sat_u_zero_v4i32_2(<2 x double> %x) { %v = shufflevector <2 x double> %x, <2 x double> zeroinitializer, <4 x i32> %a = call <4 x i32> @llvm.fptoui.sat.v4i32.v4f64(<4 x double> %v) @@ -548,23 +548,23 @@ ret <4 x i32> %a } -; CHECK-LABEL: relaxed_trunc_zero_s: -; CHECK-NEXT: .functype relaxed_trunc_zero_s (v128) -> (v128){{$}} +; CHECK-LABEL: relaxed_trunc_s_zero: +; CHECK-NEXT: .functype relaxed_trunc_s_zero (v128) -> (v128){{$}} ; CHECK-NEXT: i32x4.relaxed_trunc_f64x2_s_zero $push[[R:[0-9]+]]=, $0{{$}} ; CHECK-NEXT: return $pop[[R]]{{$}} -declare <4 x i32> @llvm.wasm.relaxed.trunc.zero.signed(<2 x double>) -define <4 x i32> @relaxed_trunc_zero_s(<2 x double> %x) { - %a = call <4 x i32> @llvm.wasm.relaxed.trunc.zero.signed(<2 x double> %x) +declare <4 x i32> @llvm.wasm.relaxed.trunc.signed.zero(<2 x double>) +define <4 x i32> @relaxed_trunc_s_zero(<2 x double> %x) { + %a = call <4 x i32> @llvm.wasm.relaxed.trunc.signed.zero(<2 x double> %x) ret <4 x i32> %a } -; CHECK-LABEL: relaxed_trunc_zero_u: -; CHECK-NEXT: .functype relaxed_trunc_zero_u (v128) -> (v128){{$}} +; CHECK-LABEL: relaxed_trunc_u_zero: +; CHECK-NEXT: .functype relaxed_trunc_u_zero (v128) -> (v128){{$}} ; CHECK-NEXT: i32x4.relaxed_trunc_f64x2_u_zero $push[[R:[0-9]+]]=, $0{{$}} ; CHECK-NEXT: return $pop[[R]]{{$}} -declare <4 x i32> @llvm.wasm.relaxed.trunc.zero.unsigned(<2 x double>) -define <4 x i32> @relaxed_trunc_zero_u(<2 x double> %x) { - %a = call <4 x i32> @llvm.wasm.relaxed.trunc.zero.unsigned(<2 x double> %x) +declare <4 x i32> @llvm.wasm.relaxed.trunc.unsigned.zero(<2 x double>) +define <4 x i32> @relaxed_trunc_u_zero(<2 x double> %x) { + %a = call <4 x i32> @llvm.wasm.relaxed.trunc.unsigned.zero(<2 x double> %x) ret <4 x i32> %a } diff --git a/llvm/test/MC/WebAssembly/simd-encodings.s b/llvm/test/MC/WebAssembly/simd-encodings.s --- a/llvm/test/MC/WebAssembly/simd-encodings.s +++ b/llvm/test/MC/WebAssembly/simd-encodings.s @@ -313,8 +313,8 @@ # CHECK: v128.load64_zero 32 # encoding: [0xfd,0x5d,0x03,0x20] v128.load64_zero 32 - # CHECK: f32x4.demote_zero_f64x2 # encoding: [0xfd,0x5e] - f32x4.demote_zero_f64x2 + # CHECK: f32x4.demote_f64x2_zero # encoding: [0xfd,0x5e] + f32x4.demote_f64x2_zero # CHECK: f64x2.promote_low_f32x4 # encoding: [0xfd,0x5f] f64x2.promote_low_f32x4 @@ -767,11 +767,11 @@ # CHECK: f32x4.convert_i32x4_u # encoding: [0xfd,0xfb,0x01] f32x4.convert_i32x4_u - # CHECK: i32x4.trunc_sat_zero_f64x2_s # encoding: [0xfd,0xfc,0x01] - i32x4.trunc_sat_zero_f64x2_s + # CHECK: i32x4.trunc_sat_f64x2_s_zero # encoding: [0xfd,0xfc,0x01] + i32x4.trunc_sat_f64x2_s_zero - # CHECK: i32x4.trunc_sat_zero_f64x2_u # encoding: [0xfd,0xfd,0x01] - i32x4.trunc_sat_zero_f64x2_u + # CHECK: i32x4.trunc_sat_f64x2_u_zero # encoding: [0xfd,0xfd,0x01] + i32x4.trunc_sat_f64x2_u_zero # CHECK: f64x2.convert_low_i32x4_s # encoding: [0xfd,0xfe,0x01] f64x2.convert_low_i32x4_s