@@ -781,12 +781,15 @@ void SYCL::fpga::BackendCompiler::ConstructJob(
781781 C.addCommand (std::move (Cmd));
782782}
783783
784+ static llvm::StringMap<StringRef> GRFModeFlagMap{
785+ {" auto" , " -ze-intel-enable-auto-large-GRF-mode" },
786+ {" small" , " -ze-intel-128-GRF-per-thread" },
787+ {" large" , " -ze-opt-large-register-file" }};
788+
784789StringRef SYCL::gen::getGenGRFFlag (StringRef GRFMode) {
785- return llvm::StringSwitch<StringRef>(GRFMode)
786- .Case (" auto" , " -ze-intel-enable-auto-large-GRF-mode" )
787- .Case (" small" , " -ze-intel-128-GRF-per-thread" )
788- .Case (" large" , " -ze-opt-large-register-file" )
789- .Default (" " );
790+ if (!GRFModeFlagMap.contains (GRFMode))
791+ return " " ;
792+ return GRFModeFlagMap[GRFMode];
790793}
791794
792795void SYCL::gen::BackendCompiler::ConstructJob (Compilation &C,
@@ -1100,6 +1103,26 @@ void SYCLToolChain::TranslateGPUTargetOpt(const llvm::opt::ArgList &Args,
11001103 }
11011104}
11021105
1106+ static void WarnForDeprecatedBackendOpts (const Driver &D,
1107+ const llvm::Triple &Triple,
1108+ StringRef Device, StringRef ArgString,
1109+ const llvm::opt::Arg *A) {
1110+ // Suggest users passing GRF backend opts on PVC to use
1111+ // -ftarget-register-alloc-mode and
1112+
1113+ if (!ArgString.contains (" -device pvc" ) && !Device.contains (" pvc" ))
1114+ return ;
1115+ // Make sure to only warn for once for gen targets as the translate
1116+ // options tree is called twice but only the second time has the
1117+ // device set.
1118+ if (Triple.isSPIR () && Triple.getSubArch () == llvm::Triple::SPIRSubArch_gen &&
1119+ !A->isClaimed ())
1120+ return ;
1121+ for (const auto &[Mode, Flag] : GRFModeFlagMap)
1122+ if (ArgString.contains (Flag))
1123+ D.Diag (diag::warn_drv_ftarget_register_alloc_mode_pvc) << Flag << Mode;
1124+ }
1125+
11031126// Expects a specific type of option (e.g. -Xsycl-target-backend) and will
11041127// extract the arguments.
11051128void SYCLToolChain::TranslateTargetOpt (const llvm::opt::ArgList &Args,
@@ -1143,7 +1166,8 @@ void SYCLToolChain::TranslateTargetOpt(const llvm::opt::ArgList &Args,
11431166 } else
11441167 // Triple found, add the next argument in line.
11451168 ArgString = A->getValue (1 );
1146-
1169+ WarnForDeprecatedBackendOpts (getDriver (), getTriple (), Device, ArgString,
1170+ A);
11471171 parseTargetOpts (ArgString, Args, CmdArgs);
11481172 A->claim ();
11491173 }
@@ -1313,12 +1337,15 @@ void SYCLToolChain::TranslateBackendTargetArgs(
13131337 if (A->getOption ().matches (options::OPT_Xs)) {
13141338 // Take the arg and create an option out of it.
13151339 CmdArgs.push_back (Args.MakeArgString (Twine (" -" ) + A->getValue ()));
1340+ WarnForDeprecatedBackendOpts (getDriver (), Triple, Device, A->getValue (),
1341+ A);
13161342 A->claim ();
13171343 continue ;
13181344 }
13191345 if (A->getOption ().matches (options::OPT_Xs_separate)) {
13201346 StringRef ArgString (A->getValue ());
13211347 parseTargetOpts (ArgString, Args, CmdArgs);
1348+ WarnForDeprecatedBackendOpts (getDriver (), Triple, Device, ArgString, A);
13221349 A->claim ();
13231350 continue ;
13241351 }
0 commit comments