aboutsummaryrefslogtreecommitdiff
path: root/lib/Driver/Driver.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-02-03 03:07:56 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-02-03 03:07:56 +0000
commit8767cbc475ed96397b6f08617814eeb9cab121bd (patch)
treee54fa788e38d32e6ed16eb12d1d2f6ac4e0c5395 /lib/Driver/Driver.cpp
parente393f4afcd1a5c3cd73697d838b064a9b5af832f (diff)
Driver: Add -[no-]integrated-as for clang.
- Requires backend support, which only exists for i386--darwin currently. No 'as' required: -- ddunbar@ozzy:tmp$ cat t.c int main() { return 42; } ddunbar@ozzy:tmp$ clang -m32 -integrated-as t.c ddunbar@ozzy:tmp$ ./a.out; echo $? 42 ddunbar@ozzy:tmp$ -- The random extra whitespace is how you know its working! :) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95194 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/Driver.cpp')
-rw-r--r--lib/Driver/Driver.cpp55
1 files changed, 41 insertions, 14 deletions
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index 62c2d12cd3..a2fc5aa08d 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -865,6 +865,44 @@ void Driver::BuildJobs(Compilation &C) const {
}
}
+static const Tool &SelectToolForJob(Compilation &C, const ToolChain *TC,
+ const JobAction *JA,
+ const ActionList *&Inputs) {
+ const Tool *ToolForJob = 0;
+
+ // See if we should look for a compiler with an integrated assembler. We match
+ // bottom up, so what we are actually looking for is an assembler job with a
+ // compiler input.
+ if (C.getArgs().hasArg(options::OPT_integrated_as,
+ options::OPT_no_integrated_as,
+ TC->IsIntegratedAssemblerDefault()) &&
+ !C.getArgs().hasArg(options::OPT_save_temps) &&
+ isa<AssembleJobAction>(JA) &&
+ Inputs->size() == 1 && isa<CompileJobAction>(*Inputs->begin())) {
+ const Tool &Compiler = TC->SelectTool(C,cast<JobAction>(**Inputs->begin()));
+ if (Compiler.hasIntegratedAssembler()) {
+ Inputs = &(*Inputs)[0]->getInputs();
+ ToolForJob = &Compiler;
+ }
+ }
+
+ // Otherwise use the tool for the current job.
+ if (!ToolForJob)
+ ToolForJob = &TC->SelectTool(C, *JA);
+
+ // See if we should use an integrated preprocessor. We do so when we have
+ // exactly one input, since this is the only use case we care about
+ // (irrelevant since we don't support combine yet).
+ if (Inputs->size() == 1 && isa<PreprocessJobAction>(*Inputs->begin()) &&
+ !C.getArgs().hasArg(options::OPT_no_integrated_cpp) &&
+ !C.getArgs().hasArg(options::OPT_traditional_cpp) &&
+ !C.getArgs().hasArg(options::OPT_save_temps) &&
+ ToolForJob->hasIntegratedCPP())
+ Inputs = &(*Inputs)[0]->getInputs();
+
+ return *ToolForJob;
+}
+
void Driver::BuildJobsForAction(Compilation &C,
const Action *A,
const ToolChain *TC,
@@ -905,21 +943,10 @@ void Driver::BuildJobsForAction(Compilation &C,
return;
}
- const JobAction *JA = cast<JobAction>(A);
- const Tool &T = TC->SelectTool(C, *JA);
-
- // See if we should use an integrated preprocessor. We do so when we have
- // exactly one input, since this is the only use case we care about
- // (irrelevant since we don't support combine yet).
const ActionList *Inputs = &A->getInputs();
- if (Inputs->size() == 1 && isa<PreprocessJobAction>(*Inputs->begin())) {
- if (!C.getArgs().hasArg(options::OPT_no_integrated_cpp) &&
- !C.getArgs().hasArg(options::OPT_traditional_cpp) &&
- !C.getArgs().hasArg(options::OPT_save_temps) &&
- T.hasIntegratedCPP()) {
- Inputs = &(*Inputs)[0]->getInputs();
- }
- }
+
+ const JobAction *JA = cast<JobAction>(A);
+ const Tool &T = SelectToolForJob(C, TC, JA, Inputs);
// Only use pipes when there is exactly one input.
bool TryToUsePipeInput = Inputs->size() == 1 && T.acceptsPipedInput();