Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mlir/include/mlir/Dialect/QC/IR/QCOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -948,8 +948,8 @@ def CtrlOp : QCOp<"ctrl",
}];

let arguments = (ins Arg<Variadic<QubitType>, "the control qubits", [MemRead, MemWrite]>:$controls);
let regions = (region SizedRegion<1>:$body);
let assemblyFormat = "`(` $controls `)` $body attr-dict `:` type($controls)";
let regions = (region SizedRegion<1>:$region);
let assemblyFormat = "`(` $controls `)` $region attr-dict `:` type($controls)";

let extraClassDeclaration = [{
[[nodiscard]] UnitaryOpInterface getBodyUnitary();
Expand Down
4 changes: 2 additions & 2 deletions mlir/include/mlir/Dialect/QCO/IR/QCOOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -1067,10 +1067,10 @@ def CtrlOp : QCOOp<"ctrl", traits =
let arguments = (ins Arg<Variadic<QubitType>, "the control qubits", [MemRead]>:$controls_in,
Arg<Variadic<QubitType>, "the target qubits", [MemRead]>:$targets_in);
let results = (outs Variadic<QubitType>:$controls_out, Variadic<QubitType>:$targets_out);
let regions = (region SizedRegion<1>:$body);
let regions = (region SizedRegion<1>:$region);
let assemblyFormat = [{
`(` $controls_in `)` $targets_in
$body attr-dict `:`
$region attr-dict `:`
`(` `{` type($controls_in) `}` ( `,` `{` type($targets_in)^ `}` )? `)`
`->`
`(` `{` type($controls_out) `}` ( `,` `{` type($targets_out)^ `}` )? `)`
Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/Conversion/QCOToQC/QCOToQC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -777,8 +777,8 @@ struct ConvertQCOCtrlOp final : OpConversionPattern<qco::CtrlOp> {
auto qcoOp = rewriter.create<qc::CtrlOp>(op.getLoc(), qcControls);

// Clone body region from QCO to QC
auto& dstRegion = qcoOp.getBody();
rewriter.cloneRegionBefore(op.getBody(), dstRegion, dstRegion.end());
auto& dstRegion = qcoOp.getRegion();
rewriter.cloneRegionBefore(op.getRegion(), dstRegion, dstRegion.end());

// Replace the output qubits with the same QC references
rewriter.replaceOp(op, adaptor.getOperands());
Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/Conversion/QCToQCO/QCToQCO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1127,8 +1127,8 @@ struct ConvertQCCtrlOp final : StatefulOpConversionPattern<qc::CtrlOp> {
state.targetsIn.try_emplace(state.inCtrlOp, qcoTargets);

// Clone body region from QC to QCO
auto& dstRegion = qcoOp.getBody();
rewriter.cloneRegionBefore(op.getBody(), dstRegion, dstRegion.end());
auto& dstRegion = qcoOp.getRegion();
rewriter.cloneRegionBefore(op.getRegion(), dstRegion, dstRegion.end());

rewriter.eraseOp(op);
return success();
Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/Dialect/QC/IR/Modifiers/CtrlOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ struct CtrlInlineGPhase final : OpRewritePattern<CtrlOp> {
} // namespace

UnitaryOpInterface CtrlOp::getBodyUnitary() {
return llvm::dyn_cast<UnitaryOpInterface>(&getBody().front().front());
return llvm::dyn_cast<UnitaryOpInterface>(&getBody()->front());
}

size_t CtrlOp::getNumQubits() { return getNumTargets() + getNumControls(); }
Expand Down Expand Up @@ -173,7 +173,7 @@ void CtrlOp::build(OpBuilder& odsBuilder, OperationState& odsState,
}

LogicalResult CtrlOp::verify() {
auto& block = getBody().front();
auto& block = *getBody();
if (block.getOperations().size() != 2) {
return emitOpError("body region must have exactly two operations");
}
Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/Dialect/QCO/IR/Modifiers/CtrlOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ struct CtrlInlineId final : OpRewritePattern<CtrlOp> {
} // namespace

UnitaryOpInterface CtrlOp::getBodyUnitary() {
return llvm::dyn_cast<UnitaryOpInterface>(&getBody().front().front());
return llvm::dyn_cast<UnitaryOpInterface>(&getBody()->front());
}

size_t CtrlOp::getNumQubits() { return getNumTargets() + getNumControls(); }
Expand Down Expand Up @@ -272,7 +272,7 @@ void CtrlOp::build(OpBuilder& odsBuilder, OperationState& odsState,
}

LogicalResult CtrlOp::verify() {
auto& block = getBody().front();
auto& block = *getBody();
if (block.getOperations().size() != 2) {
return emitOpError("body region must have exactly two operations");
}
Expand Down
Loading