diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-01-05 19:53:30 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-01-05 19:53:30 +0000 |
commit | a5677511d14bbe6181de423fb5f3cafacbdbe87c (patch) | |
tree | 86a9f3b656425398b2f4e444824347db7fcac1c3 /tools/ccc/ccclib/Types.py | |
parent | 6c6fce03ea12b7b8e812fa1b24cfe5aa8705ceca (diff) |
Add prototype ccc rewrite.
- Entry point is tools/ccc/xcc until we are a functional replacement
for ccc.
This is highly experimental (FIXME/LOC ratio of 3.4%), quite crufty,
and barely usable (and then only on my specific Darwin). However, many
of the right ideas are present, and it already fixes a number of
things gcc gets wrong.
The major missing component is argument translation for tools
(translating driver arguments into cc1/ld/as/etc. arguments). This is
a large part of the driver functionality and will probably double the
LOC, but my hope is that the current architecture is relatively
stable.
Documentation & motivation to follow soon...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61739 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/ccc/ccclib/Types.py')
-rw-r--r-- | tools/ccc/ccclib/Types.py | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/tools/ccc/ccclib/Types.py b/tools/ccc/ccclib/Types.py new file mode 100644 index 0000000000..4d04e0a3d1 --- /dev/null +++ b/tools/ccc/ccclib/Types.py @@ -0,0 +1,123 @@ +class InputType(object): + """InputType - Information about various classes of files which + the driver recognizes and control processing.""" + + def __init__(self, name, preprocess=None, onlyAssemble=False, + onlyPrecompile=False, tempSuffix=None): + assert preprocess is None or isinstance(preprocess, InputType) + self.name = name + self.preprocess = preprocess + self.onlyAssemble = onlyAssemble + self.onlyPrecompile = onlyPrecompile + self.tempSuffix = tempSuffix + + def __repr__(self): + return '%s(%r, %r, %r, %r, %r)' % (self.__class__.__name__, + self.name, + self.preprocess, + self.onlyAssemble, + self.onlyPrecompile, + self.tempSuffix) + +# C family source language (with and without preprocessing). +CTypeNoPP = InputType('cpp-output', tempSuffix='i') +CType = InputType('c', CTypeNoPP) +ObjCTypeNoPP = InputType('objective-c-cpp-output', tempSuffix='mi') +ObjCType = InputType('objective-c', ObjCTypeNoPP) +CXXTypeNoPP = InputType('c++-cpp-output', tempSuffix='ii') +CXXType = InputType('c++', CXXTypeNoPP) +ObjCXXTypeNoPP = InputType('objective-c++-cpp-output', tempSuffix='mii') +ObjCXXType = InputType('c++', ObjCXXTypeNoPP) + +# C family input files to precompile. +CHeaderNoPPType = InputType('c-header-cpp-output', onlyPrecompile=True, tempSuffix='pch') +CHeaderType = InputType('c-header', CHeaderNoPPType, onlyPrecompile=True) +ObjCHeaderNoPPType = InputType('objective-c-header-cpp-output', onlyPrecompile=True, tempSuffix='pch') +ObjCHeaderType = InputType('objective-c-header', ObjCHeaderNoPPType, onlyPrecompile=True) +CXXHeaderNoPPType = InputType('c++-header-cpp-output', onlyPrecompile=True, tempSuffix='pch') +CXXHeaderType = InputType('c++-header', CXXHeaderNoPPType, onlyPrecompile=True) +ObjCXXHeaderNoPPType = InputType('objective-c++-header-cpp-output', onlyPrecompile=True, tempSuffix='pch') +ObjCXXHeaderType = InputType('objective-c++-header', ObjCXXHeaderNoPPType, onlyPrecompile=True) + +# Other languages. +AdaType = InputType('ada') +AsmTypeNoPP = InputType('assembler', onlyAssemble=True, tempSuffix='s') +AsmType = InputType('assembler-with-cpp', AsmTypeNoPP, onlyAssemble=True) +FortranTypeNoPP = InputType('fortran') +FortranType = InputType('fortran', FortranTypeNoPP) +JavaType = InputType('java') + +# Misc. +PCHType = InputType('precompiled-header') +ObjectType = InputType('object', tempSuffix='o') +TreelangType = InputType('treelang') +ImageType = InputType('image', tempSuffix='out') +NothingType = InputType('nothing') + +### + +kDefaultOutput = "a.out" +kTypeSuffixMap = { + '.c' : CType, + '.i' : CTypeNoPP, + '.ii' : CXXTypeNoPP, + '.m' : ObjCType, + '.mi' : ObjCTypeNoPP, + '.mm' : ObjCXXType, + '.M' : ObjCXXType, + '.mii' : ObjCXXTypeNoPP, + '.h' : CHeaderType, + '.cc' : CXXType, + '.cc' : CXXType, + '.cp' : CXXType, + '.cxx' : CXXType, + '.cpp' : CXXType, + '.CPP' : CXXType, + '.cXX' : CXXType, + '.C' : CXXType, + '.hh' : CXXHeaderType, + '.H' : CXXHeaderType, + '.f' : FortranTypeNoPP, + '.for' : FortranTypeNoPP, + '.FOR' : FortranTypeNoPP, + '.F' : FortranType, + '.fpp' : FortranType, + '.FPP' : FortranType, + '.f90' : FortranTypeNoPP, + '.f95' : FortranTypeNoPP, + '.F90' : FortranType, + '.F95' : FortranType, + # Apparently the Ada F-E hardcodes these suffixes in many + # places. This explains why there is only one -x option for ada. + '.ads' : AdaType, + '.adb' : AdaType, + # FIXME: Darwin always uses a preprocessor for asm input. Where + # does this fit? + '.s' : AsmTypeNoPP, + '.S' : AsmType, +} +kTypeSpecifierMap = { + 'none' : None, + + 'c' : CType, + 'c-header' : CHeaderType, + # NOTE: gcc.info claims c-cpp-output works but the actual spelling + # is cpp-output. Nice. + 'cpp-output' : CTypeNoPP, + 'c++' : CXXType, + 'c++-header' : CXXHeaderType, + 'c++-cpp-output' : CXXTypeNoPP, + 'objective-c' : ObjCType, + 'objective-c-header' : ObjCHeaderType, + 'objective-c-cpp-output' : ObjCTypeNoPP, + 'objective-c++' : ObjCXXType, + 'objective-c++-header' : ObjCXXHeaderType, + 'objective-c++-cpp-output' : ObjCXXTypeNoPP, + 'assembler' : AsmTypeNoPP, + 'assembler-with-cpp' : AsmType, + 'ada' : AdaType, + 'f95' : FortranType, + 'f95-cpp-input' : FortranTypeNoPP, + 'java' : JavaType, + 'treelang' : TreelangType, +} |