Permalink
Browse files

AMD family 17h (znver1) enablement

Summary:
This patch enables the following
1. AMD family 17h architecture using "znver1" tune flag (-march, -mcpu).
2. ISAs that are enabled for "znver1" architecture.
3. Checks ADX isa from cpuid to identify "znver1" flag when -march=native is used.
4. ISAs FMA4, XOP are disabled as they are dropped from amdfam17.
5. For the time being, it uses the btver2 scheduler model.
6. Test file is updated to check this flag.

This is linked to llvm review item https://reviews.llvm.org/D28017

Patch by Ganesh Gopalasubramanian. Additional test cases added by Craig Topper.

Reviewers: RKSimon, craig.topper

Subscribers: cfe-commits, RKSimon, ashutosh.nema, llvm-commits

Differential Revision: https://reviews.llvm.org/D28018

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@291544 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information...
1 parent b8a7fd7 commit f8beebd359b1d8fb87dd54baf195912e2430cd50 @topperc topperc committed Jan 10, 2017
Showing with 125 additions and 0 deletions.
  1. +38 −0 lib/Basic/Targets.cpp
  2. +4 −0 test/Driver/x86-march.c
  3. +1 −0 test/Frontend/x86-target-cpu.c
  4. +82 −0 test/Preprocessor/predefined-arch-macros.c
View
@@ -2663,6 +2663,12 @@ class X86TargetInfo : public TargetInfo {
CK_BDVER4,
//@}
+ /// \name zen
+ /// Zen architecture processors.
+ //@{
+ CK_ZNVER1,
+ //@}
+
/// This specification is deprecated and will be removed in the future.
/// Users should prefer \see CK_K8.
// FIXME: Warn on this when the CPU is set to it.
@@ -2744,6 +2750,7 @@ class X86TargetInfo : public TargetInfo {
.Case("bdver2", CK_BDVER2)
.Case("bdver3", CK_BDVER3)
.Case("bdver4", CK_BDVER4)
+ .Case("znver1", CK_ZNVER1)
.Case("x86-64", CK_x86_64)
.Case("geode", CK_Geode)
.Default(CK_Generic);
@@ -2943,6 +2950,7 @@ class X86TargetInfo : public TargetInfo {
case CK_BDVER2:
case CK_BDVER3:
case CK_BDVER4:
+ case CK_ZNVER1:
case CK_x86_64:
return true;
}
@@ -3190,6 +3198,33 @@ bool X86TargetInfo::initFeatureMap(
setFeatureEnabledImpl(Features, "cx16", true);
setFeatureEnabledImpl(Features, "fxsr", true);
break;
+ case CK_ZNVER1:
+ setFeatureEnabledImpl(Features, "adx", true);
+ setFeatureEnabledImpl(Features, "aes", true);
+ setFeatureEnabledImpl(Features, "avx2", true);
+ setFeatureEnabledImpl(Features, "bmi", true);
+ setFeatureEnabledImpl(Features, "bmi2", true);
+ setFeatureEnabledImpl(Features, "clflushopt", true);
+ setFeatureEnabledImpl(Features, "cx16", true);
+ setFeatureEnabledImpl(Features, "f16c", true);
+ setFeatureEnabledImpl(Features, "fma", true);
+ setFeatureEnabledImpl(Features, "fsgsbase", true);
+ setFeatureEnabledImpl(Features, "fxsr", true);
+ setFeatureEnabledImpl(Features, "lzcnt", true);
+ setFeatureEnabledImpl(Features, "mwaitx", true);
+ setFeatureEnabledImpl(Features, "movbe", true);
+ setFeatureEnabledImpl(Features, "pclmul", true);
+ setFeatureEnabledImpl(Features, "popcnt", true);
+ setFeatureEnabledImpl(Features, "prfchw", true);
+ setFeatureEnabledImpl(Features, "rdrnd", true);
+ setFeatureEnabledImpl(Features, "rdseed", true);
+ setFeatureEnabledImpl(Features, "sha", true);
+ setFeatureEnabledImpl(Features, "sse4a", true);
+ setFeatureEnabledImpl(Features, "xsave", true);
+ setFeatureEnabledImpl(Features, "xsavec", true);
+ setFeatureEnabledImpl(Features, "xsaveopt", true);
+ setFeatureEnabledImpl(Features, "xsaves", true);
+ break;
case CK_BDVER4:
setFeatureEnabledImpl(Features, "avx2", true);
setFeatureEnabledImpl(Features, "bmi2", true);
@@ -3741,6 +3776,9 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts,
case CK_BDVER4:
defineCPUMacros(Builder, "bdver4");
break;
+ case CK_ZNVER1:
+ defineCPUMacros(Builder, "znver1");
+ break;
case CK_Geode:
defineCPUMacros(Builder, "geode");
break;
@@ -103,3 +103,7 @@
// RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=btver2 2>&1 \
// RUN: | FileCheck %s -check-prefix=btver2
// btver2: "-target-cpu" "btver2"
+//
+// RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=znver1 2>&1 \
+// RUN: | FileCheck %s -check-prefix=znver1
+// znver1: "-target-cpu" "znver1"
@@ -26,5 +26,6 @@
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu bdver4 -verify %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu btver1 -verify %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu btver2 -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu znver1 -verify %s
//
// expected-no-diagnostics
@@ -1849,6 +1849,88 @@
// CHECK_BDVER4_M64: #define __tune_bdver4__ 1
// CHECK_BDVER4_M64: #define __x86_64 1
// CHECK_BDVER4_M64: #define __x86_64__ 1
+// RUN: %clang -march=znver1 -m32 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_ZNVER1_M32
+// CHECK_ZNVER1_M32-NOT: #define __3dNOW_A__ 1
+// CHECK_ZNVER1_M32-NOT: #define __3dNOW__ 1
+// CHECK_ZNVER1_M32: #define __ADX__ 1
+// CHECK_ZNVER1_M32: #define __AES__ 1
+// CHECK_ZNVER1_M32: #define __AVX2__ 1
+// CHECK_ZNVER1_M32: #define __AVX__ 1
+// CHECK_ZNVER1_M32: #define __BMI2__ 1
+// CHECK_ZNVER1_M32: #define __BMI__ 1
+// CHECK_ZNVER1_M32: #define __F16C__ 1
+// CHECK_ZNVER1_M32: #define __FMA__ 1
+// CHECK_ZNVER1_M32: #define __FSGSBASE__ 1
+// CHECK_ZNVER1_M32: #define __LZCNT__ 1
+// CHECK_ZNVER1_M32: #define __MMX__ 1
+// CHECK_ZNVER1_M32: #define __PCLMUL__ 1
+// CHECK_ZNVER1_M32: #define __POPCNT__ 1
+// CHECK_ZNVER1_M32: #define __PRFCHW__ 1
+// CHECK_ZNVER1_M32: #define __RDRND__ 1
+// CHECK_ZNVER1_M32: #define __RDSEED__ 1
+// CHECK_ZNVER1_M32: #define __SHA__ 1
+// CHECK_ZNVER1_M32: #define __SSE2_MATH__ 1
+// CHECK_ZNVER1_M32: #define __SSE2__ 1
+// CHECK_ZNVER1_M32: #define __SSE3__ 1
+// CHECK_ZNVER1_M32: #define __SSE4A__ 1
+// CHECK_ZNVER1_M32: #define __SSE4_1__ 1
+// CHECK_ZNVER1_M32: #define __SSE4_2__ 1
+// CHECK_ZNVER1_M32: #define __SSE_MATH__ 1
+// CHECK_ZNVER1_M32: #define __SSE__ 1
+// CHECK_ZNVER1_M32: #define __SSSE3__ 1
+// CHECK_ZNVER1_M32: #define __XSAVEC__ 1
+// CHECK_ZNVER1_M32: #define __XSAVEOPT__ 1
+// CHECK_ZNVER1_M32: #define __XSAVES__ 1
+// CHECK_ZNVER1_M32: #define __XSAVE__ 1
+// CHECK_ZNVER1_M32: #define __i386 1
+// CHECK_ZNVER1_M32: #define __i386__ 1
+// CHECK_ZNVER1_M32: #define __tune_znver1__ 1
+// CHECK_ZNVER1_M32: #define __znver1 1
+// CHECK_ZNVER1_M32: #define __znver1__ 1
+// RUN: %clang -march=znver1 -m64 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_ZNVER1_M64
+// CHECK_ZNVER1_M64-NOT: #define __3dNOW_A__ 1
+// CHECK_ZNVER1_M64-NOT: #define __3dNOW__ 1
+// CHECK_ZNVER1_M64: #define __ADX__ 1
+// CHECK_ZNVER1_M64: #define __AES__ 1
+// CHECK_ZNVER1_M64: #define __AVX2__ 1
+// CHECK_ZNVER1_M64: #define __AVX__ 1
+// CHECK_ZNVER1_M64: #define __BMI2__ 1
+// CHECK_ZNVER1_M64: #define __BMI__ 1
+// CHECK_ZNVER1_M64: #define __F16C__ 1
+// CHECK_ZNVER1_M64: #define __FMA__ 1
+// CHECK_ZNVER1_M64: #define __FSGSBASE__ 1
+// CHECK_ZNVER1_M64: #define __LZCNT__ 1
+// CHECK_ZNVER1_M64: #define __MMX__ 1
+// CHECK_ZNVER1_M64: #define __PCLMUL__ 1
+// CHECK_ZNVER1_M64: #define __POPCNT__ 1
+// CHECK_ZNVER1_M64: #define __PRFCHW__ 1
+// CHECK_ZNVER1_M64: #define __RDRND__ 1
+// CHECK_ZNVER1_M64: #define __RDSEED__ 1
+// CHECK_ZNVER1_M64: #define __SHA__ 1
+// CHECK_ZNVER1_M64: #define __SSE2_MATH__ 1
+// CHECK_ZNVER1_M64: #define __SSE2__ 1
+// CHECK_ZNVER1_M64: #define __SSE3__ 1
+// CHECK_ZNVER1_M64: #define __SSE4A__ 1
+// CHECK_ZNVER1_M64: #define __SSE4_1__ 1
+// CHECK_ZNVER1_M64: #define __SSE4_2__ 1
+// CHECK_ZNVER1_M64: #define __SSE_MATH__ 1
+// CHECK_ZNVER1_M64: #define __SSE__ 1
+// CHECK_ZNVER1_M64: #define __SSSE3__ 1
+// CHECK_ZNVER1_M64: #define __XSAVEC__ 1
+// CHECK_ZNVER1_M64: #define __XSAVEOPT__ 1
+// CHECK_ZNVER1_M64: #define __XSAVES__ 1
+// CHECK_ZNVER1_M64: #define __XSAVE__ 1
+// CHECK_ZNVER1_M64: #define __amd64 1
+// CHECK_ZNVER1_M64: #define __amd64__ 1
+// CHECK_ZNVER1_M64: #define __tune_znver1__ 1
+// CHECK_ZNVER1_M64: #define __x86_64 1
+// CHECK_ZNVER1_M64: #define __x86_64__ 1
+// CHECK_ZNVER1_M64: #define __znver1 1
+// CHECK_ZNVER1_M64: #define __znver1__ 1
//
// End X86/GCC/Linux tests ------------------

0 comments on commit f8beebd

Please sign in to comment.