Skip to content

Commit c32611e

Browse files
committed
Fix linter errors
1 parent ef6852e commit c32611e

29 files changed

Lines changed: 206 additions & 163 deletions

File tree

mlir/include/mlir/Dialect/QC/Builder/QCProgramBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class QCProgramBuilder final : public ImplicitLocOpBuilder {
104104
/// The MemRef value representing the qubit register
105105
Value value;
106106
/// The allocated qubit values
107-
SmallVector<Value> qubits;
107+
llvm::SmallVector<Value> qubits;
108108

109109
/**
110110
* @brief Access a specific qubit in the register

mlir/include/mlir/Dialect/QCO/Builder/QCOProgramBuilder.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class QCOProgramBuilder final : public ImplicitLocOpBuilder {
112112
/// The QTensor value representing the qubit register
113113
Value value;
114114
/// The allocated qubit values
115-
SmallVector<Value> qubits;
115+
llvm::SmallVector<Value> qubits;
116116

117117
/**
118118
* @brief Access a specific qubit in the register
@@ -1155,7 +1155,7 @@ class QCOProgramBuilder final : public ImplicitLocOpBuilder {
11551155
* ```c++
11561156
* {controls_out, targets_out} =
11571157
* builder.ctrl(q0_in, q1_in,
1158-
* [&](ValueRange targets) -> SmallVector<Value> {
1158+
* [&](ValueRange targets) ->llvm::SmallVector<Value> {
11591159
* return {builder.x(targets[0])};
11601160
* });
11611161
* ```
@@ -1180,7 +1180,7 @@ class QCOProgramBuilder final : public ImplicitLocOpBuilder {
11801180
* @par Example:
11811181
* ```c++
11821182
* qubits_out = builder.inv(q0_in,
1183-
* [&](ValueRange qubits) -> SmallVector<Value> {
1183+
* [&](ValueRange qubits) ->llvm::SmallVector<Value> {
11841184
* return {builder.s(qubits[0])};
11851185
* }
11861186
* );
@@ -1244,7 +1244,7 @@ class QCOProgramBuilder final : public ImplicitLocOpBuilder {
12441244
* ```c++
12451245
* auto result =
12461246
* builder.qcoIf(condition, q0,
1247-
* [&](ValueRange args) -> SmallVector<Value> {
1247+
* [&](ValueRange args) ->llvm::SmallVector<Value> {
12481248
* auto q1 = builder.h(args[0]);
12491249
* return {q1};
12501250
* });

mlir/include/mlir/Dialect/QCO/Utils/Drivers.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ LogicalResult walkProgram(Region& region, const WalkProgramFn& fn) {
8888
return success();
8989
}
9090

91-
using ReleasedOps = SmallVector<UnitaryOpInterface, 8>;
91+
using ReleasedOps = llvm::SmallVector<UnitaryOpInterface, 8>;
9292
using PendingWiresMap =
93-
DenseMap<UnitaryOpInterface, SmallVector<std::size_t, 2>>;
93+
DenseMap<UnitaryOpInterface, llvm::SmallVector<std::size_t, 2>>;
9494

9595
struct IsReady {
9696
bool operator()(PendingWiresMap::value_type& kv) const {
@@ -138,18 +138,18 @@ LogicalResult walkProgramGraph(MutableArrayRef<WireIterator> wires,
138138
PendingWiresMap pending;
139139
pending.reserve(wires.size());
140140

141-
SmallVector<std::size_t> curr(wires.size());
141+
llvm::SmallVector<std::size_t> curr(wires.size());
142142
std::iota(curr.begin(), curr.end(), 0UL);
143143

144-
SmallVector<std::size_t> next;
144+
llvm::SmallVector<std::size_t> next;
145145
next.reserve(wires.size());
146146

147147
while (!curr.empty()) {
148148
for (std::size_t i : curr) {
149149
auto& it = wires[i];
150150
while (Traits::isActive(it)) {
151151
const auto res =
152-
TypeSwitch<Operation*, WalkResult>(it.operation())
152+
llvm::TypeSwitch<Operation*, WalkResult>(it.operation())
153153
.template Case<UnitaryOpInterface>([&](UnitaryOpInterface& op) {
154154
// If there are fewer wires than the qubit requires inputs,
155155
// it's impossible to release the operation. Hence, fail.

mlir/lib/Conversion/JeffToQCO/JeffToQCO.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <jeff/IR/JeffOps.h>
2121
#include <llvm/ADT/STLExtras.h>
2222
#include <llvm/ADT/STLFunctionalExtras.h>
23+
#include <llvm/ADT/SmallVector.h>
2324
#include <llvm/Support/Casting.h>
2425
#include <llvm/Support/ErrorHandling.h>
2526
#include <mlir/Dialect/Arith/IR/Arith.h>

mlir/lib/Conversion/QCOToJeff/QCOToJeff.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <jeff/IR/JeffOps.h>
2121
#include <llvm/ADT/STLExtras.h>
2222
#include <llvm/ADT/SmallVector.h>
23+
#include <llvm/ADT/StringRef.h>
2324
#include <llvm/Support/Casting.h>
2425
#include <mlir/Dialect/Arith/IR/Arith.h>
2526
#include <mlir/Dialect/Func/IR/FuncOps.h>
@@ -226,7 +227,7 @@ template <typename QCOOpType>
226227
static void createCustomOp(QCOOpType& op, ConversionPatternRewriter& rewriter,
227228
LoweringState& state, ValueRange targets,
228229
ValueRange params, const bool isAdjoint,
229-
StringRef name) {
230+
llvm::StringRef name) {
230231
auto* const it = llvm::find(state.strings, name);
231232
if (it == state.strings.end()) {
232233
state.strings.emplace_back(name);

mlir/lib/Conversion/QCToQCO/QCToQCO.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ enum class AllocationMode : std::uint8_t {
101101
struct LoweringState {
102102
struct ModifierFrame {
103103
/// QC qubits yielded from the current modifier region, in yield order.
104-
SmallVector<Value> yieldOrder;
104+
llvm::SmallVector<Value> yieldOrder;
105105

106106
/// Latest QCO SSA values for QC qubits that are remapped inside the
107107
/// modifier region.
@@ -123,7 +123,7 @@ struct LoweringState {
123123
llvm::DenseMap<Region*, llvm::DenseMap<Value, QubitInfo>> qubitInfoMap;
124124

125125
/// Stack of active modifier regions
126-
SmallVector<ModifierFrame> modifierFrames;
126+
llvm::SmallVector<ModifierFrame> modifierFrames;
127127

128128
/// The qubit allocation mode used in the module
129129
AllocationMode allocationMode = AllocationMode::Unset;
@@ -279,7 +279,7 @@ static void assignMappedTensor(LoweringState& state, Operation* anchor,
279279

280280
/** @brief Resolves a range of QC qubits to their latest QCO values. */
281281
template <typename Range>
282-
[[nodiscard]] static SmallVector<Value>
282+
[[nodiscard]] static llvm::SmallVector<Value>
283283
resolveMappedQubits(LoweringState& state, Operation* anchor,
284284
const Range& qcQubits) {
285285
return llvm::to_vector(llvm::map_range(qcQubits, [&](Value qcQubit) {

mlir/lib/Conversion/QCToQIR/QCToQIR.cpp

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
#include "mlir/Dialect/QIR/Utils/QIRMetadata.h"
1717
#include "mlir/Dialect/QIR/Utils/QIRUtils.h"
1818

19+
#include <llvm/ADT/DenseMap.h>
1920
#include <llvm/ADT/STLExtras.h>
2021
#include <llvm/ADT/SmallVector.h>
2122
#include <llvm/ADT/StringMap.h>
23+
#include <llvm/ADT/StringRef.h>
2224
#include <llvm/Support/Allocator.h>
2325
#include <llvm/Support/Casting.h>
2426
#include <llvm/Support/ErrorHandling.h>
@@ -76,10 +78,10 @@ enum class AllocationMode : std::uint8_t {
7678
*/
7779
struct LoweringState : QIRMetadata {
7880
/// Cache static qubit pointers for reuse
79-
DenseMap<int64_t, Value> staticQubits;
81+
llvm::DenseMap<int64_t, Value> staticQubits;
8082

8183
/// Cache MemRef sizes for reuse
82-
DenseMap<Value, Value> memrefSizes;
84+
llvm::DenseMap<Value, Value> memrefSizes;
8385

8486
/// Map from register name to result-array pointer
8587
llvm::StringMap<Value> resultArrays;
@@ -88,11 +90,11 @@ struct LoweringState : QIRMetadata {
8890
llvm::DenseMap<std::pair<llvm::StringRef, int64_t>, Value> loadedResults;
8991

9092
/// Map from index to result pointer for non-register results
91-
DenseMap<int64_t, Value> resultPtrs;
93+
llvm::DenseMap<int64_t, Value> resultPtrs;
9294

9395
/// Modifier information
9496
int64_t inCtrlOp = 0;
95-
DenseMap<int64_t, SmallVector<Value>> controls;
97+
llvm::DenseMap<int64_t, llvm::SmallVector<Value>> controls;
9698

9799
/// Allocator and StringSaver for stable StringRefs
98100
llvm::BumpPtrAllocator allocator;
@@ -168,16 +170,16 @@ template <typename QCOpType, typename QCOpAdaptorType>
168170
static LogicalResult
169171
convertUnitaryToCallOp(QCOpType& op, QCOpAdaptorType& adaptor,
170172
ConversionPatternRewriter& rewriter, MLIRContext* ctx,
171-
LoweringState& state, StringRef fnName,
173+
LoweringState& state, llvm::StringRef fnName,
172174
size_t numTargets, size_t numParams) {
173175
// Query state for modifier information
174176
const auto inCtrlOp = state.inCtrlOp;
175-
const SmallVector<Value> controls =
176-
inCtrlOp != 0 ? state.controls[inCtrlOp] : SmallVector<Value>{};
177+
const llvm::SmallVector<Value> controls =
178+
inCtrlOp != 0 ? state.controls[inCtrlOp] : llvm::SmallVector<Value>{};
177179
const size_t numCtrls = controls.size();
178180

179181
// Define argument types
180-
SmallVector<Type> argumentTypes;
182+
llvm::SmallVector<Type> argumentTypes;
181183
argumentTypes.reserve(numParams + numCtrls + numTargets);
182184
const auto ptrType = LLVM::LLVMPointerType::get(ctx);
183185
const auto floatType = Float64Type::get(ctx);
@@ -202,7 +204,7 @@ convertUnitaryToCallOp(QCOpType& op, QCOpAdaptorType& adaptor,
202204
const auto fnDecl =
203205
getOrCreateFunctionDeclaration(rewriter, op, fnName, fnSignature);
204206

205-
SmallVector<Value> operands;
207+
llvm::SmallVector<Value> operands;
206208
operands.reserve(numParams + numCtrls + numTargets);
207209
operands.append(controls.begin(), controls.end());
208210
operands.append(adaptor.getOperands().begin(), adaptor.getOperands().end());
@@ -865,8 +867,8 @@ struct ConvertQCCtrlOp final : StatefulOpConversionPattern<CtrlOp> {
865867
// Update modifier information
866868
auto& state = getState();
867869
state.inCtrlOp++;
868-
const SmallVector<Value> controls(adaptor.getControls().begin(),
869-
adaptor.getControls().end());
870+
const llvm::SmallVector<Value> controls(adaptor.getControls().begin(),
871+
adaptor.getControls().end());
870872
state.controls[state.inCtrlOp] = controls;
871873

872874
// Inline region and remove operation
@@ -996,12 +998,13 @@ struct QCToQIR final : impl::QCToQIRBase<QCToQIR> {
996998
// Move operations to appropriate blocks
997999
for (auto it = bodyBlock->begin(); it != bodyBlock->end();) {
9981000
// Ensure iterator remains valid after potential move
999-
if (auto& op = *it++; isa<LLVM::ReturnOp>(op)) {
1001+
if (auto& op = *it++; llvm::isa<LLVM::ReturnOp>(op)) {
10001002
// Move return to output block
10011003
outputBlockOps.splice(outputBlock->end(), bodyBlockOps,
10021004
Block::iterator(op));
1003-
} else if (isa<memref::AllocOp>(op) || isa<memref::LoadOp>(op) ||
1004-
isa<AllocOp>(op) || op.hasTrait<OpTrait::ConstantLike>()) {
1005+
} else if (llvm::isa<memref::AllocOp>(op) ||
1006+
llvm::isa<memref::LoadOp>(op) || llvm::isa<AllocOp>(op) ||
1007+
op.hasTrait<OpTrait::ConstantLike>()) {
10051008
// Move allocations and constant-like operations to entry block
10061009
entryBlock->getOperations().splice(entryBlock->end(), bodyBlockOps,
10071010
Block::iterator(op));

mlir/lib/Dialect/QC/IR/Modifiers/CtrlOp.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include <llvm/ADT/STLExtras.h>
1414
#include <llvm/ADT/STLFunctionalExtras.h>
15+
#include <llvm/ADT/SmallPtrSet.h>
1516
#include <llvm/Support/Casting.h>
1617
#include <llvm/Support/ErrorHandling.h>
1718
#include <mlir/IR/Builders.h>

0 commit comments

Comments
 (0)