@@ -2103,7 +2103,8 @@ bool Driver::HandleImmediateArgs(const Compilation &C) {
21032103
21042104 if (C.getArgs ().hasArg (options::OPT_v) ||
21052105 C.getArgs ().hasArg (options::OPT__HASH_HASH_HASH) ||
2106- C.getArgs ().hasArg (options::OPT_print_supported_cpus)) {
2106+ C.getArgs ().hasArg (options::OPT_print_supported_cpus) ||
2107+ C.getArgs ().hasArg (options::OPT_print_supported_extensions)) {
21072108 PrintVersion (C, llvm::errs ());
21082109 SuppressMissingInputWarning = true ;
21092110 }
@@ -4273,16 +4274,30 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
42734274 C.MakeAction <IfsMergeJobAction>(MergerInputs, types::TY_Image));
42744275 }
42754276
4276- // If --print-supported-cpus, -mcpu=? or -mtune=? is specified, build a custom
4277- // Compile phase that prints out supported cpu models and quits.
4278- if (Arg *A = Args.getLastArg (options::OPT_print_supported_cpus)) {
4279- // Use the -mcpu=? flag as the dummy input to cc1.
4280- Actions.clear ();
4281- Action *InputAc = C.MakeAction <InputAction>(*A, types::TY_C);
4282- Actions.push_back (
4283- C.MakeAction <PrecompileJobAction>(InputAc, types::TY_Nothing));
4284- for (auto &I : Inputs)
4285- I.second ->claim ();
4277+ for (auto Opt : {options::OPT_print_supported_cpus,
4278+ options::OPT_print_supported_extensions}) {
4279+ // If --print-supported-cpus, -mcpu=? or -mtune=? is specified, build a
4280+ // custom Compile phase that prints out supported cpu models and quits.
4281+ //
4282+ // If --print-supported-extensions is specified, call the helper function
4283+ // RISCVMarchHelp in RISCVISAInfo.cpp that prints out supported extensions
4284+ // and quits.
4285+ if (Arg *A = Args.getLastArg (Opt)) {
4286+ if (Opt == options::OPT_print_supported_extensions &&
4287+ !C.getDefaultToolChain ().getTriple ().isRISCV ()) {
4288+ C.getDriver ().Diag (diag::err_opt_not_valid_on_target)
4289+ << " --print-supported-extensions" ;
4290+ return ;
4291+ }
4292+
4293+ // Use the -mcpu=? flag as the dummy input to cc1.
4294+ Actions.clear ();
4295+ Action *InputAc = C.MakeAction <InputAction>(*A, types::TY_C);
4296+ Actions.push_back (
4297+ C.MakeAction <PrecompileJobAction>(InputAc, types::TY_Nothing));
4298+ for (auto &I : Inputs)
4299+ I.second ->claim ();
4300+ }
42864301 }
42874302
42884303 // Call validator for dxil when -Vd not in Args.
0 commit comments