Driver: Add Compilation::addCommand and switch tools to using it, now that we

don't have to deal with nested jobs.

llvm-svn: 110015
This commit is contained in:
Daniel Dunbar 2010-08-02 02:38:28 +00:00
parent b785d74080
commit 7fbaf53470
5 changed files with 47 additions and 69 deletions

View File

@ -80,6 +80,8 @@ public:
JobList &getJobs() { return Jobs; }
const JobList &getJobs() const { return Jobs; }
void addCommand(Command *C) { Jobs.addJob(C); }
const ArgStringList &getTempFiles() const { return TempFiles; }
const ArgStringList &getResultFiles() const { return ResultFiles; }

View File

@ -59,13 +59,11 @@ public:
/// ConstructJob - Construct jobs to perform the action \arg JA,
/// writing to \arg Output and with \arg Inputs.
///
/// \param Dest - Where to put the resulting commands.
/// \param TCArgs - The argument list for this toolchain, with any
/// tool chain specific translations applied.
/// \param LinkingOutput - If this output will eventually feed the
/// linker, then this is the final output name of the linked image.
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,

View File

@ -1102,7 +1102,7 @@ void Driver::BuildJobsForAction(Compilation &C,
}
llvm::errs() << "], output: " << Result.getAsString() << "\n";
} else {
T.ConstructJob(C, *JA, C.getJobs(), Result, InputInfos,
T.ConstructJob(C, *JA, Result, InputInfos,
C.getArgsForToolChain(TC, BoundArch), LinkingOutput);
}
}

View File

@ -746,7 +746,6 @@ static std::string getEffectiveClangTriple(const Driver &D,
}
void Clang::ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
@ -1511,7 +1510,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back(Args.MakeArgString(Flags.str()));
}
Dest.addCommand(new Command(JA, *this, Exec, CmdArgs));
C.addCommand(new Command(JA, *this, Exec, CmdArgs));
// Explicitly warn that these options are unsupported, even though
// we are allowing compilation to continue.
@ -1535,7 +1534,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
}
void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
@ -1587,11 +1585,10 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back(Input.getFilename());
const char *Exec = getToolChain().getDriver().getClangProgramPath();
Dest.addCommand(new Command(JA, *this, Exec, CmdArgs));
C.addCommand(new Command(JA, *this, Exec, CmdArgs));
}
void gcc::Common::ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
@ -1683,7 +1680,7 @@ void gcc::Common::ConstructJob(Compilation &C, const JobAction &JA,
const char *GCCName = getToolChain().getDriver().CCCGenericGCCName.c_str();
const char *Exec =
Args.MakeArgString(getToolChain().GetProgramPath(GCCName));
Dest.addCommand(new Command(JA, *this, Exec, CmdArgs));
C.addCommand(new Command(JA, *this, Exec, CmdArgs));
}
void gcc::Preprocess::RenderExtraToolArgs(const JobAction &JA,
@ -2053,7 +2050,7 @@ void darwin::CC1::AddCPPArgs(const ArgList &Args,
}
void darwin::Preprocess::ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest, const InputInfo &Output,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const {
@ -2084,11 +2081,11 @@ void darwin::Preprocess::ConstructJob(Compilation &C, const JobAction &JA,
const char *CC1Name = getCC1Name(Inputs[0].getType());
const char *Exec =
Args.MakeArgString(getToolChain().GetProgramPath(CC1Name));
Dest.addCommand(new Command(JA, *this, Exec, CmdArgs));
C.addCommand(new Command(JA, *this, Exec, CmdArgs));
}
void darwin::Compile::ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest, const InputInfo &Output,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const {
@ -2179,11 +2176,11 @@ void darwin::Compile::ConstructJob(Compilation &C, const JobAction &JA,
const char *CC1Name = getCC1Name(Inputs[0].getType());
const char *Exec =
Args.MakeArgString(getToolChain().GetProgramPath(CC1Name));
Dest.addCommand(new Command(JA, *this, Exec, CmdArgs));
C.addCommand(new Command(JA, *this, Exec, CmdArgs));
}
void darwin::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest, const InputInfo &Output,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const {
@ -2232,7 +2229,7 @@ void darwin::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
const char *Exec =
Args.MakeArgString(getToolChain().GetProgramPath("as"));
Dest.addCommand(new Command(JA, *this, Exec, CmdArgs));
C.addCommand(new Command(JA, *this, Exec, CmdArgs));
}
void darwin::DarwinTool::AddDarwinArch(const ArgList &Args,
@ -2393,7 +2390,7 @@ void darwin::Link::AddLinkArgs(const ArgList &Args,
}
void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest, const InputInfo &Output,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const {
@ -2551,11 +2548,11 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA,
const char *Exec =
Args.MakeArgString(getToolChain().GetProgramPath("ld"));
Dest.addCommand(new Command(JA, *this, Exec, CmdArgs));
C.addCommand(new Command(JA, *this, Exec, CmdArgs));
}
void darwin::Lipo::ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest, const InputInfo &Output,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const {
@ -2575,11 +2572,11 @@ void darwin::Lipo::ConstructJob(Compilation &C, const JobAction &JA,
}
const char *Exec =
Args.MakeArgString(getToolChain().GetProgramPath("lipo"));
Dest.addCommand(new Command(JA, *this, Exec, CmdArgs));
C.addCommand(new Command(JA, *this, Exec, CmdArgs));
}
void darwin::Dsymutil::ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest, const InputInfo &Output,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const {
@ -2595,11 +2592,11 @@ void darwin::Dsymutil::ConstructJob(Compilation &C, const JobAction &JA,
const char *Exec =
Args.MakeArgString(getToolChain().GetProgramPath("dsymutil"));
Dest.addCommand(new Command(JA, *this, Exec, CmdArgs));
C.addCommand(new Command(JA, *this, Exec, CmdArgs));
}
void auroraux::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest, const InputInfo &Output,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const {
@ -2619,11 +2616,11 @@ void auroraux::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
const char *Exec =
Args.MakeArgString(getToolChain().GetProgramPath("gas"));
Dest.addCommand(new Command(JA, *this, Exec, CmdArgs));
C.addCommand(new Command(JA, *this, Exec, CmdArgs));
}
void auroraux::Link::ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest, const InputInfo &Output,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const {
@ -2720,11 +2717,11 @@ void auroraux::Link::ConstructJob(Compilation &C, const JobAction &JA,
const char *Exec =
Args.MakeArgString(getToolChain().GetProgramPath("ld"));
Dest.addCommand(new Command(JA, *this, Exec, CmdArgs));
C.addCommand(new Command(JA, *this, Exec, CmdArgs));
}
void openbsd::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest, const InputInfo &Output,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const {
@ -2744,11 +2741,11 @@ void openbsd::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
const char *Exec =
Args.MakeArgString(getToolChain().GetProgramPath("as"));
Dest.addCommand(new Command(JA, *this, Exec, CmdArgs));
C.addCommand(new Command(JA, *this, Exec, CmdArgs));
}
void openbsd::Link::ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest, const InputInfo &Output,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const {
@ -2850,11 +2847,11 @@ void openbsd::Link::ConstructJob(Compilation &C, const JobAction &JA,
const char *Exec =
Args.MakeArgString(getToolChain().GetProgramPath("ld"));
Dest.addCommand(new Command(JA, *this, Exec, CmdArgs));
C.addCommand(new Command(JA, *this, Exec, CmdArgs));
}
void freebsd::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest, const InputInfo &Output,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const {
@ -2886,11 +2883,11 @@ void freebsd::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
const char *Exec =
Args.MakeArgString(getToolChain().GetProgramPath("as"));
Dest.addCommand(new Command(JA, *this, Exec, CmdArgs));
C.addCommand(new Command(JA, *this, Exec, CmdArgs));
}
void freebsd::Link::ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest, const InputInfo &Output,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const {
@ -3005,14 +3002,14 @@ void freebsd::Link::ConstructJob(Compilation &C, const JobAction &JA,
const char *Exec =
Args.MakeArgString(getToolChain().GetProgramPath("ld"));
Dest.addCommand(new Command(JA, *this, Exec, CmdArgs));
C.addCommand(new Command(JA, *this, Exec, CmdArgs));
}
void minix::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest, const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const {
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const {
ArgStringList CmdArgs;
Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA,
@ -3029,14 +3026,14 @@ void minix::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
const char *Exec =
Args.MakeArgString(getToolChain().GetProgramPath("gas"));
Dest.addCommand(new Command(JA, *this, Exec, CmdArgs));
C.addCommand(new Command(JA, *this, Exec, CmdArgs));
}
void minix::Link::ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest, const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const {
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const {
const Driver &D = getToolChain().getDriver();
ArgStringList CmdArgs;
@ -3097,7 +3094,7 @@ void minix::Link::ConstructJob(Compilation &C, const JobAction &JA,
const char *Exec =
Args.MakeArgString(getToolChain().GetProgramPath("/usr/gnu/bin/gld"));
Dest.addCommand(new Command(JA, *this, Exec, CmdArgs));
C.addCommand(new Command(JA, *this, Exec, CmdArgs));
}
/// DragonFly Tools
@ -3105,7 +3102,7 @@ void minix::Link::ConstructJob(Compilation &C, const JobAction &JA,
// For now, DragonFly Assemble does just about the same as for
// FreeBSD, but this may change soon.
void dragonfly::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest, const InputInfo &Output,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const {
@ -3130,14 +3127,14 @@ void dragonfly::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
const char *Exec =
Args.MakeArgString(getToolChain().GetProgramPath("as"));
Dest.addCommand(new Command(JA, *this, Exec, CmdArgs));
C.addCommand(new Command(JA, *this, Exec, CmdArgs));
}
void dragonfly::Link::ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest, const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const {
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const {
const Driver &D = getToolChain().getDriver();
ArgStringList CmdArgs;
@ -3263,5 +3260,5 @@ void dragonfly::Link::ConstructJob(Compilation &C, const JobAction &JA,
const char *Exec =
Args.MakeArgString(getToolChain().GetProgramPath("ld"));
Dest.addCommand(new Command(JA, *this, Exec, CmdArgs));
C.addCommand(new Command(JA, *this, Exec, CmdArgs));
}

View File

@ -46,7 +46,6 @@ namespace tools {
virtual bool hasIntegratedCPP() const { return true; }
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,
@ -64,7 +63,6 @@ namespace tools {
virtual bool hasIntegratedCPP() const { return false; }
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,
@ -79,7 +77,6 @@ namespace gcc {
const ToolChain &TC) : Tool(Name, ShortName, TC) {}
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,
@ -203,7 +200,6 @@ namespace darwin {
"gcc preprocessor", TC) {}
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,
@ -215,7 +211,6 @@ namespace darwin {
Compile(const ToolChain &TC) : CC1("darwin::Compile", "gcc frontend", TC) {}
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,
@ -230,7 +225,6 @@ namespace darwin {
virtual bool hasIntegratedCPP() const { return false; }
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,
@ -246,7 +240,6 @@ namespace darwin {
virtual bool hasIntegratedCPP() const { return false; }
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,
@ -260,7 +253,6 @@ namespace darwin {
virtual bool hasIntegratedCPP() const { return false; }
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,
@ -275,7 +267,6 @@ namespace darwin {
virtual bool hasIntegratedCPP() const { return false; }
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,
@ -293,7 +284,6 @@ namespace openbsd {
virtual bool hasIntegratedCPP() const { return false; }
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,
@ -306,7 +296,6 @@ namespace openbsd {
virtual bool hasIntegratedCPP() const { return false; }
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,
@ -324,7 +313,6 @@ namespace freebsd {
virtual bool hasIntegratedCPP() const { return false; }
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,
@ -337,7 +325,6 @@ namespace freebsd {
virtual bool hasIntegratedCPP() const { return false; }
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,
@ -355,7 +342,6 @@ namespace minix {
virtual bool hasIntegratedCPP() const { return false; }
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,
@ -368,7 +354,6 @@ namespace minix {
virtual bool hasIntegratedCPP() const { return false; }
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,
@ -386,7 +371,6 @@ namespace auroraux {
virtual bool hasIntegratedCPP() const { return false; }
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,
@ -399,7 +383,6 @@ namespace auroraux {
virtual bool hasIntegratedCPP() const { return false; }
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,
@ -417,7 +400,6 @@ namespace dragonfly {
virtual bool hasIntegratedCPP() const { return false; }
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,
@ -430,7 +412,6 @@ namespace dragonfly {
virtual bool hasIntegratedCPP() const { return false; }
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &TCArgs,