[clang] d3cd063 - [PowerPC] Require htm feature for HTM builtins
Qiu Chaofan via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 10 00:03:01 PST 2021
Author: Qiu Chaofan
Date: 2021-12-10T16:02:53+08:00
New Revision: d3cd0635e15a16fdf890c79035438c0f7c0d63b1
URL: https://github.com/llvm/llvm-project/commit/d3cd0635e15a16fdf890c79035438c0f7c0d63b1
DIFF: https://github.com/llvm/llvm-project/commit/d3cd0635e15a16fdf890c79035438c0f7c0d63b1.diff
LOG: [PowerPC] Require htm feature for HTM builtins
Reviewed By: jsji
Differential Revision: https://reviews.llvm.org/D114569
Added:
Modified:
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaChecking.cpp
clang/test/CodeGen/builtins-ppc-htm.c
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 0598be3a167f9..29d389ee0b0d7 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9811,6 +9811,8 @@ def err_ppc_builtin_only_on_arch : Error<
"this builtin is only valid on POWER%0 or later CPUs">;
def err_ppc_builtin_requires_vsx : Error<
"this builtin requires VSX to be enabled">;
+def err_ppc_builtin_requires_htm : Error<
+ "this builtin requires HTM to be enabled">;
def err_ppc_builtin_requires_abi : Error<
"this builtin requires ABI -mabi=%0">;
def err_ppc_invalid_use_mma_type : Error<
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 7e44e977550be..cd2dc5d9a1a98 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3533,14 +3533,43 @@ bool Sema::CheckPPCBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
case PPC::BI__builtin_altivec_dss:
return SemaBuiltinConstantArgRange(TheCall, 0, 0, 3);
case PPC::BI__builtin_tbegin:
- case PPC::BI__builtin_tend: i = 0; l = 0; u = 1; break;
- case PPC::BI__builtin_tsr: i = 0; l = 0; u = 7; break;
+ case PPC::BI__builtin_tend:
+ return SemaBuiltinConstantArgRange(TheCall, 0, 0, 1) ||
+ SemaFeatureCheck(*this, TheCall, "htm",
+ diag::err_ppc_builtin_requires_htm);
+ case PPC::BI__builtin_tsr:
+ return SemaBuiltinConstantArgRange(TheCall, 0, 0, 7) ||
+ SemaFeatureCheck(*this, TheCall, "htm",
+ diag::err_ppc_builtin_requires_htm);
case PPC::BI__builtin_tabortwc:
- case PPC::BI__builtin_tabortdc: i = 0; l = 0; u = 31; break;
+ case PPC::BI__builtin_tabortdc:
+ return SemaBuiltinConstantArgRange(TheCall, 0, 0, 31) ||
+ SemaFeatureCheck(*this, TheCall, "htm",
+ diag::err_ppc_builtin_requires_htm);
case PPC::BI__builtin_tabortwci:
case PPC::BI__builtin_tabortdci:
- return SemaBuiltinConstantArgRange(TheCall, 0, 0, 31) ||
- SemaBuiltinConstantArgRange(TheCall, 2, 0, 31);
+ return SemaFeatureCheck(*this, TheCall, "htm",
+ diag::err_ppc_builtin_requires_htm) ||
+ (SemaBuiltinConstantArgRange(TheCall, 0, 0, 31) ||
+ SemaBuiltinConstantArgRange(TheCall, 2, 0, 31));
+ case PPC::BI__builtin_tabort:
+ case PPC::BI__builtin_tcheck:
+ case PPC::BI__builtin_treclaim:
+ case PPC::BI__builtin_trechkpt:
+ case PPC::BI__builtin_tendall:
+ case PPC::BI__builtin_tresume:
+ case PPC::BI__builtin_tsuspend:
+ case PPC::BI__builtin_get_texasr:
+ case PPC::BI__builtin_get_texasru:
+ case PPC::BI__builtin_get_tfhar:
+ case PPC::BI__builtin_get_tfiar:
+ case PPC::BI__builtin_set_texasr:
+ case PPC::BI__builtin_set_texasru:
+ case PPC::BI__builtin_set_tfhar:
+ case PPC::BI__builtin_set_tfiar:
+ case PPC::BI__builtin_ttest:
+ return SemaFeatureCheck(*this, TheCall, "htm",
+ diag::err_ppc_builtin_requires_htm);
// According to GCC 'Basic PowerPC Built-in Functions Available on ISA 2.05',
// __builtin_(un)pack_longdouble are available only if long double uses IBM
// extended double representation.
diff --git a/clang/test/CodeGen/builtins-ppc-htm.c b/clang/test/CodeGen/builtins-ppc-htm.c
index 36cb795032fa7..d518c00f12caf 100644
--- a/clang/test/CodeGen/builtins-ppc-htm.c
+++ b/clang/test/CodeGen/builtins-ppc-htm.c
@@ -1,62 +1,88 @@
// REQUIRES: powerpc-registered-target
// RUN: %clang_cc1 -target-feature +altivec -target-feature +htm -triple powerpc64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: not %clang_cc1 -target-feature +altivec -target-feature -htm -triple powerpc64-unknown-unknown -emit-llvm %s 2>&1 | FileCheck %s --check-prefix=ERROR
void test1(long int *r, int code, long int *a, long int *b) {
// CHECK-LABEL: define{{.*}} void @test1
r[0] = __builtin_tbegin (0);
// CHECK: @llvm.ppc.tbegin
+// ERROR: error: this builtin requires HTM to be enabled
r[1] = __builtin_tbegin (1);
// CHECK: @llvm.ppc.tbegin
+// ERROR: error: this builtin requires HTM to be enabled
r[2] = __builtin_tend (0);
// CHECK: @llvm.ppc.tend
+// ERROR: error: this builtin requires HTM to be enabled
r[3] = __builtin_tendall ();
// CHECK: @llvm.ppc.tendall
+// ERROR: error: this builtin requires HTM to be enabled
r[4] = __builtin_tabort (code);
// CHECK: @llvm.ppc.tabort
+// ERROR: error: this builtin requires HTM to be enabled
r[5] = __builtin_tabort (0x1);
// CHECK: @llvm.ppc.tabort
+// ERROR: error: this builtin requires HTM to be enabled
r[6] = __builtin_tabortdc (0xf, a[0], b[0]);
// CHECK: @llvm.ppc.tabortdc
+// ERROR: error: this builtin requires HTM to be enabled
r[7] = __builtin_tabortdci (0xf, a[1], 0x1);
// CHECK: @llvm.ppc.tabortdc
+// ERROR: error: this builtin requires HTM to be enabled
r[8] = __builtin_tabortwc (0xf, a[2], b[2]);
// CHECK: @llvm.ppc.tabortwc
+// ERROR: error: this builtin requires HTM to be enabled
r[9] = __builtin_tabortwci (0xf, a[3], 0x1);
// CHECK: @llvm.ppc.tabortwc
+// ERROR: error: this builtin requires HTM to be enabled
r[10] = __builtin_tcheck ();
// CHECK: @llvm.ppc.tcheck
+// ERROR: error: this builtin requires HTM to be enabled
r[11] = __builtin_trechkpt ();
// CHECK: @llvm.ppc.trechkpt
+// ERROR: error: this builtin requires HTM to be enabled
r[12] = __builtin_treclaim (0);
// CHECK: @llvm.ppc.treclaim
+// ERROR: error: this builtin requires HTM to be enabled
r[13] = __builtin_tresume ();
// CHECK: @llvm.ppc.tresume
+// ERROR: error: this builtin requires HTM to be enabled
r[14] = __builtin_tsuspend ();
// CHECK: @llvm.ppc.tsuspend
+// ERROR: error: this builtin requires HTM to be enabled
r[15] = __builtin_tsr (0);
// CHECK: @llvm.ppc.tsr
+// ERROR: error: this builtin requires HTM to be enabled
r[16] = __builtin_ttest ();
// CHECK: @llvm.ppc.ttest
+// ERROR: error: this builtin requires HTM to be enabled
r[17] = __builtin_get_texasr ();
// CHECK: @llvm.ppc.get.texasr
+// ERROR: error: this builtin requires HTM to be enabled
r[18] = __builtin_get_texasru ();
// CHECK: @llvm.ppc.get.texasru
+// ERROR: error: this builtin requires HTM to be enabled
r[19] = __builtin_get_tfhar ();
// CHECK: @llvm.ppc.get.tfhar
+// ERROR: error: this builtin requires HTM to be enabled
r[20] = __builtin_get_tfiar ();
// CHECK: @llvm.ppc.get.tfiar
+// ERROR: error: this builtin requires HTM to be enabled
__builtin_set_texasr (a[21]);
// CHECK: @llvm.ppc.set.texasr
+// ERROR: error: this builtin requires HTM to be enabled
__builtin_set_texasru (a[22]);
// CHECK: @llvm.ppc.set.texasru
+// ERROR: error: this builtin requires HTM to be enabled
__builtin_set_tfhar (a[23]);
// CHECK: @llvm.ppc.set.tfhar
+// ERROR: error: this builtin requires HTM to be enabled
__builtin_set_tfiar (a[24]);
// CHECK: @llvm.ppc.set.tfiar
+// ERROR: error: this builtin requires HTM to be enabled
}
More information about the cfe-commits
mailing list