From fb624ebc05253756cf9e8ffec07150494498db31 Mon Sep 17 00:00:00 2001 From: Daniel Haag <121057143+denialhaag@users.noreply.github.com> Date: Wed, 29 Apr 2026 17:52:27 +0200 Subject: [PATCH 1/3] Remove remaining unnecessary llvm namespaces --- mlir/include/mlir/Dialect/QCO/QCOUtils.h | 16 ++++----- mlir/include/mlir/Dialect/QCO/Utils/Drivers.h | 4 +-- .../mlir/Dialect/QTensor/IR/QTensorOps.td | 34 +++++++++---------- .../mlir/Dialect/QTensor/IR/QTensorUtils.h | 16 ++++----- mlir/unittests/TestCaseUtils.h | 1 + 5 files changed, 34 insertions(+), 37 deletions(-) diff --git a/mlir/include/mlir/Dialect/QCO/QCOUtils.h b/mlir/include/mlir/Dialect/QCO/QCOUtils.h index a5fdba0c35..489fceb00e 100644 --- a/mlir/include/mlir/Dialect/QCO/QCOUtils.h +++ b/mlir/include/mlir/Dialect/QCO/QCOUtils.h @@ -29,8 +29,7 @@ template LogicalResult removeInversePairOneTargetZeroParameter(OpType op, PatternRewriter& rewriter) { // Check if the successor is the inverse operation - auto nextOp = - llvm::dyn_cast(*op.getOutputQubit(0).user_begin()); + auto nextOp = dyn_cast(*op.getOutputQubit(0).user_begin()); if (!nextOp) { return failure(); } @@ -54,8 +53,7 @@ template LogicalResult removeInversePairTwoTargetZeroParameter(OpType op, PatternRewriter& rewriter) { // Check if the successor is the inverse operation - auto nextOp = - llvm::dyn_cast(*op.getOutputQubit(0).user_begin()); + auto nextOp = dyn_cast(*op.getOutputQubit(0).user_begin()); if (!nextOp) { return failure(); } @@ -85,7 +83,7 @@ LogicalResult removeTwoTargetZeroParameterPairWithSwappedTargets(OpType op, PatternRewriter& rewriter) { // Check if the successor is the same operation - auto nextOp = llvm::dyn_cast(*op.getOutputQubit(0).user_begin()); + auto nextOp = dyn_cast(*op.getOutputQubit(0).user_begin()); if (!nextOp) { return failure(); } @@ -120,7 +118,7 @@ template LogicalResult mergeOneTargetZeroParameter(OpType op, PatternRewriter& rewriter) { // Check if the successor is the same operation - auto nextOp = llvm::dyn_cast(*op.getOutputQubit(0).user_begin()); + auto nextOp = dyn_cast(*op.getOutputQubit(0).user_begin()); if (!nextOp) { return failure(); } @@ -149,7 +147,7 @@ LogicalResult mergeOneTargetZeroParameter(OpType op, template LogicalResult mergeOneTargetOneParameter(OpType op, PatternRewriter& rewriter) { // Check if the successor is the same operation - auto nextOp = llvm::dyn_cast(*op.getOutputQubit(0).user_begin()); + auto nextOp = dyn_cast(*op.getOutputQubit(0).user_begin()); if (!nextOp) { return failure(); } @@ -179,7 +177,7 @@ LogicalResult mergeOneTargetOneParameter(OpType op, PatternRewriter& rewriter) { template LogicalResult mergeTwoTargetOneParameter(OpType op, PatternRewriter& rewriter) { // Check if the successor is the same operation - auto nextOp = llvm::dyn_cast(*op.getOutputQubit(0).user_begin()); + auto nextOp = dyn_cast(*op.getOutputQubit(0).user_begin()); if (!nextOp) { return failure(); } @@ -218,7 +216,7 @@ LogicalResult mergeTwoTargetOneParameterWithSwappedTargets(OpType op, PatternRewriter& rewriter) { // Check if the successor is the same operation - auto nextOp = llvm::dyn_cast(*op.getOutputQubit(0).user_begin()); + auto nextOp = dyn_cast(*op.getOutputQubit(0).user_begin()); if (!nextOp) { return failure(); } diff --git a/mlir/include/mlir/Dialect/QCO/Utils/Drivers.h b/mlir/include/mlir/Dialect/QCO/Utils/Drivers.h index d4670e9615..0a59e7d83e 100644 --- a/mlir/include/mlir/Dialect/QCO/Utils/Drivers.h +++ b/mlir/include/mlir/Dialect/QCO/Utils/Drivers.h @@ -64,8 +64,8 @@ LogicalResult walkProgram(Region& region, const WalkProgramFn& fn) { .template Case([&](UnitaryOpInterface& op) { for (const auto& [prevV, nextV] : llvm::zip(op.getInputQubits(), op.getOutputQubits())) { - const auto prevQ = llvm::cast>(prevV); - const auto nextQ = llvm::cast>(nextV); + const auto prevQ = cast>(prevV); + const auto nextQ = cast>(nextV); qubits.remap(prevQ, nextQ); } }) diff --git a/mlir/include/mlir/Dialect/QTensor/IR/QTensorOps.td b/mlir/include/mlir/Dialect/QTensor/IR/QTensorOps.td index 1ac3aa1885..7a0e26ea27 100644 --- a/mlir/include/mlir/Dialect/QTensor/IR/QTensorOps.td +++ b/mlir/include/mlir/Dialect/QTensor/IR/QTensorOps.td @@ -86,8 +86,8 @@ def FromElementsOp TypesMatchWith< "operand types match result element type", "result", "elements", "SmallVector(" - "::llvm::cast($_self).getNumElements(), " - "::llvm::cast($_self).getElementType())">]> { + "cast($_self).getNumElements(), " + "cast($_self).getElementType())">]> { let summary = "Create a tensor from a range of values"; let description = [{ The `qtensor.from_elements` operation is a wrapper operation of the `tensor.from_elements` operation. @@ -110,14 +110,13 @@ def FromElementsOp } def ExtractOp - : QTensorOp< - "extract", - [Pure, - TypesMatchWith<"result type matches element type of tensor", - "tensor", "result", - "::llvm::cast($_self).getElementType()">, - TypesMatchWith<"returned tensor type matches input tensor", "tensor", - "out_tensor", "$_self">]> { + : QTensorOp<"extract", + [Pure, + TypesMatchWith<"result type matches element type of tensor", + "tensor", "result", + "cast($_self).getElementType()">, + TypesMatchWith<"returned tensor type matches input tensor", + "tensor", "out_tensor", "$_self">]> { let summary = "Extract element from tensor"; let description = [{ The `qtensor.extract` operation is the modified version of the standard `tensor.extract` @@ -138,14 +137,13 @@ def ExtractOp } def InsertOp - : QTensorOp< - "insert", - [Pure, - TypesMatchWith<"result type matches type of dest", "dest", "result", - "$_self">, - TypesMatchWith< - "scalar type matches element type of dest", "dest", "scalar", - "::llvm::cast($_self).getElementType()">]> { + : QTensorOp<"insert", [Pure, + TypesMatchWith<"result type matches type of dest", + "dest", "result", "$_self">, + TypesMatchWith< + "scalar type matches element type of dest", + "dest", "scalar", + "cast($_self).getElementType()">]> { let summary = "Insert element into tensor"; let description = [{ The `qtensor.insert` operation is a wrapper operation for the `tensor.insert` operation of the tensor dialect. diff --git a/mlir/include/mlir/Dialect/QTensor/IR/QTensorUtils.h b/mlir/include/mlir/Dialect/QTensor/IR/QTensorUtils.h index 594be34481..71a321e9fc 100644 --- a/mlir/include/mlir/Dialect/QTensor/IR/QTensorUtils.h +++ b/mlir/include/mlir/Dialect/QTensor/IR/QTensorUtils.h @@ -12,9 +12,9 @@ #include "mlir/Dialect/QTensor/IR/QTensorOps.h" -#include #include #include +#include namespace mlir::qtensor { @@ -40,17 +40,17 @@ inline bool areEquivalentIndices(Value lhs, Value rhs) { * @brief Tensor-transforming ops in a scalar extract/insert chain. */ inline bool isTensorChainOp(Operation* op) { - return llvm::isa(op); + return isa(op); } /** * @brief Returns the tensor input of a tensor-transforming op. */ inline Value getTensorChainInput(Operation* op) { - if (auto insertOp = llvm::dyn_cast(op)) { + if (auto insertOp = dyn_cast(op)) { return insertOp.getDest(); } - if (auto extractOp = llvm::dyn_cast(op)) { + if (auto extractOp = dyn_cast(op)) { return extractOp.getTensor(); } return nullptr; @@ -60,10 +60,10 @@ inline Value getTensorChainInput(Operation* op) { * @brief Returns the tensor output of a tensor-transforming op. */ inline Value getTensorChainOutput(Operation* op) { - if (auto insertOp = llvm::dyn_cast(op)) { + if (auto insertOp = dyn_cast(op)) { return insertOp.getResult(); } - if (auto extractOp = llvm::dyn_cast(op)) { + if (auto extractOp = dyn_cast(op)) { return extractOp.getOutTensor(); } return nullptr; @@ -73,11 +73,11 @@ inline Value getTensorChainOutput(Operation* op) { * @brief Rewire the tensor input of a tensor-transforming op. */ inline void setTensorChainInput(Operation* op, Value tensor) { - if (llvm::isa(op)) { + if (isa(op)) { op->setOperand(1, tensor); return; } - if (llvm::isa(op)) { + if (isa(op)) { op->setOperand(0, tensor); } } diff --git a/mlir/unittests/TestCaseUtils.h b/mlir/unittests/TestCaseUtils.h index 570c86c87f..a7ca9d28f4 100644 --- a/mlir/unittests/TestCaseUtils.h +++ b/mlir/unittests/TestCaseUtils.h @@ -17,6 +17,7 @@ #include #include #include +#include #include #include From 135d393c360e189c822a7c0acc4bfe7ddce9479a Mon Sep 17 00:00:00 2001 From: Daniel Haag <121057143+denialhaag@users.noreply.github.com> Date: Wed, 29 Apr 2026 17:58:59 +0200 Subject: [PATCH 2/3] Update changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee4cc9c639..185492128d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ This project adheres to [Semantic Versioning], with the exception that minor rel - ✨ Add conversions between `jeff` and QCO ([#1479], [#1548], [#1565], [#1637]) ([**@denialhaag**]) - ✨ Add a `place-and-route` pass for mapping circuits to architectures with restricted topologies ([#1537], [#1547], [#1568], [#1581], [#1583], [#1588], [#1664]) ([**@MatthiasReumann**], [**@burgholzer**]) - ✨ Add initial infrastructure for new QC and QCO MLIR dialects - ([#1264], [#1330], [#1402], [#1428], [#1430], [#1436], [#1443], [#1446], [#1464], [#1465], [#1470], [#1471], [#1472], [#1474], [#1475], [#1506], [#1510], [#1513], [#1521], [#1542], [#1548], [#1550], [#1554], [#1567], [#1569], [#1570], [#1572], [#1573], [#1580], [#1602], [#1620], [#1623], [#1624], [#1626], [#1627], [#1635], [#1673]) + ([#1264], [#1330], [#1402], [#1428], [#1430], [#1436], [#1443], [#1446], [#1464], [#1465], [#1470], [#1471], [#1472], [#1474], [#1475], [#1506], [#1510], [#1513], [#1521], [#1542], [#1548], [#1550], [#1554], [#1567], [#1569], [#1570], [#1572], [#1573], [#1580], [#1602], [#1620], [#1623], [#1624], [#1626], [#1627], [#1635], [#1673], [#1675]) ([**@burgholzer**], [**@denialhaag**], [**@taminob**], [**@DRovara**], [**@li-mingbao**], [**@Ectras**], [**@MatthiasReumann**], [**@simon1hofmann**]) ### Changed @@ -361,6 +361,7 @@ _📚 Refer to the [GitHub Release Notes](https://github.com/munich-quantum-tool +[#1675]: https://github.com/munich-quantum-toolkit/core/pull/1675 [#1673]: https://github.com/munich-quantum-toolkit/core/pull/1673 [#1664]: https://github.com/munich-quantum-toolkit/core/pull/1664 [#1662]: https://github.com/munich-quantum-toolkit/core/pull/1662 From 3430b1ded18c87df587217244865b54e84eef081 Mon Sep 17 00:00:00 2001 From: Daniel Haag <121057143+denialhaag@users.noreply.github.com> Date: Wed, 29 Apr 2026 18:00:23 +0200 Subject: [PATCH 3/3] Simplify diff --- mlir/unittests/TestCaseUtils.h | 1 - 1 file changed, 1 deletion(-) diff --git a/mlir/unittests/TestCaseUtils.h b/mlir/unittests/TestCaseUtils.h index a7ca9d28f4..570c86c87f 100644 --- a/mlir/unittests/TestCaseUtils.h +++ b/mlir/unittests/TestCaseUtils.h @@ -17,7 +17,6 @@ #include #include #include -#include #include #include