diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -2483,6 +2483,10 @@ Group; def mno_power9_vector : Flag<["-"], "mno-power9-vector">, Group; +def mpower10_vector : Flag<["-"], "mpower10-vector">, + Group; +def mno_power10_vector : Flag<["-"], "mno-power10-vector">, + Group; def mpower8_crypto : Flag<["-"], "mcrypto">, Group; def mnopower8_crypto : Flag<["-"], "mno-crypto">, diff --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h --- a/clang/lib/Basic/Targets/PPC.h +++ b/clang/lib/Basic/Targets/PPC.h @@ -68,6 +68,7 @@ bool HasBPERMD = false; bool HasExtDiv = false; bool HasP9Vector = false; + bool HasP10Vector = false; bool HasSPE = false; protected: diff --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp --- a/clang/lib/Basic/Targets/PPC.cpp +++ b/clang/lib/Basic/Targets/PPC.cpp @@ -54,6 +54,8 @@ HasFloat128 = true; } else if (Feature == "+power9-vector") { HasP9Vector = true; + } else if (Feature == "+power10-vector") { + HasP10Vector = true; } else if (Feature == "+spe") { HasSPE = true; LongDoubleWidth = LongDoubleAlign = 64; @@ -191,6 +193,8 @@ Builder.defineMacro("__FLOAT128__"); if (HasP9Vector) Builder.defineMacro("__POWER9_VECTOR__"); + if (HasP10Vector) + Builder.defineMacro("__POWER10_VECTOR__"); Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1"); Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2"); @@ -225,6 +229,7 @@ // - direct-move // - float128 // - power9-vector +// - power10-vector // then go ahead and error since the customer has expressed an incompatible // set of options. static bool ppcUserFeaturesCheck(DiagnosticsEngine &Diags, @@ -246,6 +251,7 @@ Found |= FindVSXSubfeature("+direct-move", "-mdirect-move"); Found |= FindVSXSubfeature("+float128", "-mfloat128"); Found |= FindVSXSubfeature("+power9-vector", "-mpower9-vector"); + Found |= FindVSXSubfeature("+power10-vector", "-mpower10-vector"); // Return false if any vsx subfeatures was found. return !Found; @@ -346,6 +352,7 @@ void PPCTargetInfo::addP10SpecificFeatures( llvm::StringMap &Features) const { Features["htm"] = false; // HTM was removed for P10. + Features["power10-vector"] = true; return; } @@ -369,6 +376,7 @@ .Case("extdiv", HasExtDiv) .Case("float128", HasFloat128) .Case("power9-vector", HasP9Vector) + .Case("power10-vector", HasP10Vector) .Case("spe", HasSPE) .Default(false); } @@ -383,21 +391,27 @@ .Case("direct-move", true) .Case("power8-vector", true) .Case("power9-vector", true) + .Case("power10-vector", true) .Case("float128", true) .Default(false); if (FeatureHasVSX) Features["vsx"] = Features["altivec"] = true; if (Name == "power9-vector") Features["power8-vector"] = true; + else if (Name == "power10-vector") + Features["power8-vector"] = Features["power9-vector"] = true; Features[Name] = true; } else { // If we're disabling altivec or vsx go ahead and disable all of the vsx // features. if ((Name == "altivec") || (Name == "vsx")) Features["vsx"] = Features["direct-move"] = Features["power8-vector"] = - Features["float128"] = Features["power9-vector"] = false; + Features["float128"] = Features["power9-vector"] = + Features["power10-vector"] = false; if (Name == "power8-vector") - Features["power9-vector"] = false; + Features["power9-vector"] = Features["power10-vector"] = false; + if (Name == "power9-vector") + Features["power10-vector"] = false; Features[Name] = false; } } diff --git a/clang/test/Driver/ppc-dependent-options.cpp b/clang/test/Driver/ppc-dependent-options.cpp --- a/clang/test/Driver/ppc-dependent-options.cpp +++ b/clang/test/Driver/ppc-dependent-options.cpp @@ -58,6 +58,14 @@ // RUN: -mcpu=power9 -std=c++11 -mno-vsx -mfloat128 -mpower9-vector %s 2>&1 | \ // RUN: FileCheck %s -check-prefix=CHECK-NVSX-MULTI +// RUN: not %clang -target powerpc64le-unknown-unknown -fsyntax-only \ +// RUN: -mcpu=power10 -std=c++11 %s 2>&1 | FileCheck %s \ +// RUN: -check-prefix=CHECK-DEFAULT-P10 + +// RUN: not %clang -target powerpc64le-unknown-unknown -fsyntax-only \ +// RUN: -mcpu=power10 -std=c++11 -mno-vsx -mpower10-vector %s 2>&1 | \ +// RUN: FileCheck %s -check-prefix=CHECK-NVSX-P10V + #ifdef __VSX__ static_assert(false, "VSX enabled"); #endif @@ -70,6 +78,10 @@ static_assert(false, "P9V enabled"); #endif +#ifdef __POWER10_VECTOR__ +static_assert(false, "P10V enabled"); +#endif + #if !defined(__VSX__) && !defined(__POWER8_VECTOR__) && \ !defined(__POWER9_VECTOR__) static_assert(false, "Neither enabled"); @@ -78,8 +90,10 @@ // CHECK-DEFAULT: VSX enabled // CHECK-DEFAULT: P8V enabled // CHECK-DEFAULT-P9: P9V enabled +// CHECK-DEFAULT-P10: P10V enabled // CHECK-NVSX-P8V: error: option '-mpower8-vector' cannot be specified with '-mno-vsx' // CHECK-NVSX-P9V: error: option '-mpower9-vector' cannot be specified with '-mno-vsx' +// CHECK-NVSX-P10V: error: option '-mpower10-vector' cannot be specified with '-mno-vsx' // CHECK-NVSX-FLT128: error: option '-mfloat128' cannot be specified with '-mno-vsx' // CHECK-NVSX-DMV: error: option '-mdirect-move' cannot be specified with '-mno-vsx' // CHECK-NVSX-MULTI: error: option '-mfloat128' cannot be specified with '-mno-vsx' diff --git a/clang/test/Driver/ppc-features.cpp b/clang/test/Driver/ppc-features.cpp --- a/clang/test/Driver/ppc-features.cpp +++ b/clang/test/Driver/ppc-features.cpp @@ -150,6 +150,12 @@ // RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-power8-vector -mpower8-vector -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-P8VECTOR %s // CHECK-P8VECTOR: "-target-feature" "+power8-vector" +// RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-power10-vector -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOP10VECTOR %s +// CHECK-NOP10VECTOR: "-target-feature" "-power10-vector" + +// RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-power10-vector -mpower10-vector -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-P10VECTOR %s +// CHECK-P10VECTOR: "-target-feature" "+power10-vector" + // RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-crbits -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOCRBITS %s // CHECK-NOCRBITS: "-target-feature" "-crbits" diff --git a/llvm/lib/Target/PowerPC/PPC.td b/llvm/lib/Target/PowerPC/PPC.td --- a/llvm/lib/Target/PowerPC/PPC.td +++ b/llvm/lib/Target/PowerPC/PPC.td @@ -216,6 +216,10 @@ "Enable POWER9 vector instructions", [FeatureISA3_0, FeatureP8Vector, FeatureP9Altivec]>; +def FeatureP10Vector : SubtargetFeature<"power10-vector", "HasP10Vector", + "true", + "Enable POWER10 vector instructions", + [FeatureISA3_1, FeatureP9Vector]>; // A separate feature for this even though it is equivalent to P9Vector // because this is a feature of the implementation rather than the architecture // and may go away with future CPU's. @@ -337,7 +341,7 @@ // still exist with the exception of those we know are Power9 specific. list P10AdditionalFeatures = [DirectivePwr10, FeatureISA3_1, FeaturePrefixInstrs, - FeaturePCRelativeMemops]; + FeaturePCRelativeMemops, FeatureP10Vector]; list P10SpecificFeatures = []; list P10InheritableFeatures = !listconcat(P9InheritableFeatures, P10AdditionalFeatures); diff --git a/llvm/lib/Target/PowerPC/PPCSubtarget.h b/llvm/lib/Target/PowerPC/PPCSubtarget.h --- a/llvm/lib/Target/PowerPC/PPCSubtarget.h +++ b/llvm/lib/Target/PowerPC/PPCSubtarget.h @@ -105,6 +105,7 @@ bool HasP8Crypto; bool HasP9Vector; bool HasP9Altivec; + bool HasP10Vector; bool HasPrefixInstrs; bool HasPCRelativeMemops; bool HasFCPSGN; @@ -262,6 +263,7 @@ bool hasP8Crypto() const { return HasP8Crypto; } bool hasP9Vector() const { return HasP9Vector; } bool hasP9Altivec() const { return HasP9Altivec; } + bool hasP10Vector() const { return HasP10Vector; } bool hasPrefixInstrs() const { return HasPrefixInstrs; } bool hasPCRelativeMemops() const { return HasPCRelativeMemops; } bool hasMFOCRF() const { return HasMFOCRF; } diff --git a/llvm/lib/Target/PowerPC/PPCSubtarget.cpp b/llvm/lib/Target/PowerPC/PPCSubtarget.cpp --- a/llvm/lib/Target/PowerPC/PPCSubtarget.cpp +++ b/llvm/lib/Target/PowerPC/PPCSubtarget.cpp @@ -78,6 +78,7 @@ HasP8Crypto = false; HasP9Vector = false; HasP9Altivec = false; + HasP10Vector = false; HasPrefixInstrs = false; HasPCRelativeMemops = false; HasFCPSGN = false;