| 343 | } // anonymous namespace |
| 344 | |
| 345 | bool VariantDefs::ProcessFnVar(const LinkerOptions& options, |
| 346 | const std::vector<Module*>& modules) { |
| 347 | assert(variant_defs_.empty()); |
| 348 | assert(modules.size() == options.GetInFiles().size()); |
| 349 | |
| 350 | for (size_t i = 0; i < modules.size(); ++i) { |
| 351 | const auto* feat_mgr = modules[i]->context()->get_feature_mgr(); |
| 352 | if ((feat_mgr->HasCapability(spv::Capability::FunctionVariantsINTEL)) || |
| 353 | (feat_mgr->HasCapability(spv::Capability::SpecConditionalINTEL)) || |
| 354 | (feat_mgr->HasExtension(kSPV_INTEL_function_variants))) { |
| 355 | // In principle, it can be done but it's complicated due to having to |
| 356 | // combine the existing conditionals with the new ones. For example, |
| 357 | // conditional capabilities would need to become "doubly-conditional". |
| 358 | err_ << "Creating multitarget modules from multitarget modules is not " |
| 359 | "supported. Offending file: " |
| 360 | << options.GetInFiles()[i]; |
| 361 | return false; |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | std::vector<std::vector<std::string>> target_rows; |
| 366 | std::vector<std::vector<std::string>> architecture_rows; |
| 367 | |
| 368 | if (!options.GetFnVarTargetsCsv().empty()) { |
| 369 | const std::vector<std::string> tgt_cols = {"module", "target", "features"}; |
| 370 | if (!ParseCsv(options.GetFnVarTargetsCsv(), tgt_cols, err_, target_rows)) { |
| 371 | return false; |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | if (!options.GetFnVarArchitecturesCsv().empty()) { |
| 376 | const std::vector<std::string> arch_cols = {"module", "category", "family", |
| 377 | "op", "architecture"}; |
| 378 | if (!ParseCsv(options.GetFnVarArchitecturesCsv(), arch_cols, err_, |
| 379 | architecture_rows)) { |
| 380 | return false; |
| 381 | } |
| 382 | } |
| 383 | |
| 384 | // check that all modules defined in the CSV exist |
| 385 | |
| 386 | for (const auto& tgt_vals : target_rows) { |
| 387 | bool found = false; |
| 388 | for (const auto& in_file : options.GetInFiles()) { |
| 389 | if (tgt_vals[0] == in_file) { |
| 390 | found = true; |
| 391 | } |
| 392 | } |
| 393 | if (!found) { |
| 394 | err_ << "Module '" << tgt_vals[0] |
| 395 | << "' found in targets CSV not passed to the CLI."; |
| 396 | return false; |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | for (const auto& arch_vals : architecture_rows) { |
| 401 | bool found = false; |
| 402 | for (const auto& in_file : options.GetInFiles()) { |
no test coverage detected