r343837 - [WebAssembly] any_true and all_true builtins
Thomas Lively via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 4 17:59:37 PDT 2018
Author: tlively
Date: Thu Oct 4 17:59:37 2018
New Revision: 343837
URL: http://llvm.org/viewvc/llvm-project?rev=343837&view=rev
Log:
[WebAssembly] any_true and all_true builtins
Summary: Depends on D52858.
Reviewers: aheejin, dschuff, craig.topper
Subscribers: sbc100, jgravelle-google, sunfish, kristina, cfe-commits
Differential Revision: https://reviews.llvm.org/D52910
Modified:
cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtins-wasm.c
Modified: cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def?rev=343837&r1=343836&r2=343837&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def Thu Oct 4 17:59:37 2018
@@ -66,4 +66,13 @@ BUILTIN(__builtin_wasm_sub_saturate_u_i8
BUILTIN(__builtin_wasm_sub_saturate_s_i16x8, "V8sV8sV8s", "nc")
BUILTIN(__builtin_wasm_sub_saturate_u_i16x8, "V8sV8sV8s", "nc")
+BUILTIN(__builtin_wasm_any_true_i8x16, "iV16c", "nc")
+BUILTIN(__builtin_wasm_any_true_i16x8, "iV8s", "nc")
+BUILTIN(__builtin_wasm_any_true_i32x4, "iV4i", "nc")
+BUILTIN(__builtin_wasm_any_true_i64x2, "iV2LLi", "nc")
+BUILTIN(__builtin_wasm_all_true_i8x16, "iV16c", "nc")
+BUILTIN(__builtin_wasm_all_true_i16x8, "iV8s", "nc")
+BUILTIN(__builtin_wasm_all_true_i32x4, "iV4i", "nc")
+BUILTIN(__builtin_wasm_all_true_i64x2, "iV2LLi", "nc")
+
#undef BUILTIN
Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=343837&r1=343836&r2=343837&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Oct 4 17:59:37 2018
@@ -12536,6 +12536,35 @@ Value *CodeGenFunction::EmitWebAssemblyB
Value *Callee = CGM.getIntrinsic(IntNo, ConvertType(E->getType()));
return Builder.CreateCall(Callee, {LHS, RHS});
}
+ case WebAssembly::BI__builtin_wasm_any_true_i8x16:
+ case WebAssembly::BI__builtin_wasm_any_true_i16x8:
+ case WebAssembly::BI__builtin_wasm_any_true_i32x4:
+ case WebAssembly::BI__builtin_wasm_any_true_i64x2:
+ case WebAssembly::BI__builtin_wasm_all_true_i8x16:
+ case WebAssembly::BI__builtin_wasm_all_true_i16x8:
+ case WebAssembly::BI__builtin_wasm_all_true_i32x4:
+ case WebAssembly::BI__builtin_wasm_all_true_i64x2: {
+ unsigned IntNo;
+ switch (BuiltinID) {
+ case WebAssembly::BI__builtin_wasm_any_true_i8x16:
+ case WebAssembly::BI__builtin_wasm_any_true_i16x8:
+ case WebAssembly::BI__builtin_wasm_any_true_i32x4:
+ case WebAssembly::BI__builtin_wasm_any_true_i64x2:
+ IntNo = Intrinsic::wasm_anytrue;
+ break;
+ case WebAssembly::BI__builtin_wasm_all_true_i8x16:
+ case WebAssembly::BI__builtin_wasm_all_true_i16x8:
+ case WebAssembly::BI__builtin_wasm_all_true_i32x4:
+ case WebAssembly::BI__builtin_wasm_all_true_i64x2:
+ IntNo = Intrinsic::wasm_alltrue;
+ break;
+ default:
+ llvm_unreachable("unexpected builtin ID");
+ }
+ Value *Vec = EmitScalarExpr(E->getArg(0));
+ Value *Callee = CGM.getIntrinsic(IntNo, Vec->getType());
+ return Builder.CreateCall(Callee, {Vec});
+ }
default:
return nullptr;
Modified: cfe/trunk/test/CodeGen/builtins-wasm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-wasm.c?rev=343837&r1=343836&r2=343837&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/builtins-wasm.c (original)
+++ cfe/trunk/test/CodeGen/builtins-wasm.c Thu Oct 4 17:59:37 2018
@@ -228,3 +228,51 @@ i16x8 f32(i16x8 x, i16x8 y) {
// WEBASSEMBLY-SAME: <8 x i16> %x, <8 x i16> %y)
// WEBASSEMBLY-NEXT: ret
}
+
+int f33(i8x16 x) {
+ return __builtin_wasm_any_true_i8x16(x);
+ // WEBASSEMBLY: call i32 @llvm.wasm.anytrue.v16i8(<16 x i8> %x)
+ // WEBASSEMBLY: ret
+}
+
+int f34(i16x8 x) {
+ return __builtin_wasm_any_true_i16x8(x);
+ // WEBASSEMBLY: call i32 @llvm.wasm.anytrue.v8i16(<8 x i16> %x)
+ // WEBASSEMBLY: ret
+}
+
+int f35(i32x4 x) {
+ return __builtin_wasm_any_true_i32x4(x);
+ // WEBASSEMBLY: call i32 @llvm.wasm.anytrue.v4i32(<4 x i32> %x)
+ // WEBASSEMBLY: ret
+}
+
+int f36(i64x2 x) {
+ return __builtin_wasm_any_true_i64x2(x);
+ // WEBASSEMBLY: call i32 @llvm.wasm.anytrue.v2i64(<2 x i64> %x)
+ // WEBASSEMBLY: ret
+}
+
+int f37(i8x16 x) {
+ return __builtin_wasm_all_true_i8x16(x);
+ // WEBASSEMBLY: call i32 @llvm.wasm.alltrue.v16i8(<16 x i8> %x)
+ // WEBASSEMBLY: ret
+}
+
+int f38(i16x8 x) {
+ return __builtin_wasm_all_true_i16x8(x);
+ // WEBASSEMBLY: call i32 @llvm.wasm.alltrue.v8i16(<8 x i16> %x)
+ // WEBASSEMBLY: ret
+}
+
+int f39(i32x4 x) {
+ return __builtin_wasm_all_true_i32x4(x);
+ // WEBASSEMBLY: call i32 @llvm.wasm.alltrue.v4i32(<4 x i32> %x)
+ // WEBASSEMBLY: ret
+}
+
+int f40(i64x2 x) {
+ return __builtin_wasm_all_true_i64x2(x);
+ // WEBASSEMBLY: call i32 @llvm.wasm.alltrue.v2i64(<2 x i64> %x)
+ // WEBASSEMBLY: ret
+}
More information about the cfe-commits
mailing list