Skip to content

Commit 51d3a43

Browse files
author
git apple-llvm automerger
committed
Merge commit '840afbde48e9' from llvm.org/main into next
2 parents 5a98dce + 840afbd commit 51d3a43

File tree

4 files changed

+29
-22
lines changed

4 files changed

+29
-22
lines changed

clang/lib/Sema/SemaChecking.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3621,6 +3621,8 @@ static bool isPPC_64Builtin(unsigned BuiltinID) {
36213621
case PPC::BI__builtin_ppc_insert_exp:
36223622
case PPC::BI__builtin_ppc_extract_sig:
36233623
case PPC::BI__builtin_ppc_addex:
3624+
case PPC::BI__builtin_darn:
3625+
case PPC::BI__builtin_darn_raw:
36243626
return true;
36253627
}
36263628
return false;
@@ -3804,6 +3806,11 @@ bool Sema::CheckPPCBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
38043806
case PPC::BI__builtin_altivec_vcntmbw:
38053807
case PPC::BI__builtin_altivec_vcntmbd:
38063808
return SemaBuiltinConstantArgRange(TheCall, 1, 0, 1);
3809+
case PPC::BI__builtin_darn:
3810+
case PPC::BI__builtin_darn_raw:
3811+
case PPC::BI__builtin_darn_32:
3812+
return SemaFeatureCheck(*this, TheCall, "isa-v30-instructions",
3813+
diag::err_ppc_builtin_only_on_arch, "9");
38073814
#define CUSTOM_BUILTIN(Name, Intr, Types, Acc) \
38083815
case PPC::BI__builtin_##Name: \
38093816
return SemaBuiltinPPCMMACall(TheCall, Types);

clang/test/CodeGen/builtins-ppc-xlcompat-darn.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
// REQUIRES: powerpc-registered-target
22
// RUN: %clang_cc1 -triple powerpc64-unknown-unknown \
3-
// RUN: -emit-llvm %s -o - -target-cpu pwr9 | FileCheck %s
3+
// RUN: -emit-llvm %s -o - -target-cpu pwr9 | \
4+
// RUN: FileCheck %s --check-prefix=CHECK-64
45
// RUN: %clang_cc1 -triple powerpc64le-unknown-unknown \
5-
// RUN: -emit-llvm %s -o - -target-cpu pwr9 | FileCheck %s
6+
// RUN: -emit-llvm %s -o - -target-cpu pwr9 | \
7+
// RUN: FileCheck %s --check-prefix=CHECK-64
68
// RUN: %clang_cc1 -triple powerpc64-unknown-aix \
7-
// RUN: -emit-llvm %s -o - -target-cpu pwr9 | FileCheck %s
9+
// RUN: -emit-llvm %s -o - -target-cpu pwr9 | \
10+
// RUN: FileCheck %s --check-prefix=CHECK-64
811
// RUN: %clang_cc1 -triple powerpc-unknown-unknown \
912
// RUN: -emit-llvm %s -o - -target-cpu pwr9 | FileCheck %s
1013
// RUN: %clang_cc1 -triple powerpcle-unknown-unknown \
@@ -15,21 +18,23 @@
1518
// The darn class of builtins are Power 9 and up and only darn_32 works in
1619
// 32 bit mode.
1720

18-
// CHECK-LABEL: @testdarn(
19-
// CHECK: [[TMP0:%.*]] = call i64 @llvm.ppc.darn()
20-
// CHECK-NEXT: ret i64 [[TMP0]]
21+
#ifdef __PPC64__
22+
// CHECK-64-LABEL: @testdarn(
23+
// CHECK-64: [[TMP0:%.*]] = call i64 @llvm.ppc.darn()
24+
// CHECK-64-NEXT: ret i64 [[TMP0]]
2125
//
2226
long long testdarn(void) {
2327
return __darn();
2428
}
2529

26-
// CHECK-LABEL: @testdarn_raw(
27-
// CHECK: [[TMP0:%.*]] = call i64 @llvm.ppc.darnraw()
28-
// CHECK-NEXT: ret i64 [[TMP0]]
30+
// CHECK-64-LABEL: @testdarn_raw(
31+
// CHECK-64: [[TMP0:%.*]] = call i64 @llvm.ppc.darnraw()
32+
// CHECK-64-NEXT: ret i64 [[TMP0]]
2933
//
3034
long long testdarn_raw(void) {
3135
return __darn_raw();
3236
}
37+
#endif
3338

3439
// CHECK-LABEL: @testdarn_32(
3540
// CHECK: [[TMP0:%.*]] = call i32 @llvm.ppc.darn32()

clang/test/CodeGen/builtins-ppc-xlcompat-error.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ long long testdivde(long long dividend, long long divisor) {
9696
unsigned long long testdivdeu(unsigned long long dividend, unsigned long long divisor) {
9797
return __divdeu(dividend, divisor); //expected-error {{this builtin is only available on 64-bit targets}}
9898
}
99+
100+
int test_darn() {
101+
return __darn(); //expected-error {{this builtin is only available on 64-bit targets}}
102+
}
103+
104+
int test_darn_raw() {
105+
return __darn_raw(); //expected-error {{this builtin is only available on 64-bit targets}}
106+
}
99107
#endif
100108

101109
unsigned long test_mfspr(void) {

clang/test/CodeGen/builtins-ppc.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,3 @@ void test_builtin_ppc_flm() {
3636
// CHECK: call double @llvm.ppc.setflm(double %1)
3737
res = __builtin_setflm(res);
3838
}
39-
40-
void test_builtin_ppc_darn() {
41-
volatile long res;
42-
volatile int x;
43-
// CHECK: call i64 @llvm.ppc.darn()
44-
res = __builtin_darn();
45-
46-
// CHECK: call i64 @llvm.ppc.darnraw()
47-
res = __builtin_darn_raw();
48-
49-
// CHECK: call i32 @llvm.ppc.darn32()
50-
x = __builtin_darn_32();
51-
}

0 commit comments

Comments
 (0)