From 85393b28f99ab23acdf4bfb12694314f9b51c911 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Wed, 5 Dec 2018 21:38:35 +0000 Subject: [PATCH] [Hexagon] Add support for Hexagon V66 llvm-svn: 348415 --- clang/include/clang/Driver/Options.td | 2 ++ clang/lib/Basic/Targets/Hexagon.cpp | 5 ++++- clang/lib/Driver/ToolChains/Hexagon.cpp | 1 + clang/test/Driver/hexagon-hvx.c | 7 +++++++ clang/test/Driver/hexagon-toolchain-elf.c | 16 ++++++++++++---- clang/test/Preprocessor/hexagon-predefines.c | 24 ++++++++++++++++++++++++ 6 files changed, 50 insertions(+), 5 deletions(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index e52ae21..cde7d80 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -2708,6 +2708,8 @@ def mv62 : Flag<["-"], "mv62">, Group, Alias, AliasArgs<["hexagonv62"]>; def mv65 : Flag<["-"], "mv65">, Group, Alias, AliasArgs<["hexagonv65"]>; +def mv66 : Flag<["-"], "mv66">, Group, + Alias, AliasArgs<["hexagonv66"]>; def mhexagon_hvx : Flag<["-"], "mhvx">, Group, HelpText<"Enable Hexagon Vector eXtensions">; def mhexagon_hvx_EQ : Joined<["-"], "mhvx=">, diff --git a/clang/lib/Basic/Targets/Hexagon.cpp b/clang/lib/Basic/Targets/Hexagon.cpp index c0ce959..94e1388 100644 --- a/clang/lib/Basic/Targets/Hexagon.cpp +++ b/clang/lib/Basic/Targets/Hexagon.cpp @@ -48,6 +48,9 @@ void HexagonTargetInfo::getTargetDefines(const LangOptions &Opts, } else if (CPU == "hexagonv65") { Builder.defineMacro("__HEXAGON_V65__"); Builder.defineMacro("__HEXAGON_ARCH__", "65"); + } else if (CPU == "hexagonv66") { + Builder.defineMacro("__HEXAGON_V66__"); + Builder.defineMacro("__HEXAGON_ARCH__", "66"); } if (hasFeature("hvx-length64b")) { @@ -145,7 +148,7 @@ struct CPUSuffix { static constexpr CPUSuffix Suffixes[] = { {{"hexagonv5"}, {"5"}}, {{"hexagonv55"}, {"55"}}, {{"hexagonv60"}, {"60"}}, {{"hexagonv62"}, {"62"}}, - {{"hexagonv65"}, {"65"}}, + {{"hexagonv65"}, {"65"}}, {{"hexagonv66"}, {"66"}}, }; const char *HexagonTargetInfo::getHexagonCPUSuffix(StringRef Name) { diff --git a/clang/lib/Driver/ToolChains/Hexagon.cpp b/clang/lib/Driver/ToolChains/Hexagon.cpp index 8778a1a..68eea27 100644 --- a/clang/lib/Driver/ToolChains/Hexagon.cpp +++ b/clang/lib/Driver/ToolChains/Hexagon.cpp @@ -32,6 +32,7 @@ static StringRef getDefaultHvxLength(StringRef Cpu) { .Case("v60", "64b") .Case("v62", "64b") .Case("v65", "64b") + .Case("v66", "128b") .Default("128b"); } diff --git a/clang/test/Driver/hexagon-hvx.c b/clang/test/Driver/hexagon-hvx.c index 70699ce..4642aef 100644 --- a/clang/test/Driver/hexagon-hvx.c +++ b/clang/test/Driver/hexagon-hvx.c @@ -2,6 +2,10 @@ // Tests for the hvx features and warnings. // ----------------------------------------------------------------------------- +// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv66 -mhvx \ +// RUN: 2>&1 | FileCheck -check-prefix=CHECKHVX166 %s +// CHECKHVX166: "-target-feature" "+hvxv66" + // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv65 -mhvx \ // RUN: 2>&1 | FileCheck -check-prefix=CHECKHVX165 %s // CHECKHVX165: "-target-feature" "+hvxv65" @@ -69,6 +73,9 @@ // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv60 -mhvx \ // RUN: -mhvx-length=64B 2>&1 | FileCheck -check-prefix=CHECK-HVXLENGTH-64B %s // CHECK-HVXLENGTH-64B: "-target-feature" "+hvx{{.*}}" "-target-feature" "+hvx-length64b" +// The default mode on v66 and future archs is 128B. +// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv66 -mhvx \ +// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVXLENGTH-128B %s // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv62 -mhvx -mhvx-length=128B\ // RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVXLENGTH-128B %s // CHECK-HVXLENGTH-128B: "-target-feature" "+hvx{{.*}}" "-target-feature" "+hvx-length128b" diff --git a/clang/test/Driver/hexagon-toolchain-elf.c b/clang/test/Driver/hexagon-toolchain-elf.c index 96fa968..a7eeca0 100644 --- a/clang/test/Driver/hexagon-toolchain-elf.c +++ b/clang/test/Driver/hexagon-toolchain-elf.c @@ -99,20 +99,28 @@ // RUN: %clang -### -target hexagon-unknown-elf \ // RUN: -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \ -// RUN: -O3 \ +// RUN: -mcpu=hexagonv66 \ // RUN: %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK026 %s -// CHECK026-NOT: "-ffp-contract=fast" -// CHECK026: {{hexagon-link|ld}} +// CHECK026: "-cc1" {{.*}} "-target-cpu" "hexagonv66" +// CHECK026: {{hexagon-link|ld}}{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/hexagon/lib/v66/crt0 // RUN: %clang -### -target hexagon-unknown-elf \ // RUN: -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \ -// RUN: -O3 -ffp-contract=off \ +// RUN: -O3 \ // RUN: %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK027 %s // CHECK027-NOT: "-ffp-contract=fast" // CHECK027: {{hexagon-link|ld}} +// RUN: %clang -### -target hexagon-unknown-elf \ +// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \ +// RUN: -O3 -ffp-contract=off \ +// RUN: %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK028 %s +// CHECK028-NOT: "-ffp-contract=fast" +// CHECK028: {{hexagon-link|ld}} + // ----------------------------------------------------------------------------- // Test Linker related args // ----------------------------------------------------------------------------- diff --git a/clang/test/Preprocessor/hexagon-predefines.c b/clang/test/Preprocessor/hexagon-predefines.c index fe87262..1d122c0 100644 --- a/clang/test/Preprocessor/hexagon-predefines.c +++ b/clang/test/Preprocessor/hexagon-predefines.c @@ -34,6 +34,8 @@ // CHECK-V65: #define __hexagon__ 1 // The HVX flags are explicitly defined by the driver. +// For v60,v62,v65 - 64B mode is default +// For v66 and future archs - 128B is default // RUN: %clang_cc1 -E -dM -triple hexagon-unknown-elf -target-cpu hexagonv60 \ // RUN: -target-feature +hvxv60 -target-feature +hvx-length64b %s | FileCheck \ // RUN: %s -check-prefix CHECK-V60HVX-64B @@ -55,3 +57,25 @@ // CHECK-V60HVX-128B: #define __HVX_LENGTH__ 128 // CHECK-V60HVX-128B: #define __HVX__ 1 // CHECK-V60HVX-128B: #define __hexagon__ 1 + +// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-elf -target-cpu hexagonv66 \ +// RUN: -target-feature +hvxv66 -target-feature +hvx-length64b %s | FileCheck \ +// RUN: %s -check-prefix CHECK-V66HVX-64B +// CHECK-V66HVX-64B: #define __HEXAGON_ARCH__ 66 +// CHECK-V66HVX-64B: #define __HEXAGON_V66__ 1 +// CHECK-V66HVX-64B-NOT: #define __HVXDBL__ 1 +// CHECK-V66HVX-64B: #define __HVX_ARCH__ 66 +// CHECK-V66HVX-64B: #define __HVX_LENGTH__ 64 +// CHECK-V66HVX-64B: #define __HVX__ 1 +// CHECK-V66HVX-64B: #define __hexagon__ 1 + +// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-elf -target-cpu hexagonv66 \ +// RUN: -target-feature +hvxv66 -target-feature +hvx-length128b %s | FileCheck \ +// RUN: %s -check-prefix CHECK-V66HVX-128B +// CHECK-V66HVX-128B: #define __HEXAGON_ARCH__ 66 +// CHECK-V66HVX-128B: #define __HEXAGON_V66__ 1 +// CHECK-V66HVX-128B: #define __HVXDBL__ 1 +// CHECK-V66HVX-128B: #define __HVX_ARCH__ 66 +// CHECK-V66HVX-128B: #define __HVX_LENGTH__ 128 +// CHECK-V66HVX-128B: #define __HVX__ 1 +// CHECK-V66HVX-128B: #define __hexagon__ 1 -- 2.7.4