diff --git a/include/cudaq/Optimizer/Dialect/CC/CCOps.td b/include/cudaq/Optimizer/Dialect/CC/CCOps.td index dc523a0039..83f07ffe80 100644 --- a/include/cudaq/Optimizer/Dialect/CC/CCOps.td +++ b/include/cudaq/Optimizer/Dialect/CC/CCOps.td @@ -688,14 +688,22 @@ def cc_AllocaOp : CCOp<"alloca", [ let arguments = (ins TypeAttr:$elementType, - Optional:$seqSize + Optional:$seqSize ); let results = (outs cc_PointerType:$address); - let assemblyFormat = [{ - $elementType (`[` $seqSize^ `]`)? `:` functional-type(operands, results) - attr-dict - }]; + let hasFolder = 1; + let hasCustomAssemblyFormat = 1; + let builders = [ + OpBuilder<(ins "mlir::Type":$elementType, "mlir::Value":$seqSize), [{ + auto resTy = cudaq::cc::PointerType::get(seqSize ? + cudaq::cc::ArrayType::get(elementType) : elementType); + return build($_builder, $_state, resTy, elementType, seqSize); + }]>, + OpBuilder<(ins "mlir::Type":$elementType), [{ + return build($_builder, $_state, elementType, mlir::Value{}); + }]> + ]; } def cc_LoadOp : CCOp<"load", diff --git a/include/cudaq/Optimizer/Dialect/CC/CCTypes.td b/include/cudaq/Optimizer/Dialect/CC/CCTypes.td index b7c563a937..07daee5ce3 100644 --- a/include/cudaq/Optimizer/Dialect/CC/CCTypes.td +++ b/include/cudaq/Optimizer/Dialect/CC/CCTypes.td @@ -108,6 +108,12 @@ def cc_ArrayType : CCType<"Array", "array"> { bool isUnknownSize() const { return getSize() == unknownSize; } }]; + + let builders = [ + TypeBuilderWithInferredContext<(ins "mlir::Type":$elementType), [{ + return Base::get(elementType.getContext(), elementType, unknownSize); + }]>, + ]; } //===----------------------------------------------------------------------===// diff --git a/include/cudaq/Optimizer/Dialect/Quake/QuakeOps.td b/include/cudaq/Optimizer/Dialect/Quake/QuakeOps.td index 7f098241ba..5daa779f09 100644 --- a/include/cudaq/Optimizer/Dialect/Quake/QuakeOps.td +++ b/include/cudaq/Optimizer/Dialect/Quake/QuakeOps.td @@ -80,11 +80,14 @@ def quake_AllocaOp : QuakeOp<"alloca", [MemoryEffects<[MemAlloc, MemWrite]>]> { }]>, OpBuilder<(ins "size_t":$size), [{ return build($_builder, $_state, $_builder.getType(size), {}); + }]>, + OpBuilder<(ins "mlir::Type":$ty), [{ + return build($_builder, $_state, ty, {}); }]> ]; let assemblyFormat = [{ - (`[` $size^ `:` type($size)`]`)? qualified(type($ref_or_vec)) attr-dict + qualified(type($ref_or_vec)) (`[` $size^ `:` type($size) `]`)? attr-dict }]; let hasCanonicalizer = 1; diff --git a/lib/Frontend/nvqpp/ConvertDecl.cpp b/lib/Frontend/nvqpp/ConvertDecl.cpp index a77e94db73..adb3ba8b13 100644 --- a/lib/Frontend/nvqpp/ConvertDecl.cpp +++ b/lib/Frontend/nvqpp/ConvertDecl.cpp @@ -253,7 +253,10 @@ bool QuakeBridgeVisitor::VisitVarDecl(clang::VarDecl *x) { // this is a qreg q; auto qregSizeVal = builder.create( loc, qregSize, builder.getIntegerType(64)); - qreg = builder.create(loc, qType, qregSizeVal); + if (qregSize != 0) + qreg = builder.create(loc, qType); + else + qreg = builder.create(loc, qType, qregSizeVal); } symbolTable.insert(name, qreg); // allocated_qreg_names.push_back(name); @@ -267,12 +270,10 @@ bool QuakeBridgeVisitor::VisitVarDecl(clang::VarDecl *x) { symbolTable.insert(name, val); return pushValue(val); } - auto qregSizeVal = builder.create( - loc, 1, builder.getIntegerType(64)); auto zero = builder.create( loc, 0, builder.getIntegerType(64)); auto qregSizeOne = builder.create( - loc, quake::VeqType::get(builder.getContext(), 1), qregSizeVal); + loc, quake::VeqType::get(builder.getContext(), 1)); Value addressTheQubit = builder.create(loc, qregSizeOne, zero); symbolTable.insert(name, addressTheQubit); diff --git a/lib/Frontend/nvqpp/ConvertExpr.cpp b/lib/Frontend/nvqpp/ConvertExpr.cpp index 2e5d64f87d..2e75c1298f 100644 --- a/lib/Frontend/nvqpp/ConvertExpr.cpp +++ b/lib/Frontend/nvqpp/ConvertExpr.cpp @@ -1718,11 +1718,15 @@ bool QuakeBridgeVisitor::VisitCXXConstructExpr(clang::CXXConstructExpr *x) { auto sizeVal = popValue(); if (isa(sizeVal.getType())) return pushValue(sizeVal); + if (regTy.hasSpecifiedSize()) + return pushValue(builder.create(loc, regTy)); return pushValue( builder.create(loc, regTy, sizeVal)); } auto qregSizeVal = builder.create( loc, regTy.getSize(), builder.getIntegerType(64)); + if (regTy.hasSpecifiedSize()) + return pushValue(builder.create(loc, regTy)); return pushValue( builder.create(loc, regTy, qregSizeVal)); } diff --git a/lib/Optimizer/Dialect/CC/CCOps.cpp b/lib/Optimizer/Dialect/CC/CCOps.cpp index ccdccdf60f..0f5147aabc 100644 --- a/lib/Optimizer/Dialect/CC/CCOps.cpp +++ b/lib/Optimizer/Dialect/CC/CCOps.cpp @@ -1,10 +1,10 @@ -/*************************************************************** -*- C++ -*- *** +/****************************************************************-*- C++ -*-**** * Copyright (c) 2022 - 2023 NVIDIA Corporation & Affiliates. * * All rights reserved. * * * * This source code and the accompanying materials are made available under * * the terms of the Apache License 2.0 which accompanies this distribution. * - *******************************************************************************/ + ******************************************************************************/ #include "cudaq/Optimizer/Dialect/CC/CCOps.h" #include "cudaq/Optimizer/Builder/Factory.h" @@ -45,6 +45,62 @@ cudaq::cc::AddressOfOp::verifySymbolUses(SymbolTableCollection &symbolTable) { return success(); } +//===----------------------------------------------------------------------===// +// AllocaOp +//===----------------------------------------------------------------------===// + +void cudaq::cc::AllocaOp::print(OpAsmPrinter &p) { + p << ' ' << getElementType(); + if (auto size = getSeqSize()) + p << '[' << size << " : " << size.getType() << ']'; +} + +ParseResult cudaq::cc::AllocaOp::parse(OpAsmParser &parser, + OperationState &result) { + Type eleTy; + if (parser.parseType(eleTy)) + return failure(); + result.addAttribute("elementType", TypeAttr::get(eleTy)); + Type resTy; + if (succeeded(parser.parseOptionalLSquare())) { + OpAsmParser::UnresolvedOperand operand; + Type operTy; + if (parser.parseOperand(operand) || parser.parseColonType(operTy) || + parser.parseRSquare() || + parser.resolveOperand(operand, operTy, result.operands)) + return failure(); + resTy = cc::PointerType::get(cc::ArrayType::get(eleTy)); + } else { + resTy = cc::PointerType::get(eleTy); + } + if (!resTy || parser.parseOptionalAttrDict(result.attributes) || + parser.addTypeToList(resTy, result.types)) + return failure(); + return success(); +} + +OpFoldResult cudaq::cc::AllocaOp::fold(ArrayRef params) { + if (params.size() == 1) { + // If allocating a contiguous block of elements and the size of the block is + // a constant, fold the size into the cc.array type and allocate a constant + // sized block. + if (auto intAttr = dyn_cast_or_null(params[0])) { + auto size = intAttr.getInt(); + if (size > 0) { + auto resTy = cast( + cast(getType()).getElementType()); + auto arrTy = cc::ArrayType::get(resTy.getContext(), + resTy.getElementType(), size); + getOperation()->setAttr("elementType", TypeAttr::get(arrTy)); + getResult().setType(cc::PointerType::get(arrTy)); + getOperation()->eraseOperand(0); + return getResult(); + } + } + } + return nullptr; +} + //===----------------------------------------------------------------------===// // CastOp //===----------------------------------------------------------------------===// diff --git a/lib/Optimizer/Dialect/Quake/QuakeOps.cpp b/lib/Optimizer/Dialect/Quake/QuakeOps.cpp index 797d3bfff3..2853c4130f 100644 --- a/lib/Optimizer/Dialect/Quake/QuakeOps.cpp +++ b/lib/Optimizer/Dialect/Quake/QuakeOps.cpp @@ -49,35 +49,40 @@ Value quake::createConstantAlloca(PatternRewriter &builder, Location loc, loc, quake::VeqType::getUnsized(builder.getContext()), newAlloca); } -void quake::AllocaOp::getCanonicalizationPatterns(RewritePatternSet &patterns, - MLIRContext *context) { - patterns.add(context); -} - LogicalResult quake::AllocaOp::verify() { - auto resultType = dyn_cast(getResult().getType()); - if (auto size = getSize()) { - std::int64_t argSize = 0; - if (auto cnt = dyn_cast_or_null(size.getDefiningOp())) { - argSize = cnt.getValue().cast().getInt(); - // TODO: This is a questionable check. We could have a very large unsigned - // value that appears to be negative because of two's complement. On the - // other hand, allocating 2^64 - 1 qubits isn't going to go well. - if (argSize < 0) - return emitOpError("expected a non-negative integer size."); + // Result must be RefType or VeqType by construction. + if (auto resTy = dyn_cast(getResult().getType())) { + if (resTy.hasSpecifiedSize()) { + if (getSize()) + return emitOpError("unexpected size operand"); + } else { + if (auto size = getSize()) { + if (auto cnt = + dyn_cast_or_null(size.getDefiningOp())) { + std::int64_t argSize = cnt.getValue().cast().getInt(); + // TODO: This is a questionable check. We could have a very large + // unsigned value that appears to be negative because of two's + // complement. On the other hand, allocating 2^64 - 1 qubits isn't + // going to go well. + if (argSize < 0) + return emitOpError("expected a non-negative integer size."); + } + } else { + return emitOpError("size operand required"); + } } - if (!resultType) - return emitOpError( - "must return a vector of qubits since a size was provided."); - if (resultType.hasSpecifiedSize() && - (static_cast(argSize) != resultType.getSize())) - return emitOpError("expected operand size to match VeqType size."); - } else if (resultType && !resultType.hasSpecifiedSize()) { - return emitOpError("must return a veq with known size."); } return success(); } +void quake::AllocaOp::getCanonicalizationPatterns(RewritePatternSet &patterns, + MLIRContext *context) { + // Use a canonicalization pattern as folding the constant into the veq type + // changes the type. Uses may still expect a veq with unspecified size. + // Folding is strictly reductive and doesn't allow the creation of ops. + patterns.add(context); +} + //===----------------------------------------------------------------------===// // ExtractRef //===----------------------------------------------------------------------===// diff --git a/python/tests/compiler/adjoint.py b/python/tests/compiler/adjoint.py index 81eaf8ea78..eb840881ed 100644 --- a/python/tests/compiler/adjoint.py +++ b/python/tests/compiler/adjoint.py @@ -280,7 +280,7 @@ def test_sample_adjoint_qreg(): # CHECK-SAME: %[[VAL_0:.*]]: i32) { # CHECK: %[[VAL_1:.*]] = arith.constant 1 : index # CHECK: %[[VAL_2:.*]] = arith.constant 0 : index -# CHECK: %[[VAL_3:.*]] = quake.alloca[%[[VAL_0]] : i32] !quake.veq +# CHECK: %[[VAL_3:.*]] = quake.alloca !quake.veq[%[[VAL_0]] : i32] # CHECK: %[[VAL_4:.*]] = quake.vec_size %[[VAL_3]] : (!quake.veq) -> i64 # CHECK: %[[VAL_5:.*]] = arith.index_cast %[[VAL_4]] : i64 to index # CHECK: %[[VAL_6:.*]] = cc.loop while ((%[[VAL_7:.*]] = %[[VAL_2]]) -> (index)) { diff --git a/python/tests/compiler/qalloc.py b/python/tests/compiler/qalloc.py index 182228ad29..464e9ee858 100644 --- a/python/tests/compiler/qalloc.py +++ b/python/tests/compiler/qalloc.py @@ -83,7 +83,7 @@ def test_kernel_qalloc_quake_val(): # CHECK-LABEL: func.func @__nvqpp__mlirgen____nvqppBuilderKernel_{{.*}}( # CHECK-SAME: %[[VAL_0:.*]]: i32) { -# CHECK: %[[VAL_1:.*]] = quake.alloca[%[[VAL_0]] : i32] !quake.veq +# CHECK: %[[VAL_1:.*]] = quake.alloca !quake.veq[%[[VAL_0]] : i32] # CHECK: return # CHECK: } diff --git a/test/AST-Quake/adjoint-1.cpp b/test/AST-Quake/adjoint-1.cpp index 9bd77ec587..30fa687694 100644 --- a/test/AST-Quake/adjoint-1.cpp +++ b/test/AST-Quake/adjoint-1.cpp @@ -33,8 +33,7 @@ struct ep { }; // CHECK-LABEL: func.func @__nvqpp__mlirgen__ep() -// CHECK: %[[VAL_2:.*]] = arith.constant 3 : i64 -// CHECK: %[[VAL_3:.*]] = quake.alloca[%[[VAL_2]] : i64] !quake.veq<3> +// CHECK: %[[VAL_3:.*]] = quake.alloca !quake.veq<3> // CHECK: %[[VAL_4:.*]] = quake.relax_size %[[VAL_3]] : (!quake.veq<3>) -> !quake.veq // CHECK: quake.apply @__nvqpp__mlirgen__k %[[VAL_4]] : (!quake.veq) -> () // CHECK: return diff --git a/test/AST-Quake/adjoint-3.cpp b/test/AST-Quake/adjoint-3.cpp index a5671b5cbf..7446fb7e3c 100644 --- a/test/AST-Quake/adjoint-3.cpp +++ b/test/AST-Quake/adjoint-3.cpp @@ -48,7 +48,7 @@ struct QernelZero { // CHECK-LABEL: func.func @__nvqpp__mlirgen__run_circuit // CHECK-SAME: (%{{.*}}: i32, %{{.*}}: i32, %{{.*}}: f64) // CHECK: %[[VAL_5:.*]] = memref.alloca() : memref -// CHECK: %[[VAL_10:.*]] = quake.alloca[%{{.*}} : i64] !quake.veq +// CHECK: %[[VAL_10:.*]] = quake.alloca !quake.veq[%{{.*}} : i64] // CHECK: %[[VAL_16:.*]] = memref.load %[[VAL_5]][] : memref // CHECK: call @__nvqpp__mlirgen__statePrep_A{{.*}}(%[[VAL_10]], %[[VAL_16]]) : (!quake.veq, f64) -> () // CHECK: cc.scope { diff --git a/test/AST-Quake/callable-1.cpp b/test/AST-Quake/callable-1.cpp index 9f3ea76230..8f3f4055fe 100644 --- a/test/AST-Quake/callable-1.cpp +++ b/test/AST-Quake/callable-1.cpp @@ -48,7 +48,7 @@ int main() { // CHECK-SAME: (%[[VAL_0:.*]]: !cc.lambda<(!quake.veq) -> ()>) attributes {{{.*}}"cudaq-entrypoint"{{.*}}} { // CHECK: %[[VAL_1:.*]] = arith.constant 2 : i32 // CHECK: %[[VAL_2:.*]] = arith.extsi %[[VAL_1]] : i32 to i64 -// CHECK: %[[VAL_3:.*]] = quake.alloca[%[[VAL_2]] : i64] !quake.veq +// CHECK: %[[VAL_3:.*]] = quake.alloca !quake.veq[%[[VAL_2]] : i64] // CHECK: call @__nvqpp__mlirgen__Z4mainE3$_0(%[[VAL_3]]) : (!quake.veq) -> () // CHECK: return // CHECK: } diff --git a/test/AST-Quake/compute_action-2.cpp b/test/AST-Quake/compute_action-2.cpp index 18e59b28e6..dc8ef8a954 100644 --- a/test/AST-Quake/compute_action-2.cpp +++ b/test/AST-Quake/compute_action-2.cpp @@ -72,7 +72,7 @@ struct ctrlHeisenberg { // CHECK: %[[VAL_2:.*]] = quake.alloca !quake.ref // CHECK: %[[VAL_3:.*]] = memref.load %[[VAL_1]][] : memref // CHECK: %[[VAL_4:.*]] = arith.extsi %[[VAL_3]] : i32 to i64 -// CHECK: %[[VAL_5:.*]] = quake.alloca[%[[VAL_4]] : i64] !quake.veq +// CHECK: %[[VAL_5:.*]] = quake.alloca !quake.veq[%[[VAL_4]] : i64] // CHECK: %[[VAL_6:.*]] = quake.concat %[[VAL_2]] : (!quake.ref) -> !quake.veq // CHECK: call @__nvqpp__mlirgen__function_magic_func.{{.*}}.ctrl(%[[VAL_6]], %[[VAL_5]]) : (!quake.veq, !quake.veq) -> () // CHECK: return diff --git a/test/AST-Quake/ctrl_vector.cpp b/test/AST-Quake/ctrl_vector.cpp index f168f1472b..1fbcc4ad6c 100644 --- a/test/AST-Quake/ctrl_vector.cpp +++ b/test/AST-Quake/ctrl_vector.cpp @@ -26,9 +26,9 @@ struct lower_ctrl_as_qreg { // CHECK-LABEL: func.func @__nvqpp__mlirgen__lower_ctrl_as_qreg // CHECK-SAME: () attributes {{{.*}}"cudaq-entrypoint"{{.*}}} { // CHECK: %[[VAL_0:.*]] = arith.constant 4 : i32 -// CHECK: %[[VAL_2:.*]] = quake.alloca[%{{.*}} : i64] !quake.veq +// CHECK: %[[VAL_2:.*]] = quake.alloca !quake.veq[%{{.*}} : i64] // CHECK: %[[VAL_3:.*]] = arith.constant 2 : i32 -// CHECK: %[[VAL_5:.*]] = quake.alloca[%{{.*}} : i64] !quake.veq +// CHECK: %[[VAL_5:.*]] = quake.alloca !quake.veq[%{{.*}} : i64] // CHECK: %[[VAL_6:.*]] = arith.constant 0 : i32 // CHECK: %[[VAL_8:.*]] = quake.extract_ref %[[VAL_5]][%{{.*}}] : (!quake.veq, i64) -> !quake.ref // CHECK: quake.h [%[[VAL_2]]] %[[VAL_8]] : (!quake.veq, !quake.ref) -> () @@ -60,7 +60,7 @@ struct test_two_control_call { // CHECK: } // CHECK: } : !cc.lambda<(!quake.ref) -> ()> // CHECK: %[[VAL_4:.*]] = arith.constant 4 : i64 -// CHECK: %[[VAL_5:.*]] = quake.alloca[%[[VAL_4]] : i64] !quake.veq<4> +// CHECK: %[[VAL_5:.*]] = quake.alloca !quake.veq<4> // CHECK: %[[VAL_6:.*]] = quake.alloca !quake.ref // CHECK: quake.apply @__nvqpp__mlirgen__{{.*}}test_two_control_call{{.*}}[%[[VAL_5]]] %[[VAL_6]] : (!quake.veq<4>, !quake.ref) -> () // CHECK: %[[VAL_7:.*]] = quake.mz %[[VAL_6]] : (!quake.ref) -> i1 diff --git a/test/AST-Quake/dealloc.cpp b/test/AST-Quake/dealloc.cpp index d042d19238..3e9db0f23e 100644 --- a/test/AST-Quake/dealloc.cpp +++ b/test/AST-Quake/dealloc.cpp @@ -21,11 +21,11 @@ __qpu__ void magic_func(int N) { // CHECK-LABEL: func.func @__nvqpp__mlirgen__function_magic_func // CHECK: cc.scope { -// CHECK: %[[VAL_4:.*]] = quake.alloca[%{{.*}} : i64] !quake.veq +// CHECK: %[[VAL_4:.*]] = quake.alloca !quake.veq[%{{.*}} : i64] // CHECK: quake.dealloc %[[VAL_4]] : !quake.veq // CHECK: cc.continue // CHECK: } -// CHECK: %[[VAL_10:.*]] = quake.alloca[%{{.*}} : i64] !quake.veq +// CHECK: %[[VAL_10:.*]] = quake.alloca !quake.veq[%{{.*}} : i64] // CHECK: quake.dealloc %[[VAL_10]] : !quake.veq // CHECK: return // CHECK: } diff --git a/test/AST-Quake/if.cpp b/test/AST-Quake/if.cpp index 23fdd6fc3c..87b5d6ff25 100644 --- a/test/AST-Quake/if.cpp +++ b/test/AST-Quake/if.cpp @@ -28,7 +28,7 @@ struct kernel { // CHECK: memref.store %[[VAL_0]], %[[VAL_1]][] : memref // CHECK: %[[VAL_2:.*]] = arith.constant 2 : i32 // CHECK: %[[VAL_3:.*]] = arith.extsi %[[VAL_2]] : i32 to i64 -// CHECK: %[[VAL_4:.*]] = quake.alloca[%[[VAL_3]] : i64] !quake.veq +// CHECK: %[[VAL_4:.*]] = quake.alloca !quake.veq[%[[VAL_3]] : i64] // CHECK: %[[VAL_5:.*]] = memref.load %[[VAL_1]][] : memref // CHECK: cc.if(%[[VAL_5]]) { // CHECK: cc.scope { @@ -63,7 +63,7 @@ struct kernel_else { // CHECK: memref.store %[[VAL_0]], %[[VAL_1]][] : memref // CHECK: %[[VAL_2:.*]] = arith.constant 2 : i32 // CHECK: %[[VAL_3:.*]] = arith.extsi %[[VAL_2]] : i32 to i64 -// CHECK: %[[VAL_4:.*]] = quake.alloca[%[[VAL_3]] : i64] !quake.veq +// CHECK: %[[VAL_4:.*]] = quake.alloca !quake.veq[%[[VAL_3]] : i64] // CHECK: %[[VAL_5:.*]] = memref.load %[[VAL_1]][] : memref // CHECK: cc.if(%[[VAL_5]]) { // CHECK: cc.scope { diff --git a/test/AST-Quake/lambda_instance.cpp b/test/AST-Quake/lambda_instance.cpp index a1c3faf71b..b17d493ac5 100644 --- a/test/AST-Quake/lambda_instance.cpp +++ b/test/AST-Quake/lambda_instance.cpp @@ -22,7 +22,7 @@ struct test0 { }; // CHECK-LABEL: func.func @__nvqpp__mlirgen__test0 -// CHECK: %[[VAL_2:.*]] = quake.alloca[%{{.*}} : i64] !quake.veq +// CHECK: %[[VAL_2:.*]] = quake.alloca !quake.veq[%{{.*}} : i64] // CHECK: %[[VAL_3:.*]] = cc.create_lambda { // CHECK: } : !cc.lambda<(!quake.ref) -> ()> // CHECK: %[[VAL_12:.*]] = quake.extract_ref %[[VAL_2]][%{{.*}}] : (!quake.veq, i64) -> !quake.ref @@ -46,15 +46,13 @@ struct test1 { }; // CHECK-LABEL: func.func @__nvqpp__mlirgen__test1 -// CHECK-SAME: () attributes {"cudaq-entrypoint", "cudaq-kernel"} { -// CHECK: %[[VAL_3:.*]] = quake.alloca[%{{.*}} : i64] !quake.veq<2> +// CHECK: %[[VAL_3:.*]] = quake.alloca !quake.veq<2> // CHECK: %[[VAL_4:.*]] = cc.create_lambda { // CHECK: } : !cc.lambda<(!quake.ref) -> ()> // CHECK: %[[VAL_13:.*]] = quake.extract_ref %[[VAL_3]][%{{.*}}] : (!quake.veq<2>, i64) -> !quake.ref // CHECK: %[[VAL_16:.*]] = quake.extract_ref %[[VAL_3]][%{{.*}}] : (!quake.veq<2>, i64) -> !quake.ref // CHECK: quake.apply @__nvqpp__mlirgen__{{.*}}5test1{{.*}}[%[[VAL_13]]] %[[VAL_16]] : (!quake.ref, !quake.ref) -> () // CHECK: return -// CHECK: } // CHECK-LABEL: func.func @__nvqpp__mlirgen__ // CHECK-SAME: 5test1 @@ -84,7 +82,7 @@ struct test2b { }; // CHECK-LABEL: func.func @__nvqpp__mlirgen__test2b -// CHECK: %[[VAL_2:.*]] = quake.alloca[%{{.*}} : i64] !quake.veq +// CHECK: %[[VAL_2:.*]] = quake.alloca !quake.veq[%{{.*}} : i64] // CHECK: %[[VAL_4:.*]] = cc.create_lambda { // CHECK: } : !cc.lambda<(!quake.ref) -> ()> // CHECK: call @__nvqpp__mlirgen__instance_test2a{{.*}}(%{{.*}}, %[[VAL_2]]) : (!cc.lambda<(!quake.ref) -> ()>, !quake.veq) -> () @@ -130,7 +128,7 @@ struct test2c { }; // CHECK-LABEL: func.func @__nvqpp__mlirgen__test2c -// CHECK: %[[VAL_2:.*]] = quake.alloca[%{{.*}} : i64] !quake.veq +// CHECK: %[[VAL_2:.*]] = quake.alloca !quake.veq[%{{.*}} : i64] // CHECK: %[[VAL_3:.*]] = cc.create_lambda { // CHECK: } : !cc.lambda<(!quake.ref) -> ()> // CHECK: call @__nvqpp__mlirgen__instance_test2a_c{{.*}}(%{{.*}}, %[[VAL_2]]) : (!cc.lambda<(!quake.ref) -> ()>, !quake.veq) -> () @@ -193,7 +191,7 @@ struct test3 { // CHECK-SAME: () attributes {"cudaq-entrypoint", "cudaq-kernel"} { // CHECK: %[[VAL_0:.*]] = arith.constant 2 : i32 // CHECK: %[[VAL_1:.*]] = arith.extsi %[[VAL_0]] : i32 to i64 -// CHECK: %[[VAL_2:.*]] = quake.alloca[%[[VAL_1]] : i64] !quake.veq +// CHECK: %[[VAL_2:.*]] = quake.alloca !quake.veq[%[[VAL_1]] : i64] // CHECK: %[[VAL_3:.*]] = cc.create_lambda { // CHECK: ^bb0(%[[VAL_4:.*]]: !quake.ref): // CHECK: cc.scope { diff --git a/test/AST-Quake/lambda_variable.cpp b/test/AST-Quake/lambda_variable.cpp index 780f89168a..37f4848f82 100644 --- a/test/AST-Quake/lambda_variable.cpp +++ b/test/AST-Quake/lambda_variable.cpp @@ -46,7 +46,7 @@ struct test3_caller { // CHECK-LABEL: func.func @__nvqpp__mlirgen__test3_caller // CHECK-SAME: () attributes { -// CHECK: %[[VAL_2:.*]] = quake.alloca[%{{.*}} : i64] !quake.veq +// CHECK: %[[VAL_2:.*]] = quake.alloca !quake.veq[%{{.*}} : i64] // CHECK: %[[VAL_4:.*]] = cc.create_lambda { // CHECK: ^bb0(%[[VAL_5:.*]]: !quake.ref): // CHECK: cc.scope { @@ -84,7 +84,7 @@ struct test4_caller { // CHECK-SAME: () attributes {"cudaq-entrypoint", "cudaq-kernel"} { // CHECK: %[[VAL_0:.*]] = arith.constant 2 : i32 // CHECK: %[[VAL_1:.*]] = arith.extsi %[[VAL_0]] : i32 to i64 -// CHECK: %[[VAL_2:.*]] = quake.alloca[%[[VAL_1]] : i64] !quake.veq +// CHECK: %[[VAL_2:.*]] = quake.alloca !quake.veq[%[[VAL_1]] : i64] // CHECK: %[[VAL_3:.*]] = cc.undef !llvm.struct<"test4_callee", ()> // CHECK: %[[VAL_4:.*]] = cc.create_lambda { // CHECK: ^bb0(%[[VAL_5:.*]]: !quake.ref): diff --git a/test/AST-Quake/measure_bell.cpp b/test/AST-Quake/measure_bell.cpp index cde716e26a..b64733ec04 100644 --- a/test/AST-Quake/measure_bell.cpp +++ b/test/AST-Quake/measure_bell.cpp @@ -34,7 +34,7 @@ int main() { bell{}(100); } // CHECK: memref.store %[[VAL_0]], %[[VAL_1]][] : memref // CHECK: %[[VAL_2:.*]] = arith.constant 2 : i32 // CHECK: %[[VAL_3:.*]] = arith.extsi %[[VAL_2]] : i32 to i64 -// CHECK: %[[VAL_4:.*]] = quake.alloca[%[[VAL_3]] : i64] !quake.veq +// CHECK: %[[VAL_4:.*]] = quake.alloca !quake.veq[%[[VAL_3]] : i64] // CHECK: %[[VAL_5:.*]] = arith.constant 0 : i32 // CHECK: %[[VAL_6:.*]] = memref.alloca() : memref // CHECK: memref.store %[[VAL_5]], %[[VAL_6]][] : memref @@ -135,7 +135,7 @@ struct tinkerbell { // CHECK: memref.store %[[VAL_0]], %[[VAL_1]][] : memref // CHECK: %[[VAL_2:.*]] = arith.constant 2 : i32 // CHECK: %[[VAL_3:.*]] = arith.extsi %[[VAL_2]] : i32 to i64 -// CHECK: %[[VAL_4:.*]] = quake.alloca[%[[VAL_3]] : i64] !quake.veq +// CHECK: %[[VAL_4:.*]] = quake.alloca !quake.veq[%[[VAL_3]] : i64] // CHECK: %[[VAL_5:.*]] = arith.constant 0 : i32 // CHECK: %[[VAL_6:.*]] = memref.alloca() : memref // CHECK: memref.store %[[VAL_5]], %[[VAL_6]][] : memref @@ -199,7 +199,7 @@ struct tinkerbell { // CHECK: memref.store %[[VAL_0]], %[[VAL_1]][] : memref // CHECK: %[[VAL_2:.*]] = arith.constant 2 : i32 // CHECK: %[[VAL_3:.*]] = arith.extsi %[[VAL_2]] : i32 to i64 -// CHECK: %[[VAL_4:.*]] = quake.alloca[%[[VAL_3]] : i64] !quake.veq +// CHECK: %[[VAL_4:.*]] = quake.alloca !quake.veq[%[[VAL_3]] : i64] // CHECK: %[[VAL_5:.*]] = arith.constant 0 : i32 // CHECK: %[[VAL_6:.*]] = memref.alloca() : memref // CHECK: memref.store %[[VAL_5]], %[[VAL_6]][] : memref diff --git a/test/AST-Quake/mz.cpp b/test/AST-Quake/mz.cpp index 3b0404c5ce..03fe022a89 100644 --- a/test/AST-Quake/mz.cpp +++ b/test/AST-Quake/mz.cpp @@ -21,7 +21,7 @@ struct S { // CHECK-LABEL: func.func @__nvqpp__mlirgen__S() attributes // CHECK: %[[VAL_0:.*]] = arith.constant 20 : i32 // CHECK: %[[VAL_1:.*]] = arith.extsi %[[VAL_0]] : i32 to i64 -// CHECK: %[[VAL_2:.*]] = quake.alloca[%[[VAL_1]] : i64] !quake.veq +// CHECK: %[[VAL_2:.*]] = quake.alloca !quake.veq[%[[VAL_1]] : i64] // CHECK: %[[VAL_18:.*]] = quake.mz %[[VAL_2]] : (!quake.veq) -> !cc.stdvec // CHECK: return // CHECK: } @@ -41,10 +41,10 @@ struct VectorOfStaticVeq { // CHECK: %[[VAL_0:.*]] = quake.alloca !quake.ref // CHECK: %[[VAL_1:.*]] = arith.constant 4 : i32 // CHECK: %[[VAL_2:.*]] = arith.extsi %[[VAL_1]] : i32 to i64 -// CHECK: %[[VAL_3:.*]] = quake.alloca[%[[VAL_2]] : i64] !quake.veq +// CHECK: %[[VAL_3:.*]] = quake.alloca !quake.veq[%[[VAL_2]] : i64] // CHECK: %[[VAL_4:.*]] = arith.constant 2 : i32 // CHECK: %[[VAL_5:.*]] = arith.extsi %[[VAL_4]] : i32 to i64 -// CHECK: %[[VAL_6:.*]] = quake.alloca[%[[VAL_5]] : i64] !quake.veq +// CHECK: %[[VAL_6:.*]] = quake.alloca !quake.veq[%[[VAL_5]] : i64] // CHECK: %[[VAL_7:.*]] = quake.alloca !quake.ref // CHECK: %[[VAL_8:.*]] = quake.mz %[[VAL_0]], %[[VAL_3]], %[[VAL_6]], %[[VAL_7]] : (!quake.ref, !quake.veq, !quake.veq, !quake.ref) -> !cc.stdvec // CHECK: %[[VAL_9:.*]] = cc.stdvec_data %[[VAL_8]] : (!cc.stdvec) -> !llvm.ptr @@ -74,10 +74,10 @@ struct VectorOfDynamicVeq { // CHECK: %[[VAL_4:.*]] = quake.alloca !quake.ref // CHECK: %[[VAL_5:.*]] = memref.load %[[VAL_2]][] : memref // CHECK: %[[VAL_6:.*]] = arith.extui %[[VAL_5]] : i32 to i64 -// CHECK: %[[VAL_7:.*]] = quake.alloca[%[[VAL_6]] : i64] !quake.veq +// CHECK: %[[VAL_7:.*]] = quake.alloca !quake.veq[%[[VAL_6]] : i64] // CHECK: %[[VAL_8:.*]] = memref.load %[[VAL_3]][] : memref // CHECK: %[[VAL_9:.*]] = arith.extui %[[VAL_8]] : i32 to i64 -// CHECK: %[[VAL_10:.*]] = quake.alloca[%[[VAL_9]] : i64] !quake.veq +// CHECK: %[[VAL_10:.*]] = quake.alloca !quake.veq[%[[VAL_9]] : i64] // CHECK: %[[VAL_11:.*]] = quake.alloca !quake.ref // CHECK: %[[VAL_12:.*]] = quake.mz %[[VAL_4]], %[[VAL_7]], %[[VAL_10]], %[[VAL_11]] : (!quake.ref, !quake.veq, !quake.veq, !quake.ref) -> !cc.stdvec // CHECK: %[[VAL_13:.*]] = cc.stdvec_data %[[VAL_12]] : (!cc.stdvec) -> !llvm.ptr diff --git a/test/AST-Quake/negation.cpp b/test/AST-Quake/negation.cpp index efaf652f29..7bcf6005d0 100644 --- a/test/AST-Quake/negation.cpp +++ b/test/AST-Quake/negation.cpp @@ -21,7 +21,7 @@ struct NegationOperatorTest { // CHECK-SAME: () attributes {"cudaq-entrypoint", "cudaq-kernel"} { // CHECK: %[[VAL_0:.*]] = arith.constant 3 : i32 // CHECK: %[[VAL_1:.*]] = arith.extsi %[[VAL_0]] : i32 to i64 -// CHECK: %[[VAL_2:.*]] = quake.alloca[%[[VAL_1]] : i64] !quake.veq +// CHECK: %[[VAL_2:.*]] = quake.alloca !quake.veq[%[[VAL_1]] : i64] // CHECK: %[[VAL_3:.*]] = arith.constant 0 : i32 // CHECK: %[[VAL_4:.*]] = arith.extsi %[[VAL_3]] : i32 to i64 // CHECK: %[[VAL_5:.*]] = quake.extract_ref %[[VAL_2]][%[[VAL_4]]] : (!quake.veq, i64) -> !quake.ref diff --git a/test/AST-Quake/passQregNToQSpan.cpp b/test/AST-Quake/passQregNToQSpan.cpp index 82829ef007..f2eb1683d0 100644 --- a/test/AST-Quake/passQregNToQSpan.cpp +++ b/test/AST-Quake/passQregNToQSpan.cpp @@ -27,8 +27,7 @@ struct entry { // CHECK: } // CHECK-LABEL: func.func @__nvqpp__mlirgen__entry() attributes {"cudaq-entrypoint", "cudaq-kernel"} { -// CHECK: %[[VAL_0:.*]] = arith.constant 3 : i64 -// CHECK: %[[VAL_1:.*]] = quake.alloca[%[[VAL_0]] : i64] !quake.veq<3> +// CHECK: %[[VAL_1:.*]] = quake.alloca !quake.veq<3> // CHECK: %[[VAL_2:.*]] = quake.relax_size %[[VAL_1]] : (!quake.veq<3>) -> !quake.veq // CHECK: call @__nvqpp__mlirgen__function_mcx._Z3mcxN5cudaq5qspan{{.*}}(%[[VAL_2]]) : (!quake.veq) -> () // CHECK: return diff --git a/test/AST-Quake/qpe.cpp b/test/AST-Quake/qpe.cpp index 8f01a6df71..baf843a777 100644 --- a/test/AST-Quake/qpe.cpp +++ b/test/AST-Quake/qpe.cpp @@ -276,7 +276,7 @@ int main() { // CHECK: %[[VAL_7:.*]] = memref.load %[[VAL_5]][] : memref // CHECK: %[[VAL_8:.*]] = arith.addi %[[VAL_6]], %[[VAL_7]] : i32 // CHECK: %[[VAL_9:.*]] = arith.extsi %[[VAL_8]] : i32 to i64 -// CHECK: %[[VAL_10:.*]] = quake.alloca[%[[VAL_9]] : i64] !quake.veq +// CHECK: %[[VAL_10:.*]] = quake.alloca !quake.veq[%[[VAL_9]] : i64] // CHECK: %[[VAL_11:.*]] = memref.load %[[VAL_4]][] : memref // CHECK: %[[VAL_12:.*]] = arith.extsi %[[VAL_11]] : i32 to i64 // CHECK: %[[VAL_13:.*]] = arith.constant 0 : i64 diff --git a/test/AST-Quake/simple_qarray.cpp b/test/AST-Quake/simple_qarray.cpp index 28920cf34b..e2508079ca 100644 --- a/test/AST-Quake/simple_qarray.cpp +++ b/test/AST-Quake/simple_qarray.cpp @@ -47,8 +47,7 @@ int main() { // CHECK-LABEL: func.func @__nvqpp__mlirgen__ghz // CHECK-SAME: () -// CHECK: %[[VAL_2:.*]] = arith.constant 5 : i64 -// CHECK: %[[VAL_3:.*]] = quake.alloca[%[[VAL_2]] : i64] !quake.veq<5> +// CHECK: %[[VAL_3:.*]] = quake.alloca !quake.veq<5> // CHECK: %[[VAL_6:.*]] = arith.constant 0 : i32 // CHECK: %[[VAL_7:.*]] = arith.extsi %[[VAL_6]] : i32 to i64 // CHECK: %[[VAL_8:.*]] = quake.extract_ref %[[VAL_3]]{{\[}}%[[VAL_7]]] : (!quake.veq<5>, i64) -> !quake.ref diff --git a/test/AST-Quake/slice.cpp b/test/AST-Quake/slice.cpp index 4a39daa2dc..b1bfbb5969 100644 --- a/test/AST-Quake/slice.cpp +++ b/test/AST-Quake/slice.cpp @@ -24,7 +24,7 @@ struct SliceTest { // CHECK-SAME: (%[[VAL_0:.*]]: i32, %[[VAL_1:.*]]: i32) attributes { // CHECK: %[[VAL_4:.*]] = arith.constant 10 : i32 // CHECK: %[[VAL_5:.*]] = arith.extsi %[[VAL_4]] : i32 to i64 -// CHECK: %[[VAL_6:.*]] = quake.alloca[%[[VAL_5]] : i64] !quake.veq +// CHECK: %[[VAL_6:.*]] = quake.alloca !quake.veq[%[[VAL_5]] : i64] // CHECK: %[[VAL_11:.*]] = arith.constant 1 : i64 // CHECK: %[[VAL_12:.*]] = arith.addi %{{.*}}, %{{.*}} : i64 // CHECK: %[[VAL_13:.*]] = arith.subi %[[VAL_12]], %[[VAL_11]] : i64 diff --git a/test/AST-Quake/template_lambda.cpp b/test/AST-Quake/template_lambda.cpp index 9f448567a6..2fd5b7c29a 100644 --- a/test/AST-Quake/template_lambda.cpp +++ b/test/AST-Quake/template_lambda.cpp @@ -34,7 +34,7 @@ int main() { // CHECK-LABEL: func.func @__nvqpp__mlirgen__instance_test // CHECK-SAME: (%[[VAL_0:.*]]: !cc.lambda<(!quake.ref) -> ()>) // CHECK-NOT: %[[VAL_0]] -// CHECK: %[[VAL_3:.*]] = quake.alloca[%{{.*}} : i64] !quake.veq +// CHECK: %[[VAL_3:.*]] = quake.alloca !quake.veq[%{{.*}} : i64] // CHECK: %[[VAL_6:.*]] = quake.extract_ref %{{.*}} : (!quake.veq, i64) -> !quake.ref // CHECK: %[[VAL_9:.*]] = quake.extract_ref %{{.*}} : (!quake.veq, i64) -> !quake.ref // CHECK: quake.apply @__nvqpp__mlirgen__Z4mainE3$_0[%[[VAL_6]]] %[[VAL_9]] : (!quake.ref, !quake.ref) -> () diff --git a/test/Quake-QIR/base-profile-2.qke b/test/Quake-QIR/base-profile-2.qke index c9bd0acfbe..efb0c4a3d9 100644 --- a/test/Quake-QIR/base-profile-2.qke +++ b/test/Quake-QIR/base-profile-2.qke @@ -13,7 +13,7 @@ module attributes {quake.mangled_name_map = {__nvqpp__mlirgen__t1 = "_ZN2t1clEv" %c2_i32 = arith.constant 2 : i32 %0 = arith.extsi %c2_i32 : i32 to i64 %c2_i64 = arith.constant 2 : i64 - %1 = quake.alloca [%c2_i64 : i64] !quake.veq<2> + %1 = quake.alloca !quake.veq<2> %c1_i32 = arith.constant 1 : i32 %2 = arith.extsi %c1_i32 : i32 to i64 %3 = quake.extract_ref %1[%2] : (!quake.veq<2>,i64) -> !quake.ref diff --git a/test/Quake-QIR/base-profile-3.qke b/test/Quake-QIR/base-profile-3.qke index 7c1342b7be..4c781ee4e9 100644 --- a/test/Quake-QIR/base-profile-3.qke +++ b/test/Quake-QIR/base-profile-3.qke @@ -13,7 +13,7 @@ module attributes {quake.mangled_name_map = {__nvqpp__mlirgen__t1 = "_ZN2t1clEv" %c2_i32 = arith.constant 2 : i32 %0 = arith.extsi %c2_i32 : i32 to i64 %c2_i64 = arith.constant 2 : i64 - %1 = quake.alloca[%c2_i64 : i64] !quake.veq<2> + %1 = quake.alloca !quake.veq<2> %c1_i32 = arith.constant 1 : i32 %2 = arith.extsi %c1_i32 : i32 to i64 %3 = quake.extract_ref %1[%2] : (!quake.veq<2>,i64) -> !quake.ref diff --git a/test/Quake-QIR/basic.qke b/test/Quake-QIR/basic.qke index d9ef836904..372662baff 100644 --- a/test/Quake-QIR/basic.qke +++ b/test/Quake-QIR/basic.qke @@ -36,9 +36,9 @@ module { func.func @test_func(%p : i32) { - %qv = quake.alloca [%p : i32] !quake.veq + %qv = quake.alloca !quake.veq[%p : i32] %t = arith.constant 2 : i32 - %v = quake.alloca [%t : i32] !quake.veq + %v = quake.alloca !quake.veq[%t : i32] return } @@ -48,10 +48,10 @@ module { %one = arith.constant 1 : i32 %neg = arith.constant -5 : i32 %two = arith.constant 2 : i32 - %0 = quake.alloca [%two : i32] !quake.veq + %0 = quake.alloca !quake.veq[%two : i32] - %1 = quake.alloca [%two : i32] !quake.veq<2> - %2 = quake.alloca [%one : i32] !quake.veq + %1 = quake.alloca !quake.veq<2> + %2 = quake.alloca !quake.veq[%one : i32] %qr1 = quake.extract_ref %0[%zero] : (!quake.veq,i32) -> !quake.ref %qr2 = quake.extract_ref %1[%one] : (!quake.veq<2>,i32) -> !quake.ref diff --git a/test/Quake-QIR/ghz.qke b/test/Quake-QIR/ghz.qke index 3fedb781cb..a60e0dba5b 100644 --- a/test/Quake-QIR/ghz.qke +++ b/test/Quake-QIR/ghz.qke @@ -39,7 +39,7 @@ module { func.func @ghz(%arg0 : i32) { %c0 = arith.constant 0 : i32 %one = arith.constant 1 : i32 - %q = quake.alloca [%arg0 : i32] !quake.veq + %q = quake.alloca !quake.veq[%arg0 : i32] %q0 = quake.extract_ref %q [%c0] : (!quake.veq,i32) -> !quake.ref quake.h %q0 : (!quake.ref) -> () %size_m_1 = arith.subi %arg0, %one : i32 diff --git a/test/Quake-QIR/measure.qke b/test/Quake-QIR/measure.qke index f56d65c0d6..1860fccc59 100644 --- a/test/Quake-QIR/measure.qke +++ b/test/Quake-QIR/measure.qke @@ -13,7 +13,7 @@ module { %zero = arith.constant 0 : i32 %one = arith.constant 1 : i32 %two = arith.constant 2 : i32 - %0 = quake.alloca [%two : i32] !quake.veq + %0 = quake.alloca !quake.veq[%two : i32] %qr1 = quake.extract_ref %0[%zero] : (!quake.veq,i32) -> !quake.ref %qr2 = quake.extract_ref %0[%one] : (!quake.veq,i32) -> !quake.ref diff --git a/test/Quake-QIR/testBaseProfile.qke b/test/Quake-QIR/testBaseProfile.qke index 7fa779e713..8fdaf58918 100644 --- a/test/Quake-QIR/testBaseProfile.qke +++ b/test/Quake-QIR/testBaseProfile.qke @@ -29,7 +29,7 @@ module { %c0_i32 = arith.constant 0 : i32 %c0 = arith.constant 0 : index %c3_i32 = arith.constant 3 : i32 - %0 = quake.alloca[%c3_i32 : i32] !quake.veq<3> + %0 = quake.alloca !quake.veq<3> %1 = quake.extract_ref %0[%c0_i32] : (!quake.veq<3>,i32) -> !quake.ref quake.h %1 : (!quake.ref) -> () %2 = quake.extract_ref %0[%c0] : (!quake.veq<3>, index) -> !quake.ref diff --git a/test/Quake/basic.qke b/test/Quake/basic.qke index cf16f5d6a9..0e00b865fd 100644 --- a/test/Quake/basic.qke +++ b/test/Quake/basic.qke @@ -13,8 +13,8 @@ func.func @alloc(%size : i32) { // CHECK: %[[QUBIT:.*]] = quake.alloca !quake.ref %qubit = quake.alloca !quake.ref - // CHECK: %[[QREG0:.*]] = quake.alloca[%[[SIZE]] : i32] !quake.veq - %veq0 = quake.alloca [%size : i32] !quake.veq + // CHECK: %[[QREG0:.*]] = quake.alloca !quake.veq[%[[SIZE]] : i32] + %veq0 = quake.alloca !quake.veq[%size : i32] // CHECK: %[[QREG1:.*]] = quake.alloca !quake.veq<4> %veq1 = quake.alloca !quake.veq<4> return diff --git a/test/Quake/bell.qke b/test/Quake/bell.qke index 6af212bc58..7a66c30441 100644 --- a/test/Quake/bell.qke +++ b/test/Quake/bell.qke @@ -21,7 +21,7 @@ module { %0 = arith.constant 2 : i32 %c_0 = arith.constant 0 : i32 %c_1 = arith.constant 1 : i32 - %qubits = quake.alloca [%0 : i32] !quake.veq + %qubits = quake.alloca !quake.veq[%0 : i32] %q0 = quake.extract_ref %qubits[%c_0] : (!quake.veq,i32) -> !quake.ref %q1 = quake.extract_ref %qubits[%c_1] : (!quake.veq,i32) -> !quake.ref diff --git a/test/Quake/canonical-1.qke b/test/Quake/canonical-1.qke index 07258985ae..afef8ad538 100644 --- a/test/Quake/canonical-1.qke +++ b/test/Quake/canonical-1.qke @@ -15,7 +15,7 @@ func.func @test1(%arg0 : !quake.veq) -> i1 { func.func @test2() { %0 = arith.constant 10 : i64 - %1 = quake.alloca[%0 : i64] !quake.veq + %1 = quake.alloca !quake.veq[%0 : i64] // relax_size must be inserted here %2 = call @test1(%1) : (!quake.veq) -> i1 %3 = arith.constant 1 : i64 @@ -35,7 +35,7 @@ func.func @test2() { func.func @test3() { %0 = arith.constant 10 : i64 - %1 = quake.alloca [%0 : i64] !quake.veq + %1 = quake.alloca !quake.veq[%0 : i64] %2 = arith.constant 4 : i64 %3 = arith.constant 7 : i64 // This subvec veq can be reified to veq<4> @@ -59,7 +59,7 @@ func.func @test3() { func.func @test_qextract_1() { %c0 = arith.constant 0 : i64 %c2 = arith.constant 2 : i64 - %veq = quake.alloca [%c2 : i64] !quake.veq + %veq = quake.alloca !quake.veq[%c2 : i64] %0 = quake.extract_ref %veq[%c0] : (!quake.veq, i64) -> !quake.ref quake.h %0 : (!quake.ref) -> () %c0_0 = arith.constant 0 : i64 @@ -83,7 +83,7 @@ func.func @test_qextract_2(%arg0: i1) { %c0 = arith.constant 0 : i64 %c2 = arith.constant 2 : i64 %c1 = arith.constant 1 : i64 - %veq = quake.alloca[%c2 : i64] !quake.veq + %veq = quake.alloca !quake.veq[%c2 : i64] %0 = quake.extract_ref %veq[%c0] : (!quake.veq,i64) -> !quake.ref quake.h %0 : (!quake.ref) -> () cc.if(%arg0) { diff --git a/test/Quake/ccnot.qke b/test/Quake/ccnot.qke index 05022d1114..7dcf6fee1a 100644 --- a/test/Quake/ccnot.qke +++ b/test/Quake/ccnot.qke @@ -37,7 +37,7 @@ module { %c_0 = arith.constant 0 : i32 %c_1 = arith.constant 1 : i32 %c_2 = arith.constant 2 : i32 - %qubits = quake.alloca [ %c_3 : i32 ] !quake.veq + %qubits = quake.alloca !quake.veq [ %c_3 : i32 ] %c_3_idx = arith.index_cast %c_3 : i32 to index affine.for %i = 0 to %c_3_idx { %q0 = quake.extract_ref %qubits [%i] : (!quake.veq, index) -> !quake.ref diff --git a/test/Quake/compute_action.qke b/test/Quake/compute_action.qke index a709c0d013..1c0518f44a 100644 --- a/test/Quake/compute_action.qke +++ b/test/Quake/compute_action.qke @@ -20,7 +20,7 @@ module attributes {quake.mangled_name_map = {__nvqpp__mlirgen__t = "_Z1tv"}} { func.func @__nvqpp__mlirgen__t() attributes {"cudaq-entrypoint"} { %c5_i32 = arith.constant 5 : i32 %0 = arith.extsi %c5_i32 : i32 to i64 - %1 = quake.alloca[%0 : i64] !quake.veq + %1 = quake.alloca !quake.veq[%0 : i64] %2 = cc.create_lambda { cc.scope { %c0_i32 = arith.constant 0 : i32 diff --git a/test/Quake/deuteron.qke b/test/Quake/deuteron.qke index 6e82e48445..b3af4cb512 100644 --- a/test/Quake/deuteron.qke +++ b/test/Quake/deuteron.qke @@ -27,7 +27,7 @@ module { %c_0 = arith.constant 0 : i32 %c_1 = arith.constant 1 : i32 %c_angle = arith.constant 0.59 : f64 - %qubits = quake.alloca [ %0 : i32 ] !quake.veq + %qubits = quake.alloca !quake.veq[ %0 : i32 ] %q0 = quake.extract_ref %qubits [%c_0] : (!quake.veq,i32) -> !quake.ref %q1 = quake.extract_ref %qubits [%c_1] : (!quake.veq,i32) -> !quake.ref diff --git a/test/Quake/dummy.qke b/test/Quake/dummy.qke index 2e20237116..7038ea33ba 100644 --- a/test/Quake/dummy.qke +++ b/test/Quake/dummy.qke @@ -13,9 +13,9 @@ // CHECK-DAG: %[[C2:.*]] = arith.constant 2 : i32 // CHECK-DAG: %[[C1:.*]] = arith.constant 1 : i32 // CHECK-DAG: %[[C22:.*]] = arith.constant 22 : i64 -// CHECK: %0 = quake.alloca[%[[C2]] : i32] !quake.veq -// CHECK: %1 = quake.alloca[%[[C22]] : i64] !quake.veq -// CHECK: %2 = quake.alloca[%[[C1]] : i32] !quake.veq +// CHECK: %0 = quake.alloca !quake.veq[%[[C2]] : i32] +// CHECK: %1 = quake.alloca !quake.veq[%[[C22]] : i64] +// CHECK: %2 = quake.alloca !quake.veq[%[[C1]] : i32] // CHECK: %3 = quake.extract_ref %0[%[[C0]]] : (!quake.veq, i32) -> !quake.ref // CHECK: %4 = quake.extract_ref %1[%[[C1]]] : (!quake.veq, i32) -> !quake.ref // CHECK: quake.h %3 : @@ -27,9 +27,9 @@ func.func @bar() { %0 = arith.constant 2 : i32 %one = arith.constant 1 : i32 %1 = arith.constant 22 : i64 - %qr2 = quake.alloca [ %0 : i32 ] !quake.veq - %qr22 = quake.alloca[ %1 : i64 ] !quake.veq - %q = quake.alloca [%one : i32] !quake.veq + %qr2 = quake.alloca !quake.veq[%0 : i32] + %qr22 = quake.alloca !quake.veq[%1 : i64] + %q = quake.alloca !quake.veq[%one : i32] %r = quake.extract_ref %qr2[%3] : (!quake.veq,i32) -> !quake.ref %q1 = quake.extract_ref %qr22[%one] : (!quake.veq ,i32) -> !quake.ref diff --git a/test/Quake/ghz.qke b/test/Quake/ghz.qke index 47a9739efe..3e8e55b3c2 100644 --- a/test/Quake/ghz.qke +++ b/test/Quake/ghz.qke @@ -10,7 +10,7 @@ module { // CHECK: func.func @ghz(%[[arg0:.*]]: i32) { // CHECK: %[[C1:.*]] = arith.constant 1 : i32 - // CHECK: %0 = quake.alloca[%[[arg0]] : i32] !quake.veq + // CHECK: %0 = quake.alloca !quake.veq[%[[arg0]] : i32] // CHECK: %1 = quake.extract_ref %0[0] : (!quake.veq) -> !quake.ref // CHECK: quake.h %1 : // CHECK: %2 = arith.subi %arg0, %[[C1]] : i32 @@ -28,7 +28,7 @@ module { // %size = arith.constant 3 : i32 %c0 = arith.constant 0 : i32 %one = arith.constant 1 : i32 - %q = quake.alloca [%arg0 : i32] !quake.veq + %q = quake.alloca !quake.veq[%arg0 : i32] %q0 = quake.extract_ref %q[%c0] : (!quake.veq, i32) -> !quake.ref quake.h %q0 : (!quake.ref) -> () %size_m_1 = arith.subi %arg0, %one : i32 diff --git a/test/Quake/kernel_exec.qke b/test/Quake/kernel_exec.qke index 06ae5a069c..d2f00f1d47 100644 --- a/test/Quake/kernel_exec.qke +++ b/test/Quake/kernel_exec.qke @@ -17,7 +17,7 @@ module attributes {quake.mangled_name_map = {__nvqpp__mlirgen__ghz = "_ZN3ghzclE memref.store %arg0, %0[] : memref %1 = memref.load %0[] : memref %2 = arith.extsi %1 : i32 to i64 - %3 = quake.alloca[%2 : i64] !quake.veq + %3 = quake.alloca !quake.veq[%2 : i64] %c0_i32 = arith.constant 0 : i32 %4 = arith.extsi %c0_i32 : i32 to i64 %5 = quake.extract_ref %3[%4] : (!quake.veq,i64) -> !quake.ref diff --git a/test/Quake/lambda_kernel_exec.qke b/test/Quake/lambda_kernel_exec.qke index 970563ce8f..859c7ca980 100644 --- a/test/Quake/lambda_kernel_exec.qke +++ b/test/Quake/lambda_kernel_exec.qke @@ -18,7 +18,7 @@ module attributes {quake.mangled_name_map = {__nvqpp__mlirgen__lambda.main.canHa func.func @__nvqpp__mlirgen__lambda.main.test() attributes {"cudaq-entrypoint"} { %c2_i32 = arith.constant 2 : i32 %0 = arith.extsi %c2_i32 : i32 to i64 - %1 = quake.alloca[%0 : i64] !quake.veq + %1 = quake.alloca !quake.veq[%0 : i64] %c0_i32 = arith.constant 0 : i32 %2 = arith.extsi %c0_i32 : i32 to i64 %3 = quake.extract_ref %1[%2] : (!quake.veq,i64) -> !quake.ref @@ -52,7 +52,7 @@ module attributes {quake.mangled_name_map = {__nvqpp__mlirgen__lambda.main.canHa func.func @__nvqpp__mlirgen__lambda.main.canHaveMultiple() attributes {"cudaq-entrypoint"} { %c2_i32 = arith.constant 2 : i32 %0 = arith.extsi %c2_i32 : i32 to i64 - %1 = quake.alloca[%0 : i64] !quake.veq + %1 = quake.alloca !quake.veq[%0 : i64] %c0_i32 = arith.constant 0 : i32 %2 = arith.extsi %c0_i32 : i32 to i64 %3 = quake.extract_ref %1[%2] : (!quake.veq,i64) -> !quake.ref diff --git a/test/Quake/lambda_variable-1.qke b/test/Quake/lambda_variable-1.qke index 889cfbedf0..eea7f6d162 100644 --- a/test/Quake/lambda_variable-1.qke +++ b/test/Quake/lambda_variable-1.qke @@ -26,7 +26,7 @@ module attributes{ qtx.mangled_name_map = { __nvqpp__mlirgen__test3_callee = "_Z func.func @__nvqpp__mlirgen__test3_caller() attributes {"cudaq-entrypoint", "cudaq-kernel"} { %c2_i32 = arith.constant 2 : i32 %0 = arith.extsi %c2_i32 : i32 to i64 - %1 = quake.alloca[%0 : i64] !quake.veq + %1 = quake.alloca !quake.veq [%0 : i64] %2 = cc.undef !llvm.struct<"test3_callee", ()> %3 = cc.create_lambda { ^bb0(%arg0: !quake.ref): diff --git a/test/Quake/mz.qke b/test/Quake/mz.qke index b3cd8e6b0c..f2d9a3f3d6 100644 --- a/test/Quake/mz.qke +++ b/test/Quake/mz.qke @@ -28,8 +28,8 @@ func.func @static.mz_test() { func.func @dynamic.mz_test(%arg0 : i32, %arg1 : i32) { %0 = quake.alloca !quake.ref - %1 = quake.alloca[%arg0 : i32] !quake.veq - %2 = quake.alloca [%arg1 : i32] !quake.veq + %1 = quake.alloca !quake.veq[%arg0 : i32] + %2 = quake.alloca !quake.veq[%arg1 : i32] %3 = quake.alloca !quake.ref quake.mz %0, %1, %2, %3 : (!quake.ref, !quake.veq, !quake.veq, !quake.ref) -> !cc.stdvec return @@ -38,8 +38,8 @@ func.func @dynamic.mz_test(%arg0 : i32, %arg1 : i32) { // CHECK-LABEL: func.func @dynamic.mz_test( // CHECK-SAME: %[[VAL_0:.*]]: i32, %[[VAL_1:.*]]: i32) { // CHECK: %[[VAL_2:.*]] = quake.alloca !quake.ref -// CHECK: %[[VAL_3:.*]] = quake.alloca[%[[VAL_0]] : i32] !quake.veq -// CHECK: %[[VAL_4:.*]] = quake.alloca[%[[VAL_1]] : i32] !quake.veq +// CHECK: %[[VAL_3:.*]] = quake.alloca !quake.veq[%[[VAL_0]] : i32] +// CHECK: %[[VAL_4:.*]] = quake.alloca !quake.veq[%[[VAL_1]] : i32] // CHECK: %[[VAL_5:.*]] = quake.alloca !quake.ref // CHECK: %[[VAL_6:.*]] = quake.mz %[[VAL_2]], %[[VAL_3]], %[[VAL_4]], %[[VAL_5]] : (!quake.ref, !quake.veq, !quake.veq, !quake.ref) -> !cc.stdvec // CHECK: return diff --git a/test/Quake/qpe.qke b/test/Quake/qpe.qke index 738a3142ae..f4bd00f539 100644 --- a/test/Quake/qpe.qke +++ b/test/Quake/qpe.qke @@ -13,7 +13,7 @@ // CHECK: return // CHECK: } // CHECK: func.func @qpe_test_callable(%arg0: i32, %arg1: i32, %arg2: (!quake.veq) -> !quake.veq, %arg3: (!quake.ref) -> ()) { -// CHECK: %0 = quake.alloca[%arg0 : i32] !quake.veq +// CHECK: %0 = quake.alloca !quake.veq[%arg0 : i32] // CHECK: %1 = quake.extract_ref %0[0] : (!quake.veq) -> !quake.ref // CHECK: call_indirect %arg3(%1) : (!quake.ref) -> () // CHECK: return @@ -26,7 +26,7 @@ func.func @ctrl_t_gate(%q : !quake.ref) -> () { func.func @qpe_test_callable(%nq : i32, %nc : i32, %state_prep : (!quake.veq)->(!quake.veq), %oracle : (!quake.ref)->()) { %0 = arith.constant 0 : i32 - %qubits = quake.alloca[%nq : i32] !quake.veq + %qubits = quake.alloca !quake.veq[%nq : i32] %q = quake.extract_ref %qubits[%0] : (!quake.veq,i32) -> !quake.ref func.call_indirect %oracle(%q) : (!quake.ref)->() return diff --git a/test/Quake/quake-errors.qke b/test/Quake/quake-errors.qke index 16fca747b7..d6a45fe7de 100644 --- a/test/Quake/quake-errors.qke +++ b/test/Quake/quake-errors.qke @@ -330,11 +330,11 @@ func.func @test() { %neg = arith.constant -5 : i32 // expected-error @+1 {{expected a non-negative integer size}} -%0 = quake.alloca[%neg : i32] !quake.veq +%0 = quake.alloca !quake.veq[%neg : i32] // ----- %two = arith.constant 2 : i32 -// expected-error @+1 {{expected operand size to match VeqType size}} -%0 = quake.alloca[%two : i32] !quake.veq<4> +// expected-error @+1 {{unexpected size operand}} +%0 = quake.alloca !quake.veq<4>[%two : i32] diff --git a/test/Quake/roundtrip-ops.qke b/test/Quake/roundtrip-ops.qke index e7bd0a5ab2..34e24b41ac 100644 --- a/test/Quake/roundtrip-ops.qke +++ b/test/Quake/roundtrip-ops.qke @@ -21,7 +21,7 @@ func.func @quantum_ops() { quake.dealloc %v0 : !quake.veq<5> %1 = quake.alloca !quake.veq<4> %2 = arith.constant 2 : i32 - %3 = quake.alloca[%2 : i32] !quake.veq + %3 = quake.alloca !quake.veq[%2 : i32] %4 = quake.alloca !quake.ref // Vectors of references @@ -151,7 +151,7 @@ func.func @quantum_ops() { // CHECK: quake.dealloc %[[VAL_1]] : !quake.veq<5> // CHECK: %[[VAL_2:.*]] = quake.alloca !quake.veq<4> // CHECK: %[[VAL_3:.*]] = arith.constant 2 : i32 -// CHECK: %[[VAL_4:.*]] = quake.alloca{{\[}}%[[VAL_3]] : i32] !quake.veq +// CHECK: %[[VAL_4:.*]] = quake.alloca !quake.veq[%[[VAL_3]] : i32] // CHECK: %[[VAL_5:.*]] = quake.alloca !quake.ref // CHECK: %[[VAL_6:.*]] = arith.constant 0 : i32 // CHECK: %[[VAL_7:.*]] = arith.constant 3 : i64 @@ -290,14 +290,14 @@ func.func @quake_op3(%vec : !quake.veq, %a : i32, %b : i32) { // CHECK-LABEL: func.func @cc_op4() { // CHECK: cc.scope { -// CHECK: %[[VAL_0:.*]] = cc.alloca i32 : () -> !cc.ptr +// CHECK: %[[VAL_0:.*]] = cc.alloca i32 // CHECK: } // CHECK: return // CHECK: } func.func @cc_op4() { cc.scope { - %x = cc.alloca i32 : () -> !cc.ptr + %x = cc.alloca i32 } return } @@ -312,7 +312,8 @@ func.func private @do_nothing() -> () // CHECK: %[[VAL_1:.*]] = arith.constant 1 : i32 // CHECK: cc.return %[[VAL_1]] : i32 // CHECK: } : !cc.lambda<() -> i32> -// CHECK: %[[VAL_2:.*]] = cc.alloca !llvm.struct<(i32, i32)> : () -> !cc.ptr +// CHECK: %[[VAL_21:.*]] = cc.alloca !cc.struct<{i32, i32}> +// CHECK: %[[VAL_2:.*]] = cc.cast %[[VAL_21]] : // CHECK: %[[VAL_3:.*]] = cc.instantiate_callable @do_nothing(%[[VAL_2]]) : (!cc.ptr) -> !cc.lambda<() -> ()> // CHECK: %[[VAL_4:.*]] = cc.callable_func %[[VAL_3]] : (!cc.lambda<() -> ()>) -> (() -> ()) // CHECK: %[[VAL_5:.*]] = cc.callable_closure %[[VAL_3]] : (!cc.lambda<() -> ()>) -> !cc.ptr @@ -327,8 +328,9 @@ func.func @cc_op5() -> !cc.lambda<() -> i32> { %1 = arith.constant 1 : i32 cc.return %1 : i32 } : !cc.lambda<() -> i32> - %closure = cc.alloca !llvm.struct<(i32, i32)> : () -> !cc.ptr - %2 = cc.instantiate_callable @do_nothing(%closure) : (!cc.ptr) -> !cc.lambda<()->()> + %closure = cc.alloca !cc.struct<{i32, i32}> + %cast = cc.cast %closure : (!cc.ptr>) -> !cc.ptr + %2 = cc.instantiate_callable @do_nothing(%cast) : (!cc.ptr) -> !cc.lambda<()->()> %3 = cc.callable_func %2 : (!cc.lambda<() -> ()>) -> (() -> ()) %4 = cc.callable_closure %2 : (!cc.lambda<() -> ()>) -> !cc.ptr %5 = cc.call_callable %1 : (!cc.lambda<() -> (i32)>) -> i32 @@ -337,21 +339,21 @@ func.func @cc_op5() -> !cc.lambda<() -> i32> { } // CHECK-LABEL: func.func @cc_op6_return_test() -> i32 { -// CHECK: %[[VAL_0:.*]] = cc.alloca i32 : () -> !cc.ptr +// CHECK: %[[VAL_0:.*]] = cc.alloca i32 // CHECK: %[[VAL_1:.*]] = cc.undef i32 // CHECK: cc.scope { -// CHECK: %[[VAL_2:.*]] = cc.alloca i1 : () -> !cc.ptr +// CHECK: %[[VAL_2:.*]] = cc.alloca i1 // CHECK: %[[VAL_3:.*]] = cc.undef i1 // CHECK: cc.if(%[[VAL_3]]) { // CHECK: cc.scope { -// CHECK: %[[VAL_4:.*]] = cc.alloca i32 : () -> !cc.ptr -// CHECK: %[[VAL_5:.*]] = cc.alloca i1 : () -> !cc.ptr +// CHECK: %[[VAL_4:.*]] = cc.alloca i32 +// CHECK: %[[VAL_5:.*]] = cc.alloca i1 // CHECK: cc.loop while { // CHECK: %[[VAL_6:.*]] = cc.undef i1 // CHECK: cc.condition %[[VAL_6]] // CHECK: } do { // CHECK: cc.scope { -// CHECK: %[[VAL_7:.*]] = cc.alloca i1 : () -> !cc.ptr +// CHECK: %[[VAL_7:.*]] = cc.alloca i1 // CHECK: %[[VAL_8:.*]] = cc.undef i1 // CHECK: cc.if(%[[VAL_8]]) { // CHECK: %[[VAL_9:.*]] = cc.undef i32 @@ -371,21 +373,21 @@ func.func @cc_op5() -> !cc.lambda<() -> i32> { // CHECK: } func.func @cc_op6_return_test() -> i32 { - %1 = cc.alloca i32 : () -> !cc.ptr + %1 = cc.alloca i32 %result = cc.undef i32 cc.scope { - %2 = cc.alloca i1 : () -> !cc.ptr + %2 = cc.alloca i1 %b1 = cc.undef i1 cc.if (%b1) { cc.scope { - %3 = cc.alloca i32 : () -> !cc.ptr - %4 = cc.alloca i1 : () -> !cc.ptr + %3 = cc.alloca i32 + %4 = cc.alloca i1 cc.loop while { %b2 = cc.undef i1 cc.condition %b2 } do { cc.scope { - %5 = cc.alloca i1 : () -> !cc.ptr + %5 = cc.alloca i1 %b3 = cc.undef i1 cc.if (%b3) { %val = cc.undef i32 @@ -431,15 +433,15 @@ func.func @cc_op6_return_test() -> i32 { // CHECK: } func.func @cc_op7_break_test() -> f64 { - %1 = cc.alloca i32 : () -> !cc.ptr + %1 = cc.alloca i32 %result = cc.undef f64 cc.scope { - %2 = cc.alloca i1 : () -> !cc.ptr + %2 = cc.alloca i1 %b1 = cc.undef i1 cc.if (%b1) { cc.scope { - %3 = cc.alloca i32 : () -> !cc.ptr - %4 = cc.alloca i1 : () -> !cc.ptr + %3 = cc.alloca i32 + %4 = cc.alloca i1 %w = cc.undef i16 cc.loop while ((%arg0 = %w) -> i16) { %b2 = cc.undef i1 @@ -447,7 +449,7 @@ func.func @cc_op7_break_test() -> f64 { } do { ^bb1(%arg1 : i16): cc.scope { - %5 = cc.alloca i1 : () -> !cc.ptr + %5 = cc.alloca i1 %b3 = cc.undef i1 cc.if (%b3) { %val = cc.undef f64 @@ -495,15 +497,15 @@ func.func @cc_op7_break_test() -> f64 { // CHECK: } func.func @cc_op8_continue_test() -> f64 { - %1 = cc.alloca i32 : () -> !cc.ptr + %1 = cc.alloca i32 %result = cc.undef f64 cc.scope { - %2 = cc.alloca i1 : () -> !cc.ptr + %2 = cc.alloca i1 %b1 = cc.undef i1 cc.if (%b1) { cc.scope { - %3 = cc.alloca i32 : () -> !cc.ptr - %4 = cc.alloca i1 : () -> !cc.ptr + %3 = cc.alloca i32 + %4 = cc.alloca i1 %w = cc.undef i16 cc.loop while ((%arg0 = %w) -> i16) { %b2 = cc.undef i1 @@ -511,7 +513,7 @@ func.func @cc_op8_continue_test() -> f64 { } do { ^bb1(%arg1 : i16): cc.scope { - %5 = cc.alloca i1 : () -> !cc.ptr + %5 = cc.alloca i1 %b3 = cc.undef i1 cc.if (%b3) { %val = cc.undef f64 @@ -535,7 +537,7 @@ func.func @cc_op8_continue_test() -> f64 { // CHECK-LABEL: func.func @cc.scope_result() { // CHECK: %[[VAL_0:.*]] = cc.scope -> (i32) { -// CHECK: %[[VAL_1:.*]] = cc.alloca i32 : () -> !cc.ptr +// CHECK: %[[VAL_1:.*]] = cc.alloca i32 // CHECK: %[[VAL_2:.*]] = cc.undef i32 // CHECK: cc.continue %[[VAL_2]] : i32 // CHECK: } @@ -544,7 +546,7 @@ func.func @cc_op8_continue_test() -> f64 { func.func @cc.scope_result() { %0 = cc.scope -> i32 { - %x = cc.alloca i32 : () -> !cc.ptr + %x = cc.alloca i32 %0 = cc.undef i32 cc.continue %0 : i32 } @@ -553,7 +555,7 @@ func.func @cc.scope_result() { // CHECK-LABEL: func.func @cc.scope_blocks() { // CHECK: cc.scope { -// CHECK: %[[VAL_0:.*]] = cc.alloca i32 : () -> !cc.ptr +// CHECK: %[[VAL_0:.*]] = cc.alloca i32 // CHECK: %[[VAL_1:.*]] = cc.undef i1 // CHECK: cf.cond_br %[[VAL_1]], ^bb1, ^bb2 // CHECK: ^bb1: @@ -573,7 +575,7 @@ func.func @cc.scope_result() { func.func @cc.scope_blocks() { cc.scope { ^bb2: - %x = cc.alloca i32 : () -> !cc.ptr + %x = cc.alloca i32 %0 = cc.undef i1 cf.cond_br %0, ^bb0, ^bb1 ^bb0: @@ -653,7 +655,7 @@ func.func @cc_struct() { // CHECK: %[[VAL_4:.*]] = arith.constant 1 : i32 // CHECK: %[[VAL_5:.*]] = arith.addi %[[VAL_2]], %[[VAL_4]] : i32 // CHECK: %[[VAL_6:.*]] = cc.insert_value %[[VAL_5]], %[[VAL_0]][0] : (!cc.struct<{i32, !cc.array x 100>}>, i32) -> !cc.struct<{i32, !cc.array x 100>}> -// CHECK: %[[VAL_7:.*]] = cc.alloca !cc.struct<{i32, !cc.array x 100>}> : () -> !cc.ptr x 100>}>> +// CHECK: %[[VAL_7:.*]] = cc.alloca !cc.struct<{i32, !cc.array x 100>}> // CHECK: cc.store %[[VAL_6]], %[[VAL_7]] : !cc.ptr x 100>}>> // CHECK: %[[VAL_8:.*]] = cc.compute_ptr %[[VAL_7]][1, 4, 3] : (!cc.ptr x 100>}>>) -> !cc.ptr // CHECK: %[[VAL_9:.*]] = cc.compute_ptr %[[VAL_7]][1, %[[VAL_4]], 1] : (!cc.ptr x 100>}>>, i32) -> !cc.ptr @@ -667,7 +669,7 @@ func.func @cc_indexing(%arg0 : !cc.struct<{i32, !cc.array x 100>}>, i32) -> !cc.struct<{i32, !cc.array x 100>}> - %ss = cc.alloca !cc.struct<{i32, !cc.array x 100>}> : () -> !cc.ptr x 100>}>> + %ss = cc.alloca !cc.struct<{i32, !cc.array x 100>}> cc.store %3, %ss : !cc.ptr x 100>}>> %p = cc.compute_ptr %ss[1, 4, 3] : (!cc.ptr x 100>}>>) -> !cc.ptr %q = cc.compute_ptr %ss[1, %one, 1] : (!cc.ptr x 100>}>>, i32) -> !cc.ptr diff --git a/test/Quake/test_add_dealloc.qke b/test/Quake/test_add_dealloc.qke index 46f743044e..c17bfa8d77 100644 --- a/test/Quake/test_add_dealloc.qke +++ b/test/Quake/test_add_dealloc.qke @@ -13,8 +13,8 @@ func.func @ghz(%arg0 : i32) { %c0 = arith.constant 0 : i32 %one = arith.constant 1 : i32 - // CHECK: %[[VAL_3:.*]] = quake.alloca[%[[VAL_0]] : i32] !quake.veq - %q = quake.alloca[%arg0 : i32] !quake.veq + // CHECK: %[[VAL_3:.*]] = quake.alloca !quake.veq[%[[VAL_0]] : i32] + %q = quake.alloca !quake.veq[%arg0 : i32] %q0 = quake.extract_ref %q[%c0] : (!quake.veq, i32) -> !quake.ref quake.h %q0 : (!quake.ref) -> () // CHECK: quake.dealloc %[[VAL_3]] : !quake.veq diff --git a/test/Quake/test_inline_simpify.qke b/test/Quake/test_inline_simpify.qke index aab01ae009..292b18158b 100644 --- a/test/Quake/test_inline_simpify.qke +++ b/test/Quake/test_inline_simpify.qke @@ -15,7 +15,7 @@ // CHECK: func.func @ccnot() { // CHECK: %[[C3:.*]] = arith.constant 3 : i32 // CHECK: %[[C1:.*]] = arith.constant 1 : i32 -// CHECK: %0 = quake.alloca[%[[C3]] : i32] !quake.veq +// CHECK: %0 = quake.alloca !quake.veq[%[[C3]] : i32] // CHECK: %1 = arith.index_cast %[[C3]] : i32 to index // CHECK: affine.for %arg0 = 0 to %1 { // CHECK: %3 = quake.extract_ref %0[%arg0] : (!quake.veq, index) -> !quake.ref @@ -38,7 +38,7 @@ module { func.func @ccnot() { %c_3 = arith.constant 3 : i32 %c_1 = arith.constant 1 : i32 - %qubits = quake.alloca [%c_3 : i32 ] !quake.veq + %qubits = quake.alloca !quake.veq[%c_3 : i32 ] %c_3_idx = arith.index_cast %c_3 : i32 to index affine.for %i = 0 to %c_3_idx { %q0 = quake.extract_ref %qubits [%i] :( !quake.veq,index) -> !quake.ref diff --git a/test/Quake/test_merge_rotation.qke b/test/Quake/test_merge_rotation.qke index 42fdb187b7..5a199e719e 100644 --- a/test/Quake/test_merge_rotation.qke +++ b/test/Quake/test_merge_rotation.qke @@ -11,7 +11,7 @@ // CHECK: func.func @duplicate_rotation_check() { // CHECK: %[[C2:.*]] = arith.constant 2 : i32 // CHECK: %[[C0:.*]] = arith.constant 0 : i32 -// CHECK: %0 = quake.alloca[%[[C2]] : i32] !quake.veq +// CHECK: %0 = quake.alloca !quake.veq[%[[C2]] : i32] // CHECK: %1 = quake.extract_ref %0[%[[C0]]] : (!quake.veq, i32) -> !quake.ref // CHECK: %[[CF:.*]] = arith.constant 5.900000e-01 : f64 // CHECK: quake.rx (%[[CF]]) %1 : (f64, @@ -23,7 +23,7 @@ func.func @duplicate_rotation_check() { %0 = arith.constant 2 : i32 %c_0 = arith.constant 0 : i32 - %qubits = quake.alloca [ %0 : i32 ] !quake.veq + %qubits = quake.alloca !quake.veq[ %0 : i32 ] %q0 = quake.extract_ref %qubits[%c_0] : (!quake.veq,i32) -> !quake.ref %c_angle = arith.constant 0.59 : f64 quake.rx (%c_angle) %q0: (f64, !quake.ref) -> () @@ -35,7 +35,7 @@ func.func @duplicate_rotation_check() { // CHECK: func.func @duplicate_rotation_check2() { // CHECK: %[[C2]] = arith.constant 2 : i32 // CHECK: %[[C0]] = arith.constant 0 : i32 -// CHECK: %0 = quake.alloca[%[[C2]] : i32] !quake.veq +// CHECK: %0 = quake.alloca !quake.veq[%[[C2]] : i32] // CHECK: %1 = quake.extract_ref %0[%[[C0]]] : (!quake.veq, i32) -> !quake.ref // CHECK: %[[CF:.*]] = arith.constant 5.900000e-01 : f64 // CHECK: %[[CF2:.*]] = arith.constant 2.300000e-01 : f64 @@ -48,7 +48,7 @@ func.func @duplicate_rotation_check() { func.func @duplicate_rotation_check2() { %0 = arith.constant 2 : i32 %c_0 = arith.constant 0 : i32 - %qubits = quake.alloca [ %0 : i32] !quake.veq + %qubits = quake.alloca !quake.veq[ %0 : i32] %q0 = quake.extract_ref %qubits[%c_0] : (!quake.veq, i32) -> !quake.ref %c_angle = arith.constant 0.59 : f64 %c_angle2 = arith.constant 0.23 : f64 @@ -71,7 +71,7 @@ func.func @returns_angle(%arg0 : f64, %arg1 : f64) -> (f64) { // CHECK: func.func @duplicate_rotation_check3() { // CHECK: %[[C2:.*]] = arith.constant 2 : i32 // CHECK: %[[C0:.*]] = arith.constant 0 : i32 -// CHECK: %0 = quake.alloca[%[[C2]] : i32] !quake.veq +// CHECK: %0 = quake.alloca !quake.veq[%[[C2]] : i32] // CHECK: %1 = quake.extract_ref %0[%[[C0]]] : (!quake.veq, i32) -> !quake.ref // CHECK: %[[CF:.*]] = arith.constant 5.900000e-01 : f64 // CHECK: %[[CF2:.*]] = arith.constant 2.300000e-01 : f64 @@ -87,7 +87,7 @@ func.func @returns_angle(%arg0 : f64, %arg1 : f64) -> (f64) { func.func @duplicate_rotation_check3() { %0 = arith.constant 2 : i32 %c_0 = arith.constant 0 : i32 - %qubits = quake.alloca [ %0 : i32 ] !quake.veq + %qubits = quake.alloca !quake.veq [ %0 : i32 ] %q0 = quake.extract_ref %qubits[%c_0] : (!quake.veq, i32) -> !quake.ref %c_angle = arith.constant 0.59 : f64 %c_angle2 = arith.constant 0.23 : f64