@@ -143,10 +143,10 @@ static llvm::cl::opt<enum Action> emitAction(
143
143
llvm::cl::values(clEnumValN(GenQEM, " qem" ,
144
144
" generate a quantum executable module (qem) "
145
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" )));
146
+ llvm::cl::values(clEnumValN(
147
+ GenQEQEM, " qe-qem" ,
148
+ " generate a target-specific quantum executable module (qeqem ) "
149
+ " for execution on hardware" )));
150
150
151
151
namespace qss {
152
152
enum FileExtension { None, AST, ASTPRETTY, QASM, QOBJ, MLIR, WMEM, QEM, QEQEM };
@@ -555,13 +555,21 @@ compile_(int argc, char const **argv, std::string *outputString,
555
555
auto outputFile = mlir::openOutputFile (outputFilename, &errorMessage);
556
556
std::unique_ptr<qssc::payload::Payload> payload = nullptr ;
557
557
558
+ if (emitAction == Action::GenQEQEM && !config.targetName .has_value ())
559
+ return llvm::createStringError (
560
+ llvm::inconvertibleErrorCode (),
561
+ " Unsupported target-specific payload: no target" );
558
562
if (emitAction == Action::GenQEM || emitAction == Action::GenQEQEM) {
559
563
const std::filesystem::path payloadPath (outputFilename.c_str ());
560
564
const std::string fNamePrefix = payloadPath.stem ();
561
565
const auto payloadName =
562
- (emitAction == Action::GenQEM) ? " ZIP" : config.targetName .value_or ( " " );
566
+ (emitAction == Action::GenQEM) ? " ZIP" : config.targetName .value ( );
563
567
auto payloadInfo =
564
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);
565
573
if (outputFilename == " -" ) {
566
574
payload = std::move (
567
575
payloadInfo.getValue ()->createPluginInstance (llvm::None).get ());
0 commit comments