[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
//===--- Hexagon.cpp - Hexagon ToolChain Implementations --------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "Hexagon.h"
|
|
|
|
#include "CommonArgs.h"
|
2018-10-10 21:27:25 +08:00
|
|
|
#include "InputInfo.h"
|
[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
#include "clang/Driver/Compilation.h"
|
|
|
|
#include "clang/Driver/Driver.h"
|
|
|
|
#include "clang/Driver/DriverDiagnostic.h"
|
|
|
|
#include "clang/Driver/Options.h"
|
|
|
|
#include "llvm/ADT/StringExtras.h"
|
|
|
|
#include "llvm/Option/ArgList.h"
|
|
|
|
#include "llvm/Support/FileSystem.h"
|
|
|
|
#include "llvm/Support/Path.h"
|
2018-10-10 21:27:25 +08:00
|
|
|
#include "llvm/Support/VirtualFileSystem.h"
|
[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
|
|
|
|
using namespace clang::driver;
|
|
|
|
using namespace clang::driver::tools;
|
|
|
|
using namespace clang::driver::toolchains;
|
|
|
|
using namespace clang;
|
|
|
|
using namespace llvm::opt;
|
|
|
|
|
2017-10-19 02:10:13 +08:00
|
|
|
// Default hvx-length for various versions.
|
2017-10-19 05:43:42 +08:00
|
|
|
static StringRef getDefaultHvxLength(StringRef Cpu) {
|
|
|
|
return llvm::StringSwitch<StringRef>(Cpu)
|
2017-10-19 02:10:13 +08:00
|
|
|
.Case("v60", "64b")
|
|
|
|
.Case("v62", "64b")
|
2017-12-13 21:48:07 +08:00
|
|
|
.Case("v65", "64b")
|
2017-10-19 02:10:13 +08:00
|
|
|
.Default("128b");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void handleHVXWarnings(const Driver &D, const ArgList &Args) {
|
|
|
|
// Handle the unsupported values passed to mhvx-length.
|
|
|
|
if (Arg *A = Args.getLastArg(options::OPT_mhexagon_hvx_length_EQ)) {
|
|
|
|
StringRef Val = A->getValue();
|
2021-06-23 19:52:36 +08:00
|
|
|
if (!Val.equals_insensitive("64b") && !Val.equals_insensitive("128b"))
|
2017-10-19 02:10:13 +08:00
|
|
|
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,
|
2020-01-14 06:07:30 +08:00
|
|
|
StringRef Cpu, bool &HasHVX) {
|
2017-10-19 02:10:13 +08:00
|
|
|
// Handle HVX warnings.
|
|
|
|
handleHVXWarnings(D, Args);
|
|
|
|
|
|
|
|
// Add the +hvx* features based on commandline flags.
|
|
|
|
StringRef HVXFeature, HVXLength;
|
|
|
|
|
2018-04-03 23:59:10 +08:00
|
|
|
// Handle -mhvx, -mhvx=, -mno-hvx.
|
|
|
|
if (Arg *A = Args.getLastArg(options::OPT_mno_hexagon_hvx,
|
|
|
|
options::OPT_mhexagon_hvx,
|
|
|
|
options::OPT_mhexagon_hvx_EQ)) {
|
|
|
|
if (A->getOption().matches(options::OPT_mno_hexagon_hvx))
|
2017-10-19 02:10:13 +08:00
|
|
|
return;
|
2018-04-03 23:59:10 +08:00
|
|
|
if (A->getOption().matches(options::OPT_mhexagon_hvx_EQ)) {
|
2017-10-19 02:10:13 +08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2018-04-03 23:59:10 +08:00
|
|
|
// Handle -mhvx-length=.
|
|
|
|
if (Arg *A = Args.getLastArg(options::OPT_mhexagon_hvx_length_EQ)) {
|
Misc typos fixes in ./lib folder
Summary: Found via `codespell -q 3 -I ../clang-whitelist.txt -L uint,importd,crasher,gonna,cant,ue,ons,orign,ned`
Reviewers: teemperor
Reviewed By: teemperor
Subscribers: teemperor, jholewinski, jvesely, nhaehnle, whisperity, jfb, cfe-commits
Differential Revision: https://reviews.llvm.org/D55475
llvm-svn: 348755
2018-12-10 20:37:46 +08:00
|
|
|
// These flags are valid only if HVX in enabled.
|
2017-10-19 02:10:13 +08:00
|
|
|
if (!HasHVX)
|
|
|
|
D.Diag(diag::err_drv_invalid_hvx_length);
|
|
|
|
else if (A->getOption().matches(options::OPT_mhexagon_hvx_length_EQ))
|
|
|
|
HVXLength = A->getValue();
|
|
|
|
}
|
|
|
|
// Default hvx-length based on Cpu.
|
|
|
|
else if (HasHVX)
|
2017-10-19 05:43:42 +08:00
|
|
|
HVXLength = getDefaultHvxLength(Cpu);
|
2017-10-19 02:10:13 +08:00
|
|
|
|
|
|
|
if (!HVXLength.empty()) {
|
|
|
|
HVXFeature =
|
|
|
|
Args.MakeArgString(llvm::Twine("+hvx-length") + HVXLength.lower());
|
|
|
|
Features.push_back(HVXFeature);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-05 03:09:29 +08:00
|
|
|
// Hexagon target features.
|
2017-10-19 02:10:13 +08:00
|
|
|
void hexagon::getHexagonTargetFeatures(const Driver &D, const ArgList &Args,
|
2017-10-05 03:09:29 +08:00
|
|
|
std::vector<StringRef> &Features) {
|
|
|
|
handleTargetFeaturesGroup(Args, Features,
|
|
|
|
options::OPT_m_hexagon_Features_Group);
|
|
|
|
|
|
|
|
bool UseLongCalls = false;
|
|
|
|
if (Arg *A = Args.getLastArg(options::OPT_mlong_calls,
|
|
|
|
options::OPT_mno_long_calls)) {
|
|
|
|
if (A->getOption().matches(options::OPT_mlong_calls))
|
|
|
|
UseLongCalls = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Features.push_back(UseLongCalls ? "+long-calls" : "-long-calls");
|
2017-10-19 02:10:13 +08:00
|
|
|
|
2018-04-17 03:11:17 +08:00
|
|
|
bool HasHVX = false;
|
2020-01-14 06:07:30 +08:00
|
|
|
StringRef Cpu(toolchains::HexagonToolChain::GetTargetCPUVersion(Args));
|
|
|
|
// 't' in Cpu denotes tiny-core micro-architecture. For now, the co-processors
|
|
|
|
// have no dependency on micro-architecture.
|
|
|
|
const bool TinyCore = Cpu.contains('t');
|
|
|
|
|
|
|
|
if (TinyCore)
|
|
|
|
Cpu = Cpu.take_front(Cpu.size() - 1);
|
|
|
|
|
|
|
|
handleHVXTargetFeatures(D, Args, Features, Cpu, HasHVX);
|
2018-04-17 03:11:17 +08:00
|
|
|
|
|
|
|
if (HexagonToolChain::isAutoHVXEnabled(Args) && !HasHVX)
|
|
|
|
D.Diag(diag::warn_drv_vectorize_needs_hvx);
|
2017-10-05 03:09:29 +08:00
|
|
|
}
|
|
|
|
|
[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
// Hexagon tools start.
|
|
|
|
void hexagon::Assembler::RenderExtraToolArgs(const JobAction &JA,
|
|
|
|
ArgStringList &CmdArgs) const {
|
|
|
|
}
|
|
|
|
|
|
|
|
void hexagon::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
|
|
|
|
const InputInfo &Output,
|
|
|
|
const InputInfoList &Inputs,
|
|
|
|
const ArgList &Args,
|
|
|
|
const char *LinkingOutput) const {
|
|
|
|
claimNoWarnArgs(Args);
|
|
|
|
|
|
|
|
auto &HTC = static_cast<const toolchains::HexagonToolChain&>(getToolChain());
|
|
|
|
const Driver &D = HTC.getDriver();
|
|
|
|
ArgStringList CmdArgs;
|
|
|
|
|
2019-06-28 23:08:03 +08:00
|
|
|
CmdArgs.push_back("--arch=hexagon");
|
[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
|
|
|
|
RenderExtraToolArgs(JA, CmdArgs);
|
|
|
|
|
2019-06-28 23:08:03 +08:00
|
|
|
const char *AsName = "llvm-mc";
|
[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
CmdArgs.push_back("-filetype=obj");
|
2017-12-29 00:58:54 +08:00
|
|
|
CmdArgs.push_back(Args.MakeArgString(
|
|
|
|
"-mcpu=hexagon" +
|
|
|
|
toolchains::HexagonToolChain::GetTargetCPUVersion(Args)));
|
[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
|
|
|
|
if (Output.isFilename()) {
|
|
|
|
CmdArgs.push_back("-o");
|
|
|
|
CmdArgs.push_back(Output.getFilename());
|
|
|
|
} else {
|
|
|
|
assert(Output.isNothing() && "Unexpected output");
|
|
|
|
CmdArgs.push_back("-fsyntax-only");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (auto G = toolchains::HexagonToolChain::getSmallDataThreshold(Args)) {
|
2017-12-29 00:58:54 +08:00
|
|
|
CmdArgs.push_back(Args.MakeArgString("-gpsize=" + Twine(G.getValue())));
|
[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, options::OPT_Xassembler);
|
|
|
|
|
|
|
|
// Only pass -x if gcc will understand it; otherwise hope gcc
|
|
|
|
// understands the suffix correctly. The main use case this would go
|
|
|
|
// wrong in is for linker inputs if they happened to have an odd
|
|
|
|
// suffix; really the only way to get this to happen is a command
|
|
|
|
// like '-x foobar a.c' which will treat a.c like a linker input.
|
|
|
|
//
|
|
|
|
// FIXME: For the linker case specifically, can we safely convert
|
|
|
|
// inputs into '-Wl,' options?
|
|
|
|
for (const auto &II : Inputs) {
|
|
|
|
// Don't try to pass LLVM or AST inputs to a generic gcc.
|
|
|
|
if (types::isLLVMIR(II.getType()))
|
|
|
|
D.Diag(clang::diag::err_drv_no_linker_llvm_support)
|
|
|
|
<< HTC.getTripleString();
|
|
|
|
else if (II.getType() == types::TY_AST)
|
|
|
|
D.Diag(clang::diag::err_drv_no_ast_support)
|
|
|
|
<< HTC.getTripleString();
|
|
|
|
else if (II.getType() == types::TY_ModuleFile)
|
|
|
|
D.Diag(diag::err_drv_no_module_support)
|
|
|
|
<< HTC.getTripleString();
|
|
|
|
|
|
|
|
if (II.isFilename())
|
|
|
|
CmdArgs.push_back(II.getFilename());
|
|
|
|
else
|
|
|
|
// Don't render as input, we need gcc to do the translations.
|
|
|
|
// FIXME: What is this?
|
|
|
|
II.getInputArg().render(Args, CmdArgs);
|
|
|
|
}
|
|
|
|
|
2017-12-29 00:58:54 +08:00
|
|
|
auto *Exec = Args.MakeArgString(HTC.GetProgramPath(AsName));
|
2020-04-24 01:27:14 +08:00
|
|
|
C.addCommand(std::make_unique<Command>(JA, *this,
|
|
|
|
ResponseFileSupport::AtFileCurCP(),
|
|
|
|
Exec, CmdArgs, Inputs, Output));
|
[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void hexagon::Linker::RenderExtraToolArgs(const JobAction &JA,
|
|
|
|
ArgStringList &CmdArgs) const {
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
constructHexagonLinkArgs(Compilation &C, const JobAction &JA,
|
|
|
|
const toolchains::HexagonToolChain &HTC,
|
|
|
|
const InputInfo &Output, const InputInfoList &Inputs,
|
|
|
|
const ArgList &Args, ArgStringList &CmdArgs,
|
|
|
|
const char *LinkingOutput) {
|
|
|
|
|
|
|
|
const Driver &D = HTC.getDriver();
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool IsStatic = Args.hasArg(options::OPT_static);
|
|
|
|
bool IsShared = Args.hasArg(options::OPT_shared);
|
|
|
|
bool IsPIE = Args.hasArg(options::OPT_pie);
|
|
|
|
bool IncStdLib = !Args.hasArg(options::OPT_nostdlib);
|
|
|
|
bool IncStartFiles = !Args.hasArg(options::OPT_nostartfiles);
|
|
|
|
bool IncDefLibs = !Args.hasArg(options::OPT_nodefaultlibs);
|
|
|
|
bool UseG0 = false;
|
2019-12-03 04:10:03 +08:00
|
|
|
const char *Exec = Args.MakeArgString(HTC.GetLinkerPath());
|
2021-06-23 19:52:36 +08:00
|
|
|
bool UseLLD = (llvm::sys::path::filename(Exec).equals_insensitive("ld.lld") ||
|
|
|
|
llvm::sys::path::stem(Exec).equals_insensitive("ld.lld"));
|
[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
bool UseShared = IsShared && !IsStatic;
|
2019-12-03 04:10:03 +08:00
|
|
|
StringRef CpuVer = toolchains::HexagonToolChain::GetTargetCPUVersion(Args);
|
[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// Silence warnings for various options
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
Args.ClaimAllArgs(options::OPT_g_Group);
|
|
|
|
Args.ClaimAllArgs(options::OPT_emit_llvm);
|
|
|
|
Args.ClaimAllArgs(options::OPT_w); // Other warning options are already
|
|
|
|
// handled somewhere else.
|
|
|
|
Args.ClaimAllArgs(options::OPT_static_libgcc);
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
if (Args.hasArg(options::OPT_s))
|
|
|
|
CmdArgs.push_back("-s");
|
|
|
|
|
|
|
|
if (Args.hasArg(options::OPT_r))
|
|
|
|
CmdArgs.push_back("-r");
|
|
|
|
|
|
|
|
for (const auto &Opt : HTC.ExtraOpts)
|
|
|
|
CmdArgs.push_back(Opt.c_str());
|
|
|
|
|
2019-12-03 04:10:03 +08:00
|
|
|
if (!UseLLD) {
|
|
|
|
CmdArgs.push_back("-march=hexagon");
|
|
|
|
CmdArgs.push_back(Args.MakeArgString("-mcpu=hexagon" + CpuVer));
|
|
|
|
}
|
[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
|
|
|
|
if (IsShared) {
|
|
|
|
CmdArgs.push_back("-shared");
|
|
|
|
// The following should be the default, but doing as hexagon-gcc does.
|
|
|
|
CmdArgs.push_back("-call_shared");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsStatic)
|
|
|
|
CmdArgs.push_back("-static");
|
|
|
|
|
|
|
|
if (IsPIE && !IsShared)
|
|
|
|
CmdArgs.push_back("-pie");
|
|
|
|
|
|
|
|
if (auto G = toolchains::HexagonToolChain::getSmallDataThreshold(Args)) {
|
2017-12-29 00:58:54 +08:00
|
|
|
CmdArgs.push_back(Args.MakeArgString("-G" + Twine(G.getValue())));
|
[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
UseG0 = G.getValue() == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
CmdArgs.push_back("-o");
|
|
|
|
CmdArgs.push_back(Output.getFilename());
|
|
|
|
|
2020-02-22 03:36:41 +08:00
|
|
|
if (HTC.getTriple().isMusl()) {
|
|
|
|
if (!Args.hasArg(options::OPT_shared, options::OPT_static))
|
|
|
|
CmdArgs.push_back("-dynamic-linker=/lib/ld-musl-hexagon.so.1");
|
|
|
|
|
|
|
|
if (!Args.hasArg(options::OPT_shared, options::OPT_nostartfiles,
|
|
|
|
options::OPT_nostdlib))
|
2020-04-07 20:46:19 +08:00
|
|
|
CmdArgs.push_back(Args.MakeArgString(D.SysRoot + "/usr/lib/crt1.o"));
|
2020-02-22 03:36:41 +08:00
|
|
|
else if (Args.hasArg(options::OPT_shared) &&
|
|
|
|
!Args.hasArg(options::OPT_nostartfiles, options::OPT_nostdlib))
|
2020-04-07 20:46:19 +08:00
|
|
|
CmdArgs.push_back(Args.MakeArgString(D.SysRoot + "/usr/lib/crti.o"));
|
2020-02-22 03:36:41 +08:00
|
|
|
|
2020-04-07 20:46:19 +08:00
|
|
|
CmdArgs.push_back(
|
|
|
|
Args.MakeArgString(StringRef("-L") + D.SysRoot + "/usr/lib"));
|
2020-02-22 03:36:41 +08:00
|
|
|
Args.AddAllArgs(CmdArgs,
|
|
|
|
{options::OPT_T_Group, options::OPT_e, options::OPT_s,
|
|
|
|
options::OPT_t, options::OPT_u_Group});
|
|
|
|
AddLinkerInputs(HTC, Inputs, Args, CmdArgs, JA);
|
|
|
|
|
|
|
|
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
|
|
|
|
CmdArgs.push_back("-lclang_rt.builtins-hexagon");
|
|
|
|
CmdArgs.push_back("-lc");
|
|
|
|
}
|
2020-04-07 20:46:19 +08:00
|
|
|
if (D.CCCIsCXX()) {
|
|
|
|
if (HTC.ShouldLinkCXXStdlib(Args))
|
|
|
|
HTC.AddCXXStdlibLibArgs(Args, CmdArgs);
|
|
|
|
}
|
2020-02-22 03:36:41 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// moslib
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::vector<std::string> OsLibs;
|
|
|
|
bool HasStandalone = false;
|
|
|
|
for (const Arg *A : Args.filtered(options::OPT_moslib_EQ)) {
|
|
|
|
A->claim();
|
|
|
|
OsLibs.emplace_back(A->getValue());
|
|
|
|
HasStandalone = HasStandalone || (OsLibs.back() == "standalone");
|
|
|
|
}
|
|
|
|
if (OsLibs.empty()) {
|
|
|
|
OsLibs.push_back("standalone");
|
|
|
|
HasStandalone = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// Start Files
|
|
|
|
//----------------------------------------------------------------------------
|
2017-12-29 00:58:54 +08:00
|
|
|
const std::string MCpuSuffix = "/" + CpuVer.str();
|
[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
const std::string MCpuG0Suffix = MCpuSuffix + "/G0";
|
|
|
|
const std::string RootDir =
|
|
|
|
HTC.getHexagonTargetDir(D.InstalledDir, D.PrefixDirs) + "/";
|
|
|
|
const std::string StartSubDir =
|
|
|
|
"hexagon/lib" + (UseG0 ? MCpuG0Suffix : MCpuSuffix);
|
|
|
|
|
|
|
|
auto Find = [&HTC] (const std::string &RootDir, const std::string &SubDir,
|
|
|
|
const char *Name) -> std::string {
|
|
|
|
std::string RelName = SubDir + Name;
|
|
|
|
std::string P = HTC.GetFilePath(RelName.c_str());
|
|
|
|
if (llvm::sys::fs::exists(P))
|
|
|
|
return P;
|
|
|
|
return RootDir + RelName;
|
|
|
|
};
|
|
|
|
|
|
|
|
if (IncStdLib && IncStartFiles) {
|
|
|
|
if (!IsShared) {
|
|
|
|
if (HasStandalone) {
|
|
|
|
std::string Crt0SA = Find(RootDir, StartSubDir, "/crt0_standalone.o");
|
|
|
|
CmdArgs.push_back(Args.MakeArgString(Crt0SA));
|
|
|
|
}
|
|
|
|
std::string Crt0 = Find(RootDir, StartSubDir, "/crt0.o");
|
|
|
|
CmdArgs.push_back(Args.MakeArgString(Crt0));
|
|
|
|
}
|
|
|
|
std::string Init = UseShared
|
|
|
|
? Find(RootDir, StartSubDir + "/pic", "/initS.o")
|
|
|
|
: Find(RootDir, StartSubDir, "/init.o");
|
|
|
|
CmdArgs.push_back(Args.MakeArgString(Init));
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// Library Search Paths
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
const ToolChain::path_list &LibPaths = HTC.getFilePaths();
|
|
|
|
for (const auto &LibPath : LibPaths)
|
|
|
|
CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath));
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
Args.AddAllArgs(CmdArgs,
|
|
|
|
{options::OPT_T_Group, options::OPT_e, options::OPT_s,
|
|
|
|
options::OPT_t, options::OPT_u_Group});
|
|
|
|
|
|
|
|
AddLinkerInputs(HTC, Inputs, Args, CmdArgs, JA);
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// Libraries
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
if (IncStdLib && IncDefLibs) {
|
|
|
|
if (D.CCCIsCXX()) {
|
2017-07-26 02:02:57 +08:00
|
|
|
if (HTC.ShouldLinkCXXStdlib(Args))
|
|
|
|
HTC.AddCXXStdlibLibArgs(Args, CmdArgs);
|
[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
CmdArgs.push_back("-lm");
|
|
|
|
}
|
|
|
|
|
|
|
|
CmdArgs.push_back("--start-group");
|
|
|
|
|
|
|
|
if (!IsShared) {
|
2017-12-29 00:58:54 +08:00
|
|
|
for (StringRef Lib : OsLibs)
|
[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
CmdArgs.push_back(Args.MakeArgString("-l" + Lib));
|
|
|
|
CmdArgs.push_back("-lc");
|
|
|
|
}
|
|
|
|
CmdArgs.push_back("-lgcc");
|
|
|
|
|
|
|
|
CmdArgs.push_back("--end-group");
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// End files
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
if (IncStdLib && IncStartFiles) {
|
|
|
|
std::string Fini = UseShared
|
|
|
|
? Find(RootDir, StartSubDir + "/pic", "/finiS.o")
|
|
|
|
: Find(RootDir, StartSubDir, "/fini.o");
|
|
|
|
CmdArgs.push_back(Args.MakeArgString(Fini));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void hexagon::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
|
|
|
const InputInfo &Output,
|
|
|
|
const InputInfoList &Inputs,
|
|
|
|
const ArgList &Args,
|
|
|
|
const char *LinkingOutput) const {
|
|
|
|
auto &HTC = static_cast<const toolchains::HexagonToolChain&>(getToolChain());
|
|
|
|
|
|
|
|
ArgStringList CmdArgs;
|
|
|
|
constructHexagonLinkArgs(C, JA, HTC, Output, Inputs, Args, CmdArgs,
|
|
|
|
LinkingOutput);
|
|
|
|
|
2018-10-10 23:37:03 +08:00
|
|
|
const char *Exec = Args.MakeArgString(HTC.GetLinkerPath());
|
2020-04-24 01:27:14 +08:00
|
|
|
C.addCommand(std::make_unique<Command>(JA, *this,
|
|
|
|
ResponseFileSupport::AtFileCurCP(),
|
|
|
|
Exec, CmdArgs, Inputs, Output));
|
[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
}
|
|
|
|
// Hexagon tools end.
|
|
|
|
|
|
|
|
/// Hexagon Toolchain
|
|
|
|
|
|
|
|
std::string HexagonToolChain::getHexagonTargetDir(
|
|
|
|
const std::string &InstalledDir,
|
|
|
|
const SmallVectorImpl<std::string> &PrefixDirs) const {
|
|
|
|
std::string InstallRelDir;
|
|
|
|
const Driver &D = getDriver();
|
|
|
|
|
|
|
|
// Locate the rest of the toolchain ...
|
|
|
|
for (auto &I : PrefixDirs)
|
|
|
|
if (D.getVFS().exists(I))
|
|
|
|
return I;
|
|
|
|
|
|
|
|
if (getVFS().exists(InstallRelDir = InstalledDir + "/../target"))
|
|
|
|
return InstallRelDir;
|
|
|
|
|
|
|
|
return InstalledDir;
|
|
|
|
}
|
|
|
|
|
|
|
|
Optional<unsigned> HexagonToolChain::getSmallDataThreshold(
|
|
|
|
const ArgList &Args) {
|
|
|
|
StringRef Gn = "";
|
|
|
|
if (Arg *A = Args.getLastArg(options::OPT_G)) {
|
|
|
|
Gn = A->getValue();
|
|
|
|
} else if (Args.getLastArg(options::OPT_shared, options::OPT_fpic,
|
|
|
|
options::OPT_fPIC)) {
|
|
|
|
Gn = "0";
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned G;
|
|
|
|
if (!Gn.getAsInteger(10, G))
|
|
|
|
return G;
|
|
|
|
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
|
|
|
void HexagonToolChain::getHexagonLibraryPaths(const ArgList &Args,
|
|
|
|
ToolChain::path_list &LibPaths) const {
|
|
|
|
const Driver &D = getDriver();
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// -L Args
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
for (Arg *A : Args.filtered(options::OPT_L))
|
|
|
|
for (const char *Value : A->getValues())
|
|
|
|
LibPaths.push_back(Value);
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// Other standard paths
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::vector<std::string> RootDirs;
|
|
|
|
std::copy(D.PrefixDirs.begin(), D.PrefixDirs.end(),
|
|
|
|
std::back_inserter(RootDirs));
|
|
|
|
|
|
|
|
std::string TargetDir = getHexagonTargetDir(D.getInstalledDir(),
|
|
|
|
D.PrefixDirs);
|
2019-03-31 16:48:19 +08:00
|
|
|
if (llvm::find(RootDirs, TargetDir) == RootDirs.end())
|
[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
RootDirs.push_back(TargetDir);
|
|
|
|
|
|
|
|
bool HasPIC = Args.hasArg(options::OPT_fpic, options::OPT_fPIC);
|
|
|
|
// Assume G0 with -shared.
|
|
|
|
bool HasG0 = Args.hasArg(options::OPT_shared);
|
|
|
|
if (auto G = getSmallDataThreshold(Args))
|
|
|
|
HasG0 = G.getValue() == 0;
|
|
|
|
|
|
|
|
const std::string CpuVer = GetTargetCPUVersion(Args).str();
|
|
|
|
for (auto &Dir : RootDirs) {
|
|
|
|
std::string LibDir = Dir + "/hexagon/lib";
|
|
|
|
std::string LibDirCpu = LibDir + '/' + CpuVer;
|
|
|
|
if (HasG0) {
|
|
|
|
if (HasPIC)
|
|
|
|
LibPaths.push_back(LibDirCpu + "/G0/pic");
|
|
|
|
LibPaths.push_back(LibDirCpu + "/G0");
|
|
|
|
}
|
|
|
|
LibPaths.push_back(LibDirCpu);
|
|
|
|
LibPaths.push_back(LibDir);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HexagonToolChain::HexagonToolChain(const Driver &D, const llvm::Triple &Triple,
|
|
|
|
const llvm::opt::ArgList &Args)
|
|
|
|
: Linux(D, Triple, Args) {
|
|
|
|
const std::string TargetDir = getHexagonTargetDir(D.getInstalledDir(),
|
|
|
|
D.PrefixDirs);
|
|
|
|
|
|
|
|
// Note: Generic_GCC::Generic_GCC adds InstalledDir and getDriver().Dir to
|
|
|
|
// program paths
|
|
|
|
const std::string BinDir(TargetDir + "/bin");
|
|
|
|
if (D.getVFS().exists(BinDir))
|
|
|
|
getProgramPaths().push_back(BinDir);
|
|
|
|
|
|
|
|
ToolChain::path_list &LibPaths = getFilePaths();
|
|
|
|
|
|
|
|
// Remove paths added by Linux toolchain. Currently Hexagon_TC really targets
|
|
|
|
// 'elf' OS type, so the Linux paths are not appropriate. When we actually
|
|
|
|
// support 'linux' we'll need to fix this up
|
|
|
|
LibPaths.clear();
|
|
|
|
getHexagonLibraryPaths(Args, LibPaths);
|
|
|
|
}
|
|
|
|
|
|
|
|
HexagonToolChain::~HexagonToolChain() {}
|
|
|
|
|
2020-04-07 20:46:19 +08:00
|
|
|
void HexagonToolChain::AddCXXStdlibLibArgs(const ArgList &Args,
|
|
|
|
ArgStringList &CmdArgs) const {
|
|
|
|
CXXStdlibType Type = GetCXXStdlibType(Args);
|
|
|
|
switch (Type) {
|
|
|
|
case ToolChain::CST_Libcxx:
|
|
|
|
CmdArgs.push_back("-lc++");
|
|
|
|
CmdArgs.push_back("-lc++abi");
|
|
|
|
CmdArgs.push_back("-lunwind");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ToolChain::CST_Libstdcxx:
|
|
|
|
CmdArgs.push_back("-lstdc++");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
Tool *HexagonToolChain::buildAssembler() const {
|
|
|
|
return new tools::hexagon::Assembler(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
Tool *HexagonToolChain::buildLinker() const {
|
|
|
|
return new tools::hexagon::Linker(*this);
|
|
|
|
}
|
|
|
|
|
2017-04-26 04:51:51 +08:00
|
|
|
unsigned HexagonToolChain::getOptimizationLevel(
|
|
|
|
const llvm::opt::ArgList &DriverArgs) const {
|
|
|
|
// Copied in large part from lib/Frontend/CompilerInvocation.cpp.
|
|
|
|
Arg *A = DriverArgs.getLastArg(options::OPT_O_Group);
|
|
|
|
if (!A)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (A->getOption().matches(options::OPT_O0))
|
|
|
|
return 0;
|
2017-04-26 05:31:55 +08:00
|
|
|
if (A->getOption().matches(options::OPT_Ofast) ||
|
|
|
|
A->getOption().matches(options::OPT_O4))
|
2017-04-26 04:51:51 +08:00
|
|
|
return 3;
|
|
|
|
assert(A->getNumValues() != 0);
|
|
|
|
StringRef S(A->getValue());
|
|
|
|
if (S == "s" || S == "z" || S.empty())
|
|
|
|
return 2;
|
|
|
|
if (S == "g")
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
unsigned OptLevel;
|
|
|
|
if (S.getAsInteger(10, OptLevel))
|
|
|
|
return 0;
|
|
|
|
return OptLevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
void HexagonToolChain::addClangTargetOptions(const ArgList &DriverArgs,
|
[OpenMP] Extend CLANG target options with device offloading kind.
Summary: Pass the type of the device offloading when building the tool chain for a particular target architecture. This is required when supporting multiple tool chains that target a single device type. In our particular use case, the OpenMP and CUDA tool chains will use the same ```addClangTargetOptions ``` method. This enables the reuse of common options and ensures control over options only supported by a particular tool chain.
Reviewers: arpith-jacob, caomhin, carlo.bertolli, ABataev, jlebar, hfinkel, tstellar, Hahnfeld
Reviewed By: hfinkel
Subscribers: jgravelle-google, aheejin, rengolin, jfb, dschuff, sbc100, cfe-commits
Differential Revision: https://reviews.llvm.org/D29647
llvm-svn: 307272
2017-07-07 00:22:21 +08:00
|
|
|
ArgStringList &CC1Args,
|
|
|
|
Action::OffloadKind) const {
|
2020-03-13 01:18:35 +08:00
|
|
|
|
|
|
|
bool UseInitArrayDefault = getTriple().isMusl();
|
2020-02-27 23:04:56 +08:00
|
|
|
|
|
|
|
if (!DriverArgs.hasFlag(options::OPT_fuse_init_array,
|
|
|
|
options::OPT_fno_use_init_array,
|
|
|
|
UseInitArrayDefault))
|
|
|
|
CC1Args.push_back("-fno-use-init-array");
|
|
|
|
|
2018-03-01 04:31:55 +08:00
|
|
|
if (DriverArgs.hasArg(options::OPT_ffixed_r19)) {
|
|
|
|
CC1Args.push_back("-target-feature");
|
|
|
|
CC1Args.push_back("+reserved-r19");
|
|
|
|
}
|
2018-10-27 12:51:09 +08:00
|
|
|
if (isAutoHVXEnabled(DriverArgs)) {
|
2018-04-17 03:11:17 +08:00
|
|
|
CC1Args.push_back("-mllvm");
|
2018-10-27 12:51:09 +08:00
|
|
|
CC1Args.push_back("-hexagon-autohvx");
|
2018-04-13 00:25:35 +08:00
|
|
|
}
|
2017-04-26 04:51:51 +08:00
|
|
|
}
|
|
|
|
|
[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
void HexagonToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
|
|
|
|
ArgStringList &CC1Args) const {
|
|
|
|
if (DriverArgs.hasArg(options::OPT_nostdinc) ||
|
|
|
|
DriverArgs.hasArg(options::OPT_nostdlibinc))
|
|
|
|
return;
|
|
|
|
|
|
|
|
const Driver &D = getDriver();
|
2020-02-19 03:35:00 +08:00
|
|
|
if (!D.SysRoot.empty()) {
|
|
|
|
SmallString<128> P(D.SysRoot);
|
2020-04-07 20:46:19 +08:00
|
|
|
if (getTriple().isMusl())
|
|
|
|
llvm::sys::path::append(P, "usr/include");
|
|
|
|
else
|
|
|
|
llvm::sys::path::append(P, "include");
|
2020-02-19 03:35:00 +08:00
|
|
|
addExternCSystemInclude(DriverArgs, CC1Args, P.str());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
std::string TargetDir = getHexagonTargetDir(D.getInstalledDir(),
|
|
|
|
D.PrefixDirs);
|
|
|
|
addExternCSystemInclude(DriverArgs, CC1Args, TargetDir + "/hexagon/include");
|
|
|
|
}
|
|
|
|
|
2020-04-07 20:46:19 +08:00
|
|
|
void HexagonToolChain::addLibCxxIncludePaths(
|
|
|
|
const llvm::opt::ArgList &DriverArgs,
|
|
|
|
llvm::opt::ArgStringList &CC1Args) const {
|
|
|
|
const Driver &D = getDriver();
|
|
|
|
if (!D.SysRoot.empty() && getTriple().isMusl())
|
2021-03-22 08:33:30 +08:00
|
|
|
addLibStdCXXIncludePaths(D.SysRoot + "/usr/include/c++/v1", "", "",
|
2020-04-07 20:46:19 +08:00
|
|
|
DriverArgs, CC1Args);
|
2021-03-22 08:33:30 +08:00
|
|
|
else if (getTriple().isMusl())
|
|
|
|
addLibStdCXXIncludePaths("/usr/include/c++/v1", "", "", DriverArgs,
|
|
|
|
CC1Args);
|
2020-04-07 20:46:19 +08:00
|
|
|
else {
|
|
|
|
std::string TargetDir = getHexagonTargetDir(D.InstalledDir, D.PrefixDirs);
|
2021-03-22 08:33:30 +08:00
|
|
|
addLibStdCXXIncludePaths(TargetDir + "/hexagon/include/c++/v1", "", "",
|
|
|
|
DriverArgs, CC1Args);
|
2020-04-07 20:46:19 +08:00
|
|
|
}
|
|
|
|
}
|
[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
void HexagonToolChain::addLibStdCxxIncludePaths(
|
|
|
|
const llvm::opt::ArgList &DriverArgs,
|
|
|
|
llvm::opt::ArgStringList &CC1Args) const {
|
|
|
|
const Driver &D = getDriver();
|
|
|
|
std::string TargetDir = getHexagonTargetDir(D.InstalledDir, D.PrefixDirs);
|
2021-03-22 08:33:30 +08:00
|
|
|
addLibStdCXXIncludePaths(TargetDir + "/hexagon/include/c++", "", "",
|
[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
DriverArgs, CC1Args);
|
|
|
|
}
|
|
|
|
|
|
|
|
ToolChain::CXXStdlibType
|
|
|
|
HexagonToolChain::GetCXXStdlibType(const ArgList &Args) const {
|
|
|
|
Arg *A = Args.getLastArg(options::OPT_stdlib_EQ);
|
2020-04-07 20:46:19 +08:00
|
|
|
if (!A) {
|
|
|
|
if (getTriple().isMusl())
|
|
|
|
return ToolChain::CST_Libcxx;
|
|
|
|
else
|
|
|
|
return ToolChain::CST_Libstdcxx;
|
|
|
|
}
|
[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
StringRef Value = A->getValue();
|
2020-04-07 20:46:19 +08:00
|
|
|
if (Value != "libstdc++" && Value != "libc++")
|
[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
getDriver().Diag(diag::err_drv_invalid_stdlib_name) << A->getAsString(Args);
|
|
|
|
|
2020-04-07 20:46:19 +08:00
|
|
|
if (Value == "libstdc++")
|
|
|
|
return ToolChain::CST_Libstdcxx;
|
|
|
|
else if (Value == "libc++")
|
|
|
|
return ToolChain::CST_Libcxx;
|
|
|
|
else
|
|
|
|
return ToolChain::CST_Libstdcxx;
|
[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
}
|
|
|
|
|
2018-04-17 03:11:17 +08:00
|
|
|
bool HexagonToolChain::isAutoHVXEnabled(const llvm::opt::ArgList &Args) {
|
|
|
|
if (Arg *A = Args.getLastArg(options::OPT_fvectorize,
|
|
|
|
options::OPT_fno_vectorize))
|
|
|
|
return A->getOption().matches(options::OPT_fvectorize);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
//
|
|
|
|
// Returns the default CPU for Hexagon. This is the default compilation target
|
|
|
|
// if no Hexagon processor is selected at the command-line.
|
|
|
|
//
|
|
|
|
const StringRef HexagonToolChain::GetDefaultCPU() {
|
|
|
|
return "hexagonv60";
|
|
|
|
}
|
|
|
|
|
|
|
|
const StringRef HexagonToolChain::GetTargetCPUVersion(const ArgList &Args) {
|
|
|
|
Arg *CpuArg = nullptr;
|
2019-11-15 02:59:15 +08:00
|
|
|
if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ))
|
[Driver] Consolidate tools and toolchains by target platform. (NFC)
Summary:
(This is a move-only refactoring patch. There are no functionality changes.)
This patch splits apart the Clang driver's tool and toolchain implementation
files. Each target platform toolchain is moved to its own file, along with the
closest-related tools. Each target platform toolchain has separate headers and
implementation files, so the hierarchy of classes is unchanged.
There are some remaining shared free functions, mostly from Tools.cpp. Several
of these move to their own architecture-specific files, similar to r296056. Some
of them are only used by a single target platform; since the tools and
toolchains are now together, some helpers now live in a platform-specific file.
The balance are helpers related to manipulating argument lists, so they are now
in a new file pair, CommonArgs.h and .cpp.
I've tried to cluster the code logically, which is fairly straightforward for
most of the target platforms and shared architectures. I think I've made
reasonable choices for these, as well as the various shared helpers; but of
course, I'm happy to hear feedback in the review.
There are some particular things I don't like about this patch, but haven't been
able to find a better overall solution. The first is the proliferation of files:
there are several files that are tiny because the toolchain is not very
different from its base (usually the Gnu tools/toolchain). I think this is
mostly a reflection of the true complexity, though, so it may not be "fixable"
in any reasonable sense. The second thing I don't like are the includes like
"../Something.h". I've avoided this largely by clustering into the current file
structure. However, a few of these includes remain, and in those cases it
doesn't make sense to me to sink an existing file any deeper.
Reviewers: rsmith, mehdi_amini, compnerd, rnk, javed.absar
Subscribers: emaste, jfb, danalbert, srhines, dschuff, jyknight, nemanjai, nhaehnle, mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D30372
llvm-svn: 297250
2017-03-08 09:02:16 +08:00
|
|
|
CpuArg = A;
|
|
|
|
|
|
|
|
StringRef CPU = CpuArg ? CpuArg->getValue() : GetDefaultCPU();
|
|
|
|
if (CPU.startswith("hexagon"))
|
|
|
|
return CPU.substr(sizeof("hexagon") - 1);
|
|
|
|
return CPU;
|
|
|
|
}
|