From fd3bd63df26ad0a3865fd1fcbdbbd0063f2b0761 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Thu, 19 Aug 2021 16:23:47 -0700 Subject: [PATCH] [WebAssembly] Make bitmask instructions return unsigned ints Since they are bitmasks, it will be more common for them to be used and potentially extended to 64-bit integers as unsigned values rather than signed values. Differential Revision: https://reviews.llvm.org/D108401 --- clang/include/clang/Basic/BuiltinsWebAssembly.def | 8 ++++---- clang/lib/Headers/wasm_simd128.h | 8 ++++---- clang/test/Headers/wasm.c | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def b/clang/include/clang/Basic/BuiltinsWebAssembly.def index 04ec45a..51a819e 100644 --- a/clang/include/clang/Basic/BuiltinsWebAssembly.def +++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def @@ -119,10 +119,10 @@ TARGET_BUILTIN(__builtin_wasm_all_true_i16x8, "iV8s", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_all_true_i32x4, "iV4i", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_all_true_i64x2, "iV2LLi", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_bitmask_i8x16, "iV16Sc", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_bitmask_i16x8, "iV8s", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_bitmask_i32x4, "iV4i", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_bitmask_i64x2, "iV2LLi", "nc", "simd128") +TARGET_BUILTIN(__builtin_wasm_bitmask_i8x16, "UiV16Sc", "nc", "simd128") +TARGET_BUILTIN(__builtin_wasm_bitmask_i16x8, "UiV8s", "nc", "simd128") +TARGET_BUILTIN(__builtin_wasm_bitmask_i32x4, "UiV4i", "nc", "simd128") +TARGET_BUILTIN(__builtin_wasm_bitmask_i64x2, "UiV2LLi", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_abs_f32x4, "V4fV4f", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_abs_f64x2, "V2dV2d", "nc", "simd128") diff --git a/clang/lib/Headers/wasm_simd128.h b/clang/lib/Headers/wasm_simd128.h index 712fa03..e43c31a 100644 --- a/clang/lib/Headers/wasm_simd128.h +++ b/clang/lib/Headers/wasm_simd128.h @@ -804,7 +804,7 @@ static __inline__ bool __DEFAULT_FN_ATTRS wasm_i8x16_all_true(v128_t __a) { return __builtin_wasm_all_true_i8x16((__i8x16)__a); } -static __inline__ int32_t __DEFAULT_FN_ATTRS wasm_i8x16_bitmask(v128_t __a) { +static __inline__ uint32_t __DEFAULT_FN_ATTRS wasm_i8x16_bitmask(v128_t __a) { return __builtin_wasm_bitmask_i8x16((__i8x16)__a); } @@ -894,7 +894,7 @@ static __inline__ bool __DEFAULT_FN_ATTRS wasm_i16x8_all_true(v128_t __a) { return __builtin_wasm_all_true_i16x8((__i16x8)__a); } -static __inline__ int32_t __DEFAULT_FN_ATTRS wasm_i16x8_bitmask(v128_t __a) { +static __inline__ uint32_t __DEFAULT_FN_ATTRS wasm_i16x8_bitmask(v128_t __a) { return __builtin_wasm_bitmask_i16x8((__i16x8)__a); } @@ -985,7 +985,7 @@ static __inline__ bool __DEFAULT_FN_ATTRS wasm_i32x4_all_true(v128_t __a) { return __builtin_wasm_all_true_i32x4((__i32x4)__a); } -static __inline__ int32_t __DEFAULT_FN_ATTRS wasm_i32x4_bitmask(v128_t __a) { +static __inline__ uint32_t __DEFAULT_FN_ATTRS wasm_i32x4_bitmask(v128_t __a) { return __builtin_wasm_bitmask_i32x4((__i32x4)__a); } @@ -1056,7 +1056,7 @@ static __inline__ bool __DEFAULT_FN_ATTRS wasm_i64x2_all_true(v128_t __a) { return __builtin_wasm_all_true_i64x2((__i64x2)__a); } -static __inline__ int32_t __DEFAULT_FN_ATTRS wasm_i64x2_bitmask(v128_t __a) { +static __inline__ uint32_t __DEFAULT_FN_ATTRS wasm_i64x2_bitmask(v128_t __a) { return __builtin_wasm_bitmask_i64x2((__i64x2)__a); } diff --git a/clang/test/Headers/wasm.c b/clang/test/Headers/wasm.c index f51f005..c2f412c 100644 --- a/clang/test/Headers/wasm.c +++ b/clang/test/Headers/wasm.c @@ -1345,7 +1345,7 @@ bool test_i8x16_all_true(v128_t a) { // CHECK-NEXT: [[TMP1:%.*]] = tail call i32 @llvm.wasm.bitmask.v16i8(<16 x i8> [[TMP0]]) #[[ATTR6]] // CHECK-NEXT: ret i32 [[TMP1]] // -int32_t test_i8x16_bitmask(v128_t a) { +uint32_t test_i8x16_bitmask(v128_t a) { return wasm_i8x16_bitmask(a); } @@ -1577,7 +1577,7 @@ bool test_i16x8_all_true(v128_t a) { // CHECK-NEXT: [[TMP1:%.*]] = tail call i32 @llvm.wasm.bitmask.v8i16(<8 x i16> [[TMP0]]) #[[ATTR6]] // CHECK-NEXT: ret i32 [[TMP1]] // -int32_t test_i16x8_bitmask(v128_t a) { +uint32_t test_i16x8_bitmask(v128_t a) { return wasm_i16x8_bitmask(a); } @@ -1804,7 +1804,7 @@ bool test_i32x4_all_true(v128_t a) { // CHECK-NEXT: [[TMP0:%.*]] = tail call i32 @llvm.wasm.bitmask.v4i32(<4 x i32> [[A:%.*]]) #[[ATTR6]] // CHECK-NEXT: ret i32 [[TMP0]] // -int32_t test_i32x4_bitmask(v128_t a) { +uint32_t test_i32x4_bitmask(v128_t a) { return wasm_i32x4_bitmask(a); } @@ -1958,7 +1958,7 @@ bool test_i64x2_all_true(v128_t a) { // CHECK-NEXT: [[TMP1:%.*]] = tail call i32 @llvm.wasm.bitmask.v2i64(<2 x i64> [[TMP0]]) #[[ATTR6]] // CHECK-NEXT: ret i32 [[TMP1]] // -int32_t test_i64x2_bitmask(v128_t a) { +uint32_t test_i64x2_bitmask(v128_t a) { return wasm_i64x2_bitmask(a); } -- 2.7.4