r291544 - AMD family 17h (znver1) enablement

Craig Topper via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 9 22:02:13 PST 2017


Author: ctopper
Date: Tue Jan 10 00:02:12 2017
New Revision: 291544

URL: http://llvm.org/viewvc/llvm-project?rev=291544&view=rev
Log:
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

Modified:
    cfe/trunk/lib/Basic/Targets.cpp
    cfe/trunk/test/Driver/x86-march.c
    cfe/trunk/test/Frontend/x86-target-cpu.c
    cfe/trunk/test/Preprocessor/predefined-arch-macros.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=291544&r1=291543&r2=291544&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Jan 10 00:02:12 2017
@@ -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 @@ public:
     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(con
   case CK_BDVER4:
     defineCPUMacros(Builder, "bdver4");
     break;
+  case CK_ZNVER1:
+    defineCPUMacros(Builder, "znver1");
+    break;
   case CK_Geode:
     defineCPUMacros(Builder, "geode");
     break;

Modified: cfe/trunk/test/Driver/x86-march.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/x86-march.c?rev=291544&r1=291543&r2=291544&view=diff
==============================================================================
--- cfe/trunk/test/Driver/x86-march.c (original)
+++ cfe/trunk/test/Driver/x86-march.c Tue Jan 10 00:02:12 2017
@@ -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"

Modified: cfe/trunk/test/Frontend/x86-target-cpu.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/x86-target-cpu.c?rev=291544&r1=291543&r2=291544&view=diff
==============================================================================
--- cfe/trunk/test/Frontend/x86-target-cpu.c (original)
+++ cfe/trunk/test/Frontend/x86-target-cpu.c Tue Jan 10 00:02:12 2017
@@ -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

Modified: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-arch-macros.c?rev=291544&r1=291543&r2=291544&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/predefined-arch-macros.c (original)
+++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c Tue Jan 10 00:02:12 2017
@@ -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 ------------------
 




More information about the cfe-commits mailing list