@@ -781,12 +781,15 @@ void SYCL::fpga::BackendCompiler::ConstructJob(
781
781
C.addCommand (std::move (Cmd));
782
782
}
783
783
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
+
784
789
StringRef 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];
790
793
}
791
794
792
795
void SYCL::gen::BackendCompiler::ConstructJob (Compilation &C,
@@ -1100,6 +1103,26 @@ void SYCLToolChain::TranslateGPUTargetOpt(const llvm::opt::ArgList &Args,
1100
1103
}
1101
1104
}
1102
1105
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
+
1103
1126
// Expects a specific type of option (e.g. -Xsycl-target-backend) and will
1104
1127
// extract the arguments.
1105
1128
void SYCLToolChain::TranslateTargetOpt (const llvm::opt::ArgList &Args,
@@ -1143,7 +1166,8 @@ void SYCLToolChain::TranslateTargetOpt(const llvm::opt::ArgList &Args,
1143
1166
} else
1144
1167
// Triple found, add the next argument in line.
1145
1168
ArgString = A->getValue (1 );
1146
-
1169
+ WarnForDeprecatedBackendOpts (getDriver (), getTriple (), Device, ArgString,
1170
+ A);
1147
1171
parseTargetOpts (ArgString, Args, CmdArgs);
1148
1172
A->claim ();
1149
1173
}
@@ -1313,12 +1337,15 @@ void SYCLToolChain::TranslateBackendTargetArgs(
1313
1337
if (A->getOption ().matches (options::OPT_Xs)) {
1314
1338
// Take the arg and create an option out of it.
1315
1339
CmdArgs.push_back (Args.MakeArgString (Twine (" -" ) + A->getValue ()));
1340
+ WarnForDeprecatedBackendOpts (getDriver (), Triple, Device, A->getValue (),
1341
+ A);
1316
1342
A->claim ();
1317
1343
continue ;
1318
1344
}
1319
1345
if (A->getOption ().matches (options::OPT_Xs_separate)) {
1320
1346
StringRef ArgString (A->getValue ());
1321
1347
parseTargetOpts (ArgString, Args, CmdArgs);
1348
+ WarnForDeprecatedBackendOpts (getDriver (), Triple, Device, ArgString, A);
1322
1349
A->claim ();
1323
1350
continue ;
1324
1351
}
0 commit comments