зеркало из https://github.com/microsoft/clang-1.git
Hexagon TC: Move getHexagonTargetCPU from Tools.cpp to
ToolChains.cpp This is in anticipation of forthcoming library path changes. Also ... - Fixes some inconsistencies in how the arch is passed to tools. - Add test cases for various forms of arch flags git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169505 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
d56a737842
Коммит
6781415fa6
|
@ -1520,6 +1520,42 @@ void Hexagon_TC::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
|
|||
IncludeDir.appendComponent(Ver);
|
||||
addSystemInclude(DriverArgs, CC1Args, IncludeDir.str());
|
||||
}
|
||||
|
||||
static Arg *GetLastHexagonArchArg (const ArgList &Args)
|
||||
{
|
||||
Arg *A = NULL;
|
||||
|
||||
for (ArgList::const_iterator it = Args.begin(), ie = Args.end();
|
||||
it != ie; ++it) {
|
||||
if ((*it)->getOption().matches(options::OPT_march_EQ) ||
|
||||
(*it)->getOption().matches(options::OPT_mcpu_EQ)) {
|
||||
A = *it;
|
||||
A->claim();
|
||||
} else if ((*it)->getOption().matches(options::OPT_m_Joined)) {
|
||||
StringRef Value = (*it)->getValue(0);
|
||||
if (Value.startswith("v")) {
|
||||
A = *it;
|
||||
A->claim();
|
||||
}
|
||||
}
|
||||
}
|
||||
return A;
|
||||
}
|
||||
|
||||
StringRef Hexagon_TC::GetTargetCPU(const ArgList &Args)
|
||||
{
|
||||
// Select the default CPU (v4) if none was given or detection failed.
|
||||
Arg *A = GetLastHexagonArchArg (Args);
|
||||
if (A) {
|
||||
llvm::StringRef WhichHexagon = A->getValue();
|
||||
if (WhichHexagon.startswith("hexagon"))
|
||||
return WhichHexagon.substr(sizeof("hexagon") - 1);
|
||||
if (WhichHexagon != "")
|
||||
return WhichHexagon;
|
||||
}
|
||||
|
||||
return "v4";
|
||||
}
|
||||
// End Hexagon
|
||||
|
||||
/// TCEToolChain - A tool chain using the llvm bitcode tools to perform
|
||||
|
|
|
@ -530,6 +530,8 @@ public:
|
|||
StringRef GetGCCLibAndIncVersion() const { return GCCLibAndIncVersion.Text; }
|
||||
|
||||
static std::string GetGnuDir(const std::string &InstalledDir);
|
||||
|
||||
static StringRef GetTargetCPU(const ArgList &Args);
|
||||
};
|
||||
|
||||
/// TCEToolChain - A tool chain using the llvm bitcode tools to perform
|
||||
|
|
|
@ -1227,51 +1227,14 @@ void Clang::AddX86TargetArgs(const ArgList &Args,
|
|||
}
|
||||
}
|
||||
|
||||
static Arg* getLastHexagonArchArg (const ArgList &Args)
|
||||
{
|
||||
Arg * A = NULL;
|
||||
|
||||
for (ArgList::const_iterator it = Args.begin(), ie = Args.end();
|
||||
it != ie; ++it) {
|
||||
if ((*it)->getOption().matches(options::OPT_march_EQ) ||
|
||||
(*it)->getOption().matches(options::OPT_mcpu_EQ)) {
|
||||
A = *it;
|
||||
A->claim();
|
||||
}
|
||||
else if ((*it)->getOption().matches(options::OPT_m_Joined)){
|
||||
StringRef Value = (*it)->getValue(0);
|
||||
if (Value.startswith("v")) {
|
||||
A = *it;
|
||||
A->claim();
|
||||
}
|
||||
}
|
||||
}
|
||||
return A;
|
||||
}
|
||||
|
||||
static StringRef getHexagonTargetCPU(const ArgList &Args)
|
||||
{
|
||||
Arg *A;
|
||||
llvm::StringRef WhichHexagon;
|
||||
|
||||
// Select the default CPU (v4) if none was given or detection failed.
|
||||
if ((A = getLastHexagonArchArg (Args))) {
|
||||
WhichHexagon = A->getValue();
|
||||
if (WhichHexagon == "")
|
||||
return "v4";
|
||||
else
|
||||
return WhichHexagon;
|
||||
}
|
||||
else
|
||||
return "v4";
|
||||
}
|
||||
|
||||
void Clang::AddHexagonTargetArgs(const ArgList &Args,
|
||||
ArgStringList &CmdArgs) const {
|
||||
llvm::Triple Triple = getToolChain().getTriple();
|
||||
|
||||
CmdArgs.push_back("-target-cpu");
|
||||
CmdArgs.push_back(Args.MakeArgString("hexagon" + getHexagonTargetCPU(Args)));
|
||||
CmdArgs.push_back(Args.MakeArgString(
|
||||
"hexagon"
|
||||
+ toolchains::Hexagon_TC::GetTargetCPU(Args)));
|
||||
CmdArgs.push_back("-fno-signed-char");
|
||||
|
||||
if (Args.hasArg(options::OPT_mqdsp6_compat))
|
||||
|
@ -3506,7 +3469,7 @@ void hexagon::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
ArgStringList CmdArgs;
|
||||
|
||||
std::string MarchString = "-march=";
|
||||
MarchString += getHexagonTargetCPU(Args);
|
||||
MarchString += toolchains::Hexagon_TC::GetTargetCPU(Args);
|
||||
CmdArgs.push_back(Args.MakeArgString(MarchString));
|
||||
|
||||
RenderExtraToolArgs(JA, CmdArgs);
|
||||
|
@ -3588,17 +3551,8 @@ void hexagon::Link::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
|
||||
RenderExtraToolArgs(JA, CmdArgs);
|
||||
|
||||
// Add Arch Information
|
||||
Arg *A;
|
||||
if ((A = getLastHexagonArchArg(Args))) {
|
||||
if (A->getOption().matches(options::OPT_m_Joined))
|
||||
A->render(Args, CmdArgs);
|
||||
else
|
||||
CmdArgs.push_back (Args.MakeArgString("-m" + getHexagonTargetCPU(Args)));
|
||||
}
|
||||
else {
|
||||
CmdArgs.push_back (Args.MakeArgString("-m" + getHexagonTargetCPU(Args)));
|
||||
}
|
||||
std::string MarchString = toolchains::Hexagon_TC::GetTargetCPU(Args);
|
||||
CmdArgs.push_back(Args.MakeArgString("-m" + MarchString));
|
||||
|
||||
CmdArgs.push_back("-mqdsp6-compat");
|
||||
|
||||
|
|
|
@ -72,3 +72,41 @@
|
|||
// CHECK006: "-cc1"
|
||||
// CHECK006-NOT: "-internal-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/hexagon/include/c++/4.4.0"
|
||||
// CHECK006-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-as"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Test -march=<archname> -mcpu=<archname> -mv<number>
|
||||
// -----------------------------------------------------------------------------
|
||||
// RUN: %clang -### -target hexagon-unknown-linux \
|
||||
// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
|
||||
// RUN: -march=hexagonv3 \
|
||||
// RUN: %s 2>&1 \
|
||||
// RUN: | FileCheck -check-prefix=CHECK007 %s
|
||||
// CHECK007: "-cc1" {{.*}} "-target-cpu" "hexagonv3"
|
||||
// CHECK007-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-as"{{.*}} "-march=v3"
|
||||
// CHECK007-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-gcc"{{.*}} "-mv3"
|
||||
|
||||
// RUN: %clang -### -target hexagon-unknown-linux \
|
||||
// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
|
||||
// RUN: -mcpu=hexagonv5 \
|
||||
// RUN: %s 2>&1 \
|
||||
// RUN: | FileCheck -check-prefix=CHECK008 %s
|
||||
// CHECK008: "-cc1" {{.*}} "-target-cpu" "hexagonv5"
|
||||
// CHECK008-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-as"{{.*}} "-march=v5"
|
||||
// CHECK008-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-gcc"{{.*}} "-mv5"
|
||||
|
||||
// RUN: %clang -### -target hexagon-unknown-linux \
|
||||
// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
|
||||
// RUN: -mv2 \
|
||||
// RUN: %s 2>&1 \
|
||||
// RUN: | FileCheck -check-prefix=CHECK009 %s
|
||||
// CHECK009: "-cc1" {{.*}} "-target-cpu" "hexagonv2"
|
||||
// CHECK009-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-as"{{.*}} "-march=v2"
|
||||
// CHECK009-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-gcc"{{.*}} "-mv2"
|
||||
|
||||
// RUN: %clang -### -target hexagon-unknown-linux \
|
||||
// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
|
||||
// RUN: %s 2>&1 \
|
||||
// RUN: | FileCheck -check-prefix=CHECK010 %s
|
||||
// CHECK010: "-cc1" {{.*}} "-target-cpu" "hexagonv4"
|
||||
// CHECK010-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-as"{{.*}} "-march=v4"
|
||||
// CHECK010-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-gcc"{{.*}} "-mv4"
|
||||
|
|
Загрузка…
Ссылка в новой задаче