[PATCH] D110282: [PowerPC] SemaChecking for darn family of builtins
Albion Fung via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 22 12:39:16 PDT 2021
Conanap created this revision.
Conanap added reviewers: PowerPC, nemanjai, saghir, stefanp.
Conanap added projects: PowerPC, clang, LLVM.
Herald added a subscriber: kbarton.
Conanap requested review of this revision.
The `__darn` family of builtins are only available on Pwr9,
and only `__darn_32` is available on 32 bit, while the rest
are only available on 64 bit. The patch adds sema checking
for these builtins and separate the `__darn_32`'s 32 bit
test cases.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D110282
Files:
clang/lib/Sema/SemaChecking.cpp
clang/test/CodeGen/builtins-ppc-xlcompat-darn-32.c
clang/test/CodeGen/builtins-ppc-xlcompat-darn.c
clang/test/CodeGen/builtins-ppc.c
Index: clang/test/CodeGen/builtins-ppc.c
===================================================================
--- clang/test/CodeGen/builtins-ppc.c
+++ clang/test/CodeGen/builtins-ppc.c
@@ -36,16 +36,3 @@
// CHECK: call double @llvm.ppc.setflm(double %1)
res = __builtin_setflm(res);
}
-
-void test_builtin_ppc_darn() {
- volatile long res;
- volatile int x;
- // CHECK: call i64 @llvm.ppc.darn()
- res = __builtin_darn();
-
- // CHECK: call i64 @llvm.ppc.darnraw()
- res = __builtin_darn_raw();
-
- // CHECK: call i32 @llvm.ppc.darn32()
- x = __builtin_darn_32();
-}
Index: clang/test/CodeGen/builtins-ppc-xlcompat-darn.c
===================================================================
--- clang/test/CodeGen/builtins-ppc-xlcompat-darn.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat-darn.c
@@ -5,12 +5,6 @@
// RUN: -emit-llvm %s -o - -target-cpu pwr9 | FileCheck %s
// RUN: %clang_cc1 -triple powerpc64-unknown-aix \
// RUN: -emit-llvm %s -o - -target-cpu pwr9 | FileCheck %s
-// RUN: %clang_cc1 -triple powerpc-unknown-unknown \
-// RUN: -emit-llvm %s -o - -target-cpu pwr9 | FileCheck %s
-// RUN: %clang_cc1 -triple powerpcle-unknown-unknown \
-// RUN: -emit-llvm %s -o - -target-cpu pwr9 | FileCheck %s
-// RUN: %clang_cc1 -triple powerpc-unknown-aix \
-// RUN: -emit-llvm %s -o - -target-cpu pwr9 | FileCheck %s
// The darn class of builtins are Power 9 and up and only darn_32 works in
// 32 bit mode.
@@ -30,11 +24,3 @@
long long testdarn_raw(void) {
return __darn_raw();
}
-
-// CHECK-LABEL: @testdarn_32(
-// CHECK: [[TMP0:%.*]] = call i32 @llvm.ppc.darn32()
-// CHECK-NEXT: ret i32 [[TMP0]]
-//
-int testdarn_32(void) {
- return __darn_32();
-}
Index: clang/test/CodeGen/builtins-ppc-xlcompat-darn-32.c
===================================================================
--- /dev/null
+++ clang/test/CodeGen/builtins-ppc-xlcompat-darn-32.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple powerpc-unknown-unknown \
+// RUN: -emit-llvm %s -o - -target-cpu pwr9 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpcle-unknown-unknown \
+// RUN: -emit-llvm %s -o - -target-cpu pwr9 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc-unknown-aix \
+// RUN: -emit-llvm %s -o - -target-cpu pwr9 | FileCheck %s
+
+// CHECK-LABEL: @testdarn_32(
+// CHECK: [[TMP0:%.*]] = call i32 @llvm.ppc.darn32()
+// CHECK-NEXT: ret i32 [[TMP0]]
+//
+int testdarn_32(void) {
+ return __darn_32();
+}
Index: clang/lib/Sema/SemaChecking.cpp
===================================================================
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -3295,6 +3295,8 @@
case PPC::BI__builtin_ppc_insert_exp:
case PPC::BI__builtin_ppc_extract_sig:
case PPC::BI__builtin_ppc_addex:
+ case PPC::BI__builtin_darn:
+ case PPC::BI__builtin_darn_raw:
return true;
}
return false;
@@ -3473,6 +3475,11 @@
return SemaFeatureCheck(*this, TheCall, "isa-v207-instructions",
diag::err_ppc_builtin_only_on_arch, "8") ||
SemaBuiltinConstantArgRange(TheCall, 1, 1, 16);
+ case PPC::BI__builtin_darn:
+ case PPC::BI__builtin_darn_raw:
+ case PPC::BI__builtin_darn_32:
+ return SemaFeatureCheck(*this, TheCall, "isa-v30-instructions",
+ diag::err_ppc_builtin_only_on_arch, "9");
#define CUSTOM_BUILTIN(Name, Intr, Types, Acc) \
case PPC::BI__builtin_##Name: \
return SemaBuiltinPPCMMACall(TheCall, Types);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110282.374325.patch
Type: text/x-patch
Size: 3492 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210922/52da86ef/attachment.bin>
More information about the llvm-commits
mailing list