summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-03-13 11:28:30 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-03-13 11:28:30 +0000
commite71b9640ad2ec2f8594f81d96ef0a2ef064a144d (patch)
treec5363df64bfd61a83f52f8c86ab8b9e8a5a6be97 /clang/lib/Driver
parent58cac7ca6877b5e6571cc2a23c5116c7e19742ff (diff)
downloadbcm5719-llvm-e71b9640ad2ec2f8594f81d96ef0a2ef064a144d.tar.gz
bcm5719-llvm-e71b9640ad2ec2f8594f81d96ef0a2ef064a144d.zip
Driver: Add types::getNumCompilationPhases, getCompilationPhase to
provide information about what steps should be done for a particular file type. llvm-svn: 66881
Diffstat (limited to 'clang/lib/Driver')
-rw-r--r--clang/lib/Driver/Types.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/clang/lib/Driver/Types.cpp b/clang/lib/Driver/Types.cpp
index 88389c9ce3a..96d76dd4d60 100644
--- a/clang/lib/Driver/Types.cpp
+++ b/clang/lib/Driver/Types.cpp
@@ -128,3 +128,47 @@ types::ID types::lookupTypeForTypeSpecifier(const char *Name) {
return TY_INVALID;
}
+
+// FIXME: Why don't we just put this list in the defs file, eh.
+
+unsigned types::getNumCompilationPhases(ID Id) {
+ if (Id == TY_Object)
+ return 1;
+
+ unsigned N = 0;
+ if (getPreprocessedType(Id) != TY_INVALID)
+ N += 1;
+
+ if (onlyAssembleType(Id))
+ return N + 2; // assemble, link
+ if (onlyPrecompileType(Id))
+ return N + 1; // precompile
+
+ return N + 3; // compile, assemble, link
+}
+
+phases::ID types::getCompilationPhase(ID Id, unsigned N) {
+ assert(N < getNumCompilationPhases(Id) && "Invalid index.");
+
+ if (Id == TY_Object)
+ return phases::Link;
+
+ if (getPreprocessedType(Id) != TY_INVALID) {
+ if (N == 0)
+ return phases::Preprocess;
+ --N;
+ }
+
+ if (onlyAssembleType(Id))
+ return N == 0 ? phases::Assemble : phases::Link;
+
+ if (onlyPrecompileType(Id))
+ return phases::Precompile;
+
+ if (N == 0)
+ return phases::Compile;
+ if (N == 1)
+ return phases::Assemble;
+
+ return phases::Link;
+}
OpenPOWER on IntegriCloud