[clang] a787e09 - [WebAssembly] Prototype i64x2.bitmask
Thomas Lively via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 30 17:23:41 PDT 2020
Author: Thomas Lively
Date: 2020-10-30T17:23:30-07:00
New Revision: a787e0977912d53b7177e5c97e6e465be46285a2
URL: https://github.com/llvm/llvm-project/commit/a787e0977912d53b7177e5c97e6e465be46285a2
DIFF: https://github.com/llvm/llvm-project/commit/a787e0977912d53b7177e5c97e6e465be46285a2.diff
LOG: [WebAssembly] Prototype i64x2.bitmask
As proposed in https://github.com/WebAssembly/simd/pull/368.
Differential Revision: https://reviews.llvm.org/D90514
Added:
Modified:
clang/include/clang/Basic/BuiltinsWebAssembly.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/builtins-wasm.c
llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
llvm/test/MC/WebAssembly/simd-encodings.s
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def b/clang/include/clang/Basic/BuiltinsWebAssembly.def
index 4f448dfebeef..21a67d8d7bd7 100644
--- a/clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -154,6 +154,7 @@ TARGET_BUILTIN(__builtin_wasm_all_true_i64x2, "iV2LLi", "nc", "unimplemented-sim
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_abs_f32x4, "V4fV4f", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_abs_f64x2, "V2dV2d", "nc", "simd128")
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 448eab7bfdfc..a7c07e04b4cd 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -16734,7 +16734,8 @@ Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
}
case WebAssembly::BI__builtin_wasm_bitmask_i8x16:
case WebAssembly::BI__builtin_wasm_bitmask_i16x8:
- case WebAssembly::BI__builtin_wasm_bitmask_i32x4: {
+ case WebAssembly::BI__builtin_wasm_bitmask_i32x4:
+ case WebAssembly::BI__builtin_wasm_bitmask_i64x2: {
Value *Vec = EmitScalarExpr(E->getArg(0));
Function *Callee =
CGM.getIntrinsic(Intrinsic::wasm_bitmask, Vec->getType());
diff --git a/clang/test/CodeGen/builtins-wasm.c b/clang/test/CodeGen/builtins-wasm.c
index 4a7efaf9716e..a9158878dcc3 100644
--- a/clang/test/CodeGen/builtins-wasm.c
+++ b/clang/test/CodeGen/builtins-wasm.c
@@ -728,6 +728,12 @@ int bitmask_i32x4(i32x4 x) {
// WEBASSEMBLY: ret
}
+int bitmask_i64x2(i64x2 x) {
+ return __builtin_wasm_bitmask_i64x2(x);
+ // WEBASSEMBLY: call i32 @llvm.wasm.bitmask.v2i64(<2 x i64> %x)
+ // WEBASSEMBLY: ret
+}
+
f32x4 abs_f32x4(f32x4 x) {
return __builtin_wasm_abs_f32x4(x);
// WEBASSEMBLY: call <4 x float> @llvm.fabs.v4f32(<4 x float> %x)
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td b/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
index 05f4c28e14fc..191cdea0c0ae 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
@@ -848,6 +848,7 @@ multiclass SIMDBitmask<ValueType vec_t, string vec, bits<32> simdop> {
defm BITMASK : SIMDBitmask<v16i8, "i8x16", 100>;
defm BITMASK : SIMDBitmask<v8i16, "i16x8", 132>;
defm BITMASK : SIMDBitmask<v4i32, "i32x4", 164>;
+defm BITMASK : SIMDBitmask<v2i64, "i64x2", 196>;
//===----------------------------------------------------------------------===//
// Bit shifts
diff --git a/llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll b/llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
index 625ccf58eda4..23a7bfbde927 100644
--- a/llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
+++ b/llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
@@ -646,6 +646,16 @@ define i32 @all_v2i64(<2 x i64> %x) {
ret i32 %a
}
+; CHECK-LABEL: bitmask_v2i64:
+; SIMD128-NEXT: .functype bitmask_v2i64 (v128) -> (i32){{$}}
+; SIMD128-NEXT: i64x2.bitmask $push[[R:[0-9]+]]=, $0{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+declare i32 @llvm.wasm.bitmask.v2i64(<2 x i64>)
+define i32 @bitmask_v2i64(<2 x i64> %x) {
+ %a = call i32 @llvm.wasm.bitmask.v2i64(<2 x i64> %x)
+ ret i32 %a
+}
+
; CHECK-LABEL: bitselect_v2i64:
; SIMD128-NEXT: .functype bitselect_v2i64 (v128, v128, v128) -> (v128){{$}}
; SIMD128-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $0, $1, $2{{$}}
diff --git a/llvm/test/MC/WebAssembly/simd-encodings.s b/llvm/test/MC/WebAssembly/simd-encodings.s
index a0560b597864..509f4246475f 100644
--- a/llvm/test/MC/WebAssembly/simd-encodings.s
+++ b/llvm/test/MC/WebAssembly/simd-encodings.s
@@ -523,6 +523,9 @@ main:
# CHECK: i64x2.all_true # encoding: [0xfd,0xc3,0x01]
i64x2.all_true
+ # CHECK: i64x2.bitmask # encoding: [0xfd,0xc4,0x01]
+ i64x2.bitmask
+
# CHECK: i64x2.widen_low_i32x4_s # encoding: [0xfd,0xc7,0x01]
i64x2.widen_low_i32x4_s
More information about the cfe-commits
mailing list