@@ -27,6 +27,125 @@ using namespace clang::driver::tools;
2727using namespace clang ;
2828using namespace llvm ::opt;
2929
30+ // Struct that relates an AOT target value with
31+ // Intel CPUs and Intel GPUs.
32+ struct StringToOffloadArchSYCLMap {
33+ const char *ArchName;
34+ SYCLSupportedIntelArchs IntelArch;
35+ };
36+
37+ // Mapping of supported SYCL offloading architectures.
38+ static const StringToOffloadArchSYCLMap StringToArchNamesMap[] = {
39+ // Intel CPU mapping.
40+ {" skylake-avx512" , SYCLSupportedIntelArchs::SKYLAKEAVX512},
41+ {" core-avx2" , SYCLSupportedIntelArchs::COREAVX2},
42+ {" corei7-avx" , SYCLSupportedIntelArchs::COREI7AVX},
43+ {" corei7" , SYCLSupportedIntelArchs::COREI7},
44+ {" westmere" , SYCLSupportedIntelArchs::WESTMERE},
45+ {" sandybridge" , SYCLSupportedIntelArchs::SANDYBRIDGE},
46+ {" ivybridge" , SYCLSupportedIntelArchs::IVYBRIDGE},
47+ {" broadwell" , SYCLSupportedIntelArchs::BROADWELL},
48+ {" coffeelake" , SYCLSupportedIntelArchs::COFFEELAKE},
49+ {" alderlake" , SYCLSupportedIntelArchs::ALDERLAKE},
50+ {" skylake" , SYCLSupportedIntelArchs::SKYLAKE},
51+ {" skx" , SYCLSupportedIntelArchs::SKX},
52+ {" cascadelake" , SYCLSupportedIntelArchs::CASCADELAKE},
53+ {" icelake-client" , SYCLSupportedIntelArchs::ICELAKECLIENT},
54+ {" icelake-server" , SYCLSupportedIntelArchs::ICELAKESERVER},
55+ {" sapphirerapids" , SYCLSupportedIntelArchs::SAPPHIRERAPIDS},
56+ {" graniterapids" , SYCLSupportedIntelArchs::GRANITERAPIDS},
57+ // Intel GPU mapping.
58+ {" bdw" , SYCLSupportedIntelArchs::BDW},
59+ {" skl" , SYCLSupportedIntelArchs::SKL},
60+ {" kbl" , SYCLSupportedIntelArchs::KBL},
61+ {" cfl" , SYCLSupportedIntelArchs::CFL},
62+ {" apl" , SYCLSupportedIntelArchs::APL},
63+ {" bxt" , SYCLSupportedIntelArchs::BXT},
64+ {" glk" , SYCLSupportedIntelArchs::GLK},
65+ {" whl" , SYCLSupportedIntelArchs::WHL},
66+ {" aml" , SYCLSupportedIntelArchs::AML},
67+ {" cml" , SYCLSupportedIntelArchs::CML},
68+ {" icllp" , SYCLSupportedIntelArchs::ICLLP},
69+ {" icl" , SYCLSupportedIntelArchs::ICL},
70+ {" ehl" , SYCLSupportedIntelArchs::EHL},
71+ {" jsl" , SYCLSupportedIntelArchs::JSL},
72+ {" tgllp" , SYCLSupportedIntelArchs::TGLLP},
73+ {" tgl" , SYCLSupportedIntelArchs::TGL},
74+ {" rkl" , SYCLSupportedIntelArchs::RKL},
75+ {" adl_s" , SYCLSupportedIntelArchs::ADL_S},
76+ {" rpl_s" , SYCLSupportedIntelArchs::RPL_S},
77+ {" adl_p" , SYCLSupportedIntelArchs::ADL_P},
78+ {" adl_n" , SYCLSupportedIntelArchs::ADL_N},
79+ {" dg1" , SYCLSupportedIntelArchs::DG1},
80+ {" acm_g10" , SYCLSupportedIntelArchs::ACM_G10},
81+ {" dg2_g10" , SYCLSupportedIntelArchs::DG2_G10},
82+ {" acm_g11" , SYCLSupportedIntelArchs::ACM_G11},
83+ {" dg2_g10" , SYCLSupportedIntelArchs::DG2_G10},
84+ {" dg2_g11" , SYCLSupportedIntelArchs::DG2_G11},
85+ {" acm_g12" , SYCLSupportedIntelArchs::ACM_G12},
86+ {" dg2_g12" , SYCLSupportedIntelArchs::DG2_G12},
87+ {" pvc" , SYCLSupportedIntelArchs::PVC},
88+ {" pvc_vg" , SYCLSupportedIntelArchs::PVC_VG},
89+ {" mtl_u" , SYCLSupportedIntelArchs::MTL_U},
90+ {" mtl_s" , SYCLSupportedIntelArchs::MTL_S},
91+ {" arl_u" , SYCLSupportedIntelArchs::ARL_U},
92+ {" arl_s" , SYCLSupportedIntelArchs::ARL_S},
93+ {" mtl_h" , SYCLSupportedIntelArchs::MTL_H},
94+ {" arl_h" , SYCLSupportedIntelArchs::ARL_H},
95+ {" bmg_g21" , SYCLSupportedIntelArchs::BMG_G21},
96+ {" lnl_m" , SYCLSupportedIntelArchs::LNL_M}};
97+
98+ // Check if the user provided value for --offload-arch is a valid
99+ // SYCL supported Intel AOT target.
100+ SYCLSupportedIntelArchs
101+ clang::driver::StringToOffloadArchSYCL (llvm::StringRef ArchNameAsString) {
102+ auto result = std::find_if (
103+ std::begin (StringToArchNamesMap), std::end (StringToArchNamesMap),
104+ [ArchNameAsString](const StringToOffloadArchSYCLMap &map) {
105+ return ArchNameAsString == map.ArchName ;
106+ });
107+ if (result == std::end (StringToArchNamesMap))
108+ return SYCLSupportedIntelArchs::UNKNOWN;
109+ return result->IntelArch ;
110+ }
111+
112+ // This is a mapping between the user provided --offload-arch value for Intel
113+ // GPU targets and the spir64_gen device name accepted by OCLOC (the Intel GPU
114+ // AOT compiler).
115+ StringRef clang::driver::mapIntelGPUArchName (StringRef ArchName) {
116+ StringRef Arch;
117+ Arch = llvm::StringSwitch<StringRef>(ArchName)
118+ .Case (" bdw" , " bdw" )
119+ .Case (" skl" , " skl" )
120+ .Case (" kbl" , " kbl" )
121+ .Case (" cfl" , " cfl" )
122+ .Cases (" apl" , " bxt" , " apl" )
123+ .Case (" glk" , " glk" )
124+ .Case (" whl" , " whl" )
125+ .Case (" aml" , " aml" )
126+ .Case (" cml" , " cml" )
127+ .Cases (" icllp" , " icl" , " icllp" )
128+ .Cases (" ehl" , " jsl" , " ehl" )
129+ .Cases (" tgllp" , " tgl" , " tgllp" )
130+ .Case (" rkl" , " rkl" )
131+ .Cases (" adl_s" , " rpl_s" , " adl_s" )
132+ .Case (" adl_p" , " adl_p" )
133+ .Case (" adl_n" , " adl_n" )
134+ .Case (" dg1" , " dg1" )
135+ .Cases (" acm_g10" , " dg2_g10" , " acm_g10" )
136+ .Cases (" acm_g11" , " dg2_g11" , " acm_g11" )
137+ .Cases (" acm_g12" , " dg2_g12" , " acm_g12" )
138+ .Case (" pvc" , " pvc" )
139+ .Case (" pvc_vg" , " pvc_vg" )
140+ .Cases (" mtl_u" , " mtl_s" , " arl_u" , " arl_s" , " mtl_u" )
141+ .Case (" mtl_h" , " mtl_h" )
142+ .Case (" arl_h" , " arl_h" )
143+ .Case (" bmg_g21" , " bmg_g21" )
144+ .Case (" lnl_m" , " lnl_m" )
145+ .Default (" " );
146+ return Arch;
147+ }
148+
30149SYCLInstallationDetector::SYCLInstallationDetector (const Driver &D)
31150 : D(D), InstallationCandidates() {
32151 InstallationCandidates.emplace_back (D.Dir + " /.." );
0 commit comments