plotfi updated this revision to Diff 211652.
plotfi added a comment.

Removing 'A'


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65176/new/

https://reviews.llvm.org/D65176

Files:
  clang/include/clang/Driver/Types.def
  clang/lib/Driver/Types.cpp

Index: clang/lib/Driver/Types.cpp
===================================================================
--- clang/lib/Driver/Types.cpp
+++ clang/lib/Driver/Types.cpp
@@ -42,11 +42,19 @@
 }
 
 types::ID types::getPreprocessedType(ID Id) {
-  return getInfo(Id).PreprocessedType;
+  ID PPT = getInfo(Id).PreprocessedType;
+  assert((llvm::is_contained(getInfo(Id).Phases, phases::Preprocess) !=
+          (PPT == TY_INVALID)) &&
+         "Unexpected Preprocess Type.");
+  return PPT;
+}
+
+static bool isPrepeocessedModuleType(ID Id) {
+  return Id == TY_CXXModule || Id == TY_PP_CXXModule;
 }
 
 types::ID types::getPrecompiledType(ID Id) {
-  if (strchr(getInfo(Id).Flags, 'm'))
+  if (isPrepeocessedModuleType(Id))
     return TY_ModuleFile;
   if (onlyPrecompileType(Id))
     return TY_PCH;
@@ -71,11 +79,14 @@
 }
 
 bool types::onlyAssembleType(ID Id) {
-  return strchr(getInfo(Id).Flags, 'a');
+  return llvm::is_contained(getInfo(Id).Phases, phases::Assemble) &&
+         !llvm::is_contained(getInfo(Id).Phases, phases::Compile) &&
+         !llvm::is_contained(getInfo(Id).Phases, phases::Backend);
 }
 
 bool types::onlyPrecompileType(ID Id) {
-  return strchr(getInfo(Id).Flags, 'p');
+  return llvm::is_contained(getInfo(Id).Phases, phases::Precompile) &&
+         !isPrepeocessedModuleType(Id);
 }
 
 bool types::canTypeBeUserSpecified(ID Id) {
@@ -83,7 +94,8 @@
 }
 
 bool types::appendSuffixForType(ID Id) {
-  return strchr(getInfo(Id).Flags, 'A');
+  return Id == TY_PCH || Id == TY_dSYM || Id == TY_CUDA_FATBIN ||
+         Id == TY_HIP_FATBIN;
 }
 
 bool types::canLipoType(ID Id) {
@@ -269,39 +281,7 @@
 // FIXME: The list is now in Types.def but for now this function will verify
 //        the old behavior and a subsequent change will delete most of the body.
 void types::getCompilationPhases(ID Id, llvm::SmallVectorImpl<phases::ID> &P) {
-  if (Id != TY_Object) {
-    if (getPreprocessedType(Id) != TY_INVALID) {
-      P.push_back(phases::Preprocess);
-    }
-
-    if (getPrecompiledType(Id) != TY_INVALID) {
-      P.push_back(phases::Precompile);
-    }
-
-    if (!onlyPrecompileType(Id)) {
-      if (!onlyAssembleType(Id)) {
-        P.push_back(phases::Compile);
-        P.push_back(phases::Backend);
-      }
-      P.push_back(phases::Assemble);
-    }
-  }
-
-  if (!onlyPrecompileType(Id)) {
-    P.push_back(phases::Link);
-  }
-
-  // Check that the static Phase list matches.
-  // TODO: These will be deleted.
-  const llvm::SmallVectorImpl<phases::ID> &Phases = getInfo(Id).Phases;
-  assert(Phases.size() == P.size() &&
-         std::equal(Phases.begin(), Phases.end(), P.begin()) &&
-         "Invalid phase or size");
-
-  // TODO: This function is still being used to assert that the phase list in
-  //       Types.def is correct. Everything above this comment will be removed
-  //       in a subsequent NFC commit.
-  P = Phases;
+  P = getInfo(Id).Phases;
   assert(0 < P.size() && "Not enough phases in list");
   assert(P.size() <= phases::MaxNumberOfPhases && "Too many phases in list");
 }
Index: clang/include/clang/Driver/Types.def
===================================================================
--- clang/include/clang/Driver/Types.def
+++ clang/include/clang/Driver/Types.def
@@ -30,15 +30,20 @@
 // of this type, or null if unspecified.
 
 // The fifth value is a string containing option flags. Valid values:
-//  a - The type should only be assembled.
-//  p - The type should only be precompiled.
 //  u - The type can be user specified (with -x).
-//  m - Precompiling this type produces a module file.
-//  A - The type's temporary suffix should be appended when generating
-//      outputs of this type.
 
 // The sixth value is a variadic list of phases for each type. Eventually the
 // options flag string will be replaced with this variadic list.
+// Some of the options in Flags have been removed, so far those are:
+//  a - The type should only be assembled: Now, check that Phases contains
+//      phases::Assemble but not phases::Compile or phases::Backend.
+//  p - The type should only be precompiled: Now, check that Phases contains
+//      phases::Precompile but that Flags does not contain 'm'.
+//  m - Precompiling this type produces a module file: Now, check
+//      isPrepeocessedModuleType.
+//  A - The type's temporary suffix should be appended when generating
+//      outputs of this type: Now, check appendSuffixForType.
+
 
 // C family source language (with and without preprocessing).
 TYPE("cpp-output",               PP_C,         INVALID,         "i",     "u", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
@@ -61,22 +66,22 @@
 TYPE("renderscript",             RenderScript, PP_C,            "rs",    "u", phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, phases::Link)
 
 // C family input files to precompile.
-TYPE("c-header-cpp-output",      PP_CHeader,   INVALID,         "i",     "p",  phases::Precompile)
-TYPE("c-header",                 CHeader,      PP_CHeader,      "h",     "pu", phases::Preprocess, phases::Precompile)
-TYPE("cl-header",                CLHeader,     PP_CHeader,      "h",     "pu", phases::Preprocess, phases::Precompile)
-TYPE("objective-c-header-cpp-output", PP_ObjCHeader, INVALID,   "mi",    "p",  phases::Precompile)
-TYPE("objective-c-header",       ObjCHeader,   PP_ObjCHeader,   "h",     "pu", phases::Preprocess, phases::Precompile)
-TYPE("c++-header-cpp-output",    PP_CXXHeader, INVALID,         "ii",    "p",  phases::Precompile)
-TYPE("c++-header",               CXXHeader,    PP_CXXHeader,    "hh",    "pu", phases::Preprocess, phases::Precompile)
-TYPE("objective-c++-header-cpp-output", PP_ObjCXXHeader, INVALID, "mii", "p",  phases::Precompile)
-TYPE("objective-c++-header",     ObjCXXHeader, PP_ObjCXXHeader, "h",     "pu", phases::Preprocess, phases::Precompile)
-TYPE("c++-module",               CXXModule,    PP_CXXModule,    "cppm",  "mu", phases::Preprocess, phases::Precompile, phases::Compile, phases::Backend, phases::Assemble, phases::Link)
-TYPE("c++-module-cpp-output",    PP_CXXModule, INVALID,         "iim",   "m",  phases::Precompile, phases::Compile, phases::Backend, phases::Assemble, phases::Link)
+TYPE("c-header-cpp-output",      PP_CHeader,   INVALID,         "i",     "",   phases::Precompile)
+TYPE("c-header",                 CHeader,      PP_CHeader,      "h",     "u",  phases::Preprocess, phases::Precompile)
+TYPE("cl-header",                CLHeader,     PP_CHeader,      "h",     "u",  phases::Preprocess, phases::Precompile)
+TYPE("objective-c-header-cpp-output", PP_ObjCHeader, INVALID,   "mi",    "",   phases::Precompile)
+TYPE("objective-c-header",       ObjCHeader,   PP_ObjCHeader,   "h",     "u",  phases::Preprocess, phases::Precompile)
+TYPE("c++-header-cpp-output",    PP_CXXHeader, INVALID,         "ii",    "",   phases::Precompile)
+TYPE("c++-header",               CXXHeader,    PP_CXXHeader,    "hh",    "u",  phases::Preprocess, phases::Precompile)
+TYPE("objective-c++-header-cpp-output", PP_ObjCXXHeader, INVALID, "mii", "",   phases::Precompile)
+TYPE("objective-c++-header",     ObjCXXHeader, PP_ObjCXXHeader, "h",     "u",  phases::Preprocess, phases::Precompile)
+TYPE("c++-module",               CXXModule,    PP_CXXModule,    "cppm",  "u",  phases::Preprocess, phases::Precompile, phases::Compile, phases::Backend, phases::Assemble, phases::Link)
+TYPE("c++-module-cpp-output",    PP_CXXModule, INVALID,         "iim",   "",   phases::Precompile, phases::Compile, phases::Backend, phases::Assemble, phases::Link)
 
 // Other languages.
 TYPE("ada",                      Ada,          INVALID,         nullptr, "u",  phases::Compile, phases::Backend, phases::Assemble, phases::Link)
-TYPE("assembler",                PP_Asm,       INVALID,         "s",     "au", phases::Assemble, phases::Link)
-TYPE("assembler-with-cpp",       Asm,          PP_Asm,          "S",     "au", phases::Preprocess, phases::Assemble, phases::Link)
+TYPE("assembler",                PP_Asm,       INVALID,         "s",     "u",  phases::Assemble, phases::Link)
+TYPE("assembler-with-cpp",       Asm,          PP_Asm,          "S",     "u",  phases::Preprocess, phases::Assemble, phases::Link)
 TYPE("f95",                      PP_Fortran,   INVALID,         nullptr, "u",  phases::Compile, phases::Backend, phases::Assemble, phases::Link)
 TYPE("f95-cpp-input",            Fortran,      PP_Fortran,      nullptr, "u",  phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, phases::Link)
 TYPE("java",                     Java,         INVALID,         nullptr, "u",  phases::Compile, phases::Backend, phases::Assemble, phases::Link)
@@ -96,12 +101,12 @@
 TYPE("rewritten-objc",           RewrittenObjC,INVALID,         "cpp",   "",  phases::Compile, phases::Backend, phases::Assemble, phases::Link)
 TYPE("rewritten-legacy-objc",    RewrittenLegacyObjC,INVALID,   "cpp",   "",  phases::Compile, phases::Backend, phases::Assemble, phases::Link)
 TYPE("remap",                    Remap,        INVALID,         "remap", "",  phases::Compile, phases::Backend, phases::Assemble, phases::Link)
-TYPE("precompiled-header",       PCH,          INVALID,         "gch",   "A", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
+TYPE("precompiled-header",       PCH,          INVALID,         "gch",   "",  phases::Compile, phases::Backend, phases::Assemble, phases::Link)
 TYPE("object",                   Object,       INVALID,         "o",     "",  phases::Link)
 TYPE("treelang",                 Treelang,     INVALID,         nullptr, "u", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
 TYPE("image",                    Image,        INVALID,         "out",   "",  phases::Compile, phases::Backend, phases::Assemble, phases::Link)
-TYPE("dSYM",                     dSYM,         INVALID,         "dSYM",  "A", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
+TYPE("dSYM",                     dSYM,         INVALID,         "dSYM",  "",  phases::Compile, phases::Backend, phases::Assemble, phases::Link)
 TYPE("dependencies",             Dependencies, INVALID,         "d",     "",  phases::Compile, phases::Backend, phases::Assemble, phases::Link)
-TYPE("cuda-fatbin",              CUDA_FATBIN,  INVALID,         "fatbin","A", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
-TYPE("hip-fatbin",               HIP_FATBIN,   INVALID,         "hipfb", "A", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
+TYPE("cuda-fatbin",              CUDA_FATBIN,  INVALID,         "fatbin","",  phases::Compile, phases::Backend, phases::Assemble, phases::Link)
+TYPE("hip-fatbin",               HIP_FATBIN,   INVALID,         "hipfb", "",  phases::Compile, phases::Backend, phases::Assemble, phases::Link)
 TYPE("none",                     Nothing,      INVALID,         nullptr, "u", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to