@@ -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,14 +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" )));
138
-
139
- static llvm::cl::opt< bool >
140
- emitTargetQem ( " emit-target-qem " , llvm::cl::desc( " Emit target-specific qem" ),
141
- llvm::cl::cat(qssc::config::getQSSCCategory( )));
145
+ " for execution on hardware" )),
146
+ llvm::cl::values(
147
+ clEnumValN (GenQEQEM, " qe-qem " ,
148
+ " generate a target-specific quantum executable module ( qem) "
149
+ " for execution on hardware " )));
142
150
143
151
namespace qss {
144
- enum FileExtension { None, AST, ASTPRETTY, QASM, QOBJ, MLIR, WMEM, QEM };
152
+ enum FileExtension { None, AST, ASTPRETTY, QASM, QOBJ, MLIR, WMEM, QEM, QEQEM };
145
153
} // namespace qss
146
154
147
155
auto fileExtensionToStr (const qss::FileExtension &inExt) -> std::string {
@@ -167,6 +175,9 @@ auto fileExtensionToStr(const qss::FileExtension &inExt) -> std::string {
167
175
case qss::FileExtension::QEM:
168
176
return " qem" ;
169
177
break ;
178
+ case qss::FileExtension::QEQEM:
179
+ return " qeqem" ;
180
+ break ;
170
181
default :
171
182
return " none" ;
172
183
break ;
@@ -208,6 +219,9 @@ auto fileExtensionToAction(const qss::FileExtension &inExt) -> Action {
208
219
case qss::FileExtension::QEM:
209
220
return Action::GenQEM;
210
221
break ;
222
+ case qss::FileExtension::QEQEM:
223
+ return Action::GenQEQEM;
224
+ break ;
211
225
default :
212
226
break ;
213
227
}
@@ -229,6 +243,8 @@ auto strToFileExtension(const std::string &extStr) -> qss::FileExtension {
229
243
return qss::FileExtension::WMEM;
230
244
if (extStr == " qem" || extStr == " QEM" )
231
245
return qss::FileExtension::QEM;
246
+ if (extStr == " qeqem" || extStr == " QEQEM" )
247
+ return qss::FileExtension::QEQEM;
232
248
return qss::FileExtension::None;
233
249
}
234
250
@@ -539,27 +555,21 @@ compile_(int argc, char const **argv, std::string *outputString,
539
555
auto outputFile = mlir::openOutputFile (outputFilename, &errorMessage);
540
556
std::unique_ptr<qssc::payload::Payload> payload = nullptr ;
541
557
542
- if (emitAction == Action::GenQEM) {
558
+ if (emitAction == Action::GenQEM || emitAction == Action::GenQEQEM) {
559
+ const std::filesystem::path payloadPath (outputFilename.c_str ());
560
+ const std::string fNamePrefix = payloadPath.stem ();
561
+ const auto payloadName =
562
+ (emitAction == Action::GenQEM) ? " ZIP" : config.targetName .value_or (" " );
563
+ auto payloadInfo =
564
+ qssc::payload::registry::PayloadRegistry::lookupPluginInfo (payloadName);
543
565
if (outputFilename == " -" ) {
544
- auto payloadInfo =
545
- qssc::payload::registry::PayloadRegistry::lookupPluginInfo (" ZIP" );
546
566
payload = std::move (
547
567
payloadInfo.getValue ()->createPluginInstance (llvm::None).get ());
548
568
} else {
549
- const auto targetName = config.targetName .value_or (" " );
550
- const auto pluginName =
551
- (emitTargetQem &&
552
- qssc::payload::registry::PayloadRegistry::pluginExists (targetName))
553
- ? targetName
554
- : " ZIP" ;
555
- const std::filesystem::path payloadPath (outputFilename.c_str ());
556
- const std::string fNamePrefix = payloadPath.stem ();
557
- const qssc::payload::PayloadConfig config{fNamePrefix , fNamePrefix };
558
- auto payloadInfo =
559
- qssc::payload::registry::PayloadRegistry::lookupPluginInfo (
560
- pluginName);
561
- payload =
562
- std::move (payloadInfo.getValue ()->createPluginInstance (config).get ());
569
+ const qssc::payload::PayloadConfig payloadConfig{fNamePrefix ,
570
+ fNamePrefix };
571
+ payload = std::move (
572
+ payloadInfo.getValue ()->createPluginInstance (payloadConfig).get ());
563
573
}
564
574
}
565
575
0 commit comments