forked from OSchip/llvm-project
[Hexagon] Alter meaning of versionless -mhvx
The documentation for the official (downstream) Qualcomm Hexagon Clang states that -mhvx sets the HVX version to be the same as the CPU version. The current implementation upstream would use the most recent versioned -mhvx= flag first (if present), then the CPU version. Change the upstream behavior to match the documented behavior of the downstream compiler.
This commit is contained in:
parent
5d8d3a11c4
commit
2ecda9ec9c
|
@ -72,23 +72,25 @@ static void handleHVXTargetFeatures(const Driver &D, const ArgList &Args,
|
|||
(Cpu.back() == 'T' || Cpu.back() == 't' ? Cpu.drop_back(1) : Cpu).str();
|
||||
HasHVX = false;
|
||||
|
||||
// Handle -mhvx, -mhvx=, -mno-hvx. If both present, -mhvx= wins over -mhvx.
|
||||
auto argOrNull = [&Args](auto FlagOn, auto FlagOff) -> Arg* {
|
||||
if (Arg *A = Args.getLastArg(FlagOn, FlagOff)) {
|
||||
if (A->getOption().matches(FlagOn))
|
||||
return A;
|
||||
// Handle -mhvx, -mhvx=, -mno-hvx. If versioned and versionless flags
|
||||
// are both present, the last one wins.
|
||||
Arg *HvxEnablingArg =
|
||||
Args.getLastArg(options::OPT_mhexagon_hvx, options::OPT_mhexagon_hvx_EQ,
|
||||
options::OPT_mno_hexagon_hvx);
|
||||
if (HvxEnablingArg) {
|
||||
if (HvxEnablingArg->getOption().matches(options::OPT_mno_hexagon_hvx))
|
||||
HvxEnablingArg = nullptr;
|
||||
}
|
||||
|
||||
if (HvxEnablingArg) {
|
||||
// If -mhvx[=] was given, it takes precedence.
|
||||
if (Arg *A = Args.getLastArg(options::OPT_mhexagon_hvx,
|
||||
options::OPT_mhexagon_hvx_EQ)) {
|
||||
// If the version was given, set HvxVer. Otherwise HvxVer
|
||||
// will remain equal to the CPU version.
|
||||
if (A->getOption().matches(options::OPT_mhexagon_hvx_EQ))
|
||||
HvxVer = StringRef(A->getValue()).lower();
|
||||
}
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
Arg *HvxBareA =
|
||||
argOrNull(options::OPT_mhexagon_hvx, options::OPT_mno_hexagon_hvx);
|
||||
Arg *HvxVerA =
|
||||
argOrNull(options::OPT_mhexagon_hvx_EQ, options::OPT_mno_hexagon_hvx);
|
||||
|
||||
if (Arg *A = HvxVerA ? HvxVerA : HvxBareA) {
|
||||
if (A->getOption().matches(options::OPT_mhexagon_hvx_EQ))
|
||||
HvxVer = StringRef(A->getValue()).lower(); // lower produces std:string
|
||||
HasHVX = true;
|
||||
Features.push_back(makeFeature(Twine("hvx") + HvxVer, true));
|
||||
} else if (Arg *A = Args.getLastArg(options::OPT_mno_hexagon_hvx)) {
|
||||
|
|
|
@ -54,6 +54,23 @@
|
|||
// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVX-V68 %s
|
||||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mhvx=v69 \
|
||||
// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVX-V69 %s
|
||||
// Infer HVX version from CPU version:
|
||||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv60 -mhvx \
|
||||
// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVX-V60 %s
|
||||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv62 -mhvx \
|
||||
// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVX-V62 %s
|
||||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv65 -mhvx \
|
||||
// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVX-V65 %s
|
||||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv66 -mhvx \
|
||||
// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVX-V66 %s
|
||||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv67 -mhvx \
|
||||
// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVX-V67 %s
|
||||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv67t -mhvx \
|
||||
// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVX-V67 %s
|
||||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv68 -mhvx \
|
||||
// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVX-V68 %s
|
||||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv69 -mhvx \
|
||||
// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVX-V69 %s
|
||||
|
||||
// Direct version flag with different CPU version:
|
||||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mhvx=v60 -mv62 \
|
||||
|
@ -73,19 +90,19 @@
|
|||
|
||||
// Direct version flag with different CPU version and versionless -mhvx:
|
||||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mhvx=v60 -mv62 -mhvx \
|
||||
// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVX-V60 %s
|
||||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mhvx=v62 -mv65 -mhvx \
|
||||
// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVX-V62 %s
|
||||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mhvx=v65 -mv66 -mhvx \
|
||||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mhvx=v62 -mv65 -mhvx \
|
||||
// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVX-V65 %s
|
||||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mhvx=v66 -mv67 -mhvx \
|
||||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mhvx=v65 -mv66 -mhvx \
|
||||
// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVX-V66 %s
|
||||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mhvx=v67 -mv68 -mhvx \
|
||||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mhvx=v66 -mv67 -mhvx \
|
||||
// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVX-V67 %s
|
||||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mhvx=v68 -mv69 -mhvx \
|
||||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mhvx=v67 -mv68 -mhvx \
|
||||
// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVX-V68 %s
|
||||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mhvx=v69 -mv60 -mhvx \
|
||||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mhvx=v68 -mv69 -mhvx \
|
||||
// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVX-V69 %s
|
||||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mhvx=v69 -mv60 -mhvx \
|
||||
// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVX-V60 %s
|
||||
|
||||
// Direct version flag with different CPU version, versionless -mhvx
|
||||
// and -mno-hvx. The -mno-hvx cancels -mhvx=, versionless -mhvx wins:
|
||||
|
@ -121,25 +138,6 @@
|
|||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv60 -mhvx -mno-hvx -mhvx=v69 \
|
||||
// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVX-V69 %s
|
||||
|
||||
// Infer HVX version from CPU version:
|
||||
|
||||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv60 -mhvx \
|
||||
// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVX-V60 %s
|
||||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv62 -mhvx \
|
||||
// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVX-V62 %s
|
||||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv65 -mhvx \
|
||||
// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVX-V65 %s
|
||||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv66 -mhvx \
|
||||
// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVX-V66 %s
|
||||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv67 -mhvx \
|
||||
// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVX-V67 %s
|
||||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv67t -mhvx \
|
||||
// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVX-V67 %s
|
||||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv68 -mhvx \
|
||||
// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVX-V68 %s
|
||||
// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv69 -mhvx \
|
||||
// RUN: 2>&1 | FileCheck -check-prefix=CHECK-HVX-V69 %s
|
||||
|
||||
// Infer HVX length from flag:
|
||||
|
||||
// CHECK-HVX-L64: "-target-feature" "+hvx-length64b"
|
||||
|
|
Loading…
Reference in New Issue