quinnp created this revision. Herald added subscribers: shchenz, kbarton, nemanjai. quinnp requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
This patch is in a series of patches to provide builtins for compatibility with the XL compiler. This patch adds semachecking for an already implemented builtin, __icbt. __icbt is only valid fore Power8 and up. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D105834 Files: clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-ppc-xlcompat-pwr8.c Index: clang/test/CodeGen/builtins-ppc-xlcompat-pwr8.c =================================================================== --- /dev/null +++ clang/test/CodeGen/builtins-ppc-xlcompat-pwr8.c @@ -0,0 +1,32 @@ +// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -emit-llvm %s \ +// RUN: -target-cpu pwr8 -o - | FileCheck %s -check-prefix=CHECK-PWR8 +// RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -emit-llvm %s \ +// RUN: -target-cpu pwr8 -o - | FileCheck %s -check-prefix=CHECK-PWR8 +// RUN: %clang_cc1 -triple powerpc64-unknown-aix -emit-llvm %s \ +// RUN: -target-cpu pwr8 -o - | FileCheck %s -check-prefix=CHECK-PWR8 +// RUN: %clang_cc1 -triple powerpc-unknown-aix %s -emit-llvm %s \ +// RUN: -target-cpu pwr8 -o - | FileCheck %s -check-prefix=CHECK-PWR8 +// RUN: not %clang_cc1 -triple powerpc64-unknown-unknown -emit-llvm %s \ +// RUN: -target-cpu pwr7 2>&1 | FileCheck %s -check-prefix=CHECK-NOPWR8 +// RUN: not %clang_cc1 -triple powerpc64-unknown-aix -emit-llvm %s \ +// RUN: -target-cpu pwr7 2>&1 | FileCheck %s -check-prefix=CHECK-NOPWR8 +// RUN: not %clang_cc1 -triple powerpc-unknown-aix %s -emit-llvm %s \ +// RUN: -target-cpu pwr7 2>&1 | FileCheck %s -check-prefix=CHECK-NOPWR8 + +extern void *a; + +void test_icbt() { +// CHECK-LABEL: @test_icbt( + + __icbt(a); +// CHECK-PWR8: call void @llvm.ppc.icbt(i8* %0) +// CHECK-NOPWR8: error: this builtin is only valid on POWER8 or later CPUs +} + +void test_builtin_ppc_icbt() { +// CHECK-LABEL: @test_builtin_ppc_icbt( + + __builtin_ppc_icbt(a); +// CHECK-PWR8: call void @llvm.ppc.icbt(i8* %0) +// CHECK-NOPWR8: error: this builtin is only valid on POWER8 or later CPUs +} Index: clang/lib/Sema/SemaChecking.cpp =================================================================== --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -3355,6 +3355,9 @@ return SemaBuiltinConstantArgRange(TheCall, 2, 0, 7); case PPC::BI__builtin_vsx_xxpermx: return SemaBuiltinConstantArgRange(TheCall, 3, 0, 7); + case PPC::BI__builtin_ppc_icbt: + return SemaFeatureCheck(*this, TheCall, "isa-v207-instructions", + diag::err_ppc_builtin_only_on_arch, "8"); #define CUSTOM_BUILTIN(Name, Intr, Types, Acc) \ case PPC::BI__builtin_##Name: \ return SemaBuiltinPPCMMACall(TheCall, Types);
Index: clang/test/CodeGen/builtins-ppc-xlcompat-pwr8.c =================================================================== --- /dev/null +++ clang/test/CodeGen/builtins-ppc-xlcompat-pwr8.c @@ -0,0 +1,32 @@ +// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -emit-llvm %s \ +// RUN: -target-cpu pwr8 -o - | FileCheck %s -check-prefix=CHECK-PWR8 +// RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -emit-llvm %s \ +// RUN: -target-cpu pwr8 -o - | FileCheck %s -check-prefix=CHECK-PWR8 +// RUN: %clang_cc1 -triple powerpc64-unknown-aix -emit-llvm %s \ +// RUN: -target-cpu pwr8 -o - | FileCheck %s -check-prefix=CHECK-PWR8 +// RUN: %clang_cc1 -triple powerpc-unknown-aix %s -emit-llvm %s \ +// RUN: -target-cpu pwr8 -o - | FileCheck %s -check-prefix=CHECK-PWR8 +// RUN: not %clang_cc1 -triple powerpc64-unknown-unknown -emit-llvm %s \ +// RUN: -target-cpu pwr7 2>&1 | FileCheck %s -check-prefix=CHECK-NOPWR8 +// RUN: not %clang_cc1 -triple powerpc64-unknown-aix -emit-llvm %s \ +// RUN: -target-cpu pwr7 2>&1 | FileCheck %s -check-prefix=CHECK-NOPWR8 +// RUN: not %clang_cc1 -triple powerpc-unknown-aix %s -emit-llvm %s \ +// RUN: -target-cpu pwr7 2>&1 | FileCheck %s -check-prefix=CHECK-NOPWR8 + +extern void *a; + +void test_icbt() { +// CHECK-LABEL: @test_icbt( + + __icbt(a); +// CHECK-PWR8: call void @llvm.ppc.icbt(i8* %0) +// CHECK-NOPWR8: error: this builtin is only valid on POWER8 or later CPUs +} + +void test_builtin_ppc_icbt() { +// CHECK-LABEL: @test_builtin_ppc_icbt( + + __builtin_ppc_icbt(a); +// CHECK-PWR8: call void @llvm.ppc.icbt(i8* %0) +// CHECK-NOPWR8: error: this builtin is only valid on POWER8 or later CPUs +} Index: clang/lib/Sema/SemaChecking.cpp =================================================================== --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -3355,6 +3355,9 @@ return SemaBuiltinConstantArgRange(TheCall, 2, 0, 7); case PPC::BI__builtin_vsx_xxpermx: return SemaBuiltinConstantArgRange(TheCall, 3, 0, 7); + case PPC::BI__builtin_ppc_icbt: + return SemaFeatureCheck(*this, TheCall, "isa-v207-instructions", + diag::err_ppc_builtin_only_on_arch, "8"); #define CUSTOM_BUILTIN(Name, Intr, Types, Acc) \ case PPC::BI__builtin_##Name: \ return SemaBuiltinPPCMMACall(TheCall, Types);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits