Hi, The patch looks good with two minor typos, see below.
Matthew Curtis wrote: > > > -- > Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by > The Linux Foundation > > From 4355ad92df91e845c439469eda70c1fca265bbc6 Mon Sep 17 00:00:00 2001 > From: Matthew Curtis <[email protected]> > Date: Fri, 14 Sep 2012 12:18:25 -0500 > Subject: [PATCH 4/6] Hexagon TC: Add/improve support for small data > threshold, pic, pie > > --- > include/clang/Driver/Options.td | 3 +- > lib/Driver/Tools.cpp | 47 +++++++++++++++++++--- > test/Driver/hexagon-toolchain.c | 85 > +++++++++++++++++++++++++++++++++++++++ > 3 files changed, 128 insertions(+), 7 deletions(-) > > diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td > index 17ebbef..13f440d 100644 > --- a/include/clang/Driver/Options.td > +++ b/include/clang/Driver/Options.td > @@ -158,7 +158,8 @@ def E : Flag<"-E">, Flags<[DriverOption,CC1Option]>, > Group<Action_Group>, > HelpText<"Only run the preprocessor">; > def F : JoinedOrSeparate<"-F">, Flags<[RenderJoined,CC1Option]>, > HelpText<"Add directory to framework include search path">; > -def G : Separate<"-G">, Flags<[DriverOption]>; > +def G : JoinedOrSeparate<"-G">, Flags<[DriverOption]>; > +def G_EQ : Joined<"-G=">, Flags<[DriverOption]>; > def H : Flag<"-H">, Flags<[CC1Option]>, > HelpText<"Show header includes and nesting depth">; > def I_ : Flag<"-I-">, Group<I_Group>; > diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp > index b100192..baec90f 100644 > --- a/lib/Driver/Tools.cpp > +++ b/lib/Driver/Tools.cpp > @@ -1152,6 +1152,28 @@ void Clang::AddX86TargetArgs(const ArgList &Args, > } > } > > +static inline bool HasPICArg(const ArgList &Args) { > + return Args.hasArg(options::OPT_fPIC) > + || Args.hasArg(options::OPT_fpic); > +} > + > +static Arg* GetLastSmallDataThresholdArg(const ArgList &Args) { s/Arg* GetLastSmallDataThresholdArg/Arg *GetLastSmallDataThresholdArg/ > + return Args.getLastArg(options::OPT_G, > + options::OPT_G_EQ, > + options::OPT_msmall_data_threshold_EQ); > +} > + > +static std::string GetHexagonSmallDataThresholdValue(const ArgList &Args) { > + std::string value; > + if (HasPICArg(Args)) > + value = "0"; > + else if (Arg *A = GetLastSmallDataThresholdArg(Args)) { > + value = A->getValue(Args); > + A->claim(); > + } > + return value; > +} > + > void Clang::AddHexagonTargetArgs(const ArgList &Args, > ArgStringList &CmdArgs) const { > llvm::Triple Triple = getToolChain().getTriple(); > @@ -1165,13 +1187,11 @@ void Clang::AddHexagonTargetArgs(const ArgList &Args, > if (Args.hasArg(options::OPT_mqdsp6_compat)) > CmdArgs.push_back("-mqdsp6-compat"); > > - if (Arg *A = Args.getLastArg(options::OPT_G, > - options::OPT_msmall_data_threshold_EQ)) { > - std::string SmallDataThreshold="-small-data-threshold="; > - SmallDataThreshold += A->getValue(Args); > + std::string SmallDataThreshold = GetHexagonSmallDataThresholdValue(Args); > + if (!SmallDataThreshold.empty()) { > CmdArgs.push_back ("-mllvm"); > - CmdArgs.push_back(Args.MakeArgString(SmallDataThreshold)); > - A->claim(); > + CmdArgs.push_back(Args.MakeArgString( > + "-hexagon-small-data-threshold=" + > SmallDataThreshold)); > } > > if (!Args.hasArg(options::OPT_fno_short_enums)) > @@ -3261,6 +3281,11 @@ void hexagon::Assemble::ConstructJob(Compilation &C, > const JobAction &JA, > CmdArgs.push_back("-fsyntax-only"); > } > > + std::string SmallDataThreshold = GetHexagonSmallDataThresholdValue(Args); > + if (!SmallDataThreshold.empty()) { > + CmdArgs.push_back( > + Args.MakeArgString(std::string("-G") + SmallDataThreshold)); > + } > > // Only pass -x if gcc will understand it; otherwise hope gcc > // understands the suffix correctly. The main use case this would go > @@ -3318,6 +3343,7 @@ void hexagon::Link::ConstructJob(Compilation &C, const > JobAction &JA, > > //---------------------------------------------------------------------------- > bool hasStaticArg = Args.hasArg(options::OPT_static); > bool buildingLib = Args.hasArg(options::OPT_shared); > + bool buildPIE = 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); > @@ -3353,6 +3379,15 @@ void hexagon::Link::ConstructJob(Compilation &C, const > JobAction &JA, > if (hasStaticArg) > CmdArgs.push_back("-static"); > > + if (buildPIE && !buildingLib) > + CmdArgs.push_back("-pie"); > + > + std::string SmallDataThreshold = GetHexagonSmallDataThresholdValue(Args); > + if (!SmallDataThreshold.empty()) { You don't need braces around this single stmt then clause. > + CmdArgs.push_back( > + Args.MakeArgString(std::string("-G") + SmallDataThreshold)); > + } > + > > //---------------------------------------------------------------------------- > // > > //---------------------------------------------------------------------------- > diff --git a/test/Driver/hexagon-toolchain.c b/test/Driver/hexagon-toolchain.c > index e891607..7f7844a 100644 > --- a/test/Driver/hexagon-toolchain.c > +++ b/test/Driver/hexagon-toolchain.c > @@ -433,3 +433,88 @@ > // CHECK022: "-lstdc++" "-lm" > // CHECK022: "--start-group" "-lstandalone" "-lc" "-lgcc" "--end-group" > // CHECK022: "[[GNU_DIR]]/hexagon/lib/v4/fini.o" > + > +// > ----------------------------------------------------------------------------- > +// pic, small data threshold > +// > ----------------------------------------------------------------------------- > +// RUN: %clang -### -target hexagon-unknown-linux \ > +// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \ > +// RUN: %s 2>&1 \ > +// RUN: | FileCheck -check-prefix=CHECK023 %s > +// CHECK023: "{{.*}}clang" "-cc1" > +// CHECK023: "-mrelocation-model" "static" > +// CHECK023-NEXT: "[[GNU_DIR:.*]]/bin/hexagon-as" > +// CHECK023-NOT: "-G{{[0-9]+}}" > +// CHECK023-NEXT: "[[GNU_DIR]]/bin/hexagon-ld" > +// CHECK023-NOT: "-G{{[0-9]+}}" > + > +// RUN: %clang -### -target hexagon-unknown-linux \ > +// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \ > +// RUN: -fpic \ > +// RUN: %s 2>&1 \ > +// RUN: | FileCheck -check-prefix=CHECK024 %s > +// RUN: %clang -### -target hexagon-unknown-linux \ > +// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \ > +// RUN: -fPIC \ > +// RUN: %s 2>&1 \ > +// RUN: | FileCheck -check-prefix=CHECK024 %s > +// RUN: %clang -### -target hexagon-unknown-linux \ > +// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \ > +// RUN: -fPIC \ > +// RUN: -msmall_data_threshold=8 \ > +// RUN: %s 2>&1 \ > +// RUN: | FileCheck -check-prefix=CHECK024 %s > +// CHECK024: "{{.*}}clang" "-cc1" > +// CHECK024-NOT: "-mrelocation-model" "static" > +// CHECK024: "-pic-level" "{{[12]}}" > +// CHECK024: "-mllvm" "-hexagon-small-data-threshold=0" > +// CHECK024-NEXT: "[[GNU_DIR:.*]]/bin/hexagon-as" > +// CHECK024: "-G0" > +// CHECK024-NEXT: "[[GNU_DIR]]/bin/hexagon-ld" > +// CHECK024: "-G0" > + > +// RUN: %clang -### -target hexagon-unknown-linux \ > +// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \ > +// RUN: -G=8 \ > +// RUN: %s 2>&1 \ > +// RUN: | FileCheck -check-prefix=CHECK025 %s > +// RUN: %clang -### -target hexagon-unknown-linux \ > +// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \ > +// RUN: -G 8 \ > +// RUN: %s 2>&1 \ > +// RUN: | FileCheck -check-prefix=CHECK025 %s > +// RUN: %clang -### -target hexagon-unknown-linux \ > +// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \ > +// RUN: -msmall-data-threshold=8 \ > +// RUN: %s 2>&1 \ > +// RUN: | FileCheck -check-prefix=CHECK025 %s > +// CHECK025: "{{.*}}clang" "-cc1" > +// CHECK025: "-mrelocation-model" "static" > +// CHECK025: "-mllvm" "-hexagon-small-data-threshold=8" > +// CHECK025-NEXT: "[[GNU_DIR:.*]]/bin/hexagon-as" > +// CHECK025: "-G8" > +// CHECK025-NEXT: "[[GNU_DIR]]/bin/hexagon-ld" > +// CHECK025: "-G8" > + > +// > ----------------------------------------------------------------------------- > +// pie > +// > ----------------------------------------------------------------------------- > +// RUN: %clang -### -target hexagon-unknown-linux \ > +// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \ > +// RUN: -pie \ > +// RUN: %s 2>&1 \ > +// RUN: | FileCheck -check-prefix=CHECK026 %s > +// CHECK026: "{{.*}}clang" "-cc1" > +// CHECK026-NEXT: "[[GNU_DIR:.*]]/bin/hexagon-as" > +// CHECK026-NEXT: "[[GNU_DIR]]/bin/hexagon-ld" > +// CHECK026: "-pie" > + > +// RUN: %clang -### -target hexagon-unknown-linux \ > +// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \ > +// RUN: -pie -shared \ > +// RUN: %s 2>&1 \ > +// RUN: | FileCheck -check-prefix=CHECK027 %s > +// CHECK027: "{{.*}}clang" "-cc1" > +// CHECK027-NEXT: "[[GNU_DIR:.*]]/bin/hexagon-as" > +// CHECK027-NEXT: "[[GNU_DIR]]/bin/hexagon-ld" > +// CHECK027-NOT: "-pie" > -- > 1.7.8.3 > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
