[clang] 1d1b5ef - [Hexagon] Driver/preprocessor options for Hexagon v69
Krzysztof Parzyszek via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 23 10:18:09 PST 2021
Author: Krzysztof Parzyszek
Date: 2021-12-23T10:17:08-08:00
New Revision: 1d1b5efdef49fa814a7e4feadd175a3dfc6460a0
URL: https://github.com/llvm/llvm-project/commit/1d1b5efdef49fa814a7e4feadd175a3dfc6460a0
DIFF: https://github.com/llvm/llvm-project/commit/1d1b5efdef49fa814a7e4feadd175a3dfc6460a0.diff
LOG: [Hexagon] Driver/preprocessor options for Hexagon v69
Added:
clang/test/Driver/hexagon-hvx-ieee-fp.c
clang/test/Driver/hexagon-hvx-qfloat.c
Modified:
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Driver/Options.td
clang/lib/Basic/Targets/Hexagon.cpp
clang/lib/Driver/ToolChains/Hexagon.cpp
clang/lib/Headers/hexagon_types.h
clang/test/Driver/hexagon-hvx.c
clang/test/Driver/hexagon-toolchain-elf.c
clang/test/Misc/target-invalid-cpu-note.c
clang/test/Preprocessor/hexagon-predefines.c
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 9776cd7b7b250..3025e6fe3c02d 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -449,6 +449,11 @@ def warn_drv_vectorize_needs_hvx : Warning<
"auto-vectorization requires HVX, use -mhvx to enable it">,
InGroup<OptionIgnored>;
+def err_drv_invalid_hvx_qfloat : Error<
+ "-mhvx-qfloat is not supported without a -mhvx/-mhvx= flag.">;
+def err_drv_invalid_arch_hvx_qfloat : Error<
+ "-mhvx-qfloat is not supported on HVX %0.">;
+
def err_drv_module_header_wrong_kind : Error<
"header file '%0' input type '%1' does not match type of prior input "
"in module compilation; use '-x %2' to override">;
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 08e9e1a3432ae..dc8bd831f2a26 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4160,6 +4160,8 @@ def mv67t : Flag<["-"], "mv67t">, Group<m_hexagon_Features_Group>,
Alias<mcpu_EQ>, AliasArgs<["hexagonv67t"]>;
def mv68 : Flag<["-"], "mv68">, Group<m_hexagon_Features_Group>,
Alias<mcpu_EQ>, AliasArgs<["hexagonv68"]>;
+def mv69 : Flag<["-"], "mv69">, Group<m_hexagon_Features_Group>,
+ Alias<mcpu_EQ>, AliasArgs<["hexagonv69"]>;
def mhexagon_hvx : Flag<["-"], "mhvx">, Group<m_hexagon_Features_HVX_Group>,
HelpText<"Enable Hexagon Vector eXtensions">;
def mhexagon_hvx_EQ : Joined<["-"], "mhvx=">,
@@ -4171,6 +4173,18 @@ def mno_hexagon_hvx : Flag<["-"], "mno-hvx">,
def mhexagon_hvx_length_EQ : Joined<["-"], "mhvx-length=">,
Group<m_hexagon_Features_HVX_Group>, HelpText<"Set Hexagon Vector Length">,
Values<"64B,128B">;
+def mhexagon_hvx_qfloat : Flag<["-"], "mhvx-qfloat">,
+ Group<m_hexagon_Features_HVX_Group>,
+ HelpText<"Enable Hexagon HVX QFloat instructions">;
+def mno_hexagon_hvx_qfloat : Flag<["-"], "mno-hvx-qfloat">,
+ Group<m_hexagon_Features_HVX_Group>,
+ HelpText<"Disable Hexagon HVX QFloat instructions">;
+def mhexagon_hvx_ieee_fp : Flag<["-"], "mhvx-ieee-fp">,
+ Group<m_hexagon_Features_Group>,
+ HelpText<"Enable Hexagon HVX IEEE floating-point">;
+def mno_hexagon_hvx_ieee_fp : Flag<["-"], "mno-hvx-ieee-fp">,
+ Group<m_hexagon_Features_Group>,
+ HelpText<"Disable Hexagon HVX IEEE floating-point">;
def ffixed_r19: Flag<["-"], "ffixed-r19">,
HelpText<"Reserve register r19 (Hexagon only)">;
def mmemops : Flag<["-"], "mmemops">, Group<m_hexagon_Features_Group>,
diff --git a/clang/lib/Basic/Targets/Hexagon.cpp b/clang/lib/Basic/Targets/Hexagon.cpp
index 9c37dee7e89a4..161369242926e 100644
--- a/clang/lib/Basic/Targets/Hexagon.cpp
+++ b/clang/lib/Basic/Targets/Hexagon.cpp
@@ -68,6 +68,9 @@ void HexagonTargetInfo::getTargetDefines(const LangOptions &Opts,
} else if (CPU == "hexagonv68") {
Builder.defineMacro("__HEXAGON_V68__");
Builder.defineMacro("__HEXAGON_ARCH__", "68");
+ } else if (CPU == "hexagonv69") {
+ Builder.defineMacro("__HEXAGON_V69__");
+ Builder.defineMacro("__HEXAGON_ARCH__", "69");
}
if (hasFeature("hvx-length64b")) {
@@ -128,6 +131,10 @@ bool HexagonTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
else if (F == "+audio")
HasAudio = true;
}
+ if (CPU.compare("hexagonv68") >= 0) {
+ HasLegalHalfType = true;
+ HasFloat16 = true;
+ }
return true;
}
@@ -214,7 +221,7 @@ static constexpr CPUSuffix Suffixes[] = {
{{"hexagonv60"}, {"60"}}, {{"hexagonv62"}, {"62"}},
{{"hexagonv65"}, {"65"}}, {{"hexagonv66"}, {"66"}},
{{"hexagonv67"}, {"67"}}, {{"hexagonv67t"}, {"67t"}},
- {{"hexagonv68"}, {"68"}},
+ {{"hexagonv68"}, {"68"}}, {{"hexagonv69"}, {"69"}},
};
const char *HexagonTargetInfo::getHexagonCPUSuffix(StringRef Name) {
diff --git a/clang/lib/Driver/ToolChains/Hexagon.cpp b/clang/lib/Driver/ToolChains/Hexagon.cpp
index 2ce7904ecc40d..f9785e42025cc 100644
--- a/clang/lib/Driver/ToolChains/Hexagon.cpp
+++ b/clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -88,6 +88,27 @@ static void handleHVXTargetFeatures(const Driver &D, const ArgList &Args,
Args.MakeArgString(llvm::Twine("+hvx-length") + HVXLength.lower());
Features.push_back(HVXFeature);
}
+
+ // Handle -mhvx-qfloat.
+ // QFloat is valid only on HVX v68/v68+ as of now.
+ unsigned short CpuVer;
+ Cpu.drop_front(1).getAsInteger(10, CpuVer);
+ if (Arg *A = Args.getLastArg(options::OPT_mhexagon_hvx_qfloat,
+ options::OPT_mno_hexagon_hvx_qfloat)) {
+ if (A->getOption().matches(options::OPT_mno_hexagon_hvx_qfloat)) {
+ StringRef OptName = A->getOption().getName().substr(4);
+ Features.push_back(Args.MakeArgString("-" + OptName));
+ return;
+ }
+ StringRef OptName = A->getOption().getName().substr(1);
+ if (HasHVX) {
+ if (CpuVer >= 68)
+ Features.push_back(Args.MakeArgString("+" + OptName));
+ else
+ D.Diag(diag::err_drv_invalid_arch_hvx_qfloat) << Cpu;
+ } else
+ D.Diag(diag::err_drv_invalid_hvx_qfloat);
+ }
}
// Hexagon target features.
@@ -156,6 +177,12 @@ void hexagon::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-fsyntax-only");
}
+ if (Arg *A = Args.getLastArg(options::OPT_mhexagon_hvx_ieee_fp,
+ options::OPT_mno_hexagon_hvx_ieee_fp)) {
+ if (A->getOption().matches(options::OPT_mhexagon_hvx_ieee_fp))
+ CmdArgs.push_back("-mhvx-ieee-fp");
+ }
+
if (auto G = toolchains::HexagonToolChain::getSmallDataThreshold(Args)) {
CmdArgs.push_back(Args.MakeArgString("-gpsize=" + Twine(G.getValue())));
}
diff --git a/clang/lib/Headers/hexagon_types.h b/clang/lib/Headers/hexagon_types.h
index 6958809418d8f..029727cc48176 100644
--- a/clang/lib/Headers/hexagon_types.h
+++ b/clang/lib/Headers/hexagon_types.h
@@ -1177,37 +1177,6 @@ class HEXAGON_Vect32C {
#endif /* __cplusplus */
-// V65 Silver types
-#if __Q6S_ARCH__ >= 65
- // Silver vector types are 128 bytes, and pairs are 256. The vector predicate
- // types are 16 bytes and 32 bytes for pairs.
- typedef long HEXAGON_VecPred128 __attribute__((__vector_size__(16)))
- __attribute__((aligned(128)));
-
- typedef long HEXAGON_VecPred256 __attribute__((__vector_size__(32)))
- __attribute__((aligned(128)));
-
- typedef long HEXAGON_Vect1024 __attribute__((__vector_size__(128)))
- __attribute__((aligned(128)));
-
- typedef long HEXAGON_Vect2048 __attribute__((__vector_size__(256)))
- __attribute__((aligned(256)));
-
- typedef long HEXAGON_UVect1024 __attribute__((__vector_size__(128)))
- __attribute__((aligned(4)));
-
- typedef long HEXAGON_UVect2048 __attribute__((__vector_size__(256)))
- __attribute__((aligned(4)));
-
- #define Q6S_VectorPredPair HEXAGON_VecPred256
- #define Q6S_VectorPred HEXAGON_VecPred128
- #define Q6S_Vector HEXAGON_Vect1024
- #define Q6S_VectorPair HEXAGON_Vect2048
- #define Q6S_UVector HEXAGON_UVect1024
- #define Q6S_UVectorPair HEXAGON_UVect2048
-
-#else /* __Q6S_ARCH__ >= 65 */
-
// V65 Vector types
#if __HVX_ARCH__ >= 65
#if defined __HVX__ && (__HVX_LENGTH__ == 128)
@@ -1256,7 +1225,6 @@ class HEXAGON_Vect32C {
#endif /* defined __HVX__ && (__HVX_LENGTH__ == 64) */
#endif /* defined __HVX__ && (__HVX_LENGTH__ == 128) */
#endif /* __HVX_ARCH__ >= 65 */
-#endif /* __Q6S_ARCH__ >= 65 */
/* Predicates */
diff --git a/clang/test/Driver/hexagon-hvx-ieee-fp.c b/clang/test/Driver/hexagon-hvx-ieee-fp.c
new file mode 100644
index 0000000000000..acc9a910f0f12
--- /dev/null
+++ b/clang/test/Driver/hexagon-hvx-ieee-fp.c
@@ -0,0 +1,14 @@
+// -----------------------------------------------------------------------------
+// Tests for the hvx ieee fp feature and errors.
+// -----------------------------------------------------------------------------
+
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv68 -mhvx -mhvx-ieee-fp \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-IEEEFP %s
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv66 -mhvx=v68 -mhvx-ieee-fp \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-IEEEFP %s
+// CHECK-IEEEFP: "-target-feature" "+hvx-ieee-fp"
+
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv68 -mhvx -mhvx-ieee-fp \
+// RUN: -mno-hvx-ieee-fp 2>&1 | FileCheck -check-prefix=CHECK-NO-IEEEFP %s
+// CHECK-NO-IEEEFP: "-target-feature" "-hvx-ieee-fp"
+
diff --git a/clang/test/Driver/hexagon-hvx-qfloat.c b/clang/test/Driver/hexagon-hvx-qfloat.c
new file mode 100644
index 0000000000000..698451aae58ff
--- /dev/null
+++ b/clang/test/Driver/hexagon-hvx-qfloat.c
@@ -0,0 +1,25 @@
+// -----------------------------------------------------------------------------
+// Tests for the hvx qfloat feature and errors.
+// -----------------------------------------------------------------------------
+
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv68 -mhvx -mhvx-qfloat \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-QFLOAT %s
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv66 -mhvx=v68 -mhvx-qfloat \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-QFLOAT %s
+// CHECK-QFLOAT: "-target-feature" "+hvx-qfloat"
+
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv68 -mhvx -mhvx-qfloat \
+// RUN: -mno-hvx-qfloat 2>&1 | FileCheck -check-prefix=CHECK-NO-QFLOAT %s
+// CHECK-NO-QFLOAT: "-target-feature" "-hvx-qfloat"
+
+// QFloat is valid only on hvxv68 and hvxv68+.
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv68 -mhvx=v66 \
+// RUN: -mhvx-qfloat 2>&1 | FileCheck -check-prefix=CHECK-ERROR1 %s
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv66 -mhvx -mhvx-qfloat \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-ERROR1 %s
+// CHECK-ERROR1: error: -mhvx-qfloat is not supported on HVX v66.
+
+// QFloat is valid only if HVX is enabled.
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv68 -mhvx-qfloat \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-ERROR2 %s
+// CHECK-ERROR2: error: -mhvx-qfloat is not supported without a -mhvx/-mhvx= flag.
diff --git a/clang/test/Driver/hexagon-hvx.c b/clang/test/Driver/hexagon-hvx.c
index 4642aef81a319..aab7e329471b8 100644
--- a/clang/test/Driver/hexagon-hvx.c
+++ b/clang/test/Driver/hexagon-hvx.c
@@ -2,10 +2,6 @@
// 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"
@@ -14,6 +10,10 @@
// RUN: 2>&1 | FileCheck -check-prefix=CHECKHVX162 %s
// CHECKHVX162: "-target-feature" "+hvxv62"
+// 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: -mhvx-length=128B 2>&1 | FileCheck -check-prefix=CHECKHVX2 %s
@@ -39,6 +39,17 @@
// RUN: 2>&1 | FileCheck -check-prefix=CHECK-NOHVX %s
// CHECK-NOHVX-NOT: "-target-feature" "+hvx
+// No hvx-ieee-fp target feature must be added if -mno-hvx-ieee-fp occurs last
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv69 -mhvx-ieee-fp -mno-hvx \
+// RUN: -mno-hvx-ieee-fp 2>&1 | FileCheck -check-prefix=CHECK-NOHVX-IEEE-FP %s
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv69 -mhvx-ieee-fp -mhvx \
+// RUN: -mno-hvx-ieee-fp 2>&1 | FileCheck -check-prefix=CHECK-HVX-NOHVX-IEEE-FP %s
+//
+// CHECK-NOHVX-IEEE-FP-NOT: "-target-feature" "+hvx-ieee-fp"
+// CHECK-HVX-NOHVX-IEEE-FP-NOT: "-target-feature" "+hvx-ieee-fp"
+// CHECK-HVX-NOHVX-IEEE-FP: "-target-feature" "+hvx
+// CHECK-HVX-NOHVX-IEEE-FP-NOT: "-target-feature" "+hvx-ieee-fp"
+
// Hvx target feature should be added if -mno-hvx doesn't occur last
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv62 -mno-hvx -mhvx\
// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVXFEAT %s
@@ -93,3 +104,15 @@
// 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='
+
+// Test -mhvx-ieee-fp flag
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv69 -mhvx-ieee-fp \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVXIEEEFP-LONE %s
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv69 -mhvx -mhvx-ieee-fp \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVXIEEEFP %s
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv69 -mno-hvx -mhvx-ieee-fp \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVXIEEEFP %s
+// CHECK-HVXIEEEFP-LONE-NOT: "-target-feature" "+hvx"
+// CHECK-HVXIEEEFP-LONE: "-target-feature" "+hvx-ieee-fp"
+// CHECK-HVXIEEEFP: "-target-feature" "+hvx-ieee-fp"
+// CHECK-HVXIEEEFP-LONE-NOT: "-target-feature" "+hvx"
diff --git a/clang/test/Driver/hexagon-toolchain-elf.c b/clang/test/Driver/hexagon-toolchain-elf.c
index cc11f9fcba9e9..d7c8015547e47 100644
--- a/clang/test/Driver/hexagon-toolchain-elf.c
+++ b/clang/test/Driver/hexagon-toolchain-elf.c
@@ -151,6 +151,22 @@
// CHECK02B: "-cc1" {{.*}} "-target-cpu" "hexagonv67t"
// CHECK02B: hexagon-link{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/hexagon/lib/v67t/crt0
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
+// RUN: -mcpu=hexagonv68 -fuse-ld=hexagon-link\
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK02C %s
+// CHECK02C: "-cc1" {{.*}} "-target-cpu" "hexagonv68"
+// CHECK02C: hexagon-link{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/hexagon/lib/v68/crt0
+
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
+// RUN: -mcpu=hexagonv69 -fuse-ld=hexagon-link\
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK02D %s
+// CHECK02D: "-cc1" {{.*}} "-target-cpu" "hexagonv69"
+// CHECK02D: hexagon-link{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/hexagon/lib/v69/crt0
+
// -----------------------------------------------------------------------------
// Test Linker related args
// -----------------------------------------------------------------------------
diff --git a/clang/test/Misc/target-invalid-cpu-note.c b/clang/test/Misc/target-invalid-cpu-note.c
index 1b436d8d904f2..04f5a7532b421 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -69,7 +69,7 @@
// RUN: not %clang_cc1 -triple hexagon--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix HEXAGON
// HEXAGON: error: unknown target CPU 'not-a-cpu'
-// HEXAGON-NEXT: note: valid target CPU values are: hexagonv5, hexagonv55, hexagonv60, hexagonv62, hexagonv65, hexagonv66, hexagonv67, hexagonv67t, hexagonv68{{$}}
+// HEXAGON-NEXT: note: valid target CPU values are: hexagonv5, hexagonv55, hexagonv60, hexagonv62, hexagonv65, hexagonv66, hexagonv67, hexagonv67t, hexagonv68, hexagonv69{{$}}
// RUN: not %clang_cc1 -triple bpf--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix BPF
// BPF: error: unknown target CPU 'not-a-cpu'
diff --git a/clang/test/Preprocessor/hexagon-predefines.c b/clang/test/Preprocessor/hexagon-predefines.c
index e948d70248504..576dc4b6cb381 100644
--- a/clang/test/Preprocessor/hexagon-predefines.c
+++ b/clang/test/Preprocessor/hexagon-predefines.c
@@ -107,6 +107,17 @@
// CHECK-V68HVX-128B: #define __HVX__ 1
// CHECK-V68HVX-128B: #define __hexagon__ 1
+// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-elf -target-cpu hexagonv69 \
+// RUN: -target-feature +hvxv69 -target-feature +hvx-length128b %s | FileCheck \
+// RUN: %s -check-prefix CHECK-V69HVX-128B
+// CHECK-V69HVX-128B: #define __HEXAGON_ARCH__ 69
+// CHECK-V69HVX-128B: #define __HEXAGON_V69__ 1
+// CHECK-V69HVX-128B: #define __HVX_ARCH__ 69
+// CHECK-V69HVX-128B: #define __HVX_LENGTH__ 128
+// CHECK-V69HVX-128B: #define __HVX__ 1
+// CHECK-V69HVX-128B: #define __hexagon__ 1
+
+
// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-elf -target-cpu hexagonv67 \
// RUN: -target-feature +hvxv67 -target-feature +hvx-length128b %s | FileCheck \
// RUN: %s -check-prefix CHECK-ELF
More information about the cfe-commits
mailing list