Skip to content

Commit

Permalink
[WebAssembly] Renumber SIMD opcodes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tlively committed May 2, 2020
1 parent 8ca2fc9 commit e0f5284
Show file tree
Hide file tree
Showing 10 changed files with 392 additions and 495 deletions.
2 changes: 0 additions & 2 deletions clang/include/clang/Basic/BuiltinsWebAssembly.def
Expand Up @@ -153,8 +153,6 @@ TARGET_BUILTIN(__builtin_wasm_qfms_f64x2, "V2dV2dV2dV2d", "nc", "unimplemented-s

TARGET_BUILTIN(__builtin_wasm_trunc_saturate_s_i32x4_f32x4, "V4iV4f", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_trunc_saturate_u_i32x4_f32x4, "V4iV4f", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_trunc_saturate_s_i64x2_f64x2, "V2LLiV2d", "nc", "unimplemented-simd128")
TARGET_BUILTIN(__builtin_wasm_trunc_saturate_u_i64x2_f64x2, "V2LLiV2d", "nc", "unimplemented-simd128")

TARGET_BUILTIN(__builtin_wasm_narrow_s_i8x16_i16x8, "V16cV8sV8s", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_narrow_u_i8x16_i16x8, "V16cV8sV8s", "nc", "simd128")
Expand Down
6 changes: 2 additions & 4 deletions clang/lib/CodeGen/CGBuiltin.cpp
Expand Up @@ -15546,8 +15546,7 @@ Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
case WebAssembly::BI__builtin_wasm_trunc_saturate_s_i32_f64:
case WebAssembly::BI__builtin_wasm_trunc_saturate_s_i64_f32:
case WebAssembly::BI__builtin_wasm_trunc_saturate_s_i64_f64:
case WebAssembly::BI__builtin_wasm_trunc_saturate_s_i32x4_f32x4:
case WebAssembly::BI__builtin_wasm_trunc_saturate_s_i64x2_f64x2: {
case WebAssembly::BI__builtin_wasm_trunc_saturate_s_i32x4_f32x4: {
Value *Src = EmitScalarExpr(E->getArg(0));
llvm::Type *ResT = ConvertType(E->getType());
Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_trunc_saturate_signed,
Expand All @@ -15558,8 +15557,7 @@ Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
case WebAssembly::BI__builtin_wasm_trunc_saturate_u_i32_f64:
case WebAssembly::BI__builtin_wasm_trunc_saturate_u_i64_f32:
case WebAssembly::BI__builtin_wasm_trunc_saturate_u_i64_f64:
case WebAssembly::BI__builtin_wasm_trunc_saturate_u_i32x4_f32x4:
case WebAssembly::BI__builtin_wasm_trunc_saturate_u_i64x2_f64x2: {
case WebAssembly::BI__builtin_wasm_trunc_saturate_u_i32x4_f32x4: {
Value *Src = EmitScalarExpr(E->getArg(0));
llvm::Type *ResT = ConvertType(E->getType());
Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_trunc_saturate_unsigned,
Expand Down
28 changes: 0 additions & 28 deletions clang/lib/Headers/wasm_simd128.h
Expand Up @@ -1007,20 +1007,6 @@ wasm_u32x4_trunc_saturate_f32x4(v128_t __a) {
return (v128_t)__builtin_wasm_trunc_saturate_u_i32x4_f32x4((__f32x4)__a);
}

#ifdef __wasm_unimplemented_simd128__

static __inline__ v128_t __DEFAULT_FN_ATTRS
wasm_i64x2_trunc_saturate_f64x2(v128_t __a) {
return (v128_t)__builtin_wasm_trunc_saturate_s_i64x2_f64x2((__f64x2)__a);
}

static __inline__ v128_t __DEFAULT_FN_ATTRS
wasm_u64x2_trunc_saturate_f64x2(v128_t __a) {
return (v128_t)__builtin_wasm_trunc_saturate_s_i64x2_f64x2((__f64x2)__a);
}

#endif // __wasm_unimplemented_simd128__

static __inline__ v128_t __DEFAULT_FN_ATTRS
wasm_f32x4_convert_i32x4(v128_t __a) {
return (v128_t) __builtin_convertvector((__i32x4)__a, __f32x4);
Expand All @@ -1031,20 +1017,6 @@ wasm_f32x4_convert_u32x4(v128_t __a) {
return (v128_t) __builtin_convertvector((__u32x4)__a, __f32x4);
}

#ifdef __wasm_unimplemented_simd128__

static __inline__ v128_t __DEFAULT_FN_ATTRS
wasm_f64x2_convert_i64x2(v128_t __a) {
return (v128_t) __builtin_convertvector((__i64x2)__a, __f64x2);
}

static __inline__ v128_t __DEFAULT_FN_ATTRS
wasm_f64x2_convert_u64x2(v128_t __a) {
return (v128_t) __builtin_convertvector((__u64x2)__a, __f64x2);
}

#endif // __wasm_unimplemented_simd128__

#define wasm_v8x16_shuffle(__a, __b, __c0, __c1, __c2, __c3, __c4, __c5, __c6, \
__c7, __c8, __c9, __c10, __c11, __c12, __c13, \
__c14, __c15) \
Expand Down
12 changes: 0 additions & 12 deletions clang/test/CodeGen/builtins-wasm.c
Expand Up @@ -645,18 +645,6 @@ i32x4 trunc_saturate_u_i32x4_f32x4(f32x4 f) {
// WEBASSEMBLY-NEXT: ret
}

i64x2 trunc_saturate_s_i64x2_f64x2(f64x2 f) {
return __builtin_wasm_trunc_saturate_s_i64x2_f64x2(f);
// WEBASSEMBLY: call <2 x i64> @llvm.wasm.trunc.saturate.signed.v2i64.v2f64(<2 x double> %f)
// WEBASSEMBLY-NEXT: ret
}

i64x2 trunc_saturate_u_i64x2_f64x2(f64x2 f) {
return __builtin_wasm_trunc_saturate_u_i64x2_f64x2(f);
// WEBASSEMBLY: call <2 x i64> @llvm.wasm.trunc.saturate.unsigned.v2i64.v2f64(<2 x double> %f)
// WEBASSEMBLY-NEXT: ret
}

i8x16 narrow_s_i8x16_i16x8(i16x8 low, i16x8 high) {
return __builtin_wasm_narrow_s_i8x16_i16x8(low, high);
// WEBASSEMBLY: call <16 x i8> @llvm.wasm.narrow.signed.v16i8.v8i16(
Expand Down
9 changes: 4 additions & 5 deletions llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
Expand Up @@ -183,11 +183,10 @@ WebAssemblyTargetLowering::WebAssemblyTargetLowering(
setCondCodeAction(static_cast<ISD::CondCode>(CC), MVT::v2i64, Custom);

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

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

0 comments on commit e0f5284

Please sign in to comment.