diff options
author | Amy Kwan <amy.kwan1@ibm.com> | 2022-05-02 01:30:10 -0500 |
---|---|---|
committer | Amy Kwan <amy.kwan1@ibm.com> | 2022-05-02 12:06:15 -0500 |
commit | 2534dc120a4c9468d9a0044665a50361089f0a4d (patch) | |
tree | 1531e3e2a92231dcc577b742e3fcbe92f192015d /clang | |
parent | 3d09c9b30fe6484717181a926e14b2ee36747d13 (diff) | |
download | llvm-2534dc120a4c9468d9a0044665a50361089f0a4d.zip llvm-2534dc120a4c9468d9a0044665a50361089f0a4d.tar.gz llvm-2534dc120a4c9468d9a0044665a50361089f0a4d.tar.bz2 |
[PowerPC] Enable CR bits support for Power8 and above.
This patch turns on support for CR bit accesses for Power8 and above. The reason
why CR bits are turned on as the default for Power8 and above is that because
later architectures make use of builtins and instructions that require CR bit
accesses (such as the use of setbc in the vector string isolate predicate
and bcd builtins on Power10).
This patch also adds the clang portion to allow for turning on CR bits in the
front end if the user so desires to.
Differential Revision: https://reviews.llvm.org/D124060
Diffstat (limited to 'clang')
-rw-r--r-- | clang/docs/ClangCommandLineReference.rst | 2 | ||||
-rw-r--r-- | clang/lib/Basic/Targets/PPC.cpp | 8 | ||||
-rw-r--r-- | clang/lib/Basic/Targets/PPC.h | 1 | ||||
-rw-r--r-- | clang/test/Driver/ppc-crbits.cpp | 112 |
4 files changed, 123 insertions, 0 deletions
diff --git a/clang/docs/ClangCommandLineReference.rst b/clang/docs/ClangCommandLineReference.rst index 384b092..d8fa4b3 100644 --- a/clang/docs/ClangCommandLineReference.rst +++ b/clang/docs/ClangCommandLineReference.rst @@ -3575,6 +3575,8 @@ PowerPC .. option:: -mcrbits, -mno-crbits +Control the CR-bit tracking feature on PowerPC. ``-mcrbits`` (the enablement of CR-bit tracking support) is the default for POWER8 and above, as well as for all other CPUs when optimization is applied (-O2 and above). + .. option:: -mcrypto, -mno-crypto .. option:: -mdirect-move, -mno-direct-move diff --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp index e3ee68c..a2e50f3 100644 --- a/clang/lib/Basic/Targets/PPC.cpp +++ b/clang/lib/Basic/Targets/PPC.cpp @@ -36,6 +36,8 @@ bool PPCTargetInfo::handleTargetFeatures(std::vector<std::string> &Features, HasAltivec = true; } else if (Feature == "+vsx") { HasVSX = true; + } else if (Feature == "+crbits") { + UseCRBits = true; } else if (Feature == "+bpermd") { HasBPERMD = true; } else if (Feature == "+extdiv") { @@ -515,6 +517,11 @@ bool PPCTargetInfo::initFeatureMap( .Case("pwr9", true) .Case("pwr8", true) .Default(false); + Features["crbits"] = llvm::StringSwitch<bool>(CPU) + .Case("ppc64le", true) + .Case("pwr9", true) + .Case("pwr8", true) + .Default(false); Features["vsx"] = llvm::StringSwitch<bool>(CPU) .Case("ppc64le", true) .Case("pwr9", true) @@ -649,6 +656,7 @@ bool PPCTargetInfo::hasFeature(StringRef Feature) const { .Case("powerpc", true) .Case("altivec", HasAltivec) .Case("vsx", HasVSX) + .Case("crbits", UseCRBits) .Case("power8-vector", HasP8Vector) .Case("crypto", HasP8Crypto) .Case("direct-move", HasDirectMove) diff --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h index 44489d0..8148762 100644 --- a/clang/lib/Basic/Targets/PPC.h +++ b/clang/lib/Basic/Targets/PPC.h @@ -62,6 +62,7 @@ class LLVM_LIBRARY_VISIBILITY PPCTargetInfo : public TargetInfo { bool HasROPProtect = false; bool HasPrivileged = false; bool HasVSX = false; + bool UseCRBits = false; bool HasP8Vector = false; bool HasP8Crypto = false; bool HasDirectMove = false; diff --git a/clang/test/Driver/ppc-crbits.cpp b/clang/test/Driver/ppc-crbits.cpp new file mode 100644 index 0000000..3ed5630 --- /dev/null +++ b/clang/test/Driver/ppc-crbits.cpp @@ -0,0 +1,112 @@ +// RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -mcpu=pwr10 \ +// RUN: -mcrbits -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-CRBITS %s +// RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -mcpu=pwr10 \ +// RUN: -mno-crbits -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOCRBITS %s + +// RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -mcpu=pwr9 \ +// RUN: -mcrbits -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-CRBITS %s +// RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -mcpu=pwr9 \ +// RUN: -mno-crbits -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOCRBITS %s + +// RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -mcpu=pwr8 \ +// RUN: -mcrbits -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-CRBITS %s +// RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -mcpu=pwr8 \ +// RUN: -mno-crbits -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOCRBITS %s + +// RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -mcpu=pwr7 \ +// RUN: -mcrbits -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-CRBITS %s +// RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -mcpu=pwr7 \ +// RUN: -mno-crbits -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOCRBITS %s + +// RUN: %clang -target powerpc-ibm-aix %s -### -mcpu=pwr10 \ +// RUN: -mcrbits -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-CRBITS %s +// RUN: %clang -target powerpc-ibm-aix %s -### -mcpu=pwr10 \ +// RUN: -mno-crbits -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOCRBITS %s + +// RUN: %clang -target powerpc-ibm-aix %s -### -mcpu=pwr9 \ +// RUN: -mcrbits -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-CRBITS %s +// RUN: %clang -target powerpc-ibm-aix %s -### -mcpu=pwr9 \ +// RUN: -mno-crbits -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOCRBITS %s + +// RUN: %clang -target powerpc-ibm-aix %s -### -mcpu=pwr8 \ +// RUN: -mcrbits -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-CRBITS %s +// RUN: %clang -target powerpc-ibm-aix %s -### -mcpu=pwr8 \ +// RUN: -mno-crbits -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOCRBITS %s + +// RUN: %clang -target powerpc-ibm-aix %s -### -mcpu=pwr7 \ +// RUN: -mcrbits -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-CRBITS %s +// RUN: %clang -target powerpc-ibm-aix %s -### -mcpu=pwr7 \ +// RUN: -mno-crbits -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOCRBITS %s + + +// CHECK-NOCRBITS: "-target-feature" "-crbits" +// CHECK-CRBITS: "-target-feature" "+crbits" + + +// RUN: %clang -target powerpc64le-unknown-linux-gnu -mcpu=pwr10 -emit-llvm \ +// RUN: -S %s -o - | FileCheck %s --check-prefix=HAS-CRBITS +// RUN: %clang -target powerpc64le-unknown-linux-gnu -mcpu=pwr10 -mcrbits \ +// RUN: -emit-llvm -S %s -o - | FileCheck %s --check-prefix=HAS-CRBITS +// RUN: %clang -target powerpc64le-unknown-linux-gnu -mcpu=pwr10 -mno-crbits \ +// RUN: -emit-llvm -S %s -o - | FileCheck %s --check-prefix=HAS-NOCRBITS + +// RUN: %clang -target powerpc64le-unknown-linux-gnu -mcpu=pwr9 -emit-llvm \ +// RUN: -S %s -o - | FileCheck %s --check-prefix=HAS-CRBITS +// RUN: %clang -target powerpc64le-unknown-linux-gnu -mcpu=pwr9 -mcrbits \ +// RUN: -emit-llvm -S %s -o - | FileCheck %s --check-prefix=HAS-CRBITS +// RUN: %clang -target powerpc64le-unknown-linux-gnu -mcpu=pwr9 -mno-crbits \ +// RUN: -emit-llvm -S %s -o - | FileCheck %s --check-prefix=HAS-NOCRBITS + +// RUN: %clang -target powerpc64le-unknown-linux-gnu -mcpu=pwr8 -emit-llvm \ +// RUN: -S %s -o - | FileCheck %s --check-prefix=HAS-CRBITS +// RUN: %clang -target powerpc64le-unknown-linux-gnu -mcpu=pwr8 -mcrbits \ +// RUN: -emit-llvm -S %s -o - | FileCheck %s --check-prefix=HAS-CRBITS +// RUN: %clang -target powerpc64le-unknown-linux-gnu -mcpu=pwr8 -mno-crbits \ +// RUN: -emit-llvm -S %s -o - | FileCheck %s --check-prefix=HAS-NOCRBITS + +// RUN: %clang -target powerpc64le-unknown-linux-gnu -mcpu=pwr7 -emit-llvm \ +// RUN: -S %s -o - | FileCheck %s --check-prefix=HAS-NOCRBITS +// RUN: %clang -target powerpc64le-unknown-linux-gnu -mcpu=pwr7 -mcrbits \ +// RUN: -emit-llvm -S %s -o - | FileCheck %s --check-prefix=HAS-CRBITS +// RUN: %clang -target powerpc64le-unknown-linux-gnu -mcpu=pwr7 -mno-crbits \ +// RUN: -emit-llvm -S %s -o - | FileCheck %s --check-prefix=HAS-NOCRBITS + +// RUN: %clang -target powerpc-ibm-aix -mcpu=pwr10 -emit-llvm \ +// RUN: -S %s -o - | FileCheck %s --check-prefix=HAS-CRBITS +// RUN: %clang -target powerpc-ibm-aix -mcpu=pwr10 -mcrbits \ +// RUN: -emit-llvm -S %s -o - | FileCheck %s --check-prefix=HAS-CRBITS +// RUN: %clang -target powerpc-ibm-aix -mcpu=pwr10 -mno-crbits \ +// RUN: -emit-llvm -S %s -o - | FileCheck %s --check-prefix=HAS-NOCRBITS + +// RUN: %clang -target powerpc-ibm-aix -mcpu=pwr9 -emit-llvm \ +// RUN: -S %s -o - | FileCheck %s --check-prefix=HAS-CRBITS +// RUN: %clang -target powerpc-ibm-aix -mcpu=pwr9 -mcrbits \ +// RUN: -emit-llvm -S %s -o - | FileCheck %s --check-prefix=HAS-CRBITS +// RUN: %clang -target powerpc-ibm-aix -mcpu=pwr9 -mno-crbits \ +// RUN: -emit-llvm -S %s -o - | FileCheck %s --check-prefix=HAS-NOCRBITS + +// RUN: %clang -target powerpc-ibm-aix -mcpu=pwr8 -emit-llvm \ +// RUN: -S %s -o - | FileCheck %s --check-prefix=HAS-CRBITS +// RUN: %clang -target powerpc-ibm-aix -mcpu=pwr8 -mcrbits \ +// RUN: -emit-llvm -S %s -o - | FileCheck %s --check-prefix=HAS-CRBITS +// RUN: %clang -target powerpc-ibm-aix -mcpu=pwr8 -mno-crbits \ +// RUN: -emit-llvm -S %s -o - | FileCheck %s --check-prefix=HAS-NOCRBITS + +// RUN: %clang -target powerpc-ibm-aix -mcpu=pwr7 -emit-llvm \ +// RUN: -S %s -o - | FileCheck %s --check-prefix=HAS-NOCRBITS +// RUN: %clang -target powerpc-ibm-aix -mcpu=pwr7 -mcrbits \ +// RUN: -emit-llvm -S %s -o - | FileCheck %s --check-prefix=HAS-CRBITS +// RUN: %clang -target powerpc-ibm-aix -mcpu=pwr7 -mno-crbits \ +// RUN: -emit-llvm -S %s -o - | FileCheck %s --check-prefix=HAS-NOCRBITS + + +// HAS-CRBITS: main( +// HAS-CRBITS: attributes #0 = { +// HAS-CRBITS-SAME: +crbits +// HAS-NOCRBITS: main( +// HAS-NOCRBITS: attributes #0 = { +// HAS-NOCRBITS-SAME: -crbits + +int main(int argc, char *argv[]) { + return 0; +} |