Add dex2oat --print-pass-names and --disable-passes= options.

Add --print-pass-names to print a list of pass names.
Add --disable-passes= to disable one ore more passes
separated by comma.
Ex: Using --disable-passes=UseCount,BBOptimizations can disable UseCount
and BBOptimizations passes.

Change-Id: I0dffaf10547afdcca78a20d8e0e6b358bfb2ee8c
Signed-off-by: Chao-ying Fu <chao-ying.fu@intel.com>
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index cc78816..b51efc4 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -33,6 +33,7 @@
 #include "compiler_backend.h"
 #include "compiler_callbacks.h"
 #include "dex_file-inl.h"
+#include "dex/pass_driver.h"
 #include "dex/verification_results.h"
 #include "driver/compiler_callbacks_impl.h"
 #include "driver/compiler_driver.h"
@@ -203,6 +204,11 @@
     UsageError("");
     UsageError("  --profile-file=<filename>: specify profiler output file to use for compilation.");
   UsageError("");
+  UsageError("  --print-pass-names: print a list of pass names");
+  UsageError("");
+  UsageError("  --disable-passes=<pass-names>:  disable one or more passes separated by comma.");
+  UsageError("      Example: --disable-passes=UseCount,BBOptimizations");
+  UsageError("");
   std::cerr << "See log for usage error information\n";
   exit(EXIT_FAILURE);
 }
@@ -908,6 +914,11 @@
     } else if (option == "--no-profile-file") {
       LOG(INFO) << "dex2oat: no profile file supplied (explictly)";
       // No profile
+    } else if (option == "--print-pass-names") {
+      PassDriver::PrintPassNames();
+    } else if (option.starts_with("--disable-passes=")) {
+      std::string disable_passes = option.substr(strlen("--disable-passes=")).data();
+      PassDriver::CreateDefaultPassList(disable_passes);
     } else {
       Usage("Unknown argument %s", option.data());
     }