|
18 | 18 | #include "llvm/ADT/StringExtras.h" |
19 | 19 | #include "llvm/Analysis/ValueTracking.h" |
20 | 20 | #include "llvm/IR/IntrinsicsSPIRV.h" |
| 21 | +#include <regex> |
21 | 22 | #include <string> |
22 | 23 | #include <tuple> |
23 | 24 |
|
@@ -201,13 +202,34 @@ std::string lookupBuiltinNameHelper(StringRef DemangledCall) { |
201 | 202 | BuiltinName = BuiltinName.substr(BuiltinName.find_last_of(' ') + 1); |
202 | 203 | } |
203 | 204 |
|
204 | | - // Check if the extracted name begins with "__spirv_ImageSampleExplicitLod" |
205 | | - // contains return type information at the end "_R<type>", if so extract the |
206 | | - // plain builtin name without the type information. |
207 | | - if (StringRef(BuiltinName).contains("__spirv_ImageSampleExplicitLod") && |
208 | | - StringRef(BuiltinName).contains("_R")) { |
209 | | - BuiltinName = BuiltinName.substr(0, BuiltinName.find("_R")); |
210 | | - } |
| 205 | + // Check if the extracted name begins with: |
| 206 | + // - "__spirv_ImageSampleExplicitLod" |
| 207 | + // - "__spirv_ImageRead" |
| 208 | + // - "__spirv_ImageQuerySizeLod" |
| 209 | + // - "__spirv_UDotKHR" |
| 210 | + // - "__spirv_SDotKHR" |
| 211 | + // - "__spirv_SUDotKHR" |
| 212 | + // - "__spirv_SDotAccSatKHR" |
| 213 | + // - "__spirv_UDotAccSatKHR" |
| 214 | + // - "__spirv_SUDotAccSatKHR" |
| 215 | + // - "__spirv_ReadClockKHR" |
| 216 | + // - "__spirv_SubgroupBlockReadINTEL" |
| 217 | + // - "__spirv_SubgroupImageBlockReadINTEL" |
| 218 | + // - "__spirv_Convert" |
| 219 | + // - "__spirv_UConvert" |
| 220 | + // - "__spirv_SConvert" |
| 221 | + // - "__spirv_FConvert" |
| 222 | + // - "__spirv_SatConvert" |
| 223 | + // and contains return type information at the end "_R<type>". |
| 224 | + // If so, extract the plain builtin name without the type information. |
| 225 | + static const std::regex SpvWithR( |
| 226 | + "(__spirv_(ImageSampleExplicitLod|ImageRead|ImageQuerySizeLod|UDotKHR|" |
| 227 | + "SDotKHR|SUDotKHR|SDotAccSatKHR|UDotAccSatKHR|SUDotAccSatKHR|" |
| 228 | + "ReadClockKHR|SubgroupBlockReadINTEL|SubgroupImageBlockReadINTEL|Convert|" |
| 229 | + "UConvert|SConvert|FConvert|SatConvert).*)_R.*"); |
| 230 | + std::smatch Match; |
| 231 | + if (std::regex_match(BuiltinName, Match, SpvWithR) && Match.size() > 2) |
| 232 | + BuiltinName = Match[1].str(); |
211 | 233 |
|
212 | 234 | return BuiltinName; |
213 | 235 | } |
|
0 commit comments