ccc: Recognize -emit-llvm [-S].
- Unlike llvm-gcc, this doesn't yet treat -emit-llvm output as a
linker input.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63014 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/ccc/ccclib/Driver.py b/tools/ccc/ccclib/Driver.py
index 9a393f1..0fe5806 100644
--- a/tools/ccc/ccclib/Driver.py
+++ b/tools/ccc/ccclib/Driver.py
@@ -336,6 +336,7 @@
def buildNormalPipeline(self, args):
hasAnalyze = args.getLastArg(self.parser.analyzeOption)
hasCombine = args.getLastArg(self.parser.combineOption)
+ hasEmitLLVM = args.getLastArg(self.parser.emitLLVMOption)
hasSyntaxOnly = args.getLastArg(self.parser.syntaxOnlyOption)
hasDashC = args.getLastArg(self.parser.cOption)
hasDashE = args.getLastArg(self.parser.EOption)
@@ -368,7 +369,7 @@
# worth doing, since the tool presumably does this
# anyway, and this just adds an extra stat to the
# equation, but this is gcc compatible.
- if not os.path.exists(inputValue):
+ if inputValue != '-' and not os.path.exists(inputValue):
self.warning("%s: No such file or directory" % inputValue)
else:
inputs.append((klass, a))
@@ -408,15 +409,11 @@
if hasDashE or hasDashM or hasDashMM:
finalPhase = Phases.Phase.eOrderPreprocess
finalPhaseOpt = hasDashE
- elif hasAnalyze:
+ elif (hasAnalyze or hasSyntaxOnly or
+ hasEmitLLVM or hasDashS):
finalPhase = Phases.Phase.eOrderCompile
- finalPhaseOpt = hasAnalyze
- elif hasSyntaxOnly:
- finalPhase = Phases.Phase.eOrderCompile
- finalPhaseOpt = hasSyntaxOnly
- elif hasDashS:
- finalPhase = Phases.Phase.eOrderCompile
- finalPhaseOpt = hasDashS
+ finalPhaseOpt = (hasAnalyze or hasSyntaxOnly or
+ hasEmitLLVM or hasDashS)
elif hasDashC:
finalPhase = Phases.Phase.eOrderAssemble
finalPhaseOpt = hasDashC
@@ -464,6 +461,8 @@
sequence.append(Phases.AnalyzePhase())
elif hasSyntaxOnly:
sequence.append(Phases.SyntaxOnlyPhase())
+ elif hasEmitLLVM:
+ sequence.append(Phases.EmitLLVMPhase())
else:
sequence.extend([Phases.CompilePhase(),
Phases.AssemblePhase(),
@@ -506,6 +505,14 @@
current = Phases.JobAction(transition,
[current],
output)
+ elif isinstance(transition, Phases.EmitLLVMPhase):
+ if hasDashS:
+ output = Types.LLVMAsmType
+ else:
+ output = Types.LLVMBCType
+ current = Phases.JobAction(transition,
+ [current],
+ output)
elif isinstance(transition, Phases.CompilePhase):
output = Types.AsmTypeNoPP
current = Phases.JobAction(transition,