[cfe-commits] r63014 - in /cfe/trunk/tools/ccc/ccclib: Arguments.py Driver.py Phases.py ToolChain.py Tools.py Types.py
Daniel Dunbar
daniel at zuster.org
Mon Jan 26 09:09:15 PST 2009
Author: ddunbar
Date: Mon Jan 26 11:09:15 2009
New Revision: 63014
URL: http://llvm.org/viewvc/llvm-project?rev=63014&view=rev
Log:
ccc: Recognize -emit-llvm [-S].
- Unlike llvm-gcc, this doesn't yet treat -emit-llvm output as a
linker input.
Modified:
cfe/trunk/tools/ccc/ccclib/Arguments.py
cfe/trunk/tools/ccc/ccclib/Driver.py
cfe/trunk/tools/ccc/ccclib/Phases.py
cfe/trunk/tools/ccc/ccclib/ToolChain.py
cfe/trunk/tools/ccc/ccclib/Tools.py
cfe/trunk/tools/ccc/ccclib/Types.py
Modified: cfe/trunk/tools/ccc/ccclib/Arguments.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/Arguments.py?rev=63014&r1=63013&r2=63014&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/Arguments.py (original)
+++ cfe/trunk/tools/ccc/ccclib/Arguments.py Mon Jan 26 11:09:15 2009
@@ -689,7 +689,7 @@
self.addOption(JoinedOption('-i', self.iGroup))
- # Where are these coming from? I can't find them...
+ self.emitLLVMOption = self.addOption(FlagOption('-emit-llvm'))
self.eOption = self.addOption(JoinedOrSeparateOption('-e'))
self.rOption = self.addOption(JoinedOrSeparateOption('-r'))
Modified: cfe/trunk/tools/ccc/ccclib/Driver.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/Driver.py?rev=63014&r1=63013&r2=63014&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/Driver.py (original)
+++ cfe/trunk/tools/ccc/ccclib/Driver.py Mon Jan 26 11:09:15 2009
@@ -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,
Modified: cfe/trunk/tools/ccc/ccclib/Phases.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/Phases.py?rev=63014&r1=63013&r2=63014&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/Phases.py (original)
+++ cfe/trunk/tools/ccc/ccclib/Phases.py Mon Jan 26 11:09:15 2009
@@ -76,6 +76,10 @@
def __init__(self):
super(SyntaxOnlyPhase, self).__init__("syntax-only", Phase.eOrderCompile)
+class EmitLLVMPhase(Phase):
+ def __init__(self):
+ super(EmitLLVMPhase, self).__init__("emit-llvm", Phase.eOrderCompile)
+
class CompilePhase(Phase):
def __init__(self):
super(CompilePhase, self).__init__("compiler", Phase.eOrderCompile)
Modified: cfe/trunk/tools/ccc/ccclib/ToolChain.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/ToolChain.py?rev=63014&r1=63013&r2=63014&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/ToolChain.py (original)
+++ cfe/trunk/tools/ccc/ccclib/ToolChain.py Mon Jan 26 11:09:15 2009
@@ -64,12 +64,14 @@
self.archName = archName
self.clangTool = Tools.Clang_CompileTool(self)
+ cc = Tools.Darwin_X86_CompileTool(self)
self.toolMap = {
Phases.PreprocessPhase : Tools.Darwin_X86_PreprocessTool(self),
Phases.AnalyzePhase : self.clangTool,
- Phases.SyntaxOnlyPhase : Tools.Darwin_X86_CompileTool(self),
- Phases.CompilePhase : Tools.Darwin_X86_CompileTool(self),
- Phases.PrecompilePhase : Tools.Darwin_X86_CompileTool(self),
+ Phases.SyntaxOnlyPhase : cc,
+ Phases.EmitLLVMPhase : cc,
+ Phases.CompilePhase : cc,
+ Phases.PrecompilePhase : cc,
Phases.AssemblePhase : Tools.Darwin_AssembleTool(self),
Phases.LinkPhase : Tools.Darwin_X86_LinkTool(self),
Phases.LipoPhase : Tools.LipoTool(),
@@ -110,7 +112,9 @@
if self.driver.cccClang and self.archName == 'i386':
if (action.inputs[0].type in (Types.CType, Types.CTypeNoPP,
Types.ObjCType, Types.ObjCTypeNoPP) and
- isinstance(action.phase, Phases.CompilePhase)):
+ (isinstance(action.phase, Phases.CompilePhase) or
+ isinstance(action.phase, Phases.SyntaxOnlyPhase) or
+ isinstance(action.phase, Phases.EmitLLVMPhase))):
return self.clangTool
elif (action.inputs[0].type in (Types.CHeaderType, Types.CHeaderNoPPType,
Types.ObjCHeaderType, Types.ObjCHeaderNoPPType) and
@@ -200,11 +204,13 @@
def __init__(self, driver):
super(Generic_GCC_ToolChain, self).__init__(driver)
+ cc = Tools.GCC_CompileTool()
self.toolMap = {
Phases.PreprocessPhase : Tools.GCC_PreprocessTool(),
Phases.AnalyzePhase : Tools.Clang_CompileTool(self),
- Phases.SyntaxOnlyPhase : Tools.GCC_CompileTool(),
- Phases.CompilePhase : Tools.GCC_CompileTool(),
+ Phases.SyntaxOnlyPhase : cc,
+ Phases.EmitLLVMPhase : cc,
+ Phases.CompilePhase : cc,
Phases.PrecompilePhase : Tools.GCC_PrecompileTool(),
Phases.AssemblePhase : Tools.GCC_AssembleTool(),
Phases.LinkPhase : Tools.GCC_LinkTool(),
Modified: cfe/trunk/tools/ccc/ccclib/Tools.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/Tools.py?rev=63014&r1=63013&r2=63014&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/Tools.py (original)
+++ cfe/trunk/tools/ccc/ccclib/Tools.py Mon Jan 26 11:09:15 2009
@@ -179,9 +179,15 @@
patchOutputNameForPTH = False
if isinstance(phase.phase, Phases.AnalyzePhase):
+ assert outputType is Types.PlistType
cmd_args.append('-analyze')
elif isinstance(phase.phase, Phases.SyntaxOnlyPhase):
+ assert outputType is Types.NothingType
cmd_args.append('-fsyntax-only')
+ elif outputType is Types.LLVMAsmType:
+ cmd_args.append('-emit-llvm')
+ elif outputType is Types.LLVMBCType:
+ cmd_args.append('-emit-llvm-bc')
elif outputType is Types.AsmTypeNoPP:
cmd_args.append('-S')
elif outputType is Types.PCHType:
@@ -688,6 +694,15 @@
raise Arguments.InvalidArgumentsError("-traditional is not supported without -E")
if outputType is Types.PCHType:
+ pass
+ elif outputType is Types.AsmTypeNoPP:
+ pass
+ elif outputType is Types.LLVMAsmType:
+ cmd_args.append('-emit-llvm')
+ elif outputType is Types.LLVMBCType:
+ cmd_args.append('-emit-llvm-bc')
+
+ if outputType is Types.PCHType:
output_args = []
else:
output_args = self.getOutputArgs(arglist, output)
Modified: cfe/trunk/tools/ccc/ccclib/Types.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/Types.py?rev=63014&r1=63013&r2=63014&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/Types.py (original)
+++ cfe/trunk/tools/ccc/ccclib/Types.py Mon Jan 26 11:09:15 2009
@@ -69,6 +69,8 @@
JavaType = InputType('java', canBeUserSpecified=True)
# Misc.
+LLVMAsmType = InputType('llvm-asm', tempSuffix='ll')
+LLVMBCType = InputType('llvm-bc', tempSuffix='bc')
PlistType = InputType('plist', tempSuffix='plist')
PCHType = InputType('precompiled-header', tempSuffix='gch')
ObjectType = InputType('object', tempSuffix='o')
More information about the cfe-commits
mailing list