66 * the terms of the Apache License 2.0 which accompanies this distribution. *
77 ******************************************************************************/
88
9- #include " cudaq/Support/TargetConfigYaml .h"
9+ #include " cudaq/Target/StaticConfigYaml .h"
1010#include " llvm/Support/Allocator.h"
1111#include " llvm/Support/Base64.h"
1212#include " llvm/Support/CommandLine.h"
@@ -162,7 +162,7 @@ static std::string processSimBackendConfig(
162162}
163163
164164std::string cudaq::config::processRuntimeArgs (
165- const cudaq::config::TargetConfig &config,
165+ const cudaq::config::StaticConfig &config,
166166 const std::map<std::string, std::string> &args) {
167167 std::stringstream output;
168168 if (config.BackendConfig .has_value ())
@@ -355,8 +355,8 @@ void MappingTraits<cudaq::config::BackendFeatureMap>::mapping(
355355 io.mapRequired (" config" , info.Config );
356356}
357357
358- void MappingTraits<cudaq::config::TargetConfig >::mapping(
359- IO &io, cudaq::config::TargetConfig &info) {
358+ void MappingTraits<cudaq::config::StaticConfig >::mapping(
359+ IO &io, cudaq::config::StaticConfig &info) {
360360 io.mapRequired (" name" , info.Name );
361361 io.mapRequired (" description" , info.Description );
362362 io.mapOptional (" warning" , info.WarningMsg );
@@ -366,8 +366,8 @@ void MappingTraits<cudaq::config::TargetConfig>::mapping(
366366 io.mapOptional (" configuration-matrix" , info.ConfigMap );
367367}
368368
369- std::string MappingTraits<cudaq::config::TargetConfig >::validate(
370- IO &io, cudaq::config::TargetConfig &info) {
369+ std::string MappingTraits<cudaq::config::StaticConfig >::validate(
370+ IO &io, cudaq::config::StaticConfig &info) {
371371 // There should only ever be 1 machine-configuration entry in the target
372372 // arguments.
373373 unsigned count = 0 ;
@@ -414,76 +414,3 @@ std::string MappingTraits<cudaq::config::MachineArchitectureConfig>::validate(
414414}
415415} // namespace yaml
416416} // namespace llvm
417-
418- std::string cudaq::config::TargetConfig::getCodeGenSpec (
419- const std::map<std::string, std::string> &targetArgs) const {
420- // Check whether we have a per-machine config
421- const auto machineConfigIter = std::find_if (
422- TargetArguments.begin (), TargetArguments.end (),
423- [&](const cudaq::config::TargetArgument &argConfig) {
424- return argConfig.Type == cudaq::config::ArgumentType::MachineConfig;
425- });
426- if (machineConfigIter == TargetArguments.end ()) {
427- // No machine specific config
428- return BackendConfig.has_value () ? BackendConfig->CodegenEmission : " " ;
429- }
430-
431- // Get the machine name from the CLI argument
432- std::string machineName;
433- for (const auto &[argKey, argVal] : targetArgs) {
434- if (argKey == machineConfigIter->PlatformArgKey ) {
435- machineName = argVal;
436- break ;
437- }
438- }
439-
440- if (!machineName.empty ()) {
441- // Check for match
442- for (auto &archConfig : machineConfigIter->MachineConfigs ) {
443- // Check names first
444- if (std::find (archConfig.MachineNames .begin (),
445- archConfig.MachineNames .end (),
446- machineName) != archConfig.MachineNames .end ()) {
447- return archConfig.Configuration .CodegenEmission ;
448- }
449- // Check pattern if provided
450- if (!archConfig.MachinePattern .empty ()) {
451- llvm::Regex re (archConfig.MachinePattern );
452- if (re.match (machineName)) {
453- return archConfig.Configuration .CodegenEmission ;
454- }
455- }
456- }
457- }
458-
459- // No machine specific config rule matches, fallback to the default backend
460- // config
461- return BackendConfig.has_value () ? BackendConfig->CodegenEmission : " " ;
462- }
463-
464- bool cudaq::config::BackendEndConfigEntry::hasPassPipeline () const {
465- return !TargetPassPipeline.empty () || !JITHighLevelPipeline.empty () ||
466- !JITMidLevelPipeline.empty () || !JITLowLevelPipeline.empty ();
467- }
468-
469- std::string cudaq::config::BackendEndConfigEntry::getPassPipeline (
470- std::string_view deployStage, std::string_view finalizeStage) const {
471- if (!TargetPassPipeline.empty ())
472- return TargetPassPipeline;
473-
474- std::string pipeline;
475- auto append = [&](std::string_view stage) {
476- if (stage.empty ())
477- return ;
478- if (!pipeline.empty ())
479- pipeline += " ," ;
480- pipeline += stage;
481- };
482-
483- append (JITHighLevelPipeline);
484- append (deployStage);
485- append (JITMidLevelPipeline);
486- append (finalizeStage);
487- append (JITLowLevelPipeline);
488- return pipeline;
489- }
0 commit comments