@@ -185,7 +185,6 @@ namespace {
185185// / Static gate dispatch table, built once at startup.
186186const llvm::StringMap<GateFn> GATE_DISPATCH = buildGateDispatch();
187187
188- // / Local qubit scope used during compound gate body expansion.
189188// / Maps argument name → vector of MLIR qubit Values.
190189using QubitScope = llvm::StringMap<SmallVector<Value>>;
191190
@@ -235,7 +234,7 @@ class MLIRQasmImporter final : public qasm3::InstVisitor {
235234 // / Updated each time a measure is emitted. Used for if/else conditions.
236235 llvm::StringMap<SmallVector<Value>> bitValues;
237236
238- // / Gate library: standard gates + user-defined compound gates
237+ // / Gate library
239238 std::map<std::string, std::shared_ptr<qasm3::Gate>> gates;
240239
241240 bool openQASM2CompatMode{false };
@@ -403,8 +402,6 @@ class MLIRQasmImporter final : public qasm3::InstVisitor {
403402 }
404403 qubitNames.push_back (q->identifier );
405404 }
406- gates[id] = std::make_shared<qasm3::CompoundGate>(
407- std::move (paramNames), std::move (qubitNames), stmt->statements );
408405 }
409406
410407 void visitGateCallStatement (
@@ -509,8 +506,6 @@ class MLIRQasmImporter final : public qasm3::InstVisitor {
509506 // ===--- Core gate application ----------------------------------------===//
510507
511508 // / Apply a gate call statement, resolving qubits from \p scope.
512- // / For top-level calls pass \p qubitRegisters; for compound gate bodies
513- // / pass the local argument scope.
514509 void
515510 applyGateCallStatement (const std::shared_ptr<qasm3::GateCallStatement>& stmt,
516511 const QubitScope& scope) {
@@ -614,12 +609,12 @@ class MLIRQasmImporter final : public qasm3::InstVisitor {
614609 expandedOperands.begin () + static_cast <std::ptrdiff_t >(totalCtrlCount),
615610 expandedOperands.end ());
616611
617- // Compound gate: inline expand
612+ // Compound gate
618613 if (const auto * compound =
619614 dynamic_cast <qasm3::CompoundGate*>(it->second .get ())) {
620- applyCompoundGate (*compound, gateOperands, posControls, negControls,
621- params, invert, stmt-> debugInfo );
622- return ;
615+ throw qasm3::CompilerError (
616+ " Compound gates cannot be translated to QC at the moment. " ,
617+ stmt-> debugInfo ) ;
623618 }
624619
625620 // Standard gate: validate param count then determine broadcast width
@@ -708,87 +703,6 @@ class MLIRQasmImporter final : public qasm3::InstVisitor {
708703 }
709704 }
710705
711- // / Inline-expand a compound (user-defined) gate.
712- void applyCompoundGate (const qasm3::CompoundGate& gate,
713- const std::vector<SmallVector<Value>>& gateOperands,
714- ArrayRef<Value> posControls,
715- ArrayRef<Value> negControls, ArrayRef<double > params,
716- bool invert,
717- const std::shared_ptr<qasm3::DebugInfo>& debugInfo) {
718- if (gate.targetNames .size () != gateOperands.size ()) {
719- throw qasm3::CompilerError (" Compound gate operand count mismatch." ,
720- debugInfo);
721- }
722- if (gate.parameterNames .size () != params.size ()) {
723- throw qasm3::CompilerError (" Compound gate parameter count mismatch." ,
724- debugInfo);
725- }
726-
727- // Build local scope: argument name → Values
728- QubitScope localScope;
729- for (size_t i = 0 ; i < gate.targetNames .size (); ++i) {
730- localScope[gate.targetNames [i]] =
731- SmallVector<Value>(gateOperands[i].begin (), gateOperands[i].end ());
732- }
733-
734- // Bind parameters as constants
735- constEvalPass.pushEnv ();
736- for (size_t i = 0 ; i < gate.parameterNames .size (); ++i) {
737- constEvalPass.addConst (gate.parameterNames [i],
738- qasm3::const_eval::ConstEvalValue (params[i]));
739- }
740-
741- auto bodyFn = [&] {
742- for (const auto & bodyStmt : gate.body ) {
743- if (const auto gateCall =
744- std::dynamic_pointer_cast<qasm3::GateCallStatement>(bodyStmt)) {
745- applyGateCallStatement (gateCall, localScope);
746- } else if (const auto barrier =
747- std::dynamic_pointer_cast<qasm3::BarrierStatement>(
748- bodyStmt)) {
749- SmallVector<Value> qubits;
750- for (const auto & g : barrier->gates ) {
751- auto resolved =
752- resolveGateOperandInScope (g, localScope, barrier->debugInfo );
753- qubits.append (resolved.begin (), resolved.end ());
754- }
755- builder.barrier (qubits);
756- } else if (const auto reset =
757- std::dynamic_pointer_cast<qasm3::ResetStatement>(
758- bodyStmt)) {
759- for (auto q : resolveGateOperandInScope (reset->gate , localScope,
760- reset->debugInfo )) {
761- builder.reset (q);
762- }
763- }
764- }
765- };
766-
767- auto withInv = [&] {
768- if (invert) {
769- builder.inv (function_ref<void ()>(bodyFn));
770- } else {
771- bodyFn ();
772- }
773- };
774-
775- if (posControls.empty () && negControls.empty ()) {
776- withInv ();
777- } else {
778- for (auto q : negControls) {
779- builder.x (q);
780- }
781- SmallVector<Value> allControls (posControls.begin (), posControls.end ());
782- allControls.append (negControls.begin (), negControls.end ());
783- builder.ctrl (allControls, function_ref<void ()>(withInv));
784- for (auto q : negControls) {
785- builder.x (q);
786- }
787- }
788-
789- constEvalPass.popEnv ();
790- }
791-
792706 // ===--- If/else helpers ------------------------------------------------===//
793707
794708 // / Emit quantum statements inside an if/else block.
@@ -896,9 +810,9 @@ class MLIRQasmImporter final : public qasm3::InstVisitor {
896810 return resolveGateOperandInScope (operand, qubitRegisters, debugInfo);
897811 }
898812
899- /* * Resolve a gate operand against \p scope (top-level registers or a
900- * compound- gate local argument scope) . Returns the MLIR Values for the
901- * qubit(s) named by \p operand — a full register or a single indexed qubit .
813+ /* *
814+ * Resolve a gate operand against \p scope. Returns the qubit Values named by
815+ * \p operand.
902816 */
903817 SmallVector<Value> resolveGateOperandInScope (
904818 const std::shared_ptr<qasm3::GateOperand>& operand,
0 commit comments