summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorSebastian Pop <spop@codeaurora.org>2012-01-13 20:37:10 +0000
committerSebastian Pop <spop@codeaurora.org>2012-01-13 20:37:10 +0000
commit86500280c613dce725c4e2ad4323ea3b56bd24bc (patch)
tree9a9b3ae5068c5cabe1228a7a55146e226936977f /clang
parent9a8d528ddf1f88fe3537e4ae5865b74a96c36ad9 (diff)
downloadbcm5719-llvm-86500280c613dce725c4e2ad4323ea3b56bd24bc.tar.gz
bcm5719-llvm-86500280c613dce725c4e2ad4323ea3b56bd24bc.zip
remove assertions in the Hexagon backend specific clang driver
Patch from Jyotsna Verma: I have made the changes to remove assertions in the Hexagon backend specific clang driver. Instead of asserting on invalid arch name, it has been modified to use the default value. I have changed the implementation of the CPU flag validation for the Hexagon backend. Earlier, the clang driver performed the check and asserted on invalid inputs. In the new implementation, the driver passes the last CPU flag (or sets to "v4" if not specified) to the compiler (and also to the assembler and linker which perform their own check) instead of asserting on incorrect values. This patch changes the setCPU function for the Hexagon backend in clang/lib/Basic/Targets.cpp which causes the compiler to error out on incorrect CPU flag values. llvm-svn: 148139
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/Driver/Options.td3
-rw-r--r--clang/lib/Basic/Targets.cpp12
-rw-r--r--clang/lib/Driver/Tools.cpp79
3 files changed, 40 insertions, 54 deletions
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 3c4a73cc335..90418ebf755 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -575,9 +575,6 @@ def l : JoinedOrSeparate<"-l">, Flags<[LinkerInput, RenderJoined]>;
def lazy__framework : Separate<"-lazy_framework">, Flags<[LinkerInput]>;
def lazy__library : Separate<"-lazy_library">, Flags<[LinkerInput]>;
def m32 : Flag<"-m32">, Group<m_Group>, Flags<[DriverOption]>;
-def mv2 : Flag<"-mv2">, Group<m_Group>, Flags<[DriverOption]>;
-def mv3 : Flag<"-mv3">, Group<m_Group>, Flags<[DriverOption]>;
-def mv4 : Flag<"-mv4">, Group<m_Group>, Flags<[DriverOption]>;
def mqdsp6_compat : Flag<"-mqdsp6-compat">, Group<m_Group>, Flags<[DriverOption]>;
def m3dnowa : Flag<"-m3dnowa">, Group<m_x86_Features_Group>;
def m3dnow : Flag<"-m3dnow">, Group<m_x86_Features_Group>;
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index b08a3d30f15..47598f8152c 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -2963,7 +2963,19 @@ public:
virtual const char *getClobbers() const {
return "";
}
+
+ static const char *getHexagonCPUSuffix(StringRef Name) {
+ return llvm::StringSwitch<const char*>(Name)
+ .Case("hexagonv2", "2")
+ .Case("hexagonv3", "3")
+ .Case("hexagonv4", "4")
+ .Default(0);
+ }
+
virtual bool setCPU(const std::string &Name) {
+ if (!getHexagonCPUSuffix(Name))
+ return false;
+
CPU = Name;
return true;
}
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp
index 6baf6a64536..39868c82366 100644
--- a/clang/lib/Driver/Tools.cpp
+++ b/clang/lib/Driver/Tools.cpp
@@ -966,49 +966,39 @@ static Arg* getLastHexagonArchArg (const ArgList &Args)
{
Arg * A = NULL;
- for (ArgList::const_iterator it = Args.begin(), ie = Args.end(); it != ie; ++it) {
- if ((*it)->getOption().matches(options::OPT_mv2) ||
- (*it)->getOption().matches(options::OPT_mv3) ||
- (*it)->getOption().matches(options::OPT_mv4) ||
- (*it)->getOption().matches(options::OPT_march_EQ) ||
+ for (ArgList::const_iterator it = Args.begin(), ie = Args.end();
+ it != ie; ++it) {
+ if ((*it)->getOption().matches(options::OPT_march_EQ) ||
(*it)->getOption().matches(options::OPT_mcpu_EQ)) {
A = *it;
A->claim();
}
+ else if ((*it)->getOption().matches(options::OPT_m_Joined)){
+ StringRef Value = (*it)->getValue(Args,0);
+ if (Value.startswith("v")) {
+ A = *it;
+ A->claim();
+ }
+ }
}
return A;
}
-static const char *getHexagonTargetCPU(const ArgList &Args)
+static StringRef getHexagonTargetCPU(const ArgList &Args)
{
Arg *A;
llvm::StringRef WhichHexagon;
+ // Select the default CPU (v4) if none was given or detection failed.
if ((A = getLastHexagonArchArg (Args))) {
- if ((A->getOption().matches(options::OPT_march_EQ)) ||
- (A->getOption().matches(options::OPT_mcpu_EQ))) {
- WhichHexagon = A->getValue(Args);
- if (WhichHexagon == "v2")
- return "hexagonv2";
- else if (WhichHexagon == "v3")
- return "hexagonv3";
- else if (WhichHexagon == "v4")
- return "hexagonv4";
- else
- assert (0 && "Unknown -march or -mcpu value");
- }
- else {
- if (A->getOption().matches(options::OPT_mv2))
- return "hexagonv2";
- else if (A->getOption().matches(options::OPT_mv3))
- return "hexagonv3";
- else if (A->getOption().matches(options::OPT_mv4))
- return "hexagonv4";
- else
- assert(0 && "Unknown -m argument.");
- }
+ WhichHexagon = A->getValue(Args);
+ if (WhichHexagon == "")
+ return "v4";
+ else
+ return WhichHexagon;
}
- return "hexagonv2";
+ else
+ return "v4";
}
void Clang::AddHexagonTargetArgs(const ArgList &Args,
@@ -1016,7 +1006,7 @@ void Clang::AddHexagonTargetArgs(const ArgList &Args,
llvm::Triple Triple = getToolChain().getTriple();
CmdArgs.push_back("-target-cpu");
- CmdArgs.push_back(getHexagonTargetCPU(Args));
+ CmdArgs.push_back(Args.MakeArgString("hexagon" + getHexagonTargetCPU(Args)));
CmdArgs.push_back("-fno-signed-char");
CmdArgs.push_back("-nobuiltininc");
@@ -2898,29 +2888,16 @@ void hexagon::Link::ConstructJob(Compilation &C, const JobAction &JA,
// Add Arch Information
Arg *A;
- if ((A = getLastHexagonArchArg (Args))) {
- if ((A->getOption().matches(options::OPT_march_EQ)) ||
- (A->getOption().matches(options::OPT_mcpu_EQ))) {
- llvm::StringRef WhichHexagon = A->getValue(Args);
- if (WhichHexagon == "v2")
- CmdArgs.push_back("-mv2");
- else if (WhichHexagon == "v3")
- CmdArgs.push_back ("-mv3");
- else if (WhichHexagon == "v4")
- CmdArgs.push_back ("-mv4");
+ if ((A = getLastHexagonArchArg(Args))) {
+ if (A->getOption().matches(options::OPT_m_Joined))
+ A->render(Args, CmdArgs);
else
- assert (0 && "Unknown -march or -mcpu value");
- }
- else {
- if (A->getOption().matches(options::OPT_mv2) ||
- A->getOption().matches(options::OPT_mv3) ||
- A->getOption().matches(options::OPT_mv4))
- A->render(Args, CmdArgs);
- else
- assert(0 && "Unknown -m argument.");
- }
-
+ CmdArgs.push_back (Args.MakeArgString("-m" + getHexagonTargetCPU(Args)));
}
+ else {
+ CmdArgs.push_back (Args.MakeArgString("-m" + getHexagonTargetCPU(Args)));
+ }
+
CmdArgs.push_back("-mqdsp6-compat");
const char *GCCName;
OpenPOWER on IntegriCloud