diff --git a/docs/changelog.rst b/docs/changelog.rst index 26c1d0a9..a8b0599e 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -4,8 +4,9 @@ Changelog 0.5.0 (unreleased) ------------------ -* Updated pyqir version requirement to 0.9.0. -* removed depencency of pyqir-generator, pyqir-evaluator and pyqir-parser +* updated pyqir version requirement to 0.9.0. +* removed dependency of pyqir-generator, pyqir-evaluator and pyqir-parser +* update measurement to write to register directly 0.4.0 (October 2023) -------------------- diff --git a/pytket/qir/conversion/conversion.py b/pytket/qir/conversion/conversion.py index 83acb264..783ea38c 100644 --- a/pytket/qir/conversion/conversion.py +++ b/pytket/qir/conversion/conversion.py @@ -202,6 +202,20 @@ def __init__( ), ) + # void mz_to_creg_bit(qubit, i1* creg, int creg_index) + # measures one qubit to one bit entry in a creg + self.mz_to_creg_bit = self.module.module.add_external_function( + "mz_to_creg_bit", + pyqir.FunctionType( + pyqir.Type.void(self.module.module.context), + [ + pyqir.qubit_type(self.module.module.context), + self.qir_i1p_type, + self.qir_int_type, + ], + ), + ) + self.reg_const = {} for creg in self.circuit.c_registers: @@ -842,24 +856,12 @@ def condition_block() -> None: assert len(command.qubits) == 1 assert command.qubits[0].reg_name == "q" - module.qis.mz( - module.module.qubits[command.qubits[0].index[0]], - module.module.results[command.qubits[0].index[0]], - ) - - ssa_measureresult = self.module.builder.call( - self.read_bit_from_result, - [ - module.module.results[command.qubits[0].index[0]], - ], - ) - self.module.builder.call( - self.set_creg_bit, + self.mz_to_creg_bit, [ + module.module.qubits[command.qubits[0].index[0]], self.ssa_vars[command.bits[0].reg_name], pyqir.const(self.qir_int_type, command.bits[0].index[0]), - ssa_measureresult, ], ) diff --git a/tests/qir/test_pytket_qir.ll b/tests/qir/test_pytket_qir.ll index 2d1c6962..4549c8e3 100644 --- a/tests/qir/test_pytket_qir.ll +++ b/tests/qir/test_pytket_qir.ll @@ -24,6 +24,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() diff --git a/tests/qir/test_pytket_qir_10.ll b/tests/qir/test_pytket_qir_10.ll index 04990fe9..46274377 100644 --- a/tests/qir/test_pytket_qir_10.ll +++ b/tests/qir/test_pytket_qir_10.ll @@ -2,6 +2,7 @@ source_filename = "test_pytket_qir_10" %Result = type opaque +%Qubit = type opaque @0 = internal constant [2 x i8] c"a\00" @1 = internal constant [2 x i8] c"b\00" @@ -35,6 +36,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() diff --git a/tests/qir/test_pytket_qir_11.ll b/tests/qir/test_pytket_qir_11.ll index c57c20bc..1791cdb8 100644 --- a/tests/qir/test_pytket_qir_11.ll +++ b/tests/qir/test_pytket_qir_11.ll @@ -2,6 +2,7 @@ source_filename = "test_pytket_qir_11" %Result = type opaque +%Qubit = type opaque @0 = internal constant [2 x i8] c"a\00" @1 = internal constant [2 x i8] c"b\00" @@ -35,6 +36,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() diff --git a/tests/qir/test_pytket_qir_12.ll b/tests/qir/test_pytket_qir_12.ll index 020c9547..840fb252 100644 --- a/tests/qir/test_pytket_qir_12.ll +++ b/tests/qir/test_pytket_qir_12.ll @@ -2,6 +2,7 @@ source_filename = "test_pytket_qir_12" %Result = type opaque +%Qubit = type opaque @0 = internal constant [2 x i8] c"a\00" @@ -32,6 +33,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() diff --git a/tests/qir/test_pytket_qir_13.ll b/tests/qir/test_pytket_qir_13.ll index 77de7af6..d6e1d0bd 100644 --- a/tests/qir/test_pytket_qir_13.ll +++ b/tests/qir/test_pytket_qir_13.ll @@ -2,6 +2,7 @@ source_filename = "test_pytket_qir_13" %Result = type opaque +%Qubit = type opaque @0 = internal constant [2 x i8] c"a\00" @1 = internal constant [2 x i8] c"b\00" @@ -41,6 +42,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() diff --git a/tests/qir/test_pytket_qir_14.ll b/tests/qir/test_pytket_qir_14.ll index 726238c7..8d6804dd 100644 --- a/tests/qir/test_pytket_qir_14.ll +++ b/tests/qir/test_pytket_qir_14.ll @@ -305,6 +305,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() diff --git a/tests/qir/test_pytket_qir_14_b.ll b/tests/qir/test_pytket_qir_14_b.ll index 30e5cd5d..171230ac 100644 --- a/tests/qir/test_pytket_qir_14_b.ll +++ b/tests/qir/test_pytket_qir_14_b.ll @@ -423,6 +423,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() diff --git a/tests/qir/test_pytket_qir_15.ll b/tests/qir/test_pytket_qir_15.ll index bea31f7a..36e264d4 100644 --- a/tests/qir/test_pytket_qir_15.ll +++ b/tests/qir/test_pytket_qir_15.ll @@ -2,6 +2,7 @@ source_filename = "test_pytket_qir_15" %Result = type opaque +%Qubit = type opaque @0 = internal constant [2 x i8] c"a\00" @1 = internal constant [2 x i8] c"c\00" @@ -39,6 +40,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() diff --git a/tests/qir/test_pytket_qir_17.ll b/tests/qir/test_pytket_qir_17.ll index 8e0781ad..608710a5 100644 --- a/tests/qir/test_pytket_qir_17.ll +++ b/tests/qir/test_pytket_qir_17.ll @@ -13,17 +13,13 @@ entry: %1 = call i1* @create_creg(i64 1) call void @__quantum__qis__h__body(%Qubit* null) call void @__quantum__qis__cnot__body(%Qubit* null, %Qubit* inttoptr (i64 1 to %Qubit*)) - call void @__quantum__qis__mz__body(%Qubit* null, %Result* null) - %2 = call i1 @__quantum__qis__read_result__body(%Result* null) - call void @set_creg_bit(i1* %0, i64 0, i1 %2) - call void @__quantum__qis__mz__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - %3 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 1 to %Result*)) - call void @set_creg_bit(i1* %1, i64 0, i1 %3) + call void @mz_to_creg_bit(%Qubit* null, i1* %0, i64 0) + call void @mz_to_creg_bit(%Qubit* inttoptr (i64 1 to %Qubit*), i1* %1, i64 0) call void @__quantum__rt__tuple_start_record_output() - %4 = call i64 @get_int_from_creg(i1* %0) - call void @__quantum__rt__int_record_output(i64 %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @0, i32 0, i32 0)) - %5 = call i64 @get_int_from_creg(i1* %1) - call void @__quantum__rt__int_record_output(i64 %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @1, i32 0, i32 0)) + %2 = call i64 @get_int_from_creg(i1* %0) + call void @__quantum__rt__int_record_output(i64 %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @0, i32 0, i32 0)) + %3 = call i64 @get_int_from_creg(i1* %1) + call void @__quantum__rt__int_record_output(i64 %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @1, i32 0, i32 0)) call void @__quantum__rt__tuple_end_record_output() ret void } @@ -40,6 +36,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() @@ -50,10 +48,7 @@ declare void @__quantum__qis__h__body(%Qubit*) declare void @__quantum__qis__cnot__body(%Qubit*, %Qubit*) -declare void @__quantum__qis__mz__body(%Qubit*, %Result* writeonly) #1 - attributes #0 = { "entry_point" "num_required_qubits"="2" "num_required_results"="2" "output_labeling_schema" "qir_profiles"="custom" } -attributes #1 = { "irreversible" } !llvm.module.flags = !{!0, !1, !2, !3} diff --git a/tests/qir/test_pytket_qir_2.ll b/tests/qir/test_pytket_qir_2.ll index c31604b6..df740180 100644 --- a/tests/qir/test_pytket_qir_2.ll +++ b/tests/qir/test_pytket_qir_2.ll @@ -24,6 +24,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() diff --git a/tests/qir/test_pytket_qir_3.ll b/tests/qir/test_pytket_qir_3.ll index 98c66cb8..3926e0e0 100644 --- a/tests/qir/test_pytket_qir_3.ll +++ b/tests/qir/test_pytket_qir_3.ll @@ -31,6 +31,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() diff --git a/tests/qir/test_pytket_qir_4.ll b/tests/qir/test_pytket_qir_4.ll index ff38e72a..339872f2 100644 --- a/tests/qir/test_pytket_qir_4.ll +++ b/tests/qir/test_pytket_qir_4.ll @@ -55,6 +55,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() diff --git a/tests/qir/test_pytket_qir_5.ll b/tests/qir/test_pytket_qir_5.ll index b6417c30..e09bfabc 100644 --- a/tests/qir/test_pytket_qir_5.ll +++ b/tests/qir/test_pytket_qir_5.ll @@ -59,6 +59,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() diff --git a/tests/qir/test_pytket_qir_6.ll b/tests/qir/test_pytket_qir_6.ll index 0167fb11..5a507208 100644 --- a/tests/qir/test_pytket_qir_6.ll +++ b/tests/qir/test_pytket_qir_6.ll @@ -24,11 +24,9 @@ entry: call void @__quantum__qis__x__body(%Qubit* null) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 2 to %Qubit*)) - call void @__quantum__qis__mz__body(%Qubit* null, %Result* null) - %9 = call i1 @__quantum__qis__read_result__body(%Result* null) - call void @set_creg_bit(i1* %2, i64 4, i1 %9) - %10 = call i1 @get_creg_bit(i1* %2, i64 4) - br i1 %10, label %then, label %else + call void @mz_to_creg_bit(%Qubit* null, i1* %2, i64 4) + %9 = call i1 @get_creg_bit(i1* %2, i64 4) + br i1 %9, label %then, label %else then: ; preds = %entry call void @__quantum__qis__z__body(%Qubit* null) @@ -40,14 +38,14 @@ else: ; preds = %entry continue: ; preds = %else, %then call void @__quantum__qis__h__body(%Qubit* null) call void @__quantum__rt__tuple_start_record_output() - %11 = call i64 @get_int_from_creg(i1* %0) - call void @__quantum__rt__int_record_output(i64 %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @0, i32 0, i32 0)) - %12 = call i64 @get_int_from_creg(i1* %1) - call void @__quantum__rt__int_record_output(i64 %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @1, i32 0, i32 0)) - %13 = call i64 @get_int_from_creg(i1* %2) - call void @__quantum__rt__int_record_output(i64 %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @2, i32 0, i32 0)) - %14 = call i64 @get_int_from_creg(i1* %3) - call void @__quantum__rt__int_record_output(i64 %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @3, i32 0, i32 0)) + %10 = call i64 @get_int_from_creg(i1* %0) + call void @__quantum__rt__int_record_output(i64 %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @0, i32 0, i32 0)) + %11 = call i64 @get_int_from_creg(i1* %1) + call void @__quantum__rt__int_record_output(i64 %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @1, i32 0, i32 0)) + %12 = call i64 @get_int_from_creg(i1* %2) + call void @__quantum__rt__int_record_output(i64 %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @2, i32 0, i32 0)) + %13 = call i64 @get_int_from_creg(i1* %3) + call void @__quantum__rt__int_record_output(i64 %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @3, i32 0, i32 0)) call void @__quantum__rt__tuple_end_record_output() ret void } @@ -64,6 +62,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() @@ -74,12 +74,9 @@ declare void @__quantum__qis__x__body(%Qubit*) declare void @__quantum__qis__h__body(%Qubit*) -declare void @__quantum__qis__mz__body(%Qubit*, %Result* writeonly) #1 - declare void @__quantum__qis__z__body(%Qubit*) attributes #0 = { "entry_point" "num_required_qubits"="3" "num_required_results"="3" "output_labeling_schema" "qir_profiles"="custom" } -attributes #1 = { "irreversible" } !llvm.module.flags = !{!0, !1, !2, !3} diff --git a/tests/qir/test_pytket_qir_7.ll b/tests/qir/test_pytket_qir_7.ll index 1355fae4..158648ce 100644 --- a/tests/qir/test_pytket_qir_7.ll +++ b/tests/qir/test_pytket_qir_7.ll @@ -2,6 +2,7 @@ source_filename = "test_pytket_qir_7" %Result = type opaque +%Qubit = type opaque @0 = internal constant [2 x i8] c"a\00" @1 = internal constant [2 x i8] c"b\00" @@ -123,6 +124,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() diff --git a/tests/qir/test_pytket_qir_8.ll b/tests/qir/test_pytket_qir_8.ll index 1efbf8b4..4e318b8f 100644 --- a/tests/qir/test_pytket_qir_8.ll +++ b/tests/qir/test_pytket_qir_8.ll @@ -2,6 +2,7 @@ source_filename = "test_pytket_qir_8" %Result = type opaque +%Qubit = type opaque @0 = internal constant [2 x i8] c"a\00" @@ -39,6 +40,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() diff --git a/tests/qir/test_pytket_qir_9.ll b/tests/qir/test_pytket_qir_9.ll index c4ea1de3..412e80c8 100644 --- a/tests/qir/test_pytket_qir_9.ll +++ b/tests/qir/test_pytket_qir_9.ll @@ -2,6 +2,7 @@ source_filename = "test_pytket_qir_9" %Result = type opaque +%Qubit = type opaque @0 = internal constant [2 x i8] c"a\00" @1 = internal constant [2 x i8] c"b\00" @@ -35,6 +36,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() diff --git a/tests/qir/test_pytket_qir_barrier.ll b/tests/qir/test_pytket_qir_barrier.ll index afaa3c95..dde1c32e 100644 --- a/tests/qir/test_pytket_qir_barrier.ll +++ b/tests/qir/test_pytket_qir_barrier.ll @@ -30,6 +30,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() diff --git a/tests/qir/test_pytket_qir_barrier_ii.ll b/tests/qir/test_pytket_qir_barrier_ii.ll index c62c1685..eae4c66a 100644 --- a/tests/qir/test_pytket_qir_barrier_ii.ll +++ b/tests/qir/test_pytket_qir_barrier_ii.ll @@ -32,6 +32,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() diff --git a/tests/qir/test_pytket_qir_conditional.ll b/tests/qir/test_pytket_qir_conditional.ll index 71e7f1ac..bda375a0 100644 --- a/tests/qir/test_pytket_qir_conditional.ll +++ b/tests/qir/test_pytket_qir_conditional.ll @@ -47,24 +47,18 @@ else: ; preds = %entry br label %continue continue: ; preds = %else, %then - call void @__quantum__qis__mz__body(%Qubit* inttoptr (i64 2 to %Qubit*), %Result* inttoptr (i64 2 to %Result*)) - %20 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 2 to %Result*)) - call void @set_creg_bit(i1* %3, i64 2, i1 %20) - call void @__quantum__qis__mz__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - %21 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 1 to %Result*)) - call void @set_creg_bit(i1* %3, i64 3, i1 %21) - call void @__quantum__qis__mz__body(%Qubit* null, %Result* null) - %22 = call i1 @__quantum__qis__read_result__body(%Result* null) - call void @set_creg_bit(i1* %3, i64 4, i1 %22) + call void @mz_to_creg_bit(%Qubit* inttoptr (i64 2 to %Qubit*), i1* %3, i64 2) + call void @mz_to_creg_bit(%Qubit* inttoptr (i64 1 to %Qubit*), i1* %3, i64 3) + call void @mz_to_creg_bit(%Qubit* null, i1* %3, i64 4) call void @__quantum__rt__tuple_start_record_output() - %23 = call i64 @get_int_from_creg(i1* %0) - call void @__quantum__rt__int_record_output(i64 %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @0, i32 0, i32 0)) - %24 = call i64 @get_int_from_creg(i1* %1) - call void @__quantum__rt__int_record_output(i64 %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @1, i32 0, i32 0)) - %25 = call i64 @get_int_from_creg(i1* %2) - call void @__quantum__rt__int_record_output(i64 %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @2, i32 0, i32 0)) - %26 = call i64 @get_int_from_creg(i1* %3) - call void @__quantum__rt__int_record_output(i64 %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @3, i32 0, i32 0)) + %20 = call i64 @get_int_from_creg(i1* %0) + call void @__quantum__rt__int_record_output(i64 %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @0, i32 0, i32 0)) + %21 = call i64 @get_int_from_creg(i1* %1) + call void @__quantum__rt__int_record_output(i64 %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @1, i32 0, i32 0)) + %22 = call i64 @get_int_from_creg(i1* %2) + call void @__quantum__rt__int_record_output(i64 %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @2, i32 0, i32 0)) + %23 = call i64 @get_int_from_creg(i1* %3) + call void @__quantum__rt__int_record_output(i64 %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @3, i32 0, i32 0)) call void @__quantum__rt__tuple_end_record_output() ret void } @@ -81,6 +75,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() @@ -89,10 +85,7 @@ declare void @__quantum__rt__tuple_end_record_output() declare void @__quantum__qis__h__body(%Qubit*) -declare void @__quantum__qis__mz__body(%Qubit*, %Result* writeonly) #1 - attributes #0 = { "entry_point" "num_required_qubits"="3" "num_required_results"="3" "output_labeling_schema" "qir_profiles"="custom" } -attributes #1 = { "irreversible" } !llvm.module.flags = !{!0, !1, !2, !3} diff --git a/tests/qir/test_pytket_qir_conditional_10.ll b/tests/qir/test_pytket_qir_conditional_10.ll index 6586ff3d..595fbc42 100644 --- a/tests/qir/test_pytket_qir_conditional_10.ll +++ b/tests/qir/test_pytket_qir_conditional_10.ll @@ -53,6 +53,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() diff --git a/tests/qir/test_pytket_qir_conditional_11.ll b/tests/qir/test_pytket_qir_conditional_11.ll index 6d903e23..ff96b57c 100644 --- a/tests/qir/test_pytket_qir_conditional_11.ll +++ b/tests/qir/test_pytket_qir_conditional_11.ll @@ -960,6 +960,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() diff --git a/tests/qir/test_pytket_qir_conditional_6.ll b/tests/qir/test_pytket_qir_conditional_6.ll index 9eba07a3..74a17317 100644 --- a/tests/qir/test_pytket_qir_conditional_6.ll +++ b/tests/qir/test_pytket_qir_conditional_6.ll @@ -42,6 +42,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() diff --git a/tests/qir/test_pytket_qir_conditional_7.ll b/tests/qir/test_pytket_qir_conditional_7.ll index a41f3827..eb45dd11 100644 --- a/tests/qir/test_pytket_qir_conditional_7.ll +++ b/tests/qir/test_pytket_qir_conditional_7.ll @@ -116,6 +116,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() diff --git a/tests/qir/test_pytket_qir_conditional_8.ll b/tests/qir/test_pytket_qir_conditional_8.ll index 6c07f9b8..bf02ae22 100644 --- a/tests/qir/test_pytket_qir_conditional_8.ll +++ b/tests/qir/test_pytket_qir_conditional_8.ll @@ -42,6 +42,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() diff --git a/tests/qir/test_pytket_qir_conditional_9.ll b/tests/qir/test_pytket_qir_conditional_9.ll index 27e4bbf6..2d9e198d 100644 --- a/tests/qir/test_pytket_qir_conditional_9.ll +++ b/tests/qir/test_pytket_qir_conditional_9.ll @@ -42,6 +42,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() diff --git a/tests/qir/test_pytket_qir_conditional_ii.ll b/tests/qir/test_pytket_qir_conditional_ii.ll index 4f80bff7..0b8f042a 100644 --- a/tests/qir/test_pytket_qir_conditional_ii.ll +++ b/tests/qir/test_pytket_qir_conditional_ii.ll @@ -47,24 +47,18 @@ else: ; preds = %entry br label %continue continue: ; preds = %else, %then - call void @__quantum__qis__mz__body(%Qubit* inttoptr (i64 2 to %Qubit*), %Result* inttoptr (i64 2 to %Result*)) - %20 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 2 to %Result*)) - call void @set_creg_bit(i1* %3, i64 2, i1 %20) - call void @__quantum__qis__mz__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - %21 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 1 to %Result*)) - call void @set_creg_bit(i1* %3, i64 3, i1 %21) - call void @__quantum__qis__mz__body(%Qubit* null, %Result* null) - %22 = call i1 @__quantum__qis__read_result__body(%Result* null) - call void @set_creg_bit(i1* %3, i64 4, i1 %22) + call void @mz_to_creg_bit(%Qubit* inttoptr (i64 2 to %Qubit*), i1* %3, i64 2) + call void @mz_to_creg_bit(%Qubit* inttoptr (i64 1 to %Qubit*), i1* %3, i64 3) + call void @mz_to_creg_bit(%Qubit* null, i1* %3, i64 4) call void @__quantum__rt__tuple_start_record_output() - %23 = call i64 @get_int_from_creg(i1* %0) - call void @__quantum__rt__int_record_output(i64 %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @0, i32 0, i32 0)) - %24 = call i64 @get_int_from_creg(i1* %1) - call void @__quantum__rt__int_record_output(i64 %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @1, i32 0, i32 0)) - %25 = call i64 @get_int_from_creg(i1* %2) - call void @__quantum__rt__int_record_output(i64 %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @2, i32 0, i32 0)) - %26 = call i64 @get_int_from_creg(i1* %3) - call void @__quantum__rt__int_record_output(i64 %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @3, i32 0, i32 0)) + %20 = call i64 @get_int_from_creg(i1* %0) + call void @__quantum__rt__int_record_output(i64 %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @0, i32 0, i32 0)) + %21 = call i64 @get_int_from_creg(i1* %1) + call void @__quantum__rt__int_record_output(i64 %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @1, i32 0, i32 0)) + %22 = call i64 @get_int_from_creg(i1* %2) + call void @__quantum__rt__int_record_output(i64 %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @2, i32 0, i32 0)) + %23 = call i64 @get_int_from_creg(i1* %3) + call void @__quantum__rt__int_record_output(i64 %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @3, i32 0, i32 0)) call void @__quantum__rt__tuple_end_record_output() ret void } @@ -81,6 +75,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() @@ -89,10 +85,7 @@ declare void @__quantum__rt__tuple_end_record_output() declare void @__quantum__qis__h__body(%Qubit*) -declare void @__quantum__qis__mz__body(%Qubit*, %Result* writeonly) #1 - attributes #0 = { "entry_point" "num_required_qubits"="3" "num_required_results"="3" "output_labeling_schema" "qir_profiles"="custom" } -attributes #1 = { "irreversible" } !llvm.module.flags = !{!0, !1, !2, !3} diff --git a/tests/qir/test_pytket_qir_conditional_iii.ll b/tests/qir/test_pytket_qir_conditional_iii.ll index 27ac7b03..50841e02 100644 --- a/tests/qir/test_pytket_qir_conditional_iii.ll +++ b/tests/qir/test_pytket_qir_conditional_iii.ll @@ -90,6 +90,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() diff --git a/tests/qir/test_pytket_qir_conditional_iv.ll b/tests/qir/test_pytket_qir_conditional_iv.ll index 63a45abc..eb3a581a 100644 --- a/tests/qir/test_pytket_qir_conditional_iv.ll +++ b/tests/qir/test_pytket_qir_conditional_iv.ll @@ -11,15 +11,11 @@ entry: %0 = call i1* @create_creg(i64 2) call void @__quantum__qis__h__body(%Qubit* null) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 1 to %Qubit*)) - call void @__quantum__qis__mz__body(%Qubit* null, %Result* null) - %1 = call i1 @__quantum__qis__read_result__body(%Result* null) - call void @set_creg_bit(i1* %0, i64 0, i1 %1) - call void @__quantum__qis__mz__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - %2 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 1 to %Result*)) - call void @set_creg_bit(i1* %0, i64 1, i1 %2) - %3 = call i64 @get_int_from_creg(i1* %0) - %4 = icmp eq i64 3, %3 - br i1 %4, label %then, label %else + call void @mz_to_creg_bit(%Qubit* null, i1* %0, i64 0) + call void @mz_to_creg_bit(%Qubit* inttoptr (i64 1 to %Qubit*), i1* %0, i64 1) + %1 = call i64 @get_int_from_creg(i1* %0) + %2 = icmp eq i64 3, %1 + br i1 %2, label %then, label %else then: ; preds = %entry call void @__quantum__qis__h__body(%Qubit* null) @@ -30,8 +26,8 @@ else: ; preds = %entry continue: ; preds = %else, %then call void @__quantum__rt__tuple_start_record_output() - %5 = call i64 @get_int_from_creg(i1* %0) - call void @__quantum__rt__int_record_output(i64 %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @0, i32 0, i32 0)) + %3 = call i64 @get_int_from_creg(i1* %0) + call void @__quantum__rt__int_record_output(i64 %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @0, i32 0, i32 0)) call void @__quantum__rt__tuple_end_record_output() ret void } @@ -48,6 +44,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() @@ -56,10 +54,7 @@ declare void @__quantum__rt__tuple_end_record_output() declare void @__quantum__qis__h__body(%Qubit*) -declare void @__quantum__qis__mz__body(%Qubit*, %Result* writeonly) #1 - attributes #0 = { "entry_point" "num_required_qubits"="2" "num_required_results"="2" "output_labeling_schema" "qir_profiles"="custom" } -attributes #1 = { "irreversible" } !llvm.module.flags = !{!0, !1, !2, !3} diff --git a/tests/qir/test_pytket_qir_conditional_v.ll b/tests/qir/test_pytket_qir_conditional_v.ll index 59c119cc..df8df8f7 100644 --- a/tests/qir/test_pytket_qir_conditional_v.ll +++ b/tests/qir/test_pytket_qir_conditional_v.ll @@ -11,15 +11,11 @@ entry: %0 = call i1* @create_creg(i64 3) call void @__quantum__qis__h__body(%Qubit* null) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 1 to %Qubit*)) - call void @__quantum__qis__mz__body(%Qubit* null, %Result* null) - %1 = call i1 @__quantum__qis__read_result__body(%Result* null) - call void @set_creg_bit(i1* %0, i64 0, i1 %1) - call void @__quantum__qis__mz__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - %2 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 1 to %Result*)) - call void @set_creg_bit(i1* %0, i64 1, i1 %2) - %3 = call i64 @get_int_from_creg(i1* %0) - %4 = icmp eq i64 3, %3 - br i1 %4, label %then, label %else + call void @mz_to_creg_bit(%Qubit* null, i1* %0, i64 0) + call void @mz_to_creg_bit(%Qubit* inttoptr (i64 1 to %Qubit*), i1* %0, i64 1) + %1 = call i64 @get_int_from_creg(i1* %0) + %2 = icmp eq i64 3, %1 + br i1 %2, label %then, label %else then: ; preds = %entry call void @__quantum__qis__h__body(%Qubit* null) @@ -30,8 +26,8 @@ else: ; preds = %entry continue: ; preds = %else, %then call void @__quantum__rt__tuple_start_record_output() - %5 = call i64 @get_int_from_creg(i1* %0) - call void @__quantum__rt__int_record_output(i64 %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @0, i32 0, i32 0)) + %3 = call i64 @get_int_from_creg(i1* %0) + call void @__quantum__rt__int_record_output(i64 %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @0, i32 0, i32 0)) call void @__quantum__rt__tuple_end_record_output() ret void } @@ -48,6 +44,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() @@ -56,10 +54,7 @@ declare void @__quantum__rt__tuple_end_record_output() declare void @__quantum__qis__h__body(%Qubit*) -declare void @__quantum__qis__mz__body(%Qubit*, %Result* writeonly) #1 - attributes #0 = { "entry_point" "num_required_qubits"="2" "num_required_results"="2" "output_labeling_schema" "qir_profiles"="custom" } -attributes #1 = { "irreversible" } !llvm.module.flags = !{!0, !1, !2, !3} diff --git a/tests/qir/test_pytket_qir_module.ll b/tests/qir/test_pytket_qir_module.ll index 2d1c6962..4549c8e3 100644 --- a/tests/qir/test_pytket_qir_module.ll +++ b/tests/qir/test_pytket_qir_module.ll @@ -24,6 +24,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() diff --git a/tests/qir/test_pytket_qir_qasm.ll b/tests/qir/test_pytket_qir_qasm.ll index 29c6a0a7..0664b19f 100644 --- a/tests/qir/test_pytket_qir_qasm.ll +++ b/tests/qir/test_pytket_qir_qasm.ll @@ -2,6 +2,7 @@ source_filename = "test_pytket_qir_qasm" %Result = type opaque +%Qubit = type opaque @0 = internal constant [2 x i8] c"p\00" @1 = internal constant [2 x i8] c"s\00" @@ -47,6 +48,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() diff --git a/tests/qir/test_pytket_qir_quantum.ll b/tests/qir/test_pytket_qir_quantum.ll index e74f7181..a07984dd 100644 --- a/tests/qir/test_pytket_qir_quantum.ll +++ b/tests/qir/test_pytket_qir_quantum.ll @@ -24,6 +24,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() diff --git a/tests/qir/test_pytket_qir_quantum_ii.ll b/tests/qir/test_pytket_qir_quantum_ii.ll index 2ebb5a00..1fd73f7c 100644 --- a/tests/qir/test_pytket_qir_quantum_ii.ll +++ b/tests/qir/test_pytket_qir_quantum_ii.ll @@ -15,14 +15,12 @@ entry: call void @__quantum__qis__cnot__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Qubit* inttoptr (i64 3 to %Qubit*)) call void @__quantum__qis__y__body(%Qubit* null) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 1 to %Qubit*)) - call void @__quantum__qis__mz__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - %1 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 1 to %Result*)) - call void @set_creg_bit(i1* %0, i64 1, i1 %1) + call void @mz_to_creg_bit(%Qubit* inttoptr (i64 1 to %Qubit*), i1* %0, i64 1) call void @__quantum__qis__z__body(%Qubit* null) call void @__quantum__qis__rx__body(double 0x3FF921FB54442D18, %Qubit* null) call void @__quantum__rt__tuple_start_record_output() - %2 = call i64 @get_int_from_creg(i1* %0) - call void @__quantum__rt__int_record_output(i64 %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @0, i32 0, i32 0)) + %1 = call i64 @get_int_from_creg(i1* %0) + call void @__quantum__rt__int_record_output(i64 %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @0, i32 0, i32 0)) call void @__quantum__rt__tuple_end_record_output() ret void } @@ -39,6 +37,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() @@ -53,14 +53,11 @@ declare void @__quantum__qis__x__body(%Qubit*) declare void @__quantum__qis__y__body(%Qubit*) -declare void @__quantum__qis__mz__body(%Qubit*, %Result* writeonly) #1 - declare void @__quantum__qis__z__body(%Qubit*) declare void @__quantum__qis__rx__body(double, %Qubit*) attributes #0 = { "entry_point" "num_required_qubits"="4" "num_required_results"="4" "output_labeling_schema" "qir_profiles"="custom" } -attributes #1 = { "irreversible" } !llvm.module.flags = !{!0, !1, !2, !3} diff --git a/tests/qir/test_pytket_qir_quantum_iii.ll b/tests/qir/test_pytket_qir_quantum_iii.ll index e2401f91..ff82d864 100644 --- a/tests/qir/test_pytket_qir_quantum_iii.ll +++ b/tests/qir/test_pytket_qir_quantum_iii.ll @@ -11,15 +11,11 @@ entry: %0 = call i1* @create_creg(i64 2) call void @__quantum__qis__h__body(%Qubit* null) call void @__quantum__qis__cnot__body(%Qubit* null, %Qubit* inttoptr (i64 1 to %Qubit*)) - call void @__quantum__qis__mz__body(%Qubit* null, %Result* null) - %1 = call i1 @__quantum__qis__read_result__body(%Result* null) - call void @set_creg_bit(i1* %0, i64 0, i1 %1) - call void @__quantum__qis__mz__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - %2 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 1 to %Result*)) - call void @set_creg_bit(i1* %0, i64 1, i1 %2) + call void @mz_to_creg_bit(%Qubit* null, i1* %0, i64 0) + call void @mz_to_creg_bit(%Qubit* inttoptr (i64 1 to %Qubit*), i1* %0, i64 1) call void @__quantum__rt__tuple_start_record_output() - %3 = call i64 @get_int_from_creg(i1* %0) - call void @__quantum__rt__int_record_output(i64 %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @0, i32 0, i32 0)) + %1 = call i64 @get_int_from_creg(i1* %0) + call void @__quantum__rt__int_record_output(i64 %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @0, i32 0, i32 0)) call void @__quantum__rt__tuple_end_record_output() ret void } @@ -36,6 +32,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() @@ -46,10 +44,7 @@ declare void @__quantum__qis__h__body(%Qubit*) declare void @__quantum__qis__cnot__body(%Qubit*, %Qubit*) -declare void @__quantum__qis__mz__body(%Qubit*, %Result* writeonly) #1 - attributes #0 = { "entry_point" "num_required_qubits"="2" "num_required_results"="2" "output_labeling_schema" "qir_profiles"="custom" } -attributes #1 = { "irreversible" } !llvm.module.flags = !{!0, !1, !2, !3} diff --git a/tests/qir/test_pytket_qir_quantum_iv.ll b/tests/qir/test_pytket_qir_quantum_iv.ll index 6114a70f..45d7cad5 100644 --- a/tests/qir/test_pytket_qir_quantum_iv.ll +++ b/tests/qir/test_pytket_qir_quantum_iv.ll @@ -20,12 +20,10 @@ entry: call void @__quantum__qis__cnot__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Qubit* inttoptr (i64 2 to %Qubit*)) call void @__quantum__qis__cnot__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Qubit* inttoptr (i64 3 to %Qubit*)) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 1 to %Qubit*)) - call void @__quantum__qis__mz__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - %1 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 1 to %Result*)) - call void @set_creg_bit(i1* %0, i64 1, i1 %1) + call void @mz_to_creg_bit(%Qubit* inttoptr (i64 1 to %Qubit*), i1* %0, i64 1) call void @__quantum__rt__tuple_start_record_output() - %2 = call i64 @get_int_from_creg(i1* %0) - call void @__quantum__rt__int_record_output(i64 %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @0, i32 0, i32 0)) + %1 = call i64 @get_int_from_creg(i1* %0) + call void @__quantum__rt__int_record_output(i64 %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @0, i32 0, i32 0)) call void @__quantum__rt__tuple_end_record_output() ret void } @@ -42,6 +40,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() @@ -66,10 +66,7 @@ declare void @__quantum__qis__zzmax__body(%Qubit*, %Qubit*) declare void @__quantum__qis__cnot__body(%Qubit*, %Qubit*) -declare void @__quantum__qis__mz__body(%Qubit*, %Result* writeonly) #1 - attributes #0 = { "entry_point" "num_required_qubits"="4" "num_required_results"="4" "output_labeling_schema" "qir_profiles"="custom" } -attributes #1 = { "irreversible" } !llvm.module.flags = !{!0, !1, !2, !3} diff --git a/tests/qir/test_pytket_qir_quantum_v.ll b/tests/qir/test_pytket_qir_quantum_v.ll index 24dd33e8..af299839 100644 --- a/tests/qir/test_pytket_qir_quantum_v.ll +++ b/tests/qir/test_pytket_qir_quantum_v.ll @@ -21,12 +21,10 @@ entry: call void @__quantum__qis__cnot__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Qubit* inttoptr (i64 2 to %Qubit*)) call void @__quantum__qis__cnot__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Qubit* inttoptr (i64 3 to %Qubit*)) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 1 to %Qubit*)) - call void @__quantum__qis__mz__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - %1 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 1 to %Result*)) - call void @set_creg_bit(i1* %0, i64 1, i1 %1) + call void @mz_to_creg_bit(%Qubit* inttoptr (i64 1 to %Qubit*), i1* %0, i64 1) call void @__quantum__rt__tuple_start_record_output() - %2 = call i64 @get_int_from_creg(i1* %0) - call void @__quantum__rt__int_record_output(i64 %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @0, i32 0, i32 0)) + %1 = call i64 @get_int_from_creg(i1* %0) + call void @__quantum__rt__int_record_output(i64 %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @0, i32 0, i32 0)) call void @__quantum__rt__tuple_end_record_output() ret void } @@ -43,6 +41,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() @@ -67,10 +67,7 @@ declare void @__quantum__qis__rxxyyzz__body(double, double, double, %Qubit*, %Qu declare void @__quantum__qis__cnot__body(%Qubit*, %Qubit*) -declare void @__quantum__qis__mz__body(%Qubit*, %Result* writeonly) #1 - attributes #0 = { "entry_point" "num_required_qubits"="4" "num_required_results"="4" "output_labeling_schema" "qir_profiles"="custom" } -attributes #1 = { "irreversible" } !llvm.module.flags = !{!0, !1, !2, !3} diff --git a/tests/qir/test_pytket_qir_rangepredicate.ll b/tests/qir/test_pytket_qir_rangepredicate.ll index 1a9588eb..50e586f8 100644 --- a/tests/qir/test_pytket_qir_rangepredicate.ll +++ b/tests/qir/test_pytket_qir_rangepredicate.ll @@ -125,6 +125,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output() diff --git a/tests/qir/test_pytket_qir_wasm.ll b/tests/qir/test_pytket_qir_wasm.ll index c510b51e..9823c7a5 100644 --- a/tests/qir/test_pytket_qir_wasm.ll +++ b/tests/qir/test_pytket_qir_wasm.ll @@ -24,6 +24,8 @@ declare i1* @create_creg(i32) declare i32 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i32) + declare void @__quantum__rt__int_record_output(i32, i8*) declare void @__quantum__rt__tuple_start_record_output() diff --git a/tests/qir/test_pytket_qir_wasm_ii.ll b/tests/qir/test_pytket_qir_wasm_ii.ll index 44b3eb22..406fe1f6 100644 --- a/tests/qir/test_pytket_qir_wasm_ii.ll +++ b/tests/qir/test_pytket_qir_wasm_ii.ll @@ -2,6 +2,7 @@ source_filename = "test_pytket_qir_wasm_ii" %Result = type opaque +%Qubit = type opaque @0 = internal constant [2 x i8] c"c\00" @1 = internal constant [3 x i8] c"c0\00" @@ -51,6 +52,8 @@ declare i1* @create_creg(i32) declare i32 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i32) + declare void @__quantum__rt__int_record_output(i32, i8*) declare void @__quantum__rt__tuple_start_record_output() diff --git a/tests/qir/test_pytket_qir_wasm_ii_64.ll b/tests/qir/test_pytket_qir_wasm_ii_64.ll index 87959724..a6e52031 100644 --- a/tests/qir/test_pytket_qir_wasm_ii_64.ll +++ b/tests/qir/test_pytket_qir_wasm_ii_64.ll @@ -2,6 +2,7 @@ source_filename = "test_pytket_qir_wasm_ii_64" %Result = type opaque +%Qubit = type opaque @0 = internal constant [2 x i8] c"c\00" @1 = internal constant [3 x i8] c"c0\00" @@ -41,6 +42,8 @@ declare i1* @create_creg(i64) declare i64 @get_int_from_creg(i1*) +declare void @mz_to_creg_bit(%Qubit*, i1*, i64) + declare void @__quantum__rt__int_record_output(i64, i8*) declare void @__quantum__rt__tuple_start_record_output()