@@ -121,7 +121,15 @@ static llvm::cl::opt<enum InputType> inputType(
121
121
" load the input file as a QOBJ file" )));
122
122
123
123
namespace {
124
- enum Action { None, DumpAST, DumpASTPretty, DumpMLIR, DumpWaveMem, GenQEM };
124
+ enum Action {
125
+ None,
126
+ DumpAST,
127
+ DumpASTPretty,
128
+ DumpMLIR,
129
+ DumpWaveMem,
130
+ GenQEM,
131
+ GenQEQEM
132
+ };
125
133
} // anonymous namespace
126
134
static llvm::cl::opt<enum Action> emitAction (
127
135
" emit" , llvm::cl::init(Action::None),
@@ -134,10 +142,14 @@ static llvm::cl::opt<enum Action> emitAction(
134
142
" output the waveform memory" )),
135
143
llvm::cl::values(clEnumValN(GenQEM, " qem" ,
136
144
" generate a quantum executable module (qem) "
137
- " for execution on hardware" )));
145
+ " for execution on hardware" )),
146
+ llvm::cl::values(clEnumValN(
147
+ GenQEQEM, " qe-qem" ,
148
+ " generate a target-specific quantum executable module (qeqem) "
149
+ " for execution on hardware" )));
138
150
139
151
namespace qss {
140
- enum FileExtension { None, AST, ASTPRETTY, QASM, QOBJ, MLIR, WMEM, QEM };
152
+ enum FileExtension { None, AST, ASTPRETTY, QASM, QOBJ, MLIR, WMEM, QEM, QEQEM };
141
153
} // namespace qss
142
154
143
155
auto fileExtensionToStr (const qss::FileExtension &inExt) -> std::string {
@@ -163,6 +175,9 @@ auto fileExtensionToStr(const qss::FileExtension &inExt) -> std::string {
163
175
case qss::FileExtension::QEM:
164
176
return " qem" ;
165
177
break ;
178
+ case qss::FileExtension::QEQEM:
179
+ return " qeqem" ;
180
+ break ;
166
181
default :
167
182
return " none" ;
168
183
break ;
@@ -204,6 +219,9 @@ auto fileExtensionToAction(const qss::FileExtension &inExt) -> Action {
204
219
case qss::FileExtension::QEM:
205
220
return Action::GenQEM;
206
221
break ;
222
+ case qss::FileExtension::QEQEM:
223
+ return Action::GenQEQEM;
224
+ break ;
207
225
default :
208
226
break ;
209
227
}
@@ -225,6 +243,8 @@ auto strToFileExtension(const std::string &extStr) -> qss::FileExtension {
225
243
return qss::FileExtension::WMEM;
226
244
if (extStr == " qem" || extStr == " QEM" )
227
245
return qss::FileExtension::QEM;
246
+ if (extStr == " qeqem" || extStr == " QEQEM" )
247
+ return qss::FileExtension::QEQEM;
228
248
return qss::FileExtension::None;
229
249
}
230
250
@@ -535,20 +555,29 @@ compile_(int argc, char const **argv, std::string *outputString,
535
555
auto outputFile = mlir::openOutputFile (outputFilename, &errorMessage);
536
556
std::unique_ptr<qssc::payload::Payload> payload = nullptr ;
537
557
538
- if (emitAction == Action::GenQEM) {
558
+ if (emitAction == Action::GenQEQEM && !config.targetName .has_value ())
559
+ return llvm::createStringError (
560
+ llvm::inconvertibleErrorCode (),
561
+ " Unsupported target-specific payload: no target" );
562
+ if (emitAction == Action::GenQEM || emitAction == Action::GenQEQEM) {
563
+ const std::filesystem::path payloadPath (outputFilename.c_str ());
564
+ const std::string fNamePrefix = payloadPath.stem ();
565
+ const auto payloadName =
566
+ (emitAction == Action::GenQEM) ? " ZIP" : config.targetName .value ();
567
+ auto payloadInfo =
568
+ qssc::payload::registry::PayloadRegistry::lookupPluginInfo (payloadName);
569
+ if (payloadInfo == llvm::None)
570
+ return llvm::createStringError (llvm::inconvertibleErrorCode (),
571
+ " Unsupported target-specific payload: " +
572
+ payloadName);
539
573
if (outputFilename == " -" ) {
540
- auto payloadInfo =
541
- qssc::payload::registry::PayloadRegistry::lookupPluginInfo (" ZIP" );
542
574
payload = std::move (
543
575
payloadInfo.getValue ()->createPluginInstance (llvm::None).get ());
544
576
} else {
545
- const std::filesystem::path payloadPath (outputFilename.c_str ());
546
- const std::string fNamePrefix = payloadPath.stem ();
547
- const qssc::payload::PayloadConfig config{fNamePrefix , fNamePrefix };
548
- auto payloadInfo =
549
- qssc::payload::registry::PayloadRegistry::lookupPluginInfo (" ZIP" );
550
- payload =
551
- std::move (payloadInfo.getValue ()->createPluginInstance (config).get ());
577
+ const qssc::payload::PayloadConfig payloadConfig{fNamePrefix ,
578
+ fNamePrefix };
579
+ payload = std::move (
580
+ payloadInfo.getValue ()->createPluginInstance (payloadConfig).get ());
552
581
}
553
582
}
554
583
0 commit comments