r316102 - [Hexagon] Handling of new HVX flags and target-features

Sumanth Gundapaneni via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 18 11:10:13 PDT 2017


Author: sgundapa
Date: Wed Oct 18 11:10:13 2017
New Revision: 316102

URL: http://llvm.org/viewvc/llvm-project?rev=316102&view=rev
Log:
[Hexagon] Handling of new HVX flags and target-features

This patch has the following changes
A new flag "-mhvx-length={64B|128B}" is introduced to specify the length of the vector.
Previously we have used "-mhvx-double" for 128 Bytes. This adds the target-feature "+hvx-length{64|128}b"

The "-mhvx" flag must be provided on command line to enable HVX for Hexagon. If no -mhvx-length flag
is specified, a default length is picked from the arch mentioned in this priority order from either -mhvx=vxx
or -mcpu. For v60 and v62 the default length is 64 Byte. For unknown versions, the length is 128 Byte. The 
-mhvx flag adds the target-feature "+hvxv{hvx_version}"

The 64 Byte mode is soon going to be deprecated. A warning is emitted if 64 Byte is enabled. A warning is
still emitted for the default 64 Byte as well. This warning can be suppressed with a -Wno flag.

The "-mhvx-double" and "-mno-hvx-double" flags are deprecated. A warning is emitted if the driver sees
them on commandline. "-mhvx-double" is an alias to "-mhvx-length=128B"

The compilation will error out if -mhvx-length is specified with out an -mhvx/-mhvx= flag

The macro HVX_LENGTH is defined and is set to the length of the vector. 
Eg: #define HVX_LENGTH 64

The macro HVX_ARCH is defined and is set to the version of the HVX. 
Eg: #define HVX_ARCH 62

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

Added:
    cfe/trunk/test/Driver/hexagon-hvx.c
Modified:
    cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
    cfe/trunk/include/clang/Driver/Options.td
    cfe/trunk/lib/Basic/Targets/Hexagon.cpp
    cfe/trunk/lib/Basic/Targets/Hexagon.h
    cfe/trunk/lib/Driver/ToolChains/Clang.cpp
    cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp
    cfe/trunk/lib/Driver/ToolChains/Hexagon.h
    cfe/trunk/test/CodeGen/hexagon-inline-asm.c
    cfe/trunk/test/Preprocessor/hexagon-predefines.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=316102&r1=316101&r2=316102&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Wed Oct 18 11:10:13 2017
@@ -263,6 +263,9 @@ def err_analyzer_config_no_value : Error
 def err_analyzer_config_multiple_values : Error<
   "analyzer-config option '%0' should contain only one '='">;
 
+def err_drv_invalid_hvx_length : Error<
+  "-mhvx-length is not supported without a -mhvx/-mhvx= flag">;
+
 def err_drv_modules_validate_once_requires_timestamp : Error<
   "option '-fmodules-validate-once-per-build-session' requires "
   "'-fbuild-session-timestamp=<seconds since Epoch>' or '-fbuild-session-file=<file>'">;

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=316102&r1=316101&r2=316102&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Oct 18 11:10:13 2017
@@ -139,6 +139,10 @@ def m_arm_Features_Group : OptionGroup<"
                            Group<m_Group>, DocName<"ARM">;
 def m_hexagon_Features_Group : OptionGroup<"<hexagon features group>">,
                                Group<m_Group>, DocName<"Hexagon">;
+// The features added by this group will not be added to target features.
+// These are explicitly handled.
+def m_hexagon_Features_HVX_Group : OptionGroup<"<hexagon features group>">,
+                                   Group<m_Group>, DocName<"Hexagon">;
 def m_ppc_Features_Group : OptionGroup<"<ppc features group>">,
                            Group<m_Group>, DocName<"PowerPC">;
 def m_wasm_Features_Group : OptionGroup<"<wasm features group>">,
@@ -2495,14 +2499,26 @@ def mv60 : Flag<["-"], "mv60">, Group<m_
            Alias<mcpu_EQ>, AliasArgs<["hexagonv60"]>;
 def mv62 : Flag<["-"], "mv62">, Group<m_hexagon_Features_Group>,
            Alias<mcpu_EQ>, AliasArgs<["hexagonv62"]>;
-def mhexagon_hvx : Flag<["-"], "mhvx">, Group<m_hexagon_Features_Group>,
-    Flags<[CC1Option]>, HelpText<"Enable Hexagon Vector eXtensions">;
-def mno_hexagon_hvx : Flag<["-"], "mno-hvx">, Group<m_hexagon_Features_Group>,
-    Flags<[CC1Option]>, HelpText<"Disable Hexagon Vector eXtensions">;
-def mhexagon_hvx_double : Flag<["-"], "mhvx-double">, Group<m_hexagon_Features_Group>,
-    Flags<[CC1Option]>, HelpText<"Enable Hexagon Double Vector eXtensions">;
-def mno_hexagon_hvx_double : Flag<["-"], "mno-hvx-double">, Group<m_hexagon_Features_Group>,
-    Flags<[CC1Option]>, HelpText<"Disable Hexagon Double Vector eXtensions">;
+def mhexagon_hvx : Flag<[ "-" ], "mhvx">,
+                   Group<m_hexagon_Features_HVX_Group>,
+                   HelpText<"Enable Hexagon Vector eXtensions">;
+def mhexagon_hvx_EQ : Joined<[ "-" ], "mhvx=">,
+                     Group<m_hexagon_Features_HVX_Group>,
+                     HelpText<"Enable Hexagon Vector eXtensions">;
+def mno_hexagon_hvx : Flag<[ "-" ], "mno-hvx">,
+                      Group<m_hexagon_Features_HVX_Group>,
+                      HelpText<"Disable Hexagon Vector eXtensions">;
+def mhexagon_hvx_length_EQ : Joined<[ "-" ], "mhvx-length=">,
+                        Group<m_hexagon_Features_HVX_Group>,
+                        HelpText<"Set Hexagon Vector Length">, Values<"64B,128B">;
+// hvx-double deprecrated flag.
+def mhexagon_hvx_double : Flag<[ "-" ], "mhvx-double">,
+                          Group<m_hexagon_Features_HVX_Group>,
+                          HelpText<"Enable Hexagon Double Vector eXtensions">;
+def mno_hexagon_hvx_double
+    : Flag<[ "-" ], "mno-hvx-double">,
+      Group<m_hexagon_Features_HVX_Group>,
+      HelpText<"Disable Hexagon Double Vector eXtensions">;
 
 // These are legacy user-facing driver-level option spellings. They are always
 // aliases for options that are spelled using the more common Unix / GNU flag

Modified: cfe/trunk/lib/Basic/Targets/Hexagon.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/Hexagon.cpp?rev=316102&r1=316101&r2=316102&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets/Hexagon.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/Hexagon.cpp Wed Oct 18 11:10:13 2017
@@ -54,18 +54,24 @@ void HexagonTargetInfo::getTargetDefines
     Builder.defineMacro("__HEXAGON_ARCH__", "62");
   }
 
-  if (hasFeature("hvx")) {
+  if (hasFeature("hvx-length64b")) {
     Builder.defineMacro("__HVX__");
-    if (hasFeature("hvx-double"))
-      Builder.defineMacro("__HVXDBL__");
+    Builder.defineMacro("__HVX_ARCH__", HVXVersion);
+    Builder.defineMacro("__HVX_LENGTH__", "64");
+  }
+
+  if (hasFeature("hvx-length128b")) {
+    Builder.defineMacro("__HVX__");
+    Builder.defineMacro("__HVX_ARCH__", HVXVersion);
+    Builder.defineMacro("__HVX_LENGTH__", "128");
+    // FIXME: This macro is deprecated.
+    Builder.defineMacro("__HVXDBL__");
   }
 }
 
 bool HexagonTargetInfo::initFeatureMap(
     llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags, StringRef CPU,
     const std::vector<std::string> &FeaturesVec) const {
-  // Default for v60: -hvx, -hvx-double.
-  Features["hvx"] = false;
   Features["hvx-double"] = false;
   Features["long-calls"] = false;
 
@@ -75,16 +81,16 @@ bool HexagonTargetInfo::initFeatureMap(
 bool HexagonTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
                                              DiagnosticsEngine &Diags) {
   for (auto &F : Features) {
-    if (F == "+hvx")
+    if (F == "+hvx-length64b")
+      HasHVX = HasHVX64B = true;
+    else if (F == "+hvx-length128b")
+      HasHVX = HasHVX128B = true;
+    else if (F.find("+hvxv") != std::string::npos) {
       HasHVX = true;
-    else if (F == "-hvx")
-      HasHVX = HasHVXDouble = false;
-    else if (F == "+hvx-double")
-      HasHVX = HasHVXDouble = true;
-    else if (F == "-hvx-double")
-      HasHVXDouble = false;
-
-    if (F == "+long-calls")
+      HVXVersion = F.substr(std::string("+hvxv").length());
+    } else if (F == "-hvx")
+      HasHVX = HasHVX64B = HasHVX128B = false;
+    else if (F == "+long-calls")
       UseLongCalls = true;
     else if (F == "-long-calls")
       UseLongCalls = false;
@@ -92,18 +98,6 @@ bool HexagonTargetInfo::handleTargetFeat
   return true;
 }
 
-void HexagonTargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
-                                          StringRef Name, bool Enabled) const {
-  if (Enabled) {
-    if (Name == "hvx-double")
-      Features["hvx"] = true;
-  } else {
-    if (Name == "hvx")
-      Features["hvx-double"] = false;
-  }
-  Features[Name] = Enabled;
-}
-
 const char *const HexagonTargetInfo::GCCRegNames[] = {
     "r0",  "r1",  "r2",  "r3",  "r4",  "r5",  "r6",  "r7",  "r8",
     "r9",  "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17",
@@ -138,7 +132,8 @@ bool HexagonTargetInfo::hasFeature(Strin
   return llvm::StringSwitch<bool>(Feature)
       .Case("hexagon", true)
       .Case("hvx", HasHVX)
-      .Case("hvx-double", HasHVXDouble)
+      .Case("hvx-length64b", HasHVX64B)
+      .Case("hvx-length128b", HasHVX128B)
       .Case("long-calls", UseLongCalls)
       .Default(false);
 }

Modified: cfe/trunk/lib/Basic/Targets/Hexagon.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/Hexagon.h?rev=316102&r1=316101&r2=316102&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets/Hexagon.h (original)
+++ cfe/trunk/lib/Basic/Targets/Hexagon.h Wed Oct 18 11:10:13 2017
@@ -29,8 +29,11 @@ class LLVM_LIBRARY_VISIBILITY HexagonTar
   static const char *const GCCRegNames[];
   static const TargetInfo::GCCRegAlias GCCRegAliases[];
   std::string CPU;
-  bool HasHVX, HasHVXDouble;
-  bool UseLongCalls;
+  std::string HVXVersion;
+  bool HasHVX = false;
+  bool HasHVX64B = false;
+  bool HasHVX128B = false;
+  bool UseLongCalls = false;
 
 public:
   HexagonTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
@@ -54,8 +57,6 @@ public:
     LargeArrayAlign = 64;
     UseBitFieldTypeAlignment = true;
     ZeroLengthBitfieldBoundary = 32;
-    HasHVX = HasHVXDouble = false;
-    UseLongCalls = false;
   }
 
   ArrayRef<Builtin::Info> getTargetBuiltins() const override;
@@ -95,15 +96,12 @@ public:
   bool handleTargetFeatures(std::vector<std::string> &Features,
                             DiagnosticsEngine &Diags) override;
 
-  void setFeatureEnabled(llvm::StringMap<bool> &Features, StringRef Name,
-                         bool Enabled) const override;
-
   BuiltinVaListKind getBuiltinVaListKind() const override {
     return TargetInfo::CharPtrBuiltinVaList;
   }
 
   ArrayRef<const char *> getGCCRegNames() const override;
-  
+
   ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
 
   const char *getClobbers() const override { return ""; }

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=316102&r1=316101&r2=316102&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed Oct 18 11:10:13 2017
@@ -334,7 +334,7 @@ static void getTargetFeatures(const Tool
     x86::getX86TargetFeatures(D, Triple, Args, Features);
     break;
   case llvm::Triple::hexagon:
-    hexagon::getHexagonTargetFeatures(Args, Features);
+    hexagon::getHexagonTargetFeatures(D, Args, Features);
     break;
   case llvm::Triple::wasm32:
   case llvm::Triple::wasm64:

Modified: cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp?rev=316102&r1=316101&r2=316102&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp Wed Oct 18 11:10:13 2017
@@ -27,8 +27,83 @@ using namespace clang::driver::toolchain
 using namespace clang;
 using namespace llvm::opt;
 
+// Default hvx-length for various versions.
+static std::string getDefaultHvxLength(const StringRef &Cpu) {
+  return llvm::StringSwitch<std::string>(Cpu)
+      .Case("v60", "64b")
+      .Case("v62", "64b")
+      .Default("128b");
+}
+
+static void handleHVXWarnings(const Driver &D, const ArgList &Args) {
+  // Handle deprecated HVX double warnings.
+  if (Arg *A = Args.getLastArg(options::OPT_mhexagon_hvx_double))
+    D.Diag(diag::warn_drv_deprecated_arg)
+        << A->getAsString(Args) << "-mhvx-length=128B";
+  if (Arg *A = Args.getLastArg(options::OPT_mno_hexagon_hvx_double))
+    D.Diag(diag::warn_drv_deprecated_arg) << A->getAsString(Args) << "-mno-hvx";
+  // Handle the unsupported values passed to mhvx-length.
+  if (Arg *A = Args.getLastArg(options::OPT_mhexagon_hvx_length_EQ)) {
+    StringRef Val = A->getValue();
+    if (Val != "64B" && Val != "128B")
+      D.Diag(diag::err_drv_unsupported_option_argument)
+          << A->getOption().getName() << Val;
+  }
+}
+
+// Handle hvx target features explicitly.
+static void handleHVXTargetFeatures(const Driver &D, const ArgList &Args,
+                                    std::vector<StringRef> &Features,
+                                    bool &HasHVX) {
+  // Handle HVX warnings.
+  handleHVXWarnings(D, Args);
+
+  // Add the +hvx* features based on commandline flags.
+  StringRef HVXFeature, HVXLength;
+  StringRef Cpu(toolchains::HexagonToolChain::GetTargetCPUVersion(Args));
+
+  // Handle -mhvx, -mhvx=, -mno-hvx, -mno-hvx-double.
+  if (Arg *A = Args.getLastArg(
+          options::OPT_mno_hexagon_hvx, options::OPT_mno_hexagon_hvx_double,
+          options::OPT_mhexagon_hvx, options::OPT_mhexagon_hvx_EQ)) {
+    if (A->getOption().matches(options::OPT_mno_hexagon_hvx) ||
+        A->getOption().matches(options::OPT_mno_hexagon_hvx_double)) {
+      return;
+    } else if (A->getOption().matches(options::OPT_mhexagon_hvx_EQ)) {
+      HasHVX = true;
+      HVXFeature = Cpu = A->getValue();
+      HVXFeature = Args.MakeArgString(llvm::Twine("+hvx") + HVXFeature.lower());
+    } else if (A->getOption().matches(options::OPT_mhexagon_hvx)) {
+      HasHVX = true;
+      HVXFeature = Args.MakeArgString(llvm::Twine("+hvx") + Cpu);
+    }
+    Features.push_back(HVXFeature);
+  }
+
+  // Handle -mhvx-length=, -mhvx-double.
+  if (Arg *A = Args.getLastArg(options::OPT_mhexagon_hvx_length_EQ,
+                               options::OPT_mhexagon_hvx_double)) {
+    // These falgs are valid only if HVX in enabled.
+    if (!HasHVX)
+      D.Diag(diag::err_drv_invalid_hvx_length);
+    else if (A->getOption().matches(options::OPT_mhexagon_hvx_length_EQ))
+      HVXLength = A->getValue();
+    else if (A->getOption().matches(options::OPT_mhexagon_hvx_double))
+      HVXLength = "128b";
+  }
+  // Default hvx-length based on Cpu.
+  else if (HasHVX)
+    HVXLength = StringRef(getDefaultHvxLength(Cpu));
+
+  if (!HVXLength.empty()) {
+    HVXFeature =
+        Args.MakeArgString(llvm::Twine("+hvx-length") + HVXLength.lower());
+    Features.push_back(HVXFeature);
+  }
+}
+
 // Hexagon target features.
-void hexagon::getHexagonTargetFeatures(const ArgList &Args,
+void hexagon::getHexagonTargetFeatures(const Driver &D, const ArgList &Args,
                                        std::vector<StringRef> &Features) {
   handleTargetFeaturesGroup(Args, Features,
                             options::OPT_m_hexagon_Features_Group);
@@ -41,6 +116,9 @@ void hexagon::getHexagonTargetFeatures(c
   }
 
   Features.push_back(UseLongCalls ? "+long-calls" : "-long-calls");
+
+  bool HasHVX(false);
+  handleHVXTargetFeatures(D, Args, Features, HasHVX);
 }
 
 // Hexagon tools start.

Modified: cfe/trunk/lib/Driver/ToolChains/Hexagon.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Hexagon.h?rev=316102&r1=316101&r2=316102&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Hexagon.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/Hexagon.h Wed Oct 18 11:10:13 2017
@@ -51,7 +51,7 @@ public:
                     const char *LinkingOutput) const override;
 };
 
-void getHexagonTargetFeatures(const llvm::opt::ArgList &Args,
+void getHexagonTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args,
                               std::vector<StringRef> &Features);
 
 } // end namespace hexagon.

Modified: cfe/trunk/test/CodeGen/hexagon-inline-asm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/hexagon-inline-asm.c?rev=316102&r1=316101&r2=316102&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/hexagon-inline-asm.c (original)
+++ cfe/trunk/test/CodeGen/hexagon-inline-asm.c Wed Oct 18 11:10:13 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple hexagon-unknown-elf -target-feature +hvx -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple hexagon-unknown-elf -target-feature +hvx -target-feature +hvx-length64b -emit-llvm -o - %s | FileCheck %s
 
 typedef int v64 __attribute__((__vector_size__(64)))
     __attribute__((aligned(64)));

Added: cfe/trunk/test/Driver/hexagon-hvx.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hexagon-hvx.c?rev=316102&view=auto
==============================================================================
--- cfe/trunk/test/Driver/hexagon-hvx.c (added)
+++ cfe/trunk/test/Driver/hexagon-hvx.c Wed Oct 18 11:10:13 2017
@@ -0,0 +1,90 @@
+// -----------------------------------------------------------------------------
+// Tests for the hvx features and warnings.
+// -----------------------------------------------------------------------------
+
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv62 -mhvx \
+// RUN:  2>&1 | FileCheck -check-prefix=CHECKHVX162 %s
+// CHECKHVX162: "-target-feature" "+hvxv62"
+
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv62 -mhvx \
+// RUN:  -mhvx-double 2>&1 | FileCheck -check-prefix=CHECKHVX2 %s
+
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv62 -mhvx \
+// RUN:  -mhvx-length=128B 2>&1 | FileCheck -check-prefix=CHECKHVX2 %s
+// CHECKHVX2-NOT: "-target-feature" "+hvx-length64b"
+// CHECKHVX2: "-target-feature" "+hvx-length128b"
+
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv62 2>&1 \
+// RUN:  | FileCheck -check-prefix=CHECKHVX3 %s
+// CHECKHVX3-NOT: "-target-feature" "+hvx
+
+// -mhvx-double is deprecated.
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv62 -mhvx-double \
+// RUN:  2>&1 | FileCheck -check-prefix=CHECK-DEPRECATED %s
+// CHECK-DEPRECATED: warning: argument '-mhvx-double' is deprecated, use '-mhvx-length=128B' instead [-Wdeprecated]
+
+// -mno-hvx-double is deprecated.
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv62 -mno-hvx-double \
+// RUN:  2>&1 | FileCheck -check-prefix=CHECK-NODEPRECATED %s
+// CHECK-NODEPRECATED: warning: argument '-mno-hvx-double' is deprecated, use '-mno-hvx' instead [-Wdeprecated]
+
+// No hvx target feature must be added if -mno-hvx/-mno-hvx-double occurs last
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv62 -mno-hvx \
+// RUN:  2>&1 | FileCheck -check-prefix=CHECK-NOHVX %s
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv62 -mhvx -mno-hvx \
+// RUN:  2>&1 | FileCheck -check-prefix=CHECK-NOHVX %s
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv62 -mhvx -mno-hvx-double \
+// RUN:  2>&1 | FileCheck -check-prefix=CHECK-NOHVX %s
+// CHECK-NOHVX-NOT: "-target-feature" "+hvx
+
+// Hvx target feature should be added if -mno-hvx doesnot occur last
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv62 -mno-hvx -mhvx\
+// RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVXFEAT %s
+// CHECK-HVXFEAT: "-target-feature" "+hvxv62"
+
+// With -mhvx, the version of hvx defaults to Cpu
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv60 -mhvx \
+// RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVX-DEFAULT %s
+// CHECK-HVX-DEFAULT: "-target-feature" "+hvxv60"
+
+// Test -mhvx= flag
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv60 -mhvx=v62 \
+// RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVXEQ %s
+// CHECK-HVXEQ: "-target-feature" "+hvxv62"
+
+// Honor the last occured -mhvx=, -mhvx flag.
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv60 -mhvx=v62 -mhvx\
+// RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVXEQ-PRE %s
+// CHECK-HVXEQ-PRE-NOT: "-target-feature" "+hvxv62"
+// CHECK-HVXEQ-PRE: "-target-feature" "+hvxv60"
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv60 -mhvx -mhvx=v62\
+// RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVXEQ-PRE2 %s
+// CHECK-HVXEQ-PRE2-NOT: "-target-feature" "+hvxv60"
+// CHECK-HVXEQ-PRE2: "-target-feature" "+hvxv62"
+
+// Test -mhvx-length flag
+// The default mode on v60,v62 is 64B.
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv60 -mhvx \
+// RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVXLENGTH-64B %s
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv60 -mhvx -mhvx-length=64B\
+// RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVXLENGTH-64B %s
+// CHECK-HVXLENGTH-64B: "-target-feature" "+hvx{{.*}}" "-target-feature" "+hvx-length64b"
+// 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"
+
+// Bail out if -mhvx-length is specified without HVX enabled
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mhvx-length=64B \
+// RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVXLENGTH-ERROR %s
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mhvx-length=128B \
+// RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVXLENGTH-ERROR %s
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mhvx-double \
+// RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVXLENGTH-ERROR %s
+// CHECK-HVXLENGTH-ERROR: error: -mhvx-length is not supported without a -mhvx/-mhvx= flag
+
+// Error out if an unsupported value is passed to -mhvx-length.
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mhvx -mhvx-length=B \
+// RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVXLENGTH-VALUE-ERROR %s
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mhvx -mhvx-length=128 \
+// RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVXLENGTH-VALUE-ERROR %s
+// CHECK-HVXLENGTH-VALUE-ERROR: error: unsupported argument '{{.*}}' to option 'mhvx-length='

Modified: cfe/trunk/test/Preprocessor/hexagon-predefines.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/hexagon-predefines.c?rev=316102&r1=316101&r2=316102&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/hexagon-predefines.c (original)
+++ cfe/trunk/test/Preprocessor/hexagon-predefines.c Wed Oct 18 11:10:13 2017
@@ -1,32 +1,43 @@
 // RUN: %clang_cc1 -E -dM -triple hexagon-unknown-elf -target-cpu hexagonv5 %s | FileCheck %s -check-prefix CHECK-V5
-
 // CHECK-V5: #define __HEXAGON_ARCH__ 5
 // CHECK-V5: #define __HEXAGON_V5__ 1
+// CHECK-V5-NOT: #define __HVX_LENGTH__
+// CHECK-V5-NOT: #define __HVX__ 1
 // CHECK-V5: #define __hexagon__ 1
 
 // RUN: %clang_cc1 -E -dM -triple hexagon-unknown-elf -target-cpu hexagonv55 %s | FileCheck %s -check-prefix CHECK-V55
-
 // CHECK-V55: #define __HEXAGON_ARCH__ 55
 // CHECK-V55: #define __HEXAGON_V55__ 1
+// CHECK-V55-NOT: #define __HVX_LENGTH__
+// CHECK-V55-NOT: #define __HVX__ 1
 // CHECK-V55: #define __hexagon__ 1
 
 // RUN: %clang_cc1 -E -dM -triple hexagon-unknown-elf -target-cpu hexagonv60 %s | FileCheck %s -check-prefix CHECK-V60
-
 // CHECK-V60: #define __HEXAGON_ARCH__ 60
 // CHECK-V60: #define __HEXAGON_V60__ 1
+// CHECK-V60-NOT: #define __HVX_LENGTH__
+// CHECK-V60-NOT: #define __HVX__ 1
 // CHECK-V60: #define __hexagon__ 1
 
-// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-elf -target-cpu hexagonv60 -target-feature +hvx %s | FileCheck %s -check-prefix CHECK-V60HVX
-
-// CHECK-V60HVX: #define __HEXAGON_ARCH__ 60
-// CHECK-V60HVX: #define __HEXAGON_V60__ 1
-// CHECK-V60HVX: #define __HVX__ 1
-
-// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-elf -target-cpu hexagonv60 -target-feature +hvx-double  %s | FileCheck %s -check-prefix CHECK-V60HVXD
-
-// CHECK-V60HVXD: #define __HEXAGON_ARCH__ 60
-// CHECK-V60HVXD: #define __HEXAGON_V60__ 1
-// CHECK-V60HVXD: #define __HVXDBL__ 1
-// CHECK-V60HVXD: #define __HVX__ 1
-// CHECK-V60HVXD: #define __hexagon__ 1
-
+// The HVX flags are explicitly defined by the driver.
+// 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
+// CHECK-V60HVX-64B: #define __HEXAGON_ARCH__ 60
+// CHECK-V60HVX-64B: #define __HEXAGON_V60__ 1
+// CHECK-V60HVX-64B-NOT: #define __HVXDBL__ 1
+// CHECK-V60HVX-64B: #define __HVX_ARCH__ 60
+// CHECK-V60HVX-64B: #define __HVX_LENGTH__ 64
+// CHECK-V60HVX-64B: #define __HVX__ 1
+// CHECK-V60HVX-64B: #define __hexagon__ 1
+
+// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-elf -target-cpu hexagonv60 \
+// RUN: -target-feature +hvxv60 -target-feature +hvx-length128b %s | FileCheck \
+// RUN: %s -check-prefix CHECK-V60HVX-128B
+// CHECK-V60HVX-128B: #define __HEXAGON_ARCH__ 60
+// CHECK-V60HVX-128B: #define __HEXAGON_V60__ 1
+// CHECK-V60HVX-128B: #define __HVXDBL__ 1
+// CHECK-V60HVX-128B: #define __HVX_ARCH__ 60
+// CHECK-V60HVX-128B: #define __HVX_LENGTH__ 128
+// CHECK-V60HVX-128B: #define __HVX__ 1
+// CHECK-V60HVX-128B: #define __hexagon__ 1




More information about the cfe-commits mailing list