Loading mlir/dialect/include/Quantum/QuantumOps.td +6 −4 Original line number Diff line number Diff line Loading @@ -100,8 +100,7 @@ def InstOp : QuantumOp<"inst", [AttrSizedOperandSegments]> { let results = (outs Optional<ResultType>:$bit); let printer = [{ auto op = *this; p << "q." << op.name() << "(" << op.getOperands() << ") : "; p.printFunctionalType(op.getOperandTypes(), op.getResultTypes()); }]; p << "q." << op.name() << "(" << op.getOperands() << ") : " << op.getResultTypes(); }]; } def ValueSemanticsInstOp : QuantumOp<"value_inst", [AttrSizedOperandSegments]> { Loading @@ -110,7 +109,6 @@ def ValueSemanticsInstOp : QuantumOp<"value_inst", [AttrSizedOperandSegments]> { let printer = [{ auto op = *this; p << "qvs." << op.name() << "(" << op.getOperands() << ") : " << op.result().getType(); }]; } def DeallocOp : QuantumOp<"dealloc", []> { Loading Loading @@ -143,11 +141,15 @@ def SetQregOp : QuantumOp<"set_qreg", []> { def PrintOp : QuantumOp<"print", []> { let arguments = (ins Variadic<AnyType>:$print_args); let results = (outs); let printer = [{ auto op = *this; p << "q.print(" << op.getOperands() << ")"; }]; } def CreateStringLiteralOp : QuantumOp<"createString", []> { let arguments = (ins StrAttr:$text, StrAttr:$varname); let results = (outs StringType:$result); let printer = [{ auto op = *this; p << "q.create_string(\"" << op.text() << "\")"; }]; } #endif // Quantum_OPS No newline at end of file mlir/parsers/qasm3/visitor_handlers/quantum_types_handler.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -159,10 +159,10 @@ antlrcpp::Any qasm3_visitor::visitQuantumGateDefinition( result_qubit_vals.push_back(last_user); } std::cout << "GATE " << gate_call_name << " has " << result_qubit_vals.size() << " to return.\n"; for (auto v : result_qubit_vals) { v.dump(); } // std::cout << "GATE " << gate_call_name << " has " << result_qubit_vals.size() << " to return.\n"; // for (auto v : result_qubit_vals) { // v.dump(); // } builder.create<mlir::ReturnOp>(builder.getUnknownLoc(), llvm::makeArrayRef(result_qubit_vals)); Loading tools/driver/qcor.in +4 −0 Original line number Diff line number Diff line Loading @@ -346,6 +346,10 @@ def main(argv=None): extra_args.append('-no-entrypoint') result = subprocess.run(['@CMAKE_INSTALL_PREFIX@/bin/qcor-mlir-tool', filename] + extra_args, check=True) llvm_bin_path = str(pathlib.Path(compiler).parent) if verbose: print('[qcor-exec]: ', '@CMAKE_INSTALL_PREFIX@/bin/qcor-mlir-tool {}'.format(filename) ) print('[qcor-exec]: ', '{}'.format(' '.join([llvm_bin_path+'/llvm-as', ll_file_name, '-o', bc_file_name ])) ) print('[qcor-exec]: ', '{}'.format(' '.join([llvm_bin_path+'/llc', '-filetype=obj', bc_file_name ])) ) result = subprocess.run([llvm_bin_path+'/llvm-as', ll_file_name, '-o', bc_file_name ], check=True) result = subprocess.run([llvm_bin_path+'/llc', '-filetype=obj', bc_file_name ], check=True) if '-no-entrypoint' in extra_args: Loading Loading
mlir/dialect/include/Quantum/QuantumOps.td +6 −4 Original line number Diff line number Diff line Loading @@ -100,8 +100,7 @@ def InstOp : QuantumOp<"inst", [AttrSizedOperandSegments]> { let results = (outs Optional<ResultType>:$bit); let printer = [{ auto op = *this; p << "q." << op.name() << "(" << op.getOperands() << ") : "; p.printFunctionalType(op.getOperandTypes(), op.getResultTypes()); }]; p << "q." << op.name() << "(" << op.getOperands() << ") : " << op.getResultTypes(); }]; } def ValueSemanticsInstOp : QuantumOp<"value_inst", [AttrSizedOperandSegments]> { Loading @@ -110,7 +109,6 @@ def ValueSemanticsInstOp : QuantumOp<"value_inst", [AttrSizedOperandSegments]> { let printer = [{ auto op = *this; p << "qvs." << op.name() << "(" << op.getOperands() << ") : " << op.result().getType(); }]; } def DeallocOp : QuantumOp<"dealloc", []> { Loading Loading @@ -143,11 +141,15 @@ def SetQregOp : QuantumOp<"set_qreg", []> { def PrintOp : QuantumOp<"print", []> { let arguments = (ins Variadic<AnyType>:$print_args); let results = (outs); let printer = [{ auto op = *this; p << "q.print(" << op.getOperands() << ")"; }]; } def CreateStringLiteralOp : QuantumOp<"createString", []> { let arguments = (ins StrAttr:$text, StrAttr:$varname); let results = (outs StringType:$result); let printer = [{ auto op = *this; p << "q.create_string(\"" << op.text() << "\")"; }]; } #endif // Quantum_OPS No newline at end of file
mlir/parsers/qasm3/visitor_handlers/quantum_types_handler.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -159,10 +159,10 @@ antlrcpp::Any qasm3_visitor::visitQuantumGateDefinition( result_qubit_vals.push_back(last_user); } std::cout << "GATE " << gate_call_name << " has " << result_qubit_vals.size() << " to return.\n"; for (auto v : result_qubit_vals) { v.dump(); } // std::cout << "GATE " << gate_call_name << " has " << result_qubit_vals.size() << " to return.\n"; // for (auto v : result_qubit_vals) { // v.dump(); // } builder.create<mlir::ReturnOp>(builder.getUnknownLoc(), llvm::makeArrayRef(result_qubit_vals)); Loading
tools/driver/qcor.in +4 −0 Original line number Diff line number Diff line Loading @@ -346,6 +346,10 @@ def main(argv=None): extra_args.append('-no-entrypoint') result = subprocess.run(['@CMAKE_INSTALL_PREFIX@/bin/qcor-mlir-tool', filename] + extra_args, check=True) llvm_bin_path = str(pathlib.Path(compiler).parent) if verbose: print('[qcor-exec]: ', '@CMAKE_INSTALL_PREFIX@/bin/qcor-mlir-tool {}'.format(filename) ) print('[qcor-exec]: ', '{}'.format(' '.join([llvm_bin_path+'/llvm-as', ll_file_name, '-o', bc_file_name ])) ) print('[qcor-exec]: ', '{}'.format(' '.join([llvm_bin_path+'/llc', '-filetype=obj', bc_file_name ])) ) result = subprocess.run([llvm_bin_path+'/llvm-as', ll_file_name, '-o', bc_file_name ], check=True) result = subprocess.run([llvm_bin_path+'/llc', '-filetype=obj', bc_file_name ], check=True) if '-no-entrypoint' in extra_args: Loading