Skip to content

Commit

Permalink
rename to mz_to_creg_bit, and add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
cqc-melf committed Oct 25, 2023
1 parent d29ee48 commit 844a75d
Show file tree
Hide file tree
Showing 42 changed files with 64 additions and 63 deletions.
9 changes: 5 additions & 4 deletions pytket/qir/conversion/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,10 @@ def __init__(
),
)

# void mz_to_creg(qubit, i1* creg, int creg_index)
self.mz_to_creg = self.module.module.add_external_function(
"mz_to_creg",
# 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),
[
Expand Down Expand Up @@ -856,7 +857,7 @@ def condition_block() -> None:
assert command.qubits[0].reg_name == "q"

self.module.builder.call(
self.mz_to_creg,
self.mz_to_creg_bit,
[
module.module.qubits[command.qubits[0].index[0]],
self.ssa_vars[command.bits[0].reg_name],
Expand Down
2 changes: 1 addition & 1 deletion tests/qir/test_pytket_qir.ll
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
2 changes: 1 addition & 1 deletion tests/qir/test_pytket_qir_10.ll
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
2 changes: 1 addition & 1 deletion tests/qir/test_pytket_qir_11.ll
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
2 changes: 1 addition & 1 deletion tests/qir/test_pytket_qir_12.ll
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
2 changes: 1 addition & 1 deletion tests/qir/test_pytket_qir_13.ll
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
2 changes: 1 addition & 1 deletion tests/qir/test_pytket_qir_14.ll
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
2 changes: 1 addition & 1 deletion tests/qir/test_pytket_qir_14_b.ll
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
2 changes: 1 addition & 1 deletion tests/qir/test_pytket_qir_15.ll
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
6 changes: 3 additions & 3 deletions tests/qir/test_pytket_qir_17.ll
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ 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 @mz_to_creg(%Qubit* null, i1* %0, i64 0)
call void @mz_to_creg(%Qubit* inttoptr (i64 1 to %Qubit*), i1* %1, i64 0)
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()
%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))
Expand All @@ -36,7 +36,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
2 changes: 1 addition & 1 deletion tests/qir/test_pytket_qir_2.ll
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
2 changes: 1 addition & 1 deletion tests/qir/test_pytket_qir_3.ll
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
2 changes: 1 addition & 1 deletion tests/qir/test_pytket_qir_4.ll
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
2 changes: 1 addition & 1 deletion tests/qir/test_pytket_qir_5.ll
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
4 changes: 2 additions & 2 deletions tests/qir/test_pytket_qir_6.ll
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ 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 @mz_to_creg(%Qubit* null, i1* %2, i64 4)
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

Expand Down Expand Up @@ -62,7 +62,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
2 changes: 1 addition & 1 deletion tests/qir/test_pytket_qir_7.ll
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
2 changes: 1 addition & 1 deletion tests/qir/test_pytket_qir_8.ll
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
2 changes: 1 addition & 1 deletion tests/qir/test_pytket_qir_9.ll
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
2 changes: 1 addition & 1 deletion tests/qir/test_pytket_qir_barrier.ll
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
2 changes: 1 addition & 1 deletion tests/qir/test_pytket_qir_barrier_ii.ll
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
8 changes: 4 additions & 4 deletions tests/qir/test_pytket_qir_conditional.ll
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ else: ; preds = %entry
br label %continue

continue: ; preds = %else, %then
call void @mz_to_creg(%Qubit* inttoptr (i64 2 to %Qubit*), i1* %3, i64 2)
call void @mz_to_creg(%Qubit* inttoptr (i64 1 to %Qubit*), i1* %3, i64 3)
call void @mz_to_creg(%Qubit* null, i1* %3, i64 4)
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()
%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))
Expand All @@ -75,7 +75,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
2 changes: 1 addition & 1 deletion tests/qir/test_pytket_qir_conditional_10.ll
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
2 changes: 1 addition & 1 deletion tests/qir/test_pytket_qir_conditional_11.ll
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
2 changes: 1 addition & 1 deletion tests/qir/test_pytket_qir_conditional_6.ll
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
2 changes: 1 addition & 1 deletion tests/qir/test_pytket_qir_conditional_7.ll
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
2 changes: 1 addition & 1 deletion tests/qir/test_pytket_qir_conditional_8.ll
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
2 changes: 1 addition & 1 deletion tests/qir/test_pytket_qir_conditional_9.ll
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
8 changes: 4 additions & 4 deletions tests/qir/test_pytket_qir_conditional_ii.ll
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ else: ; preds = %entry
br label %continue

continue: ; preds = %else, %then
call void @mz_to_creg(%Qubit* inttoptr (i64 2 to %Qubit*), i1* %3, i64 2)
call void @mz_to_creg(%Qubit* inttoptr (i64 1 to %Qubit*), i1* %3, i64 3)
call void @mz_to_creg(%Qubit* null, i1* %3, i64 4)
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()
%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))
Expand All @@ -75,7 +75,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
2 changes: 1 addition & 1 deletion tests/qir/test_pytket_qir_conditional_iii.ll
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
6 changes: 3 additions & 3 deletions tests/qir/test_pytket_qir_conditional_iv.ll
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ 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 @mz_to_creg(%Qubit* null, i1* %0, i64 0)
call void @mz_to_creg(%Qubit* inttoptr (i64 1 to %Qubit*), i1* %0, i64 1)
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
Expand Down Expand Up @@ -44,7 +44,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
6 changes: 3 additions & 3 deletions tests/qir/test_pytket_qir_conditional_v.ll
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ 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 @mz_to_creg(%Qubit* null, i1* %0, i64 0)
call void @mz_to_creg(%Qubit* inttoptr (i64 1 to %Qubit*), i1* %0, i64 1)
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
Expand Down Expand Up @@ -44,7 +44,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
2 changes: 1 addition & 1 deletion tests/qir/test_pytket_qir_module.ll
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
2 changes: 1 addition & 1 deletion tests/qir/test_pytket_qir_qasm.ll
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
2 changes: 1 addition & 1 deletion tests/qir/test_pytket_qir_quantum.ll
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ declare i1* @create_creg(i64)

declare i64 @get_int_from_creg(i1*)

declare void @mz_to_creg(%Qubit*, i1*, i64)
declare void @mz_to_creg_bit(%Qubit*, i1*, i64)

declare void @__quantum__rt__int_record_output(i64, i8*)

Expand Down
Loading

0 comments on commit 844a75d

Please sign in to comment.