| 45 | } |
| 46 | |
| 47 | cudaq::CompileTarget::CompileTarget( |
| 48 | config::TargetConfig targetConfig, |
| 49 | std::map<std::string, std::string> runtimeConfig, bool emulate_) |
| 50 | : emulate(emulate_) { |
| 51 | if (!targetConfig.BackendConfig.has_value()) { |
| 52 | pipelineConfig.skipTargetLoweringPipeline = true; |
| 53 | return; |
| 54 | } |
| 55 | |
| 56 | const auto &backendConfig = *targetConfig.BackendConfig; |
| 57 | if (!backendConfig.hasPassPipeline()) { |
| 58 | pipelineConfig.skipTargetLoweringPipeline = true; |
| 59 | } |
| 60 | |
| 61 | auto prepPipeline = [&](const std::string &stage, |
| 62 | const std::string &stageName) { |
| 63 | std::string pipeline = stage; |
| 64 | if (!pipeline.empty()) { |
| 65 | substitutePipelinePlaceholders(pipeline, runtimeConfig); |
| 66 | CUDAQ_INFO("{:<27} {}", stageName + ":", pipeline); |
| 67 | } |
| 68 | return pipeline; |
| 69 | }; |
| 70 | |
| 71 | if (!backendConfig.TargetPassPipeline.empty()) { |
| 72 | pipelineConfig.overridePassPipeline = prepPipeline( |
| 73 | backendConfig.TargetPassPipeline, "Pass pipeline (overridden)"); |
| 74 | } else { |
| 75 | pipelineConfig.highLevelPipeline = |
| 76 | prepPipeline(backendConfig.JITHighLevelPipeline, "JIT high level"); |
| 77 | pipelineConfig.midLevelPipeline = |
| 78 | prepPipeline(backendConfig.JITMidLevelPipeline, "JIT mid level"); |
| 79 | pipelineConfig.lowLevelPipeline = |
| 80 | prepPipeline(backendConfig.JITLowLevelPipeline, "JIT low level"); |
| 81 | } |
| 82 | auto codegenTranslation = targetConfig.getCodeGenSpec(runtimeConfig); |
| 83 | if (!codegenTranslation.empty()) { |
| 84 | pipelineConfig.codegenTranslation = codegenTranslation; |
| 85 | CUDAQ_INFO("{:<27} {}\n", "Codegen:", codegenTranslation); |
| 86 | } |
| 87 | if (!backendConfig.PostCodeGenPasses.empty()) { |
| 88 | pipelineConfig.postCodeGenPasses = backendConfig.PostCodeGenPasses; |
| 89 | CUDAQ_INFO("{:<27} {}\n", |
| 90 | "Post-codegen:", pipelineConfig.postCodeGenPasses); |
| 91 | } |
| 92 | |
| 93 | // Handle disable_qubit_mapping runtime option. |
| 94 | auto disableQM = runtimeConfig.find("disable_qubit_mapping"); |
| 95 | if (disableQM != runtimeConfig.end() && disableQM->second == "true") { |
| 96 | pipelineConfig.disableQubitMapping = true; |
| 97 | CUDAQ_INFO("{:<27} {}\n", "disable_qubit_mapping:", "true"); |
| 98 | } |
| 99 | } |
nothing calls this directly
no test coverage detected