diff --git a/source/compiler/qsc/src/codegen/tests.rs b/source/compiler/qsc/src/codegen/tests.rs index d31516d00d..24df5a5785 100644 --- a/source/compiler/qsc/src/codegen/tests.rs +++ b/source/compiler/qsc/src/codegen/tests.rs @@ -105,16 +105,22 @@ mod base_profile { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [4 x i8] c"0_r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__rz__body(double 2.0, %Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__rz__body(double 0.0, %Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__rz__body(double 1.0, %Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - ret void + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @0, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__rz__body(double, %Qubit*) declare void @__quantum__rt__result_record_output(%Result*, i8*) @@ -150,16 +156,23 @@ mod base_profile { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [6 x i8] c"0_t0r\00" + @1 = internal constant [6 x i8] c"1_t1r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - call void @__quantum__rt__tuple_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__rt__tuple_record_output(i64, i8*) declare void @__quantum__rt__result_record_output(%Result*, i8*) @@ -198,18 +211,25 @@ mod base_profile { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [6 x i8] c"0_a0r\00" + @1 = internal constant [6 x i8] c"1_a1r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - call void @__quantum__rt__array_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - ret void + call void @__quantum__rt__array_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__x__body(%Qubit*) declare void @__quantum__rt__array_record_output(i64, i8*) @@ -249,18 +269,25 @@ mod base_profile { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [6 x i8] c"0_t0r\00" + @1 = internal constant [6 x i8] c"1_t1r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - call void @__quantum__rt__tuple_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__x__body(%Qubit*) declare void @__quantum__rt__tuple_record_output(i64, i8*) @@ -305,18 +332,25 @@ mod base_profile { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [6 x i8] c"0_t0r\00" + @1 = internal constant [6 x i8] c"1_t1r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 3 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 2 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - call void @__quantum__rt__tuple_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__x__body(%Qubit*) declare void @__quantum__rt__tuple_record_output(i64, i8*) @@ -369,16 +403,22 @@ mod adaptive_profile { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [4 x i8] c"0_r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__rz__body(double 2.0, %Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__rz__body(double 0.0, %Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__rz__body(double 1.0, %Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - ret void + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @0, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__rz__body(double, %Qubit*) declare void @__quantum__rt__result_record_output(%Result*, i8*) @@ -414,16 +454,23 @@ mod adaptive_profile { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [6 x i8] c"0_t0r\00" + @1 = internal constant [6 x i8] c"1_t1r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - call void @__quantum__rt__tuple_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__rt__tuple_record_output(i64, i8*) declare void @__quantum__rt__result_record_output(%Result*, i8*) @@ -463,14 +510,20 @@ mod adaptive_profile { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [4 x i8] c"0_r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__mx__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - ret void + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @0, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__h__body(%Qubit*) declare void @__quantum__qis__mx__body(%Qubit*, %Result*) #1 @@ -512,17 +565,24 @@ mod adaptive_profile { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [6 x i8] c"0_t0r\00" + @1 = internal constant [6 x i8] c"1_t1r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__mzz__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 0 to %Result*), %Result* inttoptr (i64 1 to %Result*)) - call void @__quantum__rt__tuple_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__h__body(%Qubit*) declare void @__quantum__qis__mzz__body(%Qubit*, %Qubit*, %Result*, %Result*) #1 @@ -563,18 +623,25 @@ mod adaptive_profile { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [6 x i8] c"0_a0r\00" + @1 = internal constant [6 x i8] c"1_a1r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - call void @__quantum__rt__array_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - ret void + call void @__quantum__rt__array_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__x__body(%Qubit*) declare void @__quantum__rt__array_record_output(i64, i8*) @@ -633,16 +700,22 @@ mod adaptive_ri_profile { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [4 x i8] c"0_r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__rz__body(double 2.0, %Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__rz__body(double 0.0, %Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__rz__body(double 1.0, %Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - ret void + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @0, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__rz__body(double, %Qubit*) declare void @__quantum__qis__mresetz__body(%Qubit*, %Result*) #1 @@ -660,7 +733,7 @@ mod adaptive_ri_profile { !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} - !4 = !{i32 1, !"int_computations", !"i64"} + !4 = !{i32 5, !"int_computations", !{!"i64"}} "#]] .assert_eq(&qir); } @@ -679,16 +752,23 @@ mod adaptive_ri_profile { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [6 x i8] c"0_t0r\00" + @1 = internal constant [6 x i8] c"1_t1r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - call void @__quantum__rt__tuple_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__mresetz__body(%Qubit*, %Result*) #1 declare void @__quantum__rt__tuple_record_output(i64, i8*) @@ -706,7 +786,7 @@ mod adaptive_ri_profile { !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} - !4 = !{i32 1, !"int_computations", !"i64"} + !4 = !{i32 5, !"int_computations", !{!"i64"}} "#]].assert_eq(&qir); } @@ -728,18 +808,25 @@ mod adaptive_ri_profile { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [6 x i8] c"0_a0r\00" + @1 = internal constant [6 x i8] c"1_a1r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - call void @__quantum__rt__array_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - ret void + call void @__quantum__rt__array_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__x__body(%Qubit*) declare void @__quantum__qis__mresetz__body(%Qubit*, %Result*) #1 @@ -759,7 +846,7 @@ mod adaptive_ri_profile { !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} - !4 = !{i32 1, !"int_computations", !"i64"} + !4 = !{i32 5, !"int_computations", !{!"i64"}} "#]].assert_eq(&qir); } @@ -780,18 +867,25 @@ mod adaptive_ri_profile { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [6 x i8] c"0_t0r\00" + @1 = internal constant [6 x i8] c"1_t1r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - call void @__quantum__rt__tuple_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__x__body(%Qubit*) declare void @__quantum__qis__mresetz__body(%Qubit*, %Result*) #1 @@ -811,7 +905,7 @@ mod adaptive_ri_profile { !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} - !4 = !{i32 1, !"int_computations", !"i64"} + !4 = !{i32 5, !"int_computations", !{!"i64"}} "#]].assert_eq(&qir); } @@ -837,20 +931,27 @@ mod adaptive_ri_profile { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [6 x i8] c"0_t0r\00" + @1 = internal constant [6 x i8] c"1_t1r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - call void @__quantum__rt__tuple_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__x__body(%Qubit*) declare void @__quantum__qis__reset__body(%Qubit*) #1 @@ -872,7 +973,7 @@ mod adaptive_ri_profile { !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} - !4 = !{i32 1, !"int_computations", !"i64"} + !4 = !{i32 5, !"int_computations", !{!"i64"}} "#]].assert_eq(&qir); } @@ -899,20 +1000,27 @@ mod adaptive_ri_profile { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [6 x i8] c"0_t0r\00" + @1 = internal constant [6 x i8] c"1_t1r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 2 to %Qubit*)) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - call void @__quantum__rt__tuple_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__x__body(%Qubit*) declare void @__quantum__qis__mresetz__body(%Qubit*, %Result*) #1 @@ -932,7 +1040,7 @@ mod adaptive_ri_profile { !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} - !4 = !{i32 1, !"int_computations", !"i64"} + !4 = !{i32 5, !"int_computations", !{!"i64"}} "#]].assert_eq(&qir); } @@ -951,11 +1059,15 @@ mod adaptive_ri_profile { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [4 x i8] c"0_i\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - %var_0 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 0 to %Result*)) + %var_0 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 0 to %Result*)) %var_1 = icmp eq i1 %var_0, false br i1 %var_1, label %block_1, label %block_2 block_1: @@ -964,15 +1076,17 @@ mod adaptive_ri_profile { br label %block_3 block_3: %var_4 = phi i64 [0, %block_1], [1, %block_2] - call void @__quantum__rt__int_record_output(i64 %var_4, i8* null) - ret void + call void @__quantum__rt__int_record_output(i64 %var_4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @0, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__h__body(%Qubit*) declare void @__quantum__qis__mresetz__body(%Qubit*, %Result*) #1 - declare i1 @__quantum__qis__read_result__body(%Result*) + declare i1 @__quantum__rt__read_result(%Result*) declare void @__quantum__rt__int_record_output(i64, i8*) @@ -987,7 +1101,7 @@ mod adaptive_ri_profile { !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} - !4 = !{i32 1, !"int_computations", !"i64"} + !4 = !{i32 5, !"int_computations", !{!"i64"}} "#]].assert_eq(&qir); } @@ -1010,14 +1124,20 @@ mod adaptive_ri_profile { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [4 x i8] c"0_r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__custom_reset__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - ret void + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @0, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__custom_reset__body(%Qubit*) #1 declare void @__quantum__qis__m__body(%Qubit*, %Result*) #1 @@ -1035,7 +1155,7 @@ mod adaptive_ri_profile { !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} - !4 = !{i32 1, !"int_computations", !"i64"} + !4 = !{i32 5, !"int_computations", !{!"i64"}} "#]] .assert_eq(&qir); } @@ -1075,16 +1195,22 @@ mod adaptive_rif_profile { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [4 x i8] c"0_r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__rz__body(double 2.0, %Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__rz__body(double 0.0, %Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__rz__body(double 1.0, %Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - ret void + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @0, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__rz__body(double, %Qubit*) declare void @__quantum__qis__mresetz__body(%Qubit*, %Result*) #1 @@ -1102,8 +1228,8 @@ mod adaptive_rif_profile { !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} - !4 = !{i32 1, !"int_computations", !"i64"} - !5 = !{i32 1, !"float_computations", !"f64"} + !4 = !{i32 5, !"int_computations", !{!"i64"}} + !5 = !{i32 5, !"float_computations", !{!"f64"}} "#]] .assert_eq(&qir); } @@ -1122,16 +1248,23 @@ mod adaptive_rif_profile { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [6 x i8] c"0_t0r\00" + @1 = internal constant [6 x i8] c"1_t1r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - call void @__quantum__rt__tuple_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__mresetz__body(%Qubit*, %Result*) #1 declare void @__quantum__rt__tuple_record_output(i64, i8*) @@ -1149,8 +1282,8 @@ mod adaptive_rif_profile { !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} - !4 = !{i32 1, !"int_computations", !"i64"} - !5 = !{i32 1, !"float_computations", !"f64"} + !4 = !{i32 5, !"int_computations", !{!"i64"}} + !5 = !{i32 5, !"float_computations", !{!"f64"}} "#]].assert_eq(&qir); } @@ -1172,18 +1305,25 @@ mod adaptive_rif_profile { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [6 x i8] c"0_a0r\00" + @1 = internal constant [6 x i8] c"1_a1r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - call void @__quantum__rt__array_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - ret void + call void @__quantum__rt__array_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__x__body(%Qubit*) declare void @__quantum__qis__mresetz__body(%Qubit*, %Result*) #1 @@ -1203,8 +1343,8 @@ mod adaptive_rif_profile { !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} - !4 = !{i32 1, !"int_computations", !"i64"} - !5 = !{i32 1, !"float_computations", !"f64"} + !4 = !{i32 5, !"int_computations", !{!"i64"}} + !5 = !{i32 5, !"float_computations", !{!"f64"}} "#]].assert_eq(&qir); } @@ -1225,18 +1365,25 @@ mod adaptive_rif_profile { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [6 x i8] c"0_t0r\00" + @1 = internal constant [6 x i8] c"1_t1r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - call void @__quantum__rt__tuple_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__x__body(%Qubit*) declare void @__quantum__qis__mresetz__body(%Qubit*, %Result*) #1 @@ -1256,8 +1403,8 @@ mod adaptive_rif_profile { !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} - !4 = !{i32 1, !"int_computations", !"i64"} - !5 = !{i32 1, !"float_computations", !"f64"} + !4 = !{i32 5, !"int_computations", !{!"i64"}} + !5 = !{i32 5, !"float_computations", !{!"f64"}} "#]].assert_eq(&qir); } @@ -1283,20 +1430,27 @@ mod adaptive_rif_profile { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [6 x i8] c"0_t0r\00" + @1 = internal constant [6 x i8] c"1_t1r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - call void @__quantum__rt__tuple_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__x__body(%Qubit*) declare void @__quantum__qis__reset__body(%Qubit*) #1 @@ -1318,8 +1472,8 @@ mod adaptive_rif_profile { !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} - !4 = !{i32 1, !"int_computations", !"i64"} - !5 = !{i32 1, !"float_computations", !"f64"} + !4 = !{i32 5, !"int_computations", !{!"i64"}} + !5 = !{i32 5, !"float_computations", !{!"f64"}} "#]].assert_eq(&qir); } @@ -1346,20 +1500,27 @@ mod adaptive_rif_profile { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [6 x i8] c"0_t0r\00" + @1 = internal constant [6 x i8] c"1_t1r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 2 to %Qubit*)) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - call void @__quantum__rt__tuple_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__x__body(%Qubit*) declare void @__quantum__qis__mresetz__body(%Qubit*, %Result*) #1 @@ -1379,8 +1540,8 @@ mod adaptive_rif_profile { !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} - !4 = !{i32 1, !"int_computations", !"i64"} - !5 = !{i32 1, !"float_computations", !"f64"} + !4 = !{i32 5, !"int_computations", !{!"i64"}} + !5 = !{i32 5, !"float_computations", !{!"f64"}} "#]].assert_eq(&qir); } @@ -1399,11 +1560,15 @@ mod adaptive_rif_profile { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [4 x i8] c"0_i\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - %var_0 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 0 to %Result*)) + %var_0 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 0 to %Result*)) %var_1 = icmp eq i1 %var_0, false br i1 %var_1, label %block_1, label %block_2 block_1: @@ -1412,15 +1577,17 @@ mod adaptive_rif_profile { br label %block_3 block_3: %var_4 = phi i64 [0, %block_1], [1, %block_2] - call void @__quantum__rt__int_record_output(i64 %var_4, i8* null) - ret void + call void @__quantum__rt__int_record_output(i64 %var_4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @0, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__h__body(%Qubit*) declare void @__quantum__qis__mresetz__body(%Qubit*, %Result*) #1 - declare i1 @__quantum__qis__read_result__body(%Result*) + declare i1 @__quantum__rt__read_result(%Result*) declare void @__quantum__rt__int_record_output(i64, i8*) @@ -1435,8 +1602,8 @@ mod adaptive_rif_profile { !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} - !4 = !{i32 1, !"int_computations", !"i64"} - !5 = !{i32 1, !"float_computations", !"f64"} + !4 = !{i32 5, !"int_computations", !{!"i64"}} + !5 = !{i32 5, !"float_computations", !{!"f64"}} "#]].assert_eq(&qir); } @@ -1455,11 +1622,15 @@ mod adaptive_rif_profile { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [4 x i8] c"0_d\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - %var_0 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 0 to %Result*)) + %var_0 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 0 to %Result*)) %var_1 = icmp eq i1 %var_0, false br i1 %var_1, label %block_1, label %block_2 block_1: @@ -1468,15 +1639,17 @@ mod adaptive_rif_profile { br label %block_3 block_3: %var_4 = phi double [0.0, %block_1], [1.0, %block_2] - call void @__quantum__rt__double_record_output(double %var_4, i8* null) - ret void + call void @__quantum__rt__double_record_output(double %var_4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @0, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__h__body(%Qubit*) declare void @__quantum__qis__mresetz__body(%Qubit*, %Result*) #1 - declare i1 @__quantum__qis__read_result__body(%Result*) + declare i1 @__quantum__rt__read_result(%Result*) declare void @__quantum__rt__double_record_output(double, i8*) @@ -1491,8 +1664,8 @@ mod adaptive_rif_profile { !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} - !4 = !{i32 1, !"int_computations", !"i64"} - !5 = !{i32 1, !"float_computations", !"f64"} + !4 = !{i32 5, !"int_computations", !{!"i64"}} + !5 = !{i32 5, !"float_computations", !{!"f64"}} "#]].assert_eq(&qir); } @@ -1515,14 +1688,20 @@ mod adaptive_rif_profile { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [4 x i8] c"0_r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__custom_reset__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - ret void + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @0, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__custom_reset__body(%Qubit*) #1 declare void @__quantum__qis__m__body(%Qubit*, %Result*) #1 @@ -1540,8 +1719,8 @@ mod adaptive_rif_profile { !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} - !4 = !{i32 1, !"int_computations", !"i64"} - !5 = !{i32 1, !"float_computations", !"f64"} + !4 = !{i32 5, !"int_computations", !{!"i64"}} + !5 = !{i32 5, !"float_computations", !{!"f64"}} "#]] .assert_eq(&qir); } @@ -1569,11 +1748,15 @@ mod adaptive_rif_profile { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [4 x i8] c"0_d\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - %var_0 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 0 to %Result*)) + %var_0 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 0 to %Result*)) %var_1 = icmp eq i1 %var_0, false br i1 %var_1, label %block_1, label %block_2 block_1: @@ -1592,15 +1775,17 @@ mod adaptive_rif_profile { call void @__quantum__qis__rz__body(double %var_7, %Qubit* inttoptr (i64 0 to %Qubit*)) call void @OpA(double %var_9, %Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__rx__body(double %var_9, %Qubit* inttoptr (i64 0 to %Qubit*)) - call void @__quantum__rt__double_record_output(double %var_9, i8* null) - ret void + call void @__quantum__rt__double_record_output(double %var_9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @0, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__h__body(%Qubit*) declare void @__quantum__qis__mresetz__body(%Qubit*, %Result*) #1 - declare i1 @__quantum__qis__read_result__body(%Result*) + declare i1 @__quantum__rt__read_result(%Result*) declare void @OpA(double, %Qubit*) @@ -1623,8 +1808,8 @@ mod adaptive_rif_profile { !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} - !4 = !{i32 1, !"int_computations", !"i64"} - !5 = !{i32 1, !"float_computations", !"f64"} + !4 = !{i32 5, !"int_computations", !{!"i64"}} + !5 = !{i32 5, !"float_computations", !{!"f64"}} "#]].assert_eq(&qir); } } diff --git a/source/compiler/qsc/src/interpret/tests.rs b/source/compiler/qsc/src/interpret/tests.rs index f4f5a5f6a9..57bb192841 100644 --- a/source/compiler/qsc/src/interpret/tests.rs +++ b/source/compiler/qsc/src/interpret/tests.rs @@ -914,14 +914,20 @@ mod given_interpreter { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [4 x i8] c"0_r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__cx__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - ret void + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @0, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__m__body(%Qubit*, %Result*) #1 declare void @__quantum__rt__result_record_output(%Result*, i8*) @@ -975,16 +981,22 @@ mod given_interpreter { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [4 x i8] c"0_r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__rz__body(double 2.0, %Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__rz__body(double 0.0, %Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__rz__body(double 1.0, %Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - ret void + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @0, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__rz__body(double, %Qubit*) declare void @__quantum__qis__mresetz__body(%Qubit*, %Result*) #1 @@ -1002,7 +1014,7 @@ mod given_interpreter { !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} - !4 = !{i32 1, !"int_computations", !"i64"} + !4 = !{i32 5, !"int_computations", !{!"i64"}} "#]] .assert_eq(&res); } @@ -1032,23 +1044,31 @@ mod given_interpreter { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [6 x i8] c"0_t0r\00" + @1 = internal constant [8 x i8] c"1_t1t0b\00" + @2 = internal constant [8 x i8] c"2_t1t1b\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - %var_0 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 0 to %Result*)) - %var_2 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 0 to %Result*)) + %var_0 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 0 to %Result*)) + %var_2 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 0 to %Result*)) %var_3 = icmp eq i1 %var_2, false - call void @__quantum__rt__tuple_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__tuple_record_output(i64 2, i8* null) - call void @__quantum__rt__bool_record_output(i1 %var_0, i8* null) - call void @__quantum__rt__bool_record_output(i1 %var_3, i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__tuple_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__bool_record_output(i1 %var_0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @1, i64 0, i64 0)) + call void @__quantum__rt__bool_record_output(i1 %var_3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @2, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__mresetz__body(%Qubit*, %Result*) #1 - declare i1 @__quantum__qis__read_result__body(%Result*) + declare i1 @__quantum__rt__read_result(%Result*) declare void @__quantum__rt__tuple_record_output(i64, i8*) @@ -1109,14 +1129,20 @@ mod given_interpreter { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [4 x i8] c"0_r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__cx__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - ret void + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @0, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__m__body(%Qubit*, %Result*) #1 declare void @__quantum__rt__result_record_output(%Result*, i8*) @@ -1153,14 +1179,20 @@ mod given_interpreter { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [4 x i8] c"0_r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__cx__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - ret void + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @0, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__m__body(%Qubit*, %Result*) #1 declare void @__quantum__rt__result_record_output(%Result*, i8*) @@ -1229,14 +1261,20 @@ mod given_interpreter { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [4 x i8] c"0_r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__cx__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - ret void + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @0, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__m__body(%Qubit*, %Result*) #1 declare void @__quantum__rt__result_record_output(%Result*, i8*) @@ -1285,14 +1323,20 @@ mod given_interpreter { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [4 x i8] c"0_r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__cx__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - ret void + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @0, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__m__body(%Qubit*, %Result*) #1 declare void @__quantum__rt__result_record_output(%Result*, i8*) @@ -1340,14 +1384,20 @@ mod given_interpreter { %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [4 x i8] c"0_b\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) %var_0 = call i1 @check_result(%Result* inttoptr (i64 0 to %Result*)) - call void @__quantum__rt__bool_record_output(i1 %var_0, i8* null) - ret void + call void @__quantum__rt__bool_record_output(i1 %var_0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @0, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__mresetz__body(%Qubit*, %Result*) #1 declare i1 @check_result(%Result*) diff --git a/source/compiler/qsc_codegen/src/qir.rs b/source/compiler/qsc_codegen/src/qir.rs index 71f307cb8f..33452baffb 100644 --- a/source/compiler/qsc_codegen/src/qir.rs +++ b/source/compiler/qsc_codegen/src/qir.rs @@ -120,6 +120,16 @@ impl ToQir for rir::Literal { rir::Literal::Pointer => "i8* null".to_string(), rir::Literal::Qubit(q) => format!("%Qubit* inttoptr (i64 {q} to %Qubit*)"), rir::Literal::Result(r) => format!("%Result* inttoptr (i64 {r} to %Result*)"), + rir::Literal::Tag(idx, len) => { + let len = len + 1; // +1 for the null terminator + format!( + "i8* getelementptr inbounds ([{len} x i8], [{len} x i8]* @{idx}, i64 0, i64 0)" + ) + } + rir::Literal::EmptyTag => { + "i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)" + .to_string() + } } } } @@ -273,7 +283,7 @@ impl ToQir for rir::Instruction { format!(" br label %{}", ToQir::::to_qir(block_id, program)) } rir::Instruction::Phi(args, variable) => phi_to_qir(args, *variable, program), - rir::Instruction::Return => " ret void".to_string(), + rir::Instruction::Return => " ret i64 0".to_string(), rir::Instruction::Sdiv(lhs, rhs, variable) => { binop_to_qir("sdiv", lhs, rhs, *variable, program) } @@ -571,6 +581,9 @@ fn get_value_as_str(value: &rir::Operand, program: &rir::Program) -> String { rir::Literal::Pointer => "null".to_string(), rir::Literal::Qubit(q) => format!("{q}"), rir::Literal::Result(r) => format!("{r}"), + rir::Literal::Tag(..) | rir::Literal::EmptyTag => panic!( + "tag literals should not be used as string values outside of output recording" + ), }, rir::Operand::Variable(var) => ToQir::::to_qir(&var.variable_id, program), } @@ -584,7 +597,7 @@ fn get_value_ty(lhs: &rir::Operand) -> &str { rir::Literal::Double(_) => get_f64_ty(), rir::Literal::Qubit(_) => "%Qubit*", rir::Literal::Result(_) => "%Result*", - rir::Literal::Pointer => "i8*", + rir::Literal::Pointer | rir::Literal::Tag(..) | rir::Literal::EmptyTag => "i8*", }, rir::Operand::Variable(var) => get_variable_ty(*var), } @@ -690,9 +703,19 @@ impl ToQir for rir::Program { } else { "adaptive_profile" }; + let mut constants = String::default(); + for (idx, tag) in self.tags.iter().enumerate() { + // We need to add the tag as a global constant. + writeln!( + constants, + "@{idx} = internal constant [{} x i8] c\"{tag}\\00\"", + tag.len() + 1 + ) + .expect("writing to string should succeed"); + } let body = format!( include_str!("./qir/template.ll"), - callables, profile, self.num_qubits, self.num_results + constants, callables, profile, self.num_qubits, self.num_results ); let flags = get_module_metadata(self); body + "\n" + &flags @@ -728,8 +751,8 @@ fn get_module_metadata(program: &rir::Program) -> String { let name = "int_computations"; writeln!( flags, - "!{} = !{{i32 {}, !\"{}\", !\"i{}\"}}", - index, 1, name, 64 + "!{} = !{{i32 {}, !\"{}\", !{{!\"i{}\"}}}}", + index, 5, name, 64 ) .expect("writing to string should succeed"); index += 1; @@ -738,8 +761,8 @@ fn get_module_metadata(program: &rir::Program) -> String { let name = "float_computations"; writeln!( flags, - "!{} = !{{i32 {}, !\"{}\", !\"f{}\"}}", - index, 1, name, 64 + "!{} = !{{i32 {}, !\"{}\", !{{!\"f{}\"}}}}", + index, 5, name, 64 ) .expect("writing to string should succeed"); index += 1; diff --git a/source/compiler/qsc_codegen/src/qir/template.ll b/source/compiler/qsc_codegen/src/qir/template.ll index b58560a733..bd9ea37c51 100644 --- a/source/compiler/qsc_codegen/src/qir/template.ll +++ b/source/compiler/qsc_codegen/src/qir/template.ll @@ -1,6 +1,8 @@ %Result = type opaque %Qubit = type opaque +@empty_tag = internal constant [1 x i8] c"\00" +{} {} attributes #0 = {{ "entry_point" "output_labeling_schema" "qir_profiles"="{}" "required_num_qubits"="{}" "required_num_results"="{}" }} diff --git a/source/compiler/qsc_codegen/src/qir/tests.rs b/source/compiler/qsc_codegen/src/qir/tests.rs index 59c2927e80..9268278c89 100644 --- a/source/compiler/qsc_codegen/src/qir/tests.rs +++ b/source/compiler/qsc_codegen/src/qir/tests.rs @@ -37,7 +37,7 @@ fn measurement_decl_works() { #[test] fn read_result_decl_works() { let decl = builder::read_result_decl(); - expect!["declare i1 @__quantum__qis__read_result__body(%Result*)"] + expect!["declare i1 @__quantum__rt__read_result(%Result*)"] .assert_eq(&decl.to_qir(&rir::Program::default())); } @@ -131,6 +131,11 @@ fn bell_program() { %Result = type opaque %Qubit = type opaque + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [4 x i8] c"0_a\00" + @1 = internal constant [6 x i8] c"1_a0r\00" + @2 = internal constant [6 x i8] c"2_a1r\00" + declare void @__quantum__qis__h__body(%Qubit*) declare void @__quantum__qis__cx__body(%Qubit*, %Qubit*) @@ -141,16 +146,16 @@ fn bell_program() { declare void @__quantum__rt__result_record_output(%Result*, i8*) - define void @ENTRYPOINT__main() #0 { + define i64 @ENTRYPOINT__main() #0 { block_0: call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__cx__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - call void @__quantum__rt__array_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - ret void + call void @__quantum__rt__array_record_output(i64 2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @2, i64 0, i64 0)) + ret i64 0 } attributes #0 = { "entry_point" "output_labeling_schema" "qir_profiles"="base_profile" "required_num_qubits"="2" "required_num_results"="2" } @@ -174,6 +179,9 @@ fn teleport_program() { %Result = type opaque %Qubit = type opaque + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [4 x i8] c"0_r\00" + declare void @__quantum__qis__h__body(%Qubit*) declare void @__quantum__qis__z__body(%Qubit*) @@ -184,11 +192,11 @@ fn teleport_program() { declare void @__quantum__qis__mresetz__body(%Qubit*, %Result*) #1 - declare i1 @__quantum__qis__read_result__body(%Result*) + declare i1 @__quantum__rt__read_result(%Result*) declare void @__quantum__rt__result_record_output(%Result*, i8*) - define void @ENTRYPOINT__main() #0 { + define i64 @ENTRYPOINT__main() #0 { block_0: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 2 to %Qubit*)) @@ -196,22 +204,22 @@ fn teleport_program() { call void @__quantum__qis__cx__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Qubit* inttoptr (i64 2 to %Qubit*)) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - %var_0 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 0 to %Result*)) + %var_0 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 0 to %Result*)) br i1 %var_0, label %block_1, label %block_2 block_1: call void @__quantum__qis__z__body(%Qubit* inttoptr (i64 1 to %Qubit*)) br label %block_2 block_2: call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 2 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - %var_1 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 1 to %Result*)) + %var_1 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 1 to %Result*)) br i1 %var_1, label %block_3, label %block_4 block_3: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 1 to %Qubit*)) br label %block_4 block_4: call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 2 to %Result*)) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* null) - ret void + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @0, i64 0, i64 0)) + ret i64 0 } attributes #0 = { "entry_point" "output_labeling_schema" "qir_profiles"="adaptive_profile" "required_num_qubits"="3" "required_num_results"="3" } diff --git a/source/compiler/qsc_partial_eval/src/lib.rs b/source/compiler/qsc_partial_eval/src/lib.rs index f106e8bb6b..9ef6c06785 100644 --- a/source/compiler/qsc_partial_eval/src/lib.rs +++ b/source/compiler/qsc_partial_eval/src/lib.rs @@ -46,7 +46,7 @@ use qsc_rca::{ }, }; use qsc_rir::{ - builder, + builder::{self, initialize_decl}, rir::{ self, Callable, CallableId, CallableType, ConditionCode, FcmpConditionCode, Instruction, Literal, Operand, Program, VariableId, @@ -225,13 +225,26 @@ impl<'a> PartialEvaluator<'a> { let entry_point = rir::Callable { name: "main".into(), input_type: Vec::new(), - output_type: None, + output_type: Some(rir::Ty::Integer), body: Some(entry_block_id), call_type: CallableType::Regular, }; program.callables.insert(entry_point_id, entry_point); program.entry = entry_point_id; + // Add the required call to the initialization function. + let init_func = initialize_decl(); + let init_id = resource_manager.next_callable(); + program.callables.insert(init_id, init_func); + program + .get_block_mut(entry_block_id) + .0 + .push(Instruction::Call( + init_id, + vec![Operand::Literal(Literal::Pointer)], + None, + )); + // Initialize the evaluation context and create a new partial evaluator. let context = EvaluationContext::new( package_id.unwrap_or_else(|| { @@ -412,7 +425,7 @@ impl<'a> PartialEvaluator<'a> { output_span: PackageSpan, ) -> Result { let output_recording: Vec = self - .generate_output_recording_instructions(ret_val, output_ty) + .generate_output_recording_instructions(ret_val, output_ty, "") .map_err(|()| Error::OutputResultLiteral(output_span))?; // Insert the return expression and return the generated program. @@ -3088,19 +3101,20 @@ impl<'a> PartialEvaluator<'a> { &mut self, ret_val: Value, ty: &Ty, + tag_root: &str, ) -> Result, ()> { let mut instrs = Vec::new(); match ret_val { Value::Result(val::Result::Val(_)) => return Err(()), - Value::Array(vals) => self.record_array(ty, &mut instrs, &vals)?, - Value::Tuple(vals) => self.record_tuple(ty, &mut instrs, &vals)?, - Value::Result(res) => self.record_result(&mut instrs, res), - Value::Var(var) => self.record_variable(ty, &mut instrs, var), - Value::Bool(val) => self.record_bool(&mut instrs, val), - Value::Int(val) => self.record_int(&mut instrs, val), - Value::Double(val) => self.record_double(&mut instrs, val), + Value::Array(vals) => self.record_array(ty, &mut instrs, &vals, tag_root)?, + Value::Tuple(vals) => self.record_tuple(ty, &mut instrs, &vals, tag_root)?, + Value::Result(res) => self.record_result(&mut instrs, res, tag_root), + Value::Var(var) => self.record_variable(ty, &mut instrs, var, tag_root), + Value::Bool(val) => self.record_bool(&mut instrs, val, tag_root), + Value::Int(val) => self.record_int(&mut instrs, val, tag_root), + Value::Double(val) => self.record_double(&mut instrs, val, tag_root), Value::BigInt(_) | Value::Closure(_) @@ -3114,61 +3128,87 @@ impl<'a> PartialEvaluator<'a> { Ok(instrs) } - fn record_int(&mut self, instrs: &mut Vec, val: i64) { + fn record_int(&mut self, instrs: &mut Vec, val: i64, tag_root: &str) { + let idx = self.program.tags.len(); + let tag = format!("{idx}_{tag_root}i"); + let len = tag.len(); + self.program.tags.push(tag); let int_record_callable_id = self.get_int_record_callable(); instrs.push(Instruction::Call( int_record_callable_id, vec![ Operand::Literal(Literal::Integer(val)), - Operand::Literal(Literal::Pointer), + Operand::Literal(Literal::Tag(idx, len)), ], None, )); } - fn record_double(&mut self, instrs: &mut Vec, val: f64) { + fn record_double(&mut self, instrs: &mut Vec, val: f64, tag_root: &str) { + let idx = self.program.tags.len(); + let tag = format!("{idx}_{tag_root}d"); + let len = tag.len(); + self.program.tags.push(tag); let double_record_callable_id = self.get_double_record_callable(); instrs.push(Instruction::Call( double_record_callable_id, vec![ Operand::Literal(Literal::Double(val)), - Operand::Literal(Literal::Pointer), + Operand::Literal(Literal::Tag(idx, len)), ], None, )); } - fn record_bool(&mut self, instrs: &mut Vec, val: bool) { + fn record_bool(&mut self, instrs: &mut Vec, val: bool, tag_root: &str) { + let idx = self.program.tags.len(); + let tag = format!("{idx}_{tag_root}b"); + let len = tag.len(); + self.program.tags.push(tag); let bool_record_callable_id = self.get_bool_record_callable(); instrs.push(Instruction::Call( bool_record_callable_id, vec![ Operand::Literal(Literal::Bool(val)), - Operand::Literal(Literal::Pointer), + Operand::Literal(Literal::Tag(idx, len)), ], None, )); } - fn record_variable(&mut self, ty: &Ty, instrs: &mut Vec, var: Var) { - let record_callable_id = match ty { - Ty::Prim(Prim::Bool) => self.get_bool_record_callable(), - Ty::Prim(Prim::Int) => self.get_int_record_callable(), - Ty::Prim(Prim::Double) => self.get_double_record_callable(), + fn record_variable( + &mut self, + ty: &Ty, + instrs: &mut Vec, + var: Var, + tag_root: &str, + ) { + let idx = self.program.tags.len(); + let (record_callable_id, tag_ty) = match ty { + Ty::Prim(Prim::Bool) => (self.get_bool_record_callable(), "b"), + Ty::Prim(Prim::Int) => (self.get_int_record_callable(), "i"), + Ty::Prim(Prim::Double) => (self.get_double_record_callable(), "d"), _ => panic!("unsupported variable type in output recording"), }; + let tag = format!("{idx}_{tag_root}{tag_ty}"); + let len = tag.len(); + self.program.tags.push(tag); instrs.push(Instruction::Call( record_callable_id, vec![ Operand::Variable(map_eval_var_to_rir_var(var)), - Operand::Literal(Literal::Pointer), + Operand::Literal(Literal::Tag(idx, len)), ], None, )); } - fn record_result(&mut self, instrs: &mut Vec, res: val::Result) { + fn record_result(&mut self, instrs: &mut Vec, res: val::Result, tag_root: &str) { + let idx = self.program.tags.len(); let result_record_callable_id = self.get_result_record_callable(); + let tag = format!("{idx}_{tag_root}r"); + let len = tag.len(); + self.program.tags.push(tag); instrs.push(Instruction::Call( result_record_callable_id, vec![ @@ -3177,7 +3217,7 @@ impl<'a> PartialEvaluator<'a> { .try_into() .expect("result id should fit into u32"), )), - Operand::Literal(Literal::Pointer), + Operand::Literal(Literal::Tag(idx, len)), ], None, )); @@ -3188,11 +3228,17 @@ impl<'a> PartialEvaluator<'a> { ty: &Ty, instrs: &mut Vec, vals: &Rc<[Value]>, + tag_root: &str, ) -> Result<(), ()> { let Ty::Tuple(elem_tys) = ty else { panic!("expected tuple type for tuple value"); }; + let new_tag_root = format!("{tag_root}t"); let tuple_record_callable_id = self.get_tuple_record_callable(); + // let idx = self.program.tags.len(); + // let tag = format!("{idx}_{new_tag_root}"); + // let len = tag.len(); + // self.program.tags.push(tag); instrs.push(Instruction::Call( tuple_record_callable_id, vec![ @@ -3201,12 +3247,17 @@ impl<'a> PartialEvaluator<'a> { .try_into() .expect("tuple length should fit into u32"), )), - Operand::Literal(Literal::Pointer), + Operand::Literal(Literal::EmptyTag), ], None, )); - for (val, elem_ty) in vals.iter().zip(elem_tys.iter()) { - instrs.extend(self.generate_output_recording_instructions(val.clone(), elem_ty)?); + for (idx, (val, elem_ty)) in vals.iter().zip(elem_tys.iter()).enumerate() { + let new_tag_root = format!("{new_tag_root}{idx}"); + instrs.extend(self.generate_output_recording_instructions( + val.clone(), + elem_ty, + &new_tag_root, + )?); } Ok(()) @@ -3217,10 +3268,16 @@ impl<'a> PartialEvaluator<'a> { ty: &Ty, instrs: &mut Vec, vals: &Rc>, + tag_root: &str, ) -> Result<(), ()> { let Ty::Array(elem_ty) = ty else { panic!("expected array type for array value"); }; + let new_tag_root = format!("{tag_root}a"); + // let idx = self.program.tags.len(); + // let tag = format!("{idx}_{new_tag_root}"); + // let len = tag.len(); + // self.program.tags.push(tag); let array_record_callable_id = self.get_array_record_callable(); instrs.push(Instruction::Call( array_record_callable_id, @@ -3230,12 +3287,17 @@ impl<'a> PartialEvaluator<'a> { .try_into() .expect("array length should fit into u32"), )), - Operand::Literal(Literal::Pointer), + Operand::Literal(Literal::EmptyTag), ], None, )); - for val in vals.iter() { - instrs.extend(self.generate_output_recording_instructions(val.clone(), elem_ty)?); + for (idx, val) in vals.iter().enumerate() { + let new_tag_root = format!("{new_tag_root}{idx}"); + instrs.extend(self.generate_output_recording_instructions( + val.clone(), + elem_ty, + &new_tag_root, + )?); } Ok(()) diff --git a/source/compiler/qsc_partial_eval/src/tests/arrays.rs b/source/compiler/qsc_partial_eval/src/tests/arrays.rs index a470378978..24bd2ef79f 100644 --- a/source/compiler/qsc_partial_eval/src/tests/arrays.rs +++ b/source/compiler/qsc_partial_eval/src/tests/arrays.rs @@ -31,14 +31,13 @@ fn array_with_dynamic_content() { &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let array_output_recording_callable_id = CallableId(2); assert_callable( @@ -46,11 +45,11 @@ fn array_with_dynamic_content() { array_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__array_record_output - call_type: OutputRecording + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit + [1]: Result output_type: body: "#]], ); @@ -60,10 +59,10 @@ fn array_with_dynamic_content() { result_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__result_record_output + name: __quantum__rt__array_record_output call_type: OutputRecording input_type: - [0]: Result + [0]: Integer [1]: Pointer output_type: body: "#]], @@ -72,13 +71,14 @@ fn array_with_dynamic_content() { &program, BlockId(0), &expect![[r#" - Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(1), args( Qubit(1), Result(1), ) - Call id(2), args( Integer(2), Pointer, ) - Call id(3), args( Result(0), Pointer, ) - Call id(3), args( Result(1), Pointer, ) - Return"#]], + Block: + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(2), args( Qubit(1), Result(1), ) + Call id(3), args( Integer(2), EmptyTag, ) + Call id(4), args( Result(0), Tag(0, 5), ) + Call id(4), args( Result(1), Tag(1, 5), ) + Return"#]], ); } @@ -99,14 +99,13 @@ fn array_with_hybrid_content() { &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let array_output_recording_callable_id = CallableId(2); assert_callable( @@ -114,11 +113,12 @@ fn array_with_hybrid_content() { array_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__qis__read_result__body - call_type: Readout + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Result - output_type: Boolean + [0]: Qubit + [1]: Result + output_type: body: "#]], ); let boolean_output_recording_callable_id = CallableId(3); @@ -127,12 +127,11 @@ fn array_with_hybrid_content() { boolean_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__array_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_block_instructions( @@ -140,12 +139,13 @@ fn array_with_hybrid_content() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Store Variable(0, Boolean) - Call id(3), args( Integer(2), Pointer, ) - Call id(4), args( Bool(true), Pointer, ) - Call id(4), args( Variable(1, Boolean), Pointer, ) + Call id(4), args( Integer(2), EmptyTag, ) + Call id(5), args( Bool(true), Tag(0, 5), ) + Call id(5), args( Variable(1, Boolean), Tag(1, 5), ) Return"#]], ); } @@ -166,14 +166,13 @@ fn array_repeat_with_dynamic_content() { &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let array_output_recording_callable_id = CallableId(2); assert_callable( @@ -181,11 +180,11 @@ fn array_repeat_with_dynamic_content() { array_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__array_record_output - call_type: OutputRecording + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit + [1]: Result output_type: body: "#]], ); @@ -195,10 +194,10 @@ fn array_repeat_with_dynamic_content() { result_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__result_record_output + name: __quantum__rt__array_record_output call_type: OutputRecording input_type: - [0]: Result + [0]: Integer [1]: Pointer output_type: body: "#]], @@ -207,12 +206,13 @@ fn array_repeat_with_dynamic_content() { &program, BlockId(0), &expect![[r#" - Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(2), args( Integer(2), Pointer, ) - Call id(3), args( Result(0), Pointer, ) - Call id(3), args( Result(0), Pointer, ) - Return"#]], + Block: + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(3), args( Integer(2), EmptyTag, ) + Call id(4), args( Result(0), Tag(0, 5), ) + Call id(4), args( Result(0), Tag(1, 5), ) + Return"#]], ); } @@ -234,11 +234,10 @@ fn result_array_value_at_index() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -248,11 +247,11 @@ fn result_array_value_at_index() { result_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__result_record_output - call_type: OutputRecording + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Result - [1]: Pointer + [0]: Qubit + [1]: Result output_type: body: "#]], ); @@ -261,9 +260,10 @@ fn result_array_value_at_index() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(1), args( Qubit(1), Result(1), ) - Call id(2), args( Result(1), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(2), args( Qubit(1), Result(1), ) + Call id(3), args( Result(1), Tag(0, 3), ) Return"#]], ); } @@ -326,11 +326,10 @@ fn result_array_slice_with_explicit_range() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -340,11 +339,11 @@ fn result_array_slice_with_explicit_range() { array_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__array_record_output - call_type: OutputRecording + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit + [1]: Result output_type: body: "#]], ); @@ -354,10 +353,10 @@ fn result_array_slice_with_explicit_range() { result_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__result_record_output + name: __quantum__rt__array_record_output call_type: OutputRecording input_type: - [0]: Result + [0]: Integer [1]: Pointer output_type: body: "#]], @@ -367,15 +366,16 @@ fn result_array_slice_with_explicit_range() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(1), args( Qubit(1), Result(1), ) - Call id(1), args( Qubit(2), Result(2), ) - Call id(1), args( Qubit(3), Result(3), ) - Call id(1), args( Qubit(4), Result(4), ) - Call id(2), args( Integer(3), Pointer, ) - Call id(3), args( Result(0), Pointer, ) - Call id(3), args( Result(2), Pointer, ) - Call id(3), args( Result(4), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(2), args( Qubit(1), Result(1), ) + Call id(2), args( Qubit(2), Result(2), ) + Call id(2), args( Qubit(3), Result(3), ) + Call id(2), args( Qubit(4), Result(4), ) + Call id(3), args( Integer(3), EmptyTag, ) + Call id(4), args( Result(0), Tag(0, 5), ) + Call id(4), args( Result(2), Tag(1, 5), ) + Call id(4), args( Result(4), Tag(2, 5), ) Return"#]], ); } @@ -398,11 +398,10 @@ fn result_array_slice_with_open_start_range() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -412,11 +411,11 @@ fn result_array_slice_with_open_start_range() { array_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__array_record_output - call_type: OutputRecording + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit + [1]: Result output_type: body: "#]], ); @@ -426,10 +425,10 @@ fn result_array_slice_with_open_start_range() { result_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__result_record_output + name: __quantum__rt__array_record_output call_type: OutputRecording input_type: - [0]: Result + [0]: Integer [1]: Pointer output_type: body: "#]], @@ -439,12 +438,13 @@ fn result_array_slice_with_open_start_range() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(1), args( Qubit(1), Result(1), ) - Call id(1), args( Qubit(2), Result(2), ) - Call id(2), args( Integer(2), Pointer, ) - Call id(3), args( Result(0), Pointer, ) - Call id(3), args( Result(1), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(2), args( Qubit(1), Result(1), ) + Call id(2), args( Qubit(2), Result(2), ) + Call id(3), args( Integer(2), EmptyTag, ) + Call id(4), args( Result(0), Tag(0, 5), ) + Call id(4), args( Result(1), Tag(1, 5), ) Return"#]], ); } @@ -467,11 +467,10 @@ fn result_array_slice_with_open_ended_range() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -481,11 +480,11 @@ fn result_array_slice_with_open_ended_range() { array_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__array_record_output - call_type: OutputRecording + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit + [1]: Result output_type: body: "#]], ); @@ -495,10 +494,10 @@ fn result_array_slice_with_open_ended_range() { result_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__result_record_output + name: __quantum__rt__array_record_output call_type: OutputRecording input_type: - [0]: Result + [0]: Integer [1]: Pointer output_type: body: "#]], @@ -508,12 +507,13 @@ fn result_array_slice_with_open_ended_range() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(1), args( Qubit(1), Result(1), ) - Call id(1), args( Qubit(2), Result(2), ) - Call id(2), args( Integer(2), Pointer, ) - Call id(3), args( Result(1), Pointer, ) - Call id(3), args( Result(2), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(2), args( Qubit(1), Result(1), ) + Call id(2), args( Qubit(2), Result(2), ) + Call id(3), args( Integer(2), EmptyTag, ) + Call id(4), args( Result(1), Tag(0, 5), ) + Call id(4), args( Result(2), Tag(1, 5), ) Return"#]], ); } @@ -536,11 +536,10 @@ fn result_array_slice_with_open_two_step_range() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -550,11 +549,11 @@ fn result_array_slice_with_open_two_step_range() { array_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__array_record_output - call_type: OutputRecording + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit + [1]: Result output_type: body: "#]], ); @@ -564,10 +563,10 @@ fn result_array_slice_with_open_two_step_range() { result_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__result_record_output + name: __quantum__rt__array_record_output call_type: OutputRecording input_type: - [0]: Result + [0]: Integer [1]: Pointer output_type: body: "#]], @@ -577,15 +576,16 @@ fn result_array_slice_with_open_two_step_range() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(1), args( Qubit(1), Result(1), ) - Call id(1), args( Qubit(2), Result(2), ) - Call id(1), args( Qubit(3), Result(3), ) - Call id(1), args( Qubit(4), Result(4), ) - Call id(2), args( Integer(3), Pointer, ) - Call id(3), args( Result(0), Pointer, ) - Call id(3), args( Result(2), Pointer, ) - Call id(3), args( Result(4), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(2), args( Qubit(1), Result(1), ) + Call id(2), args( Qubit(2), Result(2), ) + Call id(2), args( Qubit(3), Result(3), ) + Call id(2), args( Qubit(4), Result(4), ) + Call id(3), args( Integer(3), EmptyTag, ) + Call id(4), args( Result(0), Tag(0, 5), ) + Call id(4), args( Result(2), Tag(1, 5), ) + Call id(4), args( Result(4), Tag(2, 5), ) Return"#]], ); } @@ -628,11 +628,10 @@ fn result_array_copy_and_update_with_single_index() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -642,11 +641,11 @@ fn result_array_copy_and_update_with_single_index() { array_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__array_record_output - call_type: OutputRecording + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit + [1]: Result output_type: body: "#]], ); @@ -656,10 +655,10 @@ fn result_array_copy_and_update_with_single_index() { result_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__result_record_output + name: __quantum__rt__array_record_output call_type: OutputRecording input_type: - [0]: Result + [0]: Integer [1]: Pointer output_type: body: "#]], @@ -669,14 +668,15 @@ fn result_array_copy_and_update_with_single_index() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(1), args( Qubit(1), Result(1), ) - Call id(1), args( Qubit(2), Result(2), ) - Call id(1), args( Qubit(3), Result(3), ) - Call id(2), args( Integer(3), Pointer, ) - Call id(3), args( Result(0), Pointer, ) - Call id(3), args( Result(3), Pointer, ) - Call id(3), args( Result(2), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(2), args( Qubit(1), Result(1), ) + Call id(2), args( Qubit(2), Result(2), ) + Call id(2), args( Qubit(3), Result(3), ) + Call id(3), args( Integer(3), EmptyTag, ) + Call id(4), args( Result(0), Tag(0, 5), ) + Call id(4), args( Result(3), Tag(1, 5), ) + Call id(4), args( Result(2), Tag(2, 5), ) Return"#]], ); } @@ -740,11 +740,10 @@ fn result_array_copy_and_update_with_explicit_range() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -754,11 +753,11 @@ fn result_array_copy_and_update_with_explicit_range() { array_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__array_record_output - call_type: OutputRecording + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit + [1]: Result output_type: body: "#]], ); @@ -768,10 +767,10 @@ fn result_array_copy_and_update_with_explicit_range() { result_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__result_record_output + name: __quantum__rt__array_record_output call_type: OutputRecording input_type: - [0]: Result + [0]: Integer [1]: Pointer output_type: body: "#]], @@ -781,20 +780,21 @@ fn result_array_copy_and_update_with_explicit_range() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(1), args( Qubit(1), Result(1), ) - Call id(1), args( Qubit(2), Result(2), ) - Call id(1), args( Qubit(3), Result(3), ) - Call id(1), args( Qubit(4), Result(4), ) - Call id(1), args( Qubit(5), Result(5), ) - Call id(1), args( Qubit(6), Result(6), ) - Call id(1), args( Qubit(7), Result(7), ) - Call id(2), args( Integer(5), Pointer, ) - Call id(3), args( Result(5), Pointer, ) - Call id(3), args( Result(1), Pointer, ) - Call id(3), args( Result(6), Pointer, ) - Call id(3), args( Result(3), Pointer, ) - Call id(3), args( Result(7), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(2), args( Qubit(1), Result(1), ) + Call id(2), args( Qubit(2), Result(2), ) + Call id(2), args( Qubit(3), Result(3), ) + Call id(2), args( Qubit(4), Result(4), ) + Call id(2), args( Qubit(5), Result(5), ) + Call id(2), args( Qubit(6), Result(6), ) + Call id(2), args( Qubit(7), Result(7), ) + Call id(3), args( Integer(5), EmptyTag, ) + Call id(4), args( Result(5), Tag(0, 5), ) + Call id(4), args( Result(1), Tag(1, 5), ) + Call id(4), args( Result(6), Tag(2, 5), ) + Call id(4), args( Result(3), Tag(3, 5), ) + Call id(4), args( Result(7), Tag(4, 5), ) Return"#]], ); } @@ -817,11 +817,10 @@ fn result_array_copy_and_update_with_open_start_range() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -831,11 +830,11 @@ fn result_array_copy_and_update_with_open_start_range() { array_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__array_record_output - call_type: OutputRecording + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit + [1]: Result output_type: body: "#]], ); @@ -845,10 +844,10 @@ fn result_array_copy_and_update_with_open_start_range() { result_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__result_record_output + name: __quantum__rt__array_record_output call_type: OutputRecording input_type: - [0]: Result + [0]: Integer [1]: Pointer output_type: body: "#]], @@ -858,15 +857,16 @@ fn result_array_copy_and_update_with_open_start_range() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(1), args( Qubit(1), Result(1), ) - Call id(1), args( Qubit(2), Result(2), ) - Call id(1), args( Qubit(3), Result(3), ) - Call id(1), args( Qubit(4), Result(4), ) - Call id(2), args( Integer(3), Pointer, ) - Call id(3), args( Result(3), Pointer, ) - Call id(3), args( Result(4), Pointer, ) - Call id(3), args( Result(2), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(2), args( Qubit(1), Result(1), ) + Call id(2), args( Qubit(2), Result(2), ) + Call id(2), args( Qubit(3), Result(3), ) + Call id(2), args( Qubit(4), Result(4), ) + Call id(3), args( Integer(3), EmptyTag, ) + Call id(4), args( Result(3), Tag(0, 5), ) + Call id(4), args( Result(4), Tag(1, 5), ) + Call id(4), args( Result(2), Tag(2, 5), ) Return"#]], ); } @@ -889,11 +889,10 @@ fn result_array_copy_and_update_with_open_ended_range() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -903,11 +902,11 @@ fn result_array_copy_and_update_with_open_ended_range() { array_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__array_record_output - call_type: OutputRecording + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit + [1]: Result output_type: body: "#]], ); @@ -917,10 +916,10 @@ fn result_array_copy_and_update_with_open_ended_range() { result_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__result_record_output + name: __quantum__rt__array_record_output call_type: OutputRecording input_type: - [0]: Result + [0]: Integer [1]: Pointer output_type: body: "#]], @@ -930,15 +929,16 @@ fn result_array_copy_and_update_with_open_ended_range() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(1), args( Qubit(1), Result(1), ) - Call id(1), args( Qubit(2), Result(2), ) - Call id(1), args( Qubit(3), Result(3), ) - Call id(1), args( Qubit(4), Result(4), ) - Call id(2), args( Integer(3), Pointer, ) - Call id(3), args( Result(0), Pointer, ) - Call id(3), args( Result(3), Pointer, ) - Call id(3), args( Result(4), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(2), args( Qubit(1), Result(1), ) + Call id(2), args( Qubit(2), Result(2), ) + Call id(2), args( Qubit(3), Result(3), ) + Call id(2), args( Qubit(4), Result(4), ) + Call id(3), args( Integer(3), EmptyTag, ) + Call id(4), args( Result(0), Tag(0, 5), ) + Call id(4), args( Result(3), Tag(1, 5), ) + Call id(4), args( Result(4), Tag(2, 5), ) Return"#]], ); } @@ -961,11 +961,10 @@ fn result_array_copy_and_update_with_open_two_step_range() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -975,11 +974,11 @@ fn result_array_copy_and_update_with_open_two_step_range() { array_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__array_record_output - call_type: OutputRecording + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit + [1]: Result output_type: body: "#]], ); @@ -989,10 +988,10 @@ fn result_array_copy_and_update_with_open_two_step_range() { result_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__result_record_output + name: __quantum__rt__array_record_output call_type: OutputRecording input_type: - [0]: Result + [0]: Integer [1]: Pointer output_type: body: "#]], @@ -1002,15 +1001,16 @@ fn result_array_copy_and_update_with_open_two_step_range() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(1), args( Qubit(1), Result(1), ) - Call id(1), args( Qubit(2), Result(2), ) - Call id(1), args( Qubit(3), Result(3), ) - Call id(1), args( Qubit(4), Result(4), ) - Call id(2), args( Integer(3), Pointer, ) - Call id(3), args( Result(3), Pointer, ) - Call id(3), args( Result(1), Pointer, ) - Call id(3), args( Result(4), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(2), args( Qubit(1), Result(1), ) + Call id(2), args( Qubit(2), Result(2), ) + Call id(2), args( Qubit(3), Result(3), ) + Call id(2), args( Qubit(4), Result(4), ) + Call id(3), args( Integer(3), EmptyTag, ) + Call id(4), args( Result(3), Tag(0, 5), ) + Call id(4), args( Result(1), Tag(1, 5), ) + Call id(4), args( Result(4), Tag(2, 5), ) Return"#]], ); } diff --git a/source/compiler/qsc_partial_eval/src/tests/assigns.rs b/source/compiler/qsc_partial_eval/src/tests/assigns.rs index 80a076c9e6..c7091f210e 100644 --- a/source/compiler/qsc_partial_eval/src/tests/assigns.rs +++ b/source/compiler/qsc_partial_eval/src/tests/assigns.rs @@ -57,11 +57,10 @@ fn assigning_result_register_updates_value() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -71,11 +70,11 @@ fn assigning_result_register_updates_value() { output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__result_record_output - call_type: OutputRecording + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Result - [1]: Pointer + [0]: Qubit + [1]: Result output_type: body: "#]], ); @@ -84,8 +83,9 @@ fn assigning_result_register_updates_value() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(2), args( Result(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(3), args( Result(0), Tag(0, 3), ) Return"#]], ); } @@ -109,11 +109,10 @@ fn assigning_classical_bool_updates_value_and_adds_store_instructions() { output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Boolean - [1]: Pointer + [0]: Pointer output_type: body: "#]], ); @@ -122,9 +121,10 @@ fn assigning_classical_bool_updates_value_and_adds_store_instructions() { BlockId(0), &expect![[r#" Block: + Call id(1), args( Pointer, ) Variable(0, Boolean) = Store Bool(true) Variable(0, Boolean) = Store Bool(false) - Call id(1), args( Bool(false), Pointer, ) + Call id(2), args( Bool(false), Tag(0, 3), ) Return"#]], ); } @@ -148,11 +148,10 @@ fn assigning_dynamic_bool_updates_value_and_adds_store_instructions() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -161,13 +160,14 @@ fn assigning_dynamic_bool_updates_value_and_adds_store_instructions() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_recording_callable_id = CallableId(3); assert_callable( @@ -175,12 +175,11 @@ fn assigning_dynamic_bool_updates_value_and_adds_store_instructions() { output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Boolean - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_block_instructions( @@ -188,13 +187,14 @@ fn assigning_dynamic_bool_updates_value_and_adds_store_instructions() { BlockId(0), &expect![[r#" Block: + Call id(1), args( Pointer, ) Variable(0, Boolean) = Store Bool(false) - Call id(1), args( Qubit(0), Result(0), ) - Variable(1, Boolean) = Call id(2), args( Result(0), ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(1, Boolean) = Call id(3), args( Result(0), ) Variable(2, Boolean) = Store Variable(1, Boolean) Variable(0, Boolean) = Store Variable(2, Boolean) Variable(3, Boolean) = Store Variable(0, Boolean) - Call id(3), args( Variable(3, Boolean), Pointer, ) + Call id(4), args( Variable(3, Boolean), Tag(0, 3), ) Return"#]], ); } @@ -218,11 +218,10 @@ fn assigning_classical_int_updates_value_and_adds_store_instructions() { output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Integer - [1]: Pointer + [0]: Pointer output_type: body: "#]], ); @@ -231,9 +230,10 @@ fn assigning_classical_int_updates_value_and_adds_store_instructions() { BlockId(0), &expect![[r#" Block: + Call id(1), args( Pointer, ) Variable(0, Integer) = Store Integer(0) Variable(0, Integer) = Store Integer(1) - Call id(1), args( Integer(1), Pointer, ) + Call id(2), args( Integer(1), Tag(0, 3), ) Return"#]], ); } @@ -257,11 +257,10 @@ fn assigning_dynamic_int_updates_value_and_adds_store_instructions() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -270,13 +269,14 @@ fn assigning_dynamic_int_updates_value_and_adds_store_instructions() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_recording_callable_id = CallableId(3); assert_callable( @@ -284,12 +284,11 @@ fn assigning_dynamic_int_updates_value_and_adds_store_instructions() { output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -297,15 +296,16 @@ fn assigning_dynamic_int_updates_value_and_adds_store_instructions() { &expect![[r#" Blocks: Block 0:Block: + Call id(1), args( Pointer, ) Variable(0, Integer) = Store Integer(0) - Call id(1), args( Qubit(0), Result(0), ) - Variable(1, Boolean) = Call id(2), args( Result(0), ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(1, Boolean) = Call id(3), args( Result(0), ) Variable(2, Boolean) = Store Variable(1, Boolean) Branch Variable(2, Boolean), 2, 3 Block 1:Block: Variable(0, Integer) = Store Variable(3, Integer) Variable(4, Integer) = Store Variable(0, Integer) - Call id(3), args( Variable(4, Integer), Pointer, ) + Call id(4), args( Variable(4, Integer), Tag(0, 3), ) Return Block 2:Block: Variable(3, Integer) = Store Integer(1) @@ -337,11 +337,10 @@ fn assigning_classical_bool_within_dynamic_if_expression_adds_store_instruction( measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -350,13 +349,14 @@ fn assigning_classical_bool_within_dynamic_if_expression_adds_store_instruction( &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_recording_callable_id = CallableId(3); assert_callable( @@ -364,12 +364,11 @@ fn assigning_classical_bool_within_dynamic_if_expression_adds_store_instruction( output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Boolean - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -377,14 +376,15 @@ fn assigning_classical_bool_within_dynamic_if_expression_adds_store_instruction( &expect![[r#" Blocks: Block 0:Block: + Call id(1), args( Pointer, ) Variable(0, Boolean) = Store Bool(false) - Call id(1), args( Qubit(0), Result(0), ) - Variable(1, Boolean) = Call id(2), args( Result(0), ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(1, Boolean) = Call id(3), args( Result(0), ) Variable(2, Boolean) = Store Variable(1, Boolean) Branch Variable(2, Boolean), 2, 1 Block 1:Block: Variable(3, Boolean) = Store Variable(0, Boolean) - Call id(3), args( Variable(3, Boolean), Pointer, ) + Call id(4), args( Variable(3, Boolean), Tag(0, 3), ) Return Block 2:Block: Variable(0, Boolean) = Store Bool(true) @@ -415,11 +415,10 @@ fn assigning_classical_int_within_dynamic_if_else_expression_adds_store_instruct measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -428,13 +427,14 @@ fn assigning_classical_int_within_dynamic_if_else_expression_adds_store_instruct &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_recording_callable_id = CallableId(3); assert_callable( @@ -442,12 +442,11 @@ fn assigning_classical_int_within_dynamic_if_else_expression_adds_store_instruct output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -455,14 +454,15 @@ fn assigning_classical_int_within_dynamic_if_else_expression_adds_store_instruct &expect![[r#" Blocks: Block 0:Block: + Call id(1), args( Pointer, ) Variable(0, Integer) = Store Integer(0) - Call id(1), args( Qubit(0), Result(0), ) - Variable(1, Boolean) = Call id(2), args( Result(0), ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(1, Boolean) = Call id(3), args( Result(0), ) Variable(2, Boolean) = Icmp Eq, Variable(1, Boolean), Bool(false) Branch Variable(2, Boolean), 2, 3 Block 1:Block: Variable(3, Integer) = Store Variable(0, Integer) - Call id(3), args( Variable(3, Integer), Pointer, ) + Call id(4), args( Variable(3, Integer), Tag(0, 3), ) Return Block 2:Block: Variable(0, Integer) = Store Integer(1) @@ -515,11 +515,10 @@ fn array_of_results_update_element_at_index_with_dynamic_content() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -529,11 +528,11 @@ fn array_of_results_update_element_at_index_with_dynamic_content() { array_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__array_record_output - call_type: OutputRecording + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit + [1]: Result output_type: body: "#]], ); @@ -543,10 +542,10 @@ fn array_of_results_update_element_at_index_with_dynamic_content() { result_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__result_record_output + name: __quantum__rt__array_record_output call_type: OutputRecording input_type: - [0]: Result + [0]: Integer [1]: Pointer output_type: body: "#]], @@ -556,11 +555,12 @@ fn array_of_results_update_element_at_index_with_dynamic_content() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(1), args( Qubit(1), Result(1), ) - Call id(2), args( Integer(2), Pointer, ) - Call id(3), args( Result(0), Pointer, ) - Call id(3), args( Result(1), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(2), args( Qubit(1), Result(1), ) + Call id(3), args( Integer(2), EmptyTag, ) + Call id(4), args( Result(0), Tag(0, 5), ) + Call id(4), args( Result(1), Tag(1, 5), ) Return"#]], ); } @@ -584,11 +584,10 @@ fn array_of_bools_update_element_at_index_with_dynamic_content() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -598,11 +597,12 @@ fn array_of_bools_update_element_at_index_with_dynamic_content() { readout_callable_id, &expect![[r#" Callable: - name: __quantum__qis__read_result__body - call_type: Readout + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Result - output_type: Boolean + [0]: Qubit + [1]: Result + output_type: body: "#]], ); let array_output_recording_callable_id = CallableId(3); @@ -611,12 +611,11 @@ fn array_of_bools_update_element_at_index_with_dynamic_content() { array_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__array_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); let bool_output_recording_callable_id = CallableId(4); @@ -625,10 +624,10 @@ fn array_of_bools_update_element_at_index_with_dynamic_content() { bool_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__bool_record_output + name: __quantum__rt__array_record_output call_type: OutputRecording input_type: - [0]: Boolean + [0]: Integer [1]: Pointer output_type: body: "#]], @@ -638,15 +637,16 @@ fn array_of_bools_update_element_at_index_with_dynamic_content() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) - Call id(1), args( Qubit(1), Result(1), ) - Variable(2, Boolean) = Call id(2), args( Result(1), ) + Call id(2), args( Qubit(1), Result(1), ) + Variable(2, Boolean) = Call id(3), args( Result(1), ) Variable(3, Boolean) = Store Variable(2, Boolean) - Call id(3), args( Integer(2), Pointer, ) - Call id(4), args( Variable(1, Boolean), Pointer, ) - Call id(4), args( Variable(3, Boolean), Pointer, ) + Call id(4), args( Integer(2), EmptyTag, ) + Call id(5), args( Variable(1, Boolean), Tag(0, 5), ) + Call id(5), args( Variable(3, Boolean), Tag(1, 5), ) Return"#]], ); } @@ -713,11 +713,10 @@ fn array_of_results_update_slice_with_explicit_range() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -727,11 +726,11 @@ fn array_of_results_update_slice_with_explicit_range() { array_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__array_record_output - call_type: OutputRecording + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit + [1]: Result output_type: body: "#]], ); @@ -741,10 +740,10 @@ fn array_of_results_update_slice_with_explicit_range() { result_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__result_record_output + name: __quantum__rt__array_record_output call_type: OutputRecording input_type: - [0]: Result + [0]: Integer [1]: Pointer output_type: body: "#]], @@ -754,20 +753,21 @@ fn array_of_results_update_slice_with_explicit_range() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(1), args( Qubit(1), Result(1), ) - Call id(1), args( Qubit(2), Result(2), ) - Call id(1), args( Qubit(3), Result(3), ) - Call id(1), args( Qubit(4), Result(4), ) - Call id(1), args( Qubit(5), Result(5), ) - Call id(1), args( Qubit(6), Result(6), ) - Call id(1), args( Qubit(7), Result(7), ) - Call id(2), args( Integer(5), Pointer, ) - Call id(3), args( Result(5), Pointer, ) - Call id(3), args( Result(1), Pointer, ) - Call id(3), args( Result(6), Pointer, ) - Call id(3), args( Result(3), Pointer, ) - Call id(3), args( Result(7), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(2), args( Qubit(1), Result(1), ) + Call id(2), args( Qubit(2), Result(2), ) + Call id(2), args( Qubit(3), Result(3), ) + Call id(2), args( Qubit(4), Result(4), ) + Call id(2), args( Qubit(5), Result(5), ) + Call id(2), args( Qubit(6), Result(6), ) + Call id(2), args( Qubit(7), Result(7), ) + Call id(3), args( Integer(5), EmptyTag, ) + Call id(4), args( Result(5), Tag(0, 5), ) + Call id(4), args( Result(1), Tag(1, 5), ) + Call id(4), args( Result(6), Tag(2, 5), ) + Call id(4), args( Result(3), Tag(3, 5), ) + Call id(4), args( Result(7), Tag(4, 5), ) Return"#]], ); } @@ -791,11 +791,10 @@ fn array_of_results_update_slice_with_open_start_range() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -805,11 +804,11 @@ fn array_of_results_update_slice_with_open_start_range() { array_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__array_record_output - call_type: OutputRecording + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit + [1]: Result output_type: body: "#]], ); @@ -819,10 +818,10 @@ fn array_of_results_update_slice_with_open_start_range() { result_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__result_record_output + name: __quantum__rt__array_record_output call_type: OutputRecording input_type: - [0]: Result + [0]: Integer [1]: Pointer output_type: body: "#]], @@ -832,15 +831,16 @@ fn array_of_results_update_slice_with_open_start_range() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(1), args( Qubit(1), Result(1), ) - Call id(1), args( Qubit(2), Result(2), ) - Call id(1), args( Qubit(3), Result(3), ) - Call id(1), args( Qubit(4), Result(4), ) - Call id(2), args( Integer(3), Pointer, ) - Call id(3), args( Result(3), Pointer, ) - Call id(3), args( Result(4), Pointer, ) - Call id(3), args( Result(2), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(2), args( Qubit(1), Result(1), ) + Call id(2), args( Qubit(2), Result(2), ) + Call id(2), args( Qubit(3), Result(3), ) + Call id(2), args( Qubit(4), Result(4), ) + Call id(3), args( Integer(3), EmptyTag, ) + Call id(4), args( Result(3), Tag(0, 5), ) + Call id(4), args( Result(4), Tag(1, 5), ) + Call id(4), args( Result(2), Tag(2, 5), ) Return"#]], ); } @@ -864,11 +864,10 @@ fn array_of_results_update_slice_with_open_ended_range() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -878,11 +877,11 @@ fn array_of_results_update_slice_with_open_ended_range() { array_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__array_record_output - call_type: OutputRecording + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit + [1]: Result output_type: body: "#]], ); @@ -892,10 +891,10 @@ fn array_of_results_update_slice_with_open_ended_range() { result_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__result_record_output + name: __quantum__rt__array_record_output call_type: OutputRecording input_type: - [0]: Result + [0]: Integer [1]: Pointer output_type: body: "#]], @@ -905,15 +904,16 @@ fn array_of_results_update_slice_with_open_ended_range() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(1), args( Qubit(1), Result(1), ) - Call id(1), args( Qubit(2), Result(2), ) - Call id(1), args( Qubit(3), Result(3), ) - Call id(1), args( Qubit(4), Result(4), ) - Call id(2), args( Integer(3), Pointer, ) - Call id(3), args( Result(0), Pointer, ) - Call id(3), args( Result(3), Pointer, ) - Call id(3), args( Result(4), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(2), args( Qubit(1), Result(1), ) + Call id(2), args( Qubit(2), Result(2), ) + Call id(2), args( Qubit(3), Result(3), ) + Call id(2), args( Qubit(4), Result(4), ) + Call id(3), args( Integer(3), EmptyTag, ) + Call id(4), args( Result(0), Tag(0, 5), ) + Call id(4), args( Result(3), Tag(1, 5), ) + Call id(4), args( Result(4), Tag(2, 5), ) Return"#]], ); } @@ -937,11 +937,10 @@ fn array_of_results_update_slice_with_open_two_step_range() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -951,11 +950,11 @@ fn array_of_results_update_slice_with_open_two_step_range() { array_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__array_record_output - call_type: OutputRecording + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit + [1]: Result output_type: body: "#]], ); @@ -965,10 +964,10 @@ fn array_of_results_update_slice_with_open_two_step_range() { result_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__result_record_output + name: __quantum__rt__array_record_output call_type: OutputRecording input_type: - [0]: Result + [0]: Integer [1]: Pointer output_type: body: "#]], @@ -978,15 +977,16 @@ fn array_of_results_update_slice_with_open_two_step_range() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(1), args( Qubit(1), Result(1), ) - Call id(1), args( Qubit(2), Result(2), ) - Call id(1), args( Qubit(3), Result(3), ) - Call id(1), args( Qubit(4), Result(4), ) - Call id(2), args( Integer(3), Pointer, ) - Call id(3), args( Result(3), Pointer, ) - Call id(3), args( Result(1), Pointer, ) - Call id(3), args( Result(4), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(2), args( Qubit(1), Result(1), ) + Call id(2), args( Qubit(2), Result(2), ) + Call id(2), args( Qubit(3), Result(3), ) + Call id(2), args( Qubit(4), Result(4), ) + Call id(3), args( Integer(3), EmptyTag, ) + Call id(4), args( Result(3), Tag(0, 5), ) + Call id(4), args( Result(1), Tag(1, 5), ) + Call id(4), args( Result(4), Tag(2, 5), ) Return"#]], ); } @@ -1032,11 +1032,10 @@ fn empty_array_of_results_in_place_concatenation() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -1046,11 +1045,11 @@ fn empty_array_of_results_in_place_concatenation() { array_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__array_record_output - call_type: OutputRecording + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit + [1]: Result output_type: body: "#]], ); @@ -1060,10 +1059,10 @@ fn empty_array_of_results_in_place_concatenation() { result_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__result_record_output + name: __quantum__rt__array_record_output call_type: OutputRecording input_type: - [0]: Result + [0]: Integer [1]: Pointer output_type: body: "#]], @@ -1073,11 +1072,12 @@ fn empty_array_of_results_in_place_concatenation() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(1), args( Qubit(1), Result(1), ) - Call id(2), args( Integer(2), Pointer, ) - Call id(3), args( Result(0), Pointer, ) - Call id(3), args( Result(1), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(2), args( Qubit(1), Result(1), ) + Call id(3), args( Integer(2), EmptyTag, ) + Call id(4), args( Result(0), Tag(0, 5), ) + Call id(4), args( Result(1), Tag(1, 5), ) Return"#]], ); } @@ -1101,11 +1101,10 @@ fn non_empty_array_of_results_in_place_concatenation() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -1115,11 +1114,11 @@ fn non_empty_array_of_results_in_place_concatenation() { array_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__array_record_output - call_type: OutputRecording + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit + [1]: Result output_type: body: "#]], ); @@ -1129,10 +1128,10 @@ fn non_empty_array_of_results_in_place_concatenation() { result_output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__result_record_output + name: __quantum__rt__array_record_output call_type: OutputRecording input_type: - [0]: Result + [0]: Integer [1]: Pointer output_type: body: "#]], @@ -1142,11 +1141,12 @@ fn non_empty_array_of_results_in_place_concatenation() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(1), args( Qubit(1), Result(1), ) - Call id(2), args( Integer(2), Pointer, ) - Call id(3), args( Result(0), Pointer, ) - Call id(3), args( Result(1), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(2), args( Qubit(1), Result(1), ) + Call id(3), args( Integer(2), EmptyTag, ) + Call id(4), args( Result(0), Tag(0, 5), ) + Call id(4), args( Result(1), Tag(1, 5), ) Return"#]], ); } @@ -1173,11 +1173,10 @@ fn logical_and_assign_with_lhs_classical_true_is_optimized_as_store() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -1186,41 +1185,42 @@ fn logical_and_assign_with_lhs_classical_true_is_optimized_as_store() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( &program, output_record_id, &expect![[r#" - Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording - input_type: - [0]: Boolean - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Store Variable(0, Boolean) Variable(2, Boolean) = Store Variable(1, Boolean) Variable(3, Boolean) = Store Bool(true) Variable(3, Boolean) = Store Variable(2, Boolean) Variable(4, Boolean) = Store Variable(3, Boolean) - Call id(3), args( Variable(4, Boolean), Pointer, ) + Call id(4), args( Variable(4, Boolean), Tag(0, 3), ) Return"#]], ); } @@ -1247,11 +1247,10 @@ fn logical_and_assign_with_lhs_classical_false_short_circuits_evaluation() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -1260,40 +1259,41 @@ fn logical_and_assign_with_lhs_classical_false_short_circuits_evaluation() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( &program, output_record_id, &expect![[r#" - Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording - input_type: - [0]: Boolean - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Store Variable(0, Boolean) Variable(2, Boolean) = Store Variable(1, Boolean) Variable(3, Boolean) = Store Bool(false) Variable(3, Boolean) = Store Bool(false) - Call id(3), args( Bool(false), Pointer, ) + Call id(4), args( Bool(false), Tag(0, 3), ) Return"#]], ); } @@ -1319,11 +1319,10 @@ fn logical_and_assign_with_dynamic_lhs_and_dynamic_rhs_short_circuits_when_rhs_i measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -1332,35 +1331,36 @@ fn logical_and_assign_with_dynamic_lhs_and_dynamic_rhs_short_circuits_when_rhs_i &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( &program, output_record_id, &expect![[r#" - Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording - input_type: - [0]: Boolean - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); assert_blocks( &program, &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Ne, Variable(0, Boolean), Bool(true) Variable(2, Boolean) = Store Variable(1, Boolean) Variable(3, Boolean) = Store Bool(false) @@ -1368,11 +1368,11 @@ fn logical_and_assign_with_dynamic_lhs_and_dynamic_rhs_short_circuits_when_rhs_i Block 1:Block: Variable(2, Boolean) = Store Variable(3, Boolean) Variable(6, Boolean) = Store Variable(2, Boolean) - Call id(3), args( Variable(6, Boolean), Pointer, ) + Call id(4), args( Variable(6, Boolean), Tag(0, 3), ) Return Block 2:Block: - Call id(1), args( Qubit(0), Result(1), ) - Variable(4, Boolean) = Call id(2), args( Result(1), ) + Call id(2), args( Qubit(0), Result(1), ) + Variable(4, Boolean) = Call id(3), args( Result(1), ) Variable(5, Boolean) = Icmp Ne, Variable(4, Boolean), Bool(true) Variable(3, Boolean) = Store Variable(5, Boolean) Jump(1)"#]], @@ -1401,11 +1401,10 @@ fn logical_or_assign_with_lhs_classical_true_short_circuits_evaluation() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -1414,40 +1413,41 @@ fn logical_or_assign_with_lhs_classical_true_short_circuits_evaluation() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( &program, output_record_id, &expect![[r#" - Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording - input_type: - [0]: Boolean - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Store Variable(0, Boolean) Variable(2, Boolean) = Store Variable(1, Boolean) Variable(3, Boolean) = Store Bool(true) Variable(3, Boolean) = Store Bool(true) - Call id(3), args( Bool(true), Pointer, ) + Call id(4), args( Bool(true), Tag(0, 3), ) Return"#]], ); } @@ -1474,11 +1474,10 @@ fn logical_or_assign_with_lhs_classical_false_is_optimized_as_store() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -1487,41 +1486,42 @@ fn logical_or_assign_with_lhs_classical_false_is_optimized_as_store() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( &program, output_record_id, &expect![[r#" - Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording - input_type: - [0]: Boolean - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Store Variable(0, Boolean) Variable(2, Boolean) = Store Variable(1, Boolean) Variable(3, Boolean) = Store Bool(false) Variable(3, Boolean) = Store Variable(2, Boolean) Variable(4, Boolean) = Store Variable(3, Boolean) - Call id(3), args( Variable(4, Boolean), Pointer, ) + Call id(4), args( Variable(4, Boolean), Tag(0, 3), ) Return"#]], ); } @@ -1547,11 +1547,10 @@ fn logical_or_assign_with_dynamic_lhs_and_dynamic_rhs_short_circuits_when_rhs_is measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -1560,35 +1559,36 @@ fn logical_or_assign_with_dynamic_lhs_and_dynamic_rhs_short_circuits_when_rhs_is &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( &program, output_record_id, &expect![[r#" - Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording - input_type: - [0]: Boolean - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); assert_blocks( &program, &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Ne, Variable(0, Boolean), Bool(true) Variable(2, Boolean) = Store Variable(1, Boolean) Variable(3, Boolean) = Store Bool(true) @@ -1596,11 +1596,11 @@ fn logical_or_assign_with_dynamic_lhs_and_dynamic_rhs_short_circuits_when_rhs_is Block 1:Block: Variable(2, Boolean) = Store Variable(3, Boolean) Variable(6, Boolean) = Store Variable(2, Boolean) - Call id(3), args( Variable(6, Boolean), Pointer, ) + Call id(4), args( Variable(6, Boolean), Tag(0, 3), ) Return Block 2:Block: - Call id(1), args( Qubit(0), Result(1), ) - Variable(4, Boolean) = Call id(2), args( Result(1), ) + Call id(2), args( Qubit(0), Result(1), ) + Variable(4, Boolean) = Call id(3), args( Result(1), ) Variable(5, Boolean) = Icmp Ne, Variable(4, Boolean), Bool(true) Variable(3, Boolean) = Store Variable(5, Boolean) Jump(1)"#]], @@ -1628,11 +1628,10 @@ fn integer_assign_add_with_lhs_classical_integer_and_rhs_dynamic_integer() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -1641,13 +1640,14 @@ fn integer_assign_add_with_lhs_classical_integer_and_rhs_dynamic_integer() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -1655,12 +1655,11 @@ fn integer_assign_add_with_lhs_classical_integer_and_rhs_dynamic_integer() { output_record_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -1668,16 +1667,17 @@ fn integer_assign_add_with_lhs_classical_integer_and_rhs_dynamic_integer() { &expect![[r#" Blocks: Block 0:Block: + Call id(1), args( Pointer, ) Variable(0, Integer) = Store Integer(0) - Call id(1), args( Qubit(0), Result(0), ) - Variable(1, Boolean) = Call id(2), args( Result(0), ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(1, Boolean) = Call id(3), args( Result(0), ) Variable(2, Boolean) = Icmp Eq, Variable(1, Boolean), Bool(false) Branch Variable(2, Boolean), 2, 3 Block 1:Block: Variable(4, Integer) = Add Integer(0), Variable(3, Integer) Variable(0, Integer) = Store Variable(4, Integer) Variable(5, Integer) = Store Variable(0, Integer) - Call id(3), args( Variable(5, Integer), Pointer, ) + Call id(4), args( Variable(5, Integer), Tag(0, 3), ) Return Block 2:Block: Variable(3, Integer) = Store Integer(0) @@ -1709,11 +1709,10 @@ fn integer_assign_sub_with_lhs_dynamic_integer_and_rhs_classical_integer() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -1722,13 +1721,14 @@ fn integer_assign_sub_with_lhs_dynamic_integer_and_rhs_classical_integer() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -1736,12 +1736,11 @@ fn integer_assign_sub_with_lhs_dynamic_integer_and_rhs_classical_integer() { output_record_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -1749,8 +1748,9 @@ fn integer_assign_sub_with_lhs_dynamic_integer_and_rhs_classical_integer() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: @@ -1758,7 +1758,7 @@ fn integer_assign_sub_with_lhs_dynamic_integer_and_rhs_classical_integer() { Variable(4, Integer) = Sub Variable(3, Integer), Integer(1) Variable(3, Integer) = Store Variable(4, Integer) Variable(5, Integer) = Store Variable(3, Integer) - Call id(3), args( Variable(5, Integer), Pointer, ) + Call id(4), args( Variable(5, Integer), Tag(0, 3), ) Return Block 2:Block: Variable(2, Integer) = Store Integer(0) @@ -1790,11 +1790,10 @@ fn integer_assign_mul_with_lhs_dynamic_integer_and_rhs_dynamic_integer() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -1803,13 +1802,14 @@ fn integer_assign_mul_with_lhs_dynamic_integer_and_rhs_dynamic_integer() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -1817,12 +1817,11 @@ fn integer_assign_mul_with_lhs_dynamic_integer_and_rhs_dynamic_integer() { output_record_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -1830,14 +1829,15 @@ fn integer_assign_mul_with_lhs_dynamic_integer_and_rhs_dynamic_integer() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Integer) = Store Variable(2, Integer) - Call id(1), args( Qubit(0), Result(1), ) - Variable(4, Boolean) = Call id(2), args( Result(1), ) + Call id(2), args( Qubit(0), Result(1), ) + Variable(4, Boolean) = Call id(3), args( Result(1), ) Variable(5, Boolean) = Icmp Eq, Variable(4, Boolean), Bool(false) Branch Variable(5, Boolean), 5, 6 Block 2:Block: @@ -1850,7 +1850,7 @@ fn integer_assign_mul_with_lhs_dynamic_integer_and_rhs_dynamic_integer() { Variable(7, Integer) = Mul Variable(3, Integer), Variable(6, Integer) Variable(3, Integer) = Store Variable(7, Integer) Variable(8, Integer) = Store Variable(3, Integer) - Call id(3), args( Variable(8, Integer), Pointer, ) + Call id(4), args( Variable(8, Integer), Tag(0, 3), ) Return Block 5:Block: Variable(6, Integer) = Store Integer(1) @@ -1882,11 +1882,10 @@ fn integer_assign_div_with_lhs_classical_integer_and_rhs_dynamic_integer() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -1895,13 +1894,14 @@ fn integer_assign_div_with_lhs_classical_integer_and_rhs_dynamic_integer() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -1909,12 +1909,11 @@ fn integer_assign_div_with_lhs_classical_integer_and_rhs_dynamic_integer() { output_record_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -1922,16 +1921,17 @@ fn integer_assign_div_with_lhs_classical_integer_and_rhs_dynamic_integer() { &expect![[r#" Blocks: Block 0:Block: + Call id(1), args( Pointer, ) Variable(0, Integer) = Store Integer(0) - Call id(1), args( Qubit(0), Result(0), ) - Variable(1, Boolean) = Call id(2), args( Result(0), ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(1, Boolean) = Call id(3), args( Result(0), ) Variable(2, Boolean) = Icmp Eq, Variable(1, Boolean), Bool(false) Branch Variable(2, Boolean), 2, 3 Block 1:Block: Variable(4, Integer) = Sdiv Integer(0), Variable(3, Integer) Variable(0, Integer) = Store Variable(4, Integer) Variable(5, Integer) = Store Variable(0, Integer) - Call id(3), args( Variable(5, Integer), Pointer, ) + Call id(4), args( Variable(5, Integer), Tag(0, 3), ) Return Block 2:Block: Variable(3, Integer) = Store Integer(0) @@ -1963,11 +1963,10 @@ fn integer_assign_mod_with_lhs_dynamic_integer_and_rhs_classical_integer() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -1976,13 +1975,14 @@ fn integer_assign_mod_with_lhs_dynamic_integer_and_rhs_classical_integer() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -1990,12 +1990,11 @@ fn integer_assign_mod_with_lhs_dynamic_integer_and_rhs_classical_integer() { output_record_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -2003,8 +2002,9 @@ fn integer_assign_mod_with_lhs_dynamic_integer_and_rhs_classical_integer() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: @@ -2012,7 +2012,7 @@ fn integer_assign_mod_with_lhs_dynamic_integer_and_rhs_classical_integer() { Variable(4, Integer) = Srem Variable(3, Integer), Integer(1) Variable(3, Integer) = Store Variable(4, Integer) Variable(5, Integer) = Store Variable(3, Integer) - Call id(3), args( Variable(5, Integer), Pointer, ) + Call id(4), args( Variable(5, Integer), Tag(0, 3), ) Return Block 2:Block: Variable(2, Integer) = Store Integer(0) @@ -2090,11 +2090,10 @@ fn integer_assign_exp_with_lhs_dynamic_integer_and_rhs_classical_zero_integer() measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -2103,13 +2102,14 @@ fn integer_assign_exp_with_lhs_dynamic_integer_and_rhs_classical_zero_integer() &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -2117,12 +2117,11 @@ fn integer_assign_exp_with_lhs_dynamic_integer_and_rhs_classical_zero_integer() output_record_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -2130,8 +2129,9 @@ fn integer_assign_exp_with_lhs_dynamic_integer_and_rhs_classical_zero_integer() &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: @@ -2139,7 +2139,7 @@ fn integer_assign_exp_with_lhs_dynamic_integer_and_rhs_classical_zero_integer() Variable(4, Integer) = Store Integer(1) Variable(3, Integer) = Store Variable(4, Integer) Variable(5, Integer) = Store Variable(3, Integer) - Call id(3), args( Variable(5, Integer), Pointer, ) + Call id(4), args( Variable(5, Integer), Tag(0, 3), ) Return Block 2:Block: Variable(2, Integer) = Store Integer(0) @@ -2171,11 +2171,10 @@ fn integer_assign_exp_with_lhs_dynamic_integer_and_rhs_classical_positive_intege measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -2184,13 +2183,14 @@ fn integer_assign_exp_with_lhs_dynamic_integer_and_rhs_classical_positive_intege &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -2198,12 +2198,11 @@ fn integer_assign_exp_with_lhs_dynamic_integer_and_rhs_classical_positive_intege output_record_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -2211,8 +2210,9 @@ fn integer_assign_exp_with_lhs_dynamic_integer_and_rhs_classical_positive_intege &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: @@ -2223,7 +2223,7 @@ fn integer_assign_exp_with_lhs_dynamic_integer_and_rhs_classical_positive_intege Variable(7, Integer) = Mul Variable(6, Integer), Variable(3, Integer) Variable(3, Integer) = Store Variable(7, Integer) Variable(8, Integer) = Store Variable(3, Integer) - Call id(3), args( Variable(8, Integer), Pointer, ) + Call id(4), args( Variable(8, Integer), Tag(0, 3), ) Return Block 2:Block: Variable(2, Integer) = Store Integer(0) @@ -2278,11 +2278,10 @@ fn integer_assign_bitwise_and_with_lhs_dynamic_integer_and_rhs_dynamic_integer() measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -2291,13 +2290,14 @@ fn integer_assign_bitwise_and_with_lhs_dynamic_integer_and_rhs_dynamic_integer() &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -2305,12 +2305,11 @@ fn integer_assign_bitwise_and_with_lhs_dynamic_integer_and_rhs_dynamic_integer() output_record_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -2318,14 +2317,15 @@ fn integer_assign_bitwise_and_with_lhs_dynamic_integer_and_rhs_dynamic_integer() &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Integer) = Store Variable(2, Integer) - Call id(1), args( Qubit(0), Result(1), ) - Variable(4, Boolean) = Call id(2), args( Result(1), ) + Call id(2), args( Qubit(0), Result(1), ) + Variable(4, Boolean) = Call id(3), args( Result(1), ) Variable(5, Boolean) = Icmp Eq, Variable(4, Boolean), Bool(false) Branch Variable(5, Boolean), 5, 6 Block 2:Block: @@ -2338,7 +2338,7 @@ fn integer_assign_bitwise_and_with_lhs_dynamic_integer_and_rhs_dynamic_integer() Variable(7, Integer) = BitwiseAnd Variable(3, Integer), Variable(6, Integer) Variable(3, Integer) = Store Variable(7, Integer) Variable(8, Integer) = Store Variable(3, Integer) - Call id(3), args( Variable(8, Integer), Pointer, ) + Call id(4), args( Variable(8, Integer), Tag(0, 3), ) Return Block 5:Block: Variable(6, Integer) = Store Integer(1) @@ -2370,11 +2370,10 @@ fn integer_assign_bitwise_or_with_lhs_classical_integer_and_rhs_dynamic_integer( measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -2383,13 +2382,14 @@ fn integer_assign_bitwise_or_with_lhs_classical_integer_and_rhs_dynamic_integer( &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -2397,12 +2397,11 @@ fn integer_assign_bitwise_or_with_lhs_classical_integer_and_rhs_dynamic_integer( output_record_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -2410,16 +2409,17 @@ fn integer_assign_bitwise_or_with_lhs_classical_integer_and_rhs_dynamic_integer( &expect![[r#" Blocks: Block 0:Block: + Call id(1), args( Pointer, ) Variable(0, Integer) = Store Integer(0) - Call id(1), args( Qubit(0), Result(0), ) - Variable(1, Boolean) = Call id(2), args( Result(0), ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(1, Boolean) = Call id(3), args( Result(0), ) Variable(2, Boolean) = Icmp Eq, Variable(1, Boolean), Bool(false) Branch Variable(2, Boolean), 2, 3 Block 1:Block: Variable(4, Integer) = BitwiseOr Integer(0), Variable(3, Integer) Variable(0, Integer) = Store Variable(4, Integer) Variable(5, Integer) = Store Variable(0, Integer) - Call id(3), args( Variable(5, Integer), Pointer, ) + Call id(4), args( Variable(5, Integer), Tag(0, 3), ) Return Block 2:Block: Variable(3, Integer) = Store Integer(0) @@ -2451,11 +2451,10 @@ fn integer_bitwise_xor_with_lhs_dynamic_integer_and_rhs_classical_integer() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -2464,13 +2463,14 @@ fn integer_bitwise_xor_with_lhs_dynamic_integer_and_rhs_classical_integer() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -2478,12 +2478,11 @@ fn integer_bitwise_xor_with_lhs_dynamic_integer_and_rhs_classical_integer() { output_record_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -2491,8 +2490,9 @@ fn integer_bitwise_xor_with_lhs_dynamic_integer_and_rhs_classical_integer() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: @@ -2500,7 +2500,7 @@ fn integer_bitwise_xor_with_lhs_dynamic_integer_and_rhs_classical_integer() { Variable(4, Integer) = BitwiseXor Variable(3, Integer), Integer(1) Variable(3, Integer) = Store Variable(4, Integer) Variable(5, Integer) = Store Variable(3, Integer) - Call id(3), args( Variable(5, Integer), Pointer, ) + Call id(4), args( Variable(5, Integer), Tag(0, 3), ) Return Block 2:Block: Variable(2, Integer) = Store Integer(0) @@ -2532,11 +2532,10 @@ fn integer_assign_bitwise_left_shift_with_lhs_dynamic_integer_and_rhs_dynamic_in measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -2545,13 +2544,14 @@ fn integer_assign_bitwise_left_shift_with_lhs_dynamic_integer_and_rhs_dynamic_in &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -2559,12 +2559,11 @@ fn integer_assign_bitwise_left_shift_with_lhs_dynamic_integer_and_rhs_dynamic_in output_record_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -2572,14 +2571,15 @@ fn integer_assign_bitwise_left_shift_with_lhs_dynamic_integer_and_rhs_dynamic_in &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Integer) = Store Variable(2, Integer) - Call id(1), args( Qubit(0), Result(1), ) - Variable(4, Boolean) = Call id(2), args( Result(1), ) + Call id(2), args( Qubit(0), Result(1), ) + Variable(4, Boolean) = Call id(3), args( Result(1), ) Variable(5, Boolean) = Icmp Eq, Variable(4, Boolean), Bool(false) Branch Variable(5, Boolean), 5, 6 Block 2:Block: @@ -2592,7 +2592,7 @@ fn integer_assign_bitwise_left_shift_with_lhs_dynamic_integer_and_rhs_dynamic_in Variable(7, Integer) = Shl Variable(3, Integer), Variable(6, Integer) Variable(3, Integer) = Store Variable(7, Integer) Variable(8, Integer) = Store Variable(3, Integer) - Call id(3), args( Variable(8, Integer), Pointer, ) + Call id(4), args( Variable(8, Integer), Tag(0, 3), ) Return Block 5:Block: Variable(6, Integer) = Store Integer(1) @@ -2624,11 +2624,10 @@ fn integer_assign_bitwise_right_shift_with_lhs_classical_integer_and_rhs_dynamic measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -2637,13 +2636,14 @@ fn integer_assign_bitwise_right_shift_with_lhs_classical_integer_and_rhs_dynamic &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -2651,12 +2651,11 @@ fn integer_assign_bitwise_right_shift_with_lhs_classical_integer_and_rhs_dynamic output_record_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -2664,16 +2663,17 @@ fn integer_assign_bitwise_right_shift_with_lhs_classical_integer_and_rhs_dynamic &expect![[r#" Blocks: Block 0:Block: + Call id(1), args( Pointer, ) Variable(0, Integer) = Store Integer(0) - Call id(1), args( Qubit(0), Result(0), ) - Variable(1, Boolean) = Call id(2), args( Result(0), ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(1, Boolean) = Call id(3), args( Result(0), ) Variable(2, Boolean) = Icmp Eq, Variable(1, Boolean), Bool(false) Branch Variable(2, Boolean), 2, 3 Block 1:Block: Variable(4, Integer) = Ashr Integer(0), Variable(3, Integer) Variable(0, Integer) = Store Variable(4, Integer) Variable(5, Integer) = Store Variable(0, Integer) - Call id(3), args( Variable(5, Integer), Pointer, ) + Call id(4), args( Variable(5, Integer), Tag(0, 3), ) Return Block 2:Block: Variable(3, Integer) = Store Integer(0) @@ -2705,11 +2705,10 @@ fn double_assign_add_with_lhs_classical_double_and_rhs_dynamic_double() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -2718,13 +2717,14 @@ fn double_assign_add_with_lhs_classical_double_and_rhs_dynamic_double() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -2732,12 +2732,11 @@ fn double_assign_add_with_lhs_classical_double_and_rhs_dynamic_double() { output_record_id, &expect![[r#" Callable: - name: __quantum__rt__double_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Double - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -2745,16 +2744,17 @@ fn double_assign_add_with_lhs_classical_double_and_rhs_dynamic_double() { &expect![[r#" Blocks: Block 0:Block: + Call id(1), args( Pointer, ) Variable(0, Double) = Store Double(0) - Call id(1), args( Qubit(0), Result(0), ) - Variable(1, Boolean) = Call id(2), args( Result(0), ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(1, Boolean) = Call id(3), args( Result(0), ) Variable(2, Boolean) = Icmp Eq, Variable(1, Boolean), Bool(false) Branch Variable(2, Boolean), 2, 3 Block 1:Block: Variable(4, Double) = Fadd Double(0), Variable(3, Double) Variable(0, Double) = Store Variable(4, Double) Variable(5, Double) = Store Variable(0, Double) - Call id(3), args( Variable(5, Double), Pointer, ) + Call id(4), args( Variable(5, Double), Tag(0, 3), ) Return Block 2:Block: Variable(3, Double) = Store Double(0) @@ -2786,11 +2786,10 @@ fn double_assign_sub_with_lhs_dynamic_double_and_rhs_classical_double() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -2799,13 +2798,14 @@ fn double_assign_sub_with_lhs_dynamic_double_and_rhs_classical_double() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -2813,12 +2813,11 @@ fn double_assign_sub_with_lhs_dynamic_double_and_rhs_classical_double() { output_record_id, &expect![[r#" Callable: - name: __quantum__rt__double_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Double - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -2826,8 +2825,9 @@ fn double_assign_sub_with_lhs_dynamic_double_and_rhs_classical_double() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: @@ -2835,7 +2835,7 @@ fn double_assign_sub_with_lhs_dynamic_double_and_rhs_classical_double() { Variable(4, Double) = Fsub Variable(3, Double), Double(1) Variable(3, Double) = Store Variable(4, Double) Variable(5, Double) = Store Variable(3, Double) - Call id(3), args( Variable(5, Double), Pointer, ) + Call id(4), args( Variable(5, Double), Tag(0, 3), ) Return Block 2:Block: Variable(2, Double) = Store Double(0) @@ -2867,11 +2867,10 @@ fn double_assign_mul_with_lhs_dynamic_double_and_rhs_dynamic_double() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -2880,13 +2879,14 @@ fn double_assign_mul_with_lhs_dynamic_double_and_rhs_dynamic_double() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -2894,12 +2894,11 @@ fn double_assign_mul_with_lhs_dynamic_double_and_rhs_dynamic_double() { output_record_id, &expect![[r#" Callable: - name: __quantum__rt__double_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Double - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -2907,14 +2906,15 @@ fn double_assign_mul_with_lhs_dynamic_double_and_rhs_dynamic_double() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Double) = Store Variable(2, Double) - Call id(1), args( Qubit(0), Result(1), ) - Variable(4, Boolean) = Call id(2), args( Result(1), ) + Call id(2), args( Qubit(0), Result(1), ) + Variable(4, Boolean) = Call id(3), args( Result(1), ) Variable(5, Boolean) = Icmp Eq, Variable(4, Boolean), Bool(false) Branch Variable(5, Boolean), 5, 6 Block 2:Block: @@ -2927,7 +2927,7 @@ fn double_assign_mul_with_lhs_dynamic_double_and_rhs_dynamic_double() { Variable(7, Double) = Fmul Variable(3, Double), Variable(6, Double) Variable(3, Double) = Store Variable(7, Double) Variable(8, Double) = Store Variable(3, Double) - Call id(3), args( Variable(8, Double), Pointer, ) + Call id(4), args( Variable(8, Double), Tag(0, 3), ) Return Block 5:Block: Variable(6, Double) = Store Double(1.1) @@ -2959,11 +2959,10 @@ fn double_assign_div_with_lhs_classical_double_and_rhs_dynamic_double() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -2972,13 +2971,14 @@ fn double_assign_div_with_lhs_classical_double_and_rhs_dynamic_double() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -2986,12 +2986,11 @@ fn double_assign_div_with_lhs_classical_double_and_rhs_dynamic_double() { output_record_id, &expect![[r#" Callable: - name: __quantum__rt__double_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Double - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -2999,16 +2998,17 @@ fn double_assign_div_with_lhs_classical_double_and_rhs_dynamic_double() { &expect![[r#" Blocks: Block 0:Block: + Call id(1), args( Pointer, ) Variable(0, Double) = Store Double(0) - Call id(1), args( Qubit(0), Result(0), ) - Variable(1, Boolean) = Call id(2), args( Result(0), ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(1, Boolean) = Call id(3), args( Result(0), ) Variable(2, Boolean) = Icmp Eq, Variable(1, Boolean), Bool(false) Branch Variable(2, Boolean), 2, 3 Block 1:Block: Variable(4, Double) = Fdiv Double(0), Variable(3, Double) Variable(0, Double) = Store Variable(4, Double) Variable(5, Double) = Store Variable(0, Double) - Call id(3), args( Variable(5, Double), Pointer, ) + Call id(4), args( Variable(5, Double), Tag(0, 3), ) Return Block 2:Block: Variable(3, Double) = Store Double(0) diff --git a/source/compiler/qsc_partial_eval/src/tests/bindings.rs b/source/compiler/qsc_partial_eval/src/tests/bindings.rs index cc8e55d83f..c1eb44571d 100644 --- a/source/compiler/qsc_partial_eval/src/tests/bindings.rs +++ b/source/compiler/qsc_partial_eval/src/tests/bindings.rs @@ -30,11 +30,10 @@ fn immutable_result_binding_does_not_generate_store_instruction() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -44,11 +43,11 @@ fn immutable_result_binding_does_not_generate_store_instruction() { output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__result_record_output - call_type: OutputRecording + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Result - [1]: Pointer + [0]: Qubit + [1]: Result output_type: body: "#]], ); @@ -57,8 +56,9 @@ fn immutable_result_binding_does_not_generate_store_instruction() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(2), args( Result(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(3), args( Result(0), Tag(0, 3), ) Return"#]], ); } @@ -81,11 +81,10 @@ fn mutable_result_binding_does_not_generate_store_instruction() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -95,11 +94,11 @@ fn mutable_result_binding_does_not_generate_store_instruction() { output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__result_record_output - call_type: OutputRecording + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Result - [1]: Pointer + [0]: Qubit + [1]: Result output_type: body: "#]], ); @@ -108,8 +107,9 @@ fn mutable_result_binding_does_not_generate_store_instruction() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(2), args( Result(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(3), args( Result(0), Tag(0, 3), ) Return"#]], ); } @@ -132,11 +132,10 @@ fn immutable_bool_binding_does_not_generate_store_instruction() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -146,11 +145,12 @@ fn immutable_bool_binding_does_not_generate_store_instruction() { read_result_callable_id, &expect![[r#" Callable: - name: __quantum__qis__read_result__body - call_type: Readout + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Result - output_type: Boolean + [0]: Qubit + [1]: Result + output_type: body: "#]], ); let output_recording_callable_id = CallableId(3); @@ -159,12 +159,11 @@ fn immutable_bool_binding_does_not_generate_store_instruction() { output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Boolean - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_block_instructions( @@ -172,12 +171,13 @@ fn immutable_bool_binding_does_not_generate_store_instruction() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Store Variable(0, Boolean) Variable(2, Boolean) = Store Variable(1, Boolean) Variable(3, Boolean) = Store Variable(2, Boolean) - Call id(3), args( Variable(3, Boolean), Pointer, ) + Call id(4), args( Variable(3, Boolean), Tag(0, 3), ) Return"#]], ); } @@ -200,11 +200,10 @@ fn mutable_bool_binding_generates_store_instruction() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -214,11 +213,12 @@ fn mutable_bool_binding_generates_store_instruction() { read_result_callable_id, &expect![[r#" Callable: - name: __quantum__qis__read_result__body - call_type: Readout + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Result - output_type: Boolean + [0]: Qubit + [1]: Result + output_type: body: "#]], ); let output_recording_callable_id = CallableId(3); @@ -227,12 +227,11 @@ fn mutable_bool_binding_generates_store_instruction() { output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Boolean - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_block_instructions( @@ -240,12 +239,13 @@ fn mutable_bool_binding_generates_store_instruction() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Store Variable(0, Boolean) Variable(2, Boolean) = Store Variable(1, Boolean) Variable(3, Boolean) = Store Variable(2, Boolean) - Call id(3), args( Variable(3, Boolean), Pointer, ) + Call id(4), args( Variable(3, Boolean), Tag(0, 3), ) Return"#]], ); } @@ -268,11 +268,10 @@ fn immutable_int_binding_does_not_generate_store_instruction() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -282,11 +281,12 @@ fn immutable_int_binding_does_not_generate_store_instruction() { read_result_callable_id, &expect![[r#" Callable: - name: __quantum__qis__read_result__body - call_type: Readout + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Result - output_type: Boolean + [0]: Qubit + [1]: Result + output_type: body: "#]], ); let output_recording_callable_id = CallableId(3); @@ -295,12 +295,11 @@ fn immutable_int_binding_does_not_generate_store_instruction() { output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -308,14 +307,15 @@ fn immutable_int_binding_does_not_generate_store_instruction() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Store Variable(0, Boolean) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Integer) = Store Variable(2, Integer) Variable(4, Integer) = Store Variable(3, Integer) - Call id(3), args( Variable(4, Integer), Pointer, ) + Call id(4), args( Variable(4, Integer), Tag(0, 3), ) Return Block 2:Block: Variable(2, Integer) = Store Integer(0) @@ -344,11 +344,10 @@ fn mutable_int_binding_does_generate_store_instruction() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -358,11 +357,12 @@ fn mutable_int_binding_does_generate_store_instruction() { read_result_callable_id, &expect![[r#" Callable: - name: __quantum__qis__read_result__body - call_type: Readout + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Result - output_type: Boolean + [0]: Qubit + [1]: Result + output_type: body: "#]], ); let output_recording_callable_id = CallableId(3); @@ -371,12 +371,11 @@ fn mutable_int_binding_does_generate_store_instruction() { output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -384,14 +383,15 @@ fn mutable_int_binding_does_generate_store_instruction() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Store Variable(0, Boolean) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Integer) = Store Variable(2, Integer) Variable(4, Integer) = Store Variable(3, Integer) - Call id(3), args( Variable(4, Integer), Pointer, ) + Call id(4), args( Variable(4, Integer), Tag(0, 3), ) Return Block 2:Block: Variable(2, Integer) = Store Integer(0) @@ -430,11 +430,10 @@ fn mutable_variable_in_outer_scope_set_to_mutable_from_inner_scope() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -444,11 +443,12 @@ fn mutable_variable_in_outer_scope_set_to_mutable_from_inner_scope() { read_result_callable_id, &expect![[r#" Callable: - name: __quantum__qis__read_result__body - call_type: Readout + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Result - output_type: Boolean + [0]: Qubit + [1]: Result + output_type: body: "#]], ); let output_recording_callable_id = CallableId(3); @@ -457,12 +457,11 @@ fn mutable_variable_in_outer_scope_set_to_mutable_from_inner_scope() { output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -470,14 +469,15 @@ fn mutable_variable_in_outer_scope_set_to_mutable_from_inner_scope() { &expect![[r#" Blocks: Block 0:Block: + Call id(1), args( Pointer, ) Variable(0, Integer) = Store Integer(0) - Call id(1), args( Qubit(0), Result(0), ) - Variable(1, Boolean) = Call id(2), args( Result(0), ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(1, Boolean) = Call id(3), args( Result(0), ) Variable(2, Boolean) = Store Variable(1, Boolean) Branch Variable(2, Boolean), 2, 3 Block 1:Block: Variable(4, Integer) = Store Variable(0, Integer) - Call id(3), args( Variable(4, Integer), Pointer, ) + Call id(4), args( Variable(4, Integer), Tag(0, 3), ) Return Block 2:Block: Variable(3, Integer) = Store Integer(1) @@ -507,11 +507,10 @@ fn mutable_double_binding_does_generate_store_instruction() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -521,11 +520,12 @@ fn mutable_double_binding_does_generate_store_instruction() { read_result_callable_id, &expect![[r#" Callable: - name: __quantum__qis__read_result__body - call_type: Readout + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Result - output_type: Boolean + [0]: Qubit + [1]: Result + output_type: body: "#]], ); let output_recording_callable_id = CallableId(3); @@ -534,12 +534,11 @@ fn mutable_double_binding_does_generate_store_instruction() { output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__double_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Double - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -547,14 +546,15 @@ fn mutable_double_binding_does_generate_store_instruction() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Store Variable(0, Boolean) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Double) = Store Variable(2, Double) Variable(4, Double) = Store Variable(3, Double) - Call id(3), args( Variable(4, Double), Pointer, ) + Call id(4), args( Variable(4, Double), Tag(0, 3), ) Return Block 2:Block: Variable(2, Double) = Store Double(0.1) diff --git a/source/compiler/qsc_partial_eval/src/tests/branching.rs b/source/compiler/qsc_partial_eval/src/tests/branching.rs index b8d508d326..d39754728f 100644 --- a/source/compiler/qsc_partial_eval/src/tests/branching.rs +++ b/source/compiler/qsc_partial_eval/src/tests/branching.rs @@ -35,22 +35,23 @@ fn if_expression_with_true_condition() { &program, op_a_callable_id, &expect![[r#" - Callable: - name: opA - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); assert_blocks( &program, &expect![[r#" - Blocks: - Block 0:Block: - Call id(1), args( Qubit(0), ) - Call id(2), args( Integer(0), Pointer, ) - Return"#]], + Blocks: + Block 0:Block: + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), ) + Call id(3), args( Integer(0), EmptyTag, ) + Return"#]], ); } @@ -73,10 +74,11 @@ fn if_expression_with_false_condition() { assert_blocks( &program, &expect![[r#" - Blocks: - Block 0:Block: - Call id(1), args( Integer(0), Pointer, ) - Return"#]], + Blocks: + Block 0:Block: + Call id(1), args( Pointer, ) + Call id(2), args( Integer(0), EmptyTag, ) + Return"#]], ); } @@ -104,22 +106,23 @@ fn if_else_expression_with_true_condition() { &program, op_a_callable_id, &expect![[r#" - Callable: - name: opA - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); assert_blocks( &program, &expect![[r#" - Blocks: - Block 0:Block: - Call id(1), args( Qubit(0), ) - Call id(2), args( Integer(0), Pointer, ) - Return"#]], + Blocks: + Block 0:Block: + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), ) + Call id(3), args( Integer(0), EmptyTag, ) + Return"#]], ); } @@ -147,22 +150,23 @@ fn if_else_expression_with_false_condition() { &program, op_b_callable_id, &expect![[r#" - Callable: - name: opB - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); assert_blocks( &program, &expect![[r#" - Blocks: - Block 0:Block: - Call id(1), args( Qubit(0), ) - Call id(2), args( Integer(0), Pointer, ) - Return"#]], + Blocks: + Block 0:Block: + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), ) + Call id(3), args( Integer(0), EmptyTag, ) + Return"#]], ); } @@ -193,22 +197,23 @@ fn if_elif_else_expression_with_true_elif_condition() { &program, op_b_callable_id, &expect![[r#" - Callable: - name: opB - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); assert_blocks( &program, &expect![[r#" - Blocks: - Block 0:Block: - Call id(1), args( Qubit(0), ) - Call id(2), args( Integer(0), Pointer, ) - Return"#]], + Blocks: + Block 0:Block: + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), ) + Call id(3), args( Integer(0), EmptyTag, ) + Return"#]], ); } @@ -236,40 +241,40 @@ fn if_expression_with_dynamic_condition() { &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let read_result_callable_id = CallableId(2); assert_callable( &program, read_result_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let op_a_callable_id = CallableId(3); assert_callable( &program, op_a_callable_id, &expect![[r#" - Callable: - name: opA - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); assert_blocks( @@ -277,15 +282,16 @@ fn if_expression_with_dynamic_condition() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 1 Block 1:Block: - Call id(4), args( Integer(0), Pointer, ) + Call id(5), args( Integer(0), EmptyTag, ) Return Block 2:Block: - Call id(3), args( Qubit(0), ) + Call id(4), args( Qubit(0), ) Jump(1)"#]], ); } @@ -317,53 +323,53 @@ fn if_else_expression_with_dynamic_condition() { &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let read_result_callable_id = CallableId(2); assert_callable( &program, read_result_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let op_a_callable_id = CallableId(3); assert_callable( &program, op_a_callable_id, &expect![[r#" - Callable: - name: opA - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); let op_b_callable_id = CallableId(4); assert_callable( &program, op_b_callable_id, &expect![[r#" - Callable: - name: opB - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: opA + call_type: Regular + input_type: + [0]: Qubit + output_type: + body: "#]], ); assert_blocks( @@ -371,18 +377,19 @@ fn if_else_expression_with_dynamic_condition() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Store Variable(0, Boolean) Branch Variable(1, Boolean), 2, 3 Block 1:Block: - Call id(5), args( Integer(0), Pointer, ) + Call id(6), args( Integer(0), EmptyTag, ) Return Block 2:Block: - Call id(3), args( Qubit(0), ) + Call id(4), args( Qubit(0), ) Jump(1) Block 3:Block: - Call id(4), args( Qubit(0), ) + Call id(5), args( Qubit(0), ) Jump(1)"#]], ); } @@ -418,66 +425,66 @@ fn if_elif_else_expression_with_dynamic_condition() { &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let read_result_callable_id = CallableId(2); assert_callable( &program, read_result_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let op_a_callable_id = CallableId(3); assert_callable( &program, op_a_callable_id, &expect![[r#" - Callable: - name: opA - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); let op_b_callable_id = CallableId(4); assert_callable( &program, op_b_callable_id, &expect![[r#" - Callable: - name: opB - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: opA + call_type: Regular + input_type: + [0]: Qubit + output_type: + body: "#]], ); let op_c_callable_id = CallableId(5); assert_callable( &program, op_c_callable_id, &expect![[r#" - Callable: - name: opC - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: opB + call_type: Regular + input_type: + [0]: Qubit + output_type: + body: "#]], ); assert_blocks( @@ -485,28 +492,29 @@ fn if_elif_else_expression_with_dynamic_condition() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(1), args( Qubit(1), Result(1), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(2), args( Qubit(1), Result(1), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Store Variable(0, Boolean) Branch Variable(1, Boolean), 2, 3 Block 1:Block: - Call id(6), args( Integer(0), Pointer, ) + Call id(7), args( Integer(0), EmptyTag, ) Return Block 2:Block: - Call id(3), args( Qubit(2), ) + Call id(4), args( Qubit(2), ) Jump(1) Block 3:Block: - Variable(2, Boolean) = Call id(2), args( Result(1), ) + Variable(2, Boolean) = Call id(3), args( Result(1), ) Variable(3, Boolean) = Store Variable(2, Boolean) Branch Variable(3, Boolean), 5, 6 Block 4:Block: Jump(1) Block 5:Block: - Call id(4), args( Qubit(2), ) + Call id(5), args( Qubit(2), ) Jump(4) Block 6:Block: - Call id(5), args( Qubit(2), ) + Call id(6), args( Qubit(2), ) Jump(4)"#]], ); } @@ -537,57 +545,58 @@ fn if_expression_with_dynamic_condition_and_nested_if_expression_with_true_condi &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let read_result_callable_id = CallableId(2); assert_callable( &program, read_result_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let op_a_callable_id = CallableId(3); assert_callable( &program, op_a_callable_id, &expect![[r#" - Callable: - name: opA - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); assert_blocks( &program, &expect![[r#" - Blocks: - Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) - Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) - Branch Variable(1, Boolean), 2, 1 - Block 1:Block: - Call id(4), args( Integer(0), Pointer, ) - Return - Block 2:Block: - Call id(3), args( Qubit(0), ) - Jump(1)"#]], + Blocks: + Block 0:Block: + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) + Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) + Branch Variable(1, Boolean), 2, 1 + Block 1:Block: + Call id(5), args( Integer(0), EmptyTag, ) + Return + Block 2:Block: + Call id(4), args( Qubit(0), ) + Jump(1)"#]], ); } @@ -617,43 +626,44 @@ fn if_expression_with_dynamic_condition_and_nested_if_expression_with_false_cond &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let read_result_callable_id = CallableId(2); assert_callable( &program, read_result_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); assert_blocks( &program, &expect![[r#" - Blocks: - Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) - Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) - Branch Variable(1, Boolean), 2, 1 - Block 1:Block: - Call id(3), args( Integer(0), Pointer, ) - Return - Block 2:Block: - Jump(1)"#]], + Blocks: + Block 0:Block: + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) + Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) + Branch Variable(1, Boolean), 2, 1 + Block 1:Block: + Call id(4), args( Integer(0), EmptyTag, ) + Return + Block 2:Block: + Jump(1)"#]], ); } @@ -686,53 +696,53 @@ fn if_else_expression_with_dynamic_condition_and_nested_if_expression_with_true_ &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let read_result_callable_id = CallableId(2); assert_callable( &program, read_result_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let op_a_callable_id = CallableId(3); assert_callable( &program, op_a_callable_id, &expect![[r#" - Callable: - name: opA - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); let op_b_callable_id = CallableId(4); assert_callable( &program, op_b_callable_id, &expect![[r#" - Callable: - name: opB - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: opA + call_type: Regular + input_type: + [0]: Qubit + output_type: + body: "#]], ); assert_blocks( @@ -740,18 +750,19 @@ fn if_else_expression_with_dynamic_condition_and_nested_if_expression_with_true_ &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Store Variable(0, Boolean) Branch Variable(1, Boolean), 2, 3 Block 1:Block: - Call id(5), args( Integer(0), Pointer, ) + Call id(6), args( Integer(0), EmptyTag, ) Return Block 2:Block: - Call id(3), args( Qubit(0), ) + Call id(4), args( Qubit(0), ) Jump(1) Block 3:Block: - Call id(4), args( Qubit(0), ) + Call id(5), args( Qubit(0), ) Jump(1)"#]], ); } @@ -785,40 +796,40 @@ fn if_else_expression_with_dynamic_condition_and_nested_if_expression_with_false &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let read_result_callable_id = CallableId(2); assert_callable( &program, read_result_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let op_a_callable_id = CallableId(3); assert_callable( &program, op_a_callable_id, &expect![[r#" - Callable: - name: opA - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); assert_blocks( @@ -826,15 +837,16 @@ fn if_else_expression_with_dynamic_condition_and_nested_if_expression_with_false &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Store Variable(0, Boolean) Branch Variable(1, Boolean), 2, 3 Block 1:Block: - Call id(4), args( Integer(0), Pointer, ) + Call id(5), args( Integer(0), EmptyTag, ) Return Block 2:Block: - Call id(3), args( Qubit(0), ) + Call id(4), args( Qubit(0), ) Jump(1) Block 3:Block: Jump(1)"#]], @@ -868,40 +880,40 @@ fn if_expression_with_dynamic_condition_and_nested_if_expression_with_dynamic_co &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let read_result_callable_id = CallableId(2); assert_callable( &program, read_result_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let op_a_callable_id = CallableId(3); assert_callable( &program, op_a_callable_id, &expect![[r#" - Callable: - name: opA - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); assert_blocks( @@ -909,22 +921,23 @@ fn if_expression_with_dynamic_condition_and_nested_if_expression_with_dynamic_co &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(1), args( Qubit(1), Result(1), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(2), args( Qubit(1), Result(1), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 1 Block 1:Block: - Call id(4), args( Integer(0), Pointer, ) + Call id(5), args( Integer(0), EmptyTag, ) Return Block 2:Block: - Variable(2, Boolean) = Call id(2), args( Result(1), ) + Variable(2, Boolean) = Call id(3), args( Result(1), ) Variable(3, Boolean) = Store Variable(2, Boolean) Branch Variable(3, Boolean), 4, 3 Block 3:Block: Jump(1) Block 4:Block: - Call id(3), args( Qubit(2), ) + Call id(4), args( Qubit(2), ) Jump(3)"#]], ); } @@ -968,79 +981,79 @@ fn doubly_nested_if_else_expressions_with_dynamic_conditions() { &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let read_result_callable_id = CallableId(2); assert_callable( &program, read_result_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let op_a_callable_id = CallableId(3); assert_callable( &program, op_a_callable_id, &expect![[r#" - Callable: - name: opA - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); let op_b_callable_id = CallableId(4); assert_callable( &program, op_b_callable_id, &expect![[r#" - Callable: - name: opB - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: opA + call_type: Regular + input_type: + [0]: Qubit + output_type: + body: "#]], ); let op_c_callable_id = CallableId(5); assert_callable( &program, op_c_callable_id, &expect![[r#" - Callable: - name: opC - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: opB + call_type: Regular + input_type: + [0]: Qubit + output_type: + body: "#]], ); let op_d_callable_id = CallableId(6); assert_callable( &program, op_d_callable_id, &expect![[r#" - Callable: - name: opD - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: opC + call_type: Regular + input_type: + [0]: Qubit + output_type: + body: "#]], ); assert_blocks( @@ -1048,37 +1061,38 @@ fn doubly_nested_if_else_expressions_with_dynamic_conditions() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(1), args( Qubit(1), Result(1), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(2), args( Qubit(1), Result(1), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 6 Block 1:Block: - Call id(7), args( Integer(0), Pointer, ) + Call id(8), args( Integer(0), EmptyTag, ) Return Block 2:Block: - Variable(2, Boolean) = Call id(2), args( Result(1), ) + Variable(2, Boolean) = Call id(3), args( Result(1), ) Variable(3, Boolean) = Icmp Eq, Variable(2, Boolean), Bool(false) Branch Variable(3, Boolean), 4, 5 Block 3:Block: Jump(1) Block 4:Block: - Call id(3), args( Qubit(2), ) + Call id(4), args( Qubit(2), ) Jump(3) Block 5:Block: - Call id(4), args( Qubit(2), ) + Call id(5), args( Qubit(2), ) Jump(3) Block 6:Block: - Variable(4, Boolean) = Call id(2), args( Result(1), ) + Variable(4, Boolean) = Call id(3), args( Result(1), ) Variable(5, Boolean) = Store Variable(4, Boolean) Branch Variable(5, Boolean), 8, 9 Block 7:Block: Jump(1) Block 8:Block: - Call id(5), args( Qubit(2), ) + Call id(6), args( Qubit(2), ) Jump(7) Block 9:Block: - Call id(6), args( Qubit(2), ) + Call id(7), args( Qubit(2), ) Jump(7)"#]], ); } @@ -1109,71 +1123,72 @@ fn if_expression_with_dynamic_condition_and_subsequent_call_to_operation() { &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let read_result_callable_id = CallableId(2); assert_callable( &program, read_result_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let op_a_callable_id = CallableId(3); assert_callable( &program, op_a_callable_id, &expect![[r#" - Callable: - name: opA - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); let op_b_callable_id = CallableId(4); assert_callable( &program, op_b_callable_id, &expect![[r#" - Callable: - name: opB - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: opA + call_type: Regular + input_type: + [0]: Qubit + output_type: + body: "#]], ); assert_blocks( &program, &expect![[r#" - Blocks: - Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) - Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) - Branch Variable(1, Boolean), 2, 1 - Block 1:Block: - Call id(4), args( Qubit(0), ) - Call id(5), args( Integer(0), Pointer, ) - Return - Block 2:Block: - Call id(3), args( Qubit(0), ) - Jump(1)"#]], + Blocks: + Block 0:Block: + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) + Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) + Branch Variable(1, Boolean), 2, 1 + Block 1:Block: + Call id(5), args( Qubit(0), ) + Call id(6), args( Integer(0), EmptyTag, ) + Return + Block 2:Block: + Call id(4), args( Qubit(0), ) + Jump(1)"#]], ); } @@ -1206,66 +1221,66 @@ fn if_else_expression_with_dynamic_condition_and_subsequent_call_to_operation() &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let read_result_callable_id = CallableId(2); assert_callable( &program, read_result_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let op_a_callable_id = CallableId(3); assert_callable( &program, op_a_callable_id, &expect![[r#" - Callable: - name: opA - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); let op_b_callable_id = CallableId(4); assert_callable( &program, op_b_callable_id, &expect![[r#" - Callable: - name: opB - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: opA + call_type: Regular + input_type: + [0]: Qubit + output_type: + body: "#]], ); let op_c_callable_id = CallableId(5); assert_callable( &program, op_c_callable_id, &expect![[r#" - Callable: - name: opC - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: opB + call_type: Regular + input_type: + [0]: Qubit + output_type: + body: "#]], ); assert_blocks( @@ -1273,19 +1288,20 @@ fn if_else_expression_with_dynamic_condition_and_subsequent_call_to_operation() &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Store Variable(0, Boolean) Branch Variable(1, Boolean), 2, 3 Block 1:Block: - Call id(5), args( Qubit(0), ) - Call id(6), args( Integer(0), Pointer, ) + Call id(6), args( Qubit(0), ) + Call id(7), args( Integer(0), EmptyTag, ) Return Block 2:Block: - Call id(3), args( Qubit(0), ) + Call id(4), args( Qubit(0), ) Jump(1) Block 3:Block: - Call id(4), args( Qubit(0), ) + Call id(5), args( Qubit(0), ) Jump(1)"#]], ); } @@ -1336,27 +1352,27 @@ fn if_expression_with_classical_operand_from_hybrid_results_array_comparing_to_l &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let x_callable_id = CallableId(2); assert_callable( &program, x_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__x__body - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let record_array_callable_id = CallableId(3); assert_callable( @@ -1364,11 +1380,10 @@ fn if_expression_with_classical_operand_from_hybrid_results_array_comparing_to_l record_array_callable_id, &expect![[r#" Callable: - name: __quantum__rt__array_record_output - call_type: OutputRecording + name: __quantum__qis__x__body + call_type: Regular input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit output_type: body: "#]], ); @@ -1378,10 +1393,10 @@ fn if_expression_with_classical_operand_from_hybrid_results_array_comparing_to_l record_result_callable_id, &expect![[r#" Callable: - name: __quantum__rt__result_record_output + name: __quantum__rt__array_record_output call_type: OutputRecording input_type: - [0]: Result + [0]: Integer [1]: Pointer output_type: body: "#]], @@ -1389,15 +1404,16 @@ fn if_expression_with_classical_operand_from_hybrid_results_array_comparing_to_l assert_blocks( &program, &expect![[r#" - Blocks: - Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(2), args( Qubit(1), ) - Call id(1), args( Qubit(1), Result(1), ) - Call id(3), args( Integer(2), Pointer, ) - Call id(4), args( Result(0), Pointer, ) - Call id(4), args( Result(1), Pointer, ) - Return"#]], + Blocks: + Block 0:Block: + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(3), args( Qubit(1), ) + Call id(2), args( Qubit(1), Result(1), ) + Call id(4), args( Integer(2), EmptyTag, ) + Call id(5), args( Result(0), Tag(0, 5), ) + Call id(5), args( Result(1), Tag(1, 5), ) + Return"#]], ); } @@ -1425,27 +1441,27 @@ fn if_expression_with_classical_operand_from_hybrid_results_array_comparing_to_l &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let x_callable_id = CallableId(2); assert_callable( &program, x_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__x__body - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let record_array_callable_id = CallableId(3); assert_callable( @@ -1453,11 +1469,10 @@ fn if_expression_with_classical_operand_from_hybrid_results_array_comparing_to_l record_array_callable_id, &expect![[r#" Callable: - name: __quantum__rt__array_record_output - call_type: OutputRecording + name: __quantum__qis__x__body + call_type: Regular input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit output_type: body: "#]], ); @@ -1467,10 +1482,10 @@ fn if_expression_with_classical_operand_from_hybrid_results_array_comparing_to_l record_result_callable_id, &expect![[r#" Callable: - name: __quantum__rt__result_record_output + name: __quantum__rt__array_record_output call_type: OutputRecording input_type: - [0]: Result + [0]: Integer [1]: Pointer output_type: body: "#]], @@ -1478,15 +1493,16 @@ fn if_expression_with_classical_operand_from_hybrid_results_array_comparing_to_l assert_blocks( &program, &expect![[r#" - Blocks: - Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(2), args( Qubit(1), ) - Call id(1), args( Qubit(1), Result(1), ) - Call id(3), args( Integer(2), Pointer, ) - Call id(4), args( Result(0), Pointer, ) - Call id(4), args( Result(1), Pointer, ) - Return"#]], + Blocks: + Block 0:Block: + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(3), args( Qubit(1), ) + Call id(2), args( Qubit(1), Result(1), ) + Call id(4), args( Integer(2), EmptyTag, ) + Call id(5), args( Result(0), Tag(0, 5), ) + Call id(5), args( Result(1), Tag(1, 5), ) + Return"#]], ); } @@ -1514,14 +1530,13 @@ fn if_expression_with_dynamic_operand_from_hybrid_results_array() { &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let read_result_callable_id = CallableId(2); assert_callable( @@ -1529,11 +1544,12 @@ fn if_expression_with_dynamic_operand_from_hybrid_results_array() { read_result_callable_id, &expect![[r#" Callable: - name: __quantum__qis__read_result__body - call_type: Readout + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Result - output_type: Boolean + [0]: Qubit + [1]: Result + output_type: body: "#]], ); let x_callable_id = CallableId(3); @@ -1542,11 +1558,11 @@ fn if_expression_with_dynamic_operand_from_hybrid_results_array() { x_callable_id, &expect![[r#" Callable: - name: __quantum__qis__x__body - call_type: Regular + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Qubit - output_type: + [0]: Result + output_type: Boolean body: "#]], ); let record_array_callable_id = CallableId(4); @@ -1555,11 +1571,10 @@ fn if_expression_with_dynamic_operand_from_hybrid_results_array() { record_array_callable_id, &expect![[r#" Callable: - name: __quantum__rt__array_record_output - call_type: OutputRecording + name: __quantum__qis__x__body + call_type: Regular input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit output_type: body: "#]], ); @@ -1569,10 +1584,10 @@ fn if_expression_with_dynamic_operand_from_hybrid_results_array() { record_result_callable_id, &expect![[r#" Callable: - name: __quantum__rt__result_record_output + name: __quantum__rt__array_record_output call_type: OutputRecording input_type: - [0]: Result + [0]: Integer [1]: Pointer output_type: body: "#]], @@ -1582,18 +1597,19 @@ fn if_expression_with_dynamic_operand_from_hybrid_results_array() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 1 Block 1:Block: - Call id(1), args( Qubit(1), Result(1), ) - Call id(4), args( Integer(2), Pointer, ) - Call id(5), args( Result(0), Pointer, ) - Call id(5), args( Result(1), Pointer, ) + Call id(2), args( Qubit(1), Result(1), ) + Call id(5), args( Integer(2), EmptyTag, ) + Call id(6), args( Result(0), Tag(0, 5), ) + Call id(6), args( Result(1), Tag(1, 5), ) Return Block 2:Block: - Call id(3), args( Qubit(1), ) + Call id(4), args( Qubit(1), ) Jump(1)"#]], ); } @@ -1622,14 +1638,13 @@ fn if_expression_with_classical_operand_from_hybrid_booleans_array() { &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let read_result_callable_id = CallableId(2); assert_callable( @@ -1637,11 +1652,12 @@ fn if_expression_with_classical_operand_from_hybrid_booleans_array() { read_result_callable_id, &expect![[r#" Callable: - name: __quantum__qis__read_result__body - call_type: Readout + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Result - output_type: Boolean + [0]: Qubit + [1]: Result + output_type: body: "#]], ); let x_callable_id = CallableId(3); @@ -1650,11 +1666,11 @@ fn if_expression_with_classical_operand_from_hybrid_booleans_array() { x_callable_id, &expect![[r#" Callable: - name: __quantum__qis__x__body - call_type: Regular + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Qubit - output_type: + [0]: Result + output_type: Boolean body: "#]], ); let record_array_callable_id = CallableId(4); @@ -1663,11 +1679,10 @@ fn if_expression_with_classical_operand_from_hybrid_booleans_array() { record_array_callable_id, &expect![[r#" Callable: - name: __quantum__rt__array_record_output - call_type: OutputRecording + name: __quantum__qis__x__body + call_type: Regular input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit output_type: body: "#]], ); @@ -1677,10 +1692,10 @@ fn if_expression_with_classical_operand_from_hybrid_booleans_array() { record_bool_callable_id, &expect![[r#" Callable: - name: __quantum__rt__bool_record_output + name: __quantum__rt__array_record_output call_type: OutputRecording input_type: - [0]: Boolean + [0]: Integer [1]: Pointer output_type: body: "#]], @@ -1690,16 +1705,17 @@ fn if_expression_with_classical_operand_from_hybrid_booleans_array() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Store Variable(0, Boolean) - Call id(3), args( Qubit(1), ) - Call id(1), args( Qubit(1), Result(1), ) - Variable(2, Boolean) = Call id(2), args( Result(1), ) + Call id(4), args( Qubit(1), ) + Call id(2), args( Qubit(1), Result(1), ) + Variable(2, Boolean) = Call id(3), args( Result(1), ) Variable(3, Boolean) = Store Variable(2, Boolean) - Call id(4), args( Integer(2), Pointer, ) - Call id(5), args( Variable(1, Boolean), Pointer, ) - Call id(5), args( Variable(3, Boolean), Pointer, ) + Call id(5), args( Integer(2), EmptyTag, ) + Call id(6), args( Variable(1, Boolean), Tag(0, 5), ) + Call id(6), args( Variable(3, Boolean), Tag(1, 5), ) Return"#]], ); } @@ -1728,14 +1744,13 @@ fn if_expression_with_dynamic_operand_from_hybrid_booleans_array() { &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let read_result_callable_id = CallableId(2); assert_callable( @@ -1743,11 +1758,12 @@ fn if_expression_with_dynamic_operand_from_hybrid_booleans_array() { read_result_callable_id, &expect![[r#" Callable: - name: __quantum__qis__read_result__body - call_type: Readout + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Result - output_type: Boolean + [0]: Qubit + [1]: Result + output_type: body: "#]], ); let x_callable_id = CallableId(3); @@ -1756,11 +1772,11 @@ fn if_expression_with_dynamic_operand_from_hybrid_booleans_array() { x_callable_id, &expect![[r#" Callable: - name: __quantum__qis__x__body - call_type: Regular + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Qubit - output_type: + [0]: Result + output_type: Boolean body: "#]], ); let record_array_callable_id = CallableId(4); @@ -1769,11 +1785,10 @@ fn if_expression_with_dynamic_operand_from_hybrid_booleans_array() { record_array_callable_id, &expect![[r#" Callable: - name: __quantum__rt__array_record_output - call_type: OutputRecording + name: __quantum__qis__x__body + call_type: Regular input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit output_type: body: "#]], ); @@ -1783,10 +1798,10 @@ fn if_expression_with_dynamic_operand_from_hybrid_booleans_array() { record_bool_callable_id, &expect![[r#" Callable: - name: __quantum__rt__bool_record_output + name: __quantum__rt__array_record_output call_type: OutputRecording input_type: - [0]: Boolean + [0]: Integer [1]: Pointer output_type: body: "#]], @@ -1796,20 +1811,21 @@ fn if_expression_with_dynamic_operand_from_hybrid_booleans_array() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Store Variable(0, Boolean) Branch Variable(1, Boolean), 2, 1 Block 1:Block: - Call id(1), args( Qubit(1), Result(1), ) - Variable(2, Boolean) = Call id(2), args( Result(1), ) + Call id(2), args( Qubit(1), Result(1), ) + Variable(2, Boolean) = Call id(3), args( Result(1), ) Variable(3, Boolean) = Store Variable(2, Boolean) - Call id(4), args( Integer(2), Pointer, ) - Call id(5), args( Variable(1, Boolean), Pointer, ) - Call id(5), args( Variable(3, Boolean), Pointer, ) + Call id(5), args( Integer(2), EmptyTag, ) + Call id(6), args( Variable(1, Boolean), Tag(0, 5), ) + Call id(6), args( Variable(3, Boolean), Tag(1, 5), ) Return Block 2:Block: - Call id(3), args( Qubit(1), ) + Call id(4), args( Qubit(1), ) Jump(1)"#]], ); } @@ -1838,14 +1854,13 @@ fn if_expression_with_classical_operand_from_hybrid_integers_array() { &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let read_result_callable_id = CallableId(2); assert_callable( @@ -1853,11 +1868,12 @@ fn if_expression_with_classical_operand_from_hybrid_integers_array() { read_result_callable_id, &expect![[r#" Callable: - name: __quantum__qis__read_result__body - call_type: Readout + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Result - output_type: Boolean + [0]: Qubit + [1]: Result + output_type: body: "#]], ); let x_callable_id = CallableId(3); @@ -1866,11 +1882,11 @@ fn if_expression_with_classical_operand_from_hybrid_integers_array() { x_callable_id, &expect![[r#" Callable: - name: __quantum__qis__x__body - call_type: Regular + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Qubit - output_type: + [0]: Result + output_type: Boolean body: "#]], ); let record_array_callable_id = CallableId(4); @@ -1879,11 +1895,10 @@ fn if_expression_with_classical_operand_from_hybrid_integers_array() { record_array_callable_id, &expect![[r#" Callable: - name: __quantum__rt__array_record_output - call_type: OutputRecording + name: __quantum__qis__x__body + call_type: Regular input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit output_type: body: "#]], ); @@ -1893,7 +1908,7 @@ fn if_expression_with_classical_operand_from_hybrid_integers_array() { record_int_callable_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output + name: __quantum__rt__array_record_output call_type: OutputRecording input_type: [0]: Integer @@ -1906,14 +1921,15 @@ fn if_expression_with_classical_operand_from_hybrid_integers_array() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: - Call id(3), args( Qubit(1), ) - Call id(1), args( Qubit(1), Result(1), ) - Variable(3, Boolean) = Call id(2), args( Result(1), ) + Call id(4), args( Qubit(1), ) + Call id(2), args( Qubit(1), Result(1), ) + Variable(3, Boolean) = Call id(3), args( Result(1), ) Variable(4, Boolean) = Icmp Eq, Variable(3, Boolean), Bool(false) Branch Variable(4, Boolean), 5, 6 Block 2:Block: @@ -1923,9 +1939,9 @@ fn if_expression_with_classical_operand_from_hybrid_integers_array() { Variable(2, Integer) = Store Integer(1) Jump(1) Block 4:Block: - Call id(4), args( Integer(2), Pointer, ) - Call id(5), args( Variable(2, Integer), Pointer, ) - Call id(5), args( Variable(5, Integer), Pointer, ) + Call id(5), args( Integer(2), EmptyTag, ) + Call id(6), args( Variable(2, Integer), Tag(0, 5), ) + Call id(6), args( Variable(5, Integer), Tag(1, 5), ) Return Block 5:Block: Variable(5, Integer) = Store Integer(0) @@ -1960,14 +1976,13 @@ fn if_expression_with_dynamic_operand_from_hybrid_integers_array() { &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let read_result_callable_id = CallableId(2); assert_callable( @@ -1975,11 +1990,12 @@ fn if_expression_with_dynamic_operand_from_hybrid_integers_array() { read_result_callable_id, &expect![[r#" Callable: - name: __quantum__qis__read_result__body - call_type: Readout + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Result - output_type: Boolean + [0]: Qubit + [1]: Result + output_type: body: "#]], ); let x_callable_id = CallableId(3); @@ -1988,11 +2004,11 @@ fn if_expression_with_dynamic_operand_from_hybrid_integers_array() { x_callable_id, &expect![[r#" Callable: - name: __quantum__qis__x__body - call_type: Regular + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Qubit - output_type: + [0]: Result + output_type: Boolean body: "#]], ); let record_array_callable_id = CallableId(4); @@ -2001,11 +2017,10 @@ fn if_expression_with_dynamic_operand_from_hybrid_integers_array() { record_array_callable_id, &expect![[r#" Callable: - name: __quantum__rt__array_record_output - call_type: OutputRecording + name: __quantum__qis__x__body + call_type: Regular input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit output_type: body: "#]], ); @@ -2015,7 +2030,7 @@ fn if_expression_with_dynamic_operand_from_hybrid_integers_array() { record_int_callable_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output + name: __quantum__rt__array_record_output call_type: OutputRecording input_type: [0]: Integer @@ -2028,8 +2043,9 @@ fn if_expression_with_dynamic_operand_from_hybrid_integers_array() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: @@ -2042,17 +2058,17 @@ fn if_expression_with_dynamic_operand_from_hybrid_integers_array() { Variable(2, Integer) = Store Integer(1) Jump(1) Block 4:Block: - Call id(1), args( Qubit(1), Result(1), ) - Variable(4, Boolean) = Call id(2), args( Result(1), ) + Call id(2), args( Qubit(1), Result(1), ) + Variable(4, Boolean) = Call id(3), args( Result(1), ) Variable(5, Boolean) = Icmp Eq, Variable(4, Boolean), Bool(false) Branch Variable(5, Boolean), 7, 8 Block 5:Block: - Call id(3), args( Qubit(1), ) + Call id(4), args( Qubit(1), ) Jump(4) Block 6:Block: - Call id(4), args( Integer(2), Pointer, ) - Call id(5), args( Variable(2, Integer), Pointer, ) - Call id(5), args( Variable(6, Integer), Pointer, ) + Call id(5), args( Integer(2), EmptyTag, ) + Call id(6), args( Variable(2, Integer), Tag(0, 5), ) + Call id(6), args( Variable(6, Integer), Tag(1, 5), ) Return Block 7:Block: Variable(6, Integer) = Store Integer(0) @@ -2087,14 +2103,13 @@ fn if_expression_with_classical_operand_from_hybrid_doubles_array() { &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let read_result_callable_id = CallableId(2); assert_callable( @@ -2102,11 +2117,12 @@ fn if_expression_with_classical_operand_from_hybrid_doubles_array() { read_result_callable_id, &expect![[r#" Callable: - name: __quantum__qis__read_result__body - call_type: Readout + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Result - output_type: Boolean + [0]: Qubit + [1]: Result + output_type: body: "#]], ); let x_callable_id = CallableId(3); @@ -2115,11 +2131,11 @@ fn if_expression_with_classical_operand_from_hybrid_doubles_array() { x_callable_id, &expect![[r#" Callable: - name: __quantum__qis__x__body - call_type: Regular + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Qubit - output_type: + [0]: Result + output_type: Boolean body: "#]], ); let record_array_callable_id = CallableId(4); @@ -2128,11 +2144,10 @@ fn if_expression_with_classical_operand_from_hybrid_doubles_array() { record_array_callable_id, &expect![[r#" Callable: - name: __quantum__rt__array_record_output - call_type: OutputRecording + name: __quantum__qis__x__body + call_type: Regular input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit output_type: body: "#]], ); @@ -2142,10 +2157,10 @@ fn if_expression_with_classical_operand_from_hybrid_doubles_array() { record_int_callable_id, &expect![[r#" Callable: - name: __quantum__rt__double_record_output + name: __quantum__rt__array_record_output call_type: OutputRecording input_type: - [0]: Double + [0]: Integer [1]: Pointer output_type: body: "#]], @@ -2155,14 +2170,15 @@ fn if_expression_with_classical_operand_from_hybrid_doubles_array() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: - Call id(3), args( Qubit(1), ) - Call id(1), args( Qubit(1), Result(1), ) - Variable(3, Boolean) = Call id(2), args( Result(1), ) + Call id(4), args( Qubit(1), ) + Call id(2), args( Qubit(1), Result(1), ) + Variable(3, Boolean) = Call id(3), args( Result(1), ) Variable(4, Boolean) = Icmp Eq, Variable(3, Boolean), Bool(false) Branch Variable(4, Boolean), 5, 6 Block 2:Block: @@ -2172,9 +2188,9 @@ fn if_expression_with_classical_operand_from_hybrid_doubles_array() { Variable(2, Double) = Store Double(1.1) Jump(1) Block 4:Block: - Call id(4), args( Integer(2), Pointer, ) - Call id(5), args( Variable(2, Double), Pointer, ) - Call id(5), args( Variable(5, Double), Pointer, ) + Call id(5), args( Integer(2), EmptyTag, ) + Call id(6), args( Variable(2, Double), Tag(0, 5), ) + Call id(6), args( Variable(5, Double), Tag(1, 5), ) Return Block 5:Block: Variable(5, Double) = Store Double(0.1) @@ -2209,14 +2225,13 @@ fn if_expression_with_dynamic_operand_from_hybrid_doubles_array() { &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let read_result_callable_id = CallableId(2); assert_callable( @@ -2224,11 +2239,12 @@ fn if_expression_with_dynamic_operand_from_hybrid_doubles_array() { read_result_callable_id, &expect![[r#" Callable: - name: __quantum__qis__read_result__body - call_type: Readout + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Result - output_type: Boolean + [0]: Qubit + [1]: Result + output_type: body: "#]], ); let x_callable_id = CallableId(3); @@ -2237,11 +2253,11 @@ fn if_expression_with_dynamic_operand_from_hybrid_doubles_array() { x_callable_id, &expect![[r#" Callable: - name: __quantum__qis__x__body - call_type: Regular + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Qubit - output_type: + [0]: Result + output_type: Boolean body: "#]], ); let record_array_callable_id = CallableId(4); @@ -2250,11 +2266,10 @@ fn if_expression_with_dynamic_operand_from_hybrid_doubles_array() { record_array_callable_id, &expect![[r#" Callable: - name: __quantum__rt__array_record_output - call_type: OutputRecording + name: __quantum__qis__x__body + call_type: Regular input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit output_type: body: "#]], ); @@ -2264,10 +2279,10 @@ fn if_expression_with_dynamic_operand_from_hybrid_doubles_array() { record_int_callable_id, &expect![[r#" Callable: - name: __quantum__rt__double_record_output + name: __quantum__rt__array_record_output call_type: OutputRecording input_type: - [0]: Double + [0]: Integer [1]: Pointer output_type: body: "#]], @@ -2277,8 +2292,9 @@ fn if_expression_with_dynamic_operand_from_hybrid_doubles_array() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: @@ -2291,17 +2307,17 @@ fn if_expression_with_dynamic_operand_from_hybrid_doubles_array() { Variable(2, Double) = Store Double(1.1) Jump(1) Block 4:Block: - Call id(1), args( Qubit(1), Result(1), ) - Variable(4, Boolean) = Call id(2), args( Result(1), ) + Call id(2), args( Qubit(1), Result(1), ) + Variable(4, Boolean) = Call id(3), args( Result(1), ) Variable(5, Boolean) = Icmp Eq, Variable(4, Boolean), Bool(false) Branch Variable(5, Boolean), 7, 8 Block 5:Block: - Call id(3), args( Qubit(1), ) + Call id(4), args( Qubit(1), ) Jump(4) Block 6:Block: - Call id(4), args( Integer(2), Pointer, ) - Call id(5), args( Variable(2, Double), Pointer, ) - Call id(5), args( Variable(6, Double), Pointer, ) + Call id(5), args( Integer(2), EmptyTag, ) + Call id(6), args( Variable(2, Double), Tag(0, 5), ) + Call id(6), args( Variable(6, Double), Tag(1, 5), ) Return Block 7:Block: Variable(6, Double) = Store Double(0.1) @@ -2335,13 +2351,14 @@ fn if_expression_with_implicit_return_in_callable_supported() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Store Variable(0, Boolean) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Integer) = Store Variable(2, Integer) - Call id(3), args( Variable(3, Integer), Pointer, ) + Call id(4), args( Variable(3, Integer), Tag(0, 3), ) Return Block 2:Block: Variable(2, Integer) = Store Integer(1) diff --git a/source/compiler/qsc_partial_eval/src/tests/calls.rs b/source/compiler/qsc_partial_eval/src/tests/calls.rs index ec72565842..9b36c4534c 100644 --- a/source/compiler/qsc_partial_eval/src/tests/calls.rs +++ b/source/compiler/qsc_partial_eval/src/tests/calls.rs @@ -38,23 +38,24 @@ fn call_to_single_qubit_unitary_with_two_calls_to_the_same_intrinsic() { &program, op_callable_id, &expect![[r#" - Callable: - name: Op - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" - Block: - Call id(1), args( Qubit(0), ) - Call id(1), args( Qubit(0), ) - Call id(2), args( Integer(0), Pointer, ) - Return"#]], + Block: + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), ) + Call id(2), args( Qubit(0), ) + Call id(3), args( Integer(0), EmptyTag, ) + Return"#]], ); } @@ -81,35 +82,36 @@ fn call_to_single_qubit_unitary_with_calls_to_different_intrinsics() { &program, op_a_callable_id, &expect![[r#" - Callable: - name: OpA - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); assert_callable( &program, op_b_callable_id, &expect![[r#" - Callable: - name: OpB - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: OpA + call_type: Regular + input_type: + [0]: Qubit + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" - Block: - Call id(1), args( Qubit(0), ) - Call id(2), args( Qubit(0), ) - Call id(3), args( Integer(0), Pointer, ) - Return"#]], + Block: + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), ) + Call id(3), args( Qubit(0), ) + Call id(4), args( Integer(0), EmptyTag, ) + Return"#]], ); } @@ -134,24 +136,24 @@ fn call_to_two_qubit_unitary() { &program, op_callable_id, &expect![[r#" - Callable: - name: Op - call_type: Regular - input_type: - [0]: Qubit - [1]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" - Block: - Call id(1), args( Qubit(0), Qubit(1), ) - Call id(1), args( Qubit(1), Qubit(0), ) - Call id(2), args( Integer(0), Pointer, ) - Return"#]], + Block: + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Qubit(1), ) + Call id(2), args( Qubit(1), Qubit(0), ) + Call id(3), args( Integer(0), EmptyTag, ) + Return"#]], ); } @@ -178,37 +180,37 @@ fn call_to_unitary_that_receives_double_and_qubit() { &program, double_first_callable_id, &expect![[r#" - Callable: - name: DoubleFirst - call_type: Regular - input_type: - [0]: Double - [1]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); assert_callable( &program, qubit_first_callable_id, &expect![[r#" - Callable: - name: QubitFirst - call_type: Regular - input_type: - [0]: Qubit - [1]: Double - output_type: - body: "#]], + Callable: + name: DoubleFirst + call_type: Regular + input_type: + [0]: Double + [1]: Qubit + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" - Block: - Call id(1), args( Double(1), Qubit(0), ) - Call id(2), args( Qubit(0), Double(1), ) - Call id(3), args( Integer(0), Pointer, ) - Return"#]], + Block: + Call id(1), args( Pointer, ) + Call id(2), args( Double(1), Qubit(0), ) + Call id(3), args( Qubit(0), Double(1), ) + Call id(4), args( Integer(0), EmptyTag, ) + Return"#]], ); } @@ -238,13 +240,13 @@ fn calls_to_unitary_that_conditionally_calls_intrinsic_with_classical_bool() { &program, op_a_callable_id, &expect![[r#" - Callable: - name: OpA - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let op_b_callable_id = CallableId(2); assert_callable( @@ -252,7 +254,7 @@ fn calls_to_unitary_that_conditionally_calls_intrinsic_with_classical_bool() { op_b_callable_id, &expect![[r#" Callable: - name: OpB + name: OpA call_type: Regular input_type: [0]: Qubit @@ -265,11 +267,10 @@ fn calls_to_unitary_that_conditionally_calls_intrinsic_with_classical_bool() { output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__tuple_record_output - call_type: OutputRecording + name: OpB + call_type: Regular input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit output_type: body: "#]], ); @@ -277,11 +278,12 @@ fn calls_to_unitary_that_conditionally_calls_intrinsic_with_classical_bool() { &program, BlockId(0), &expect![[r#" - Block: - Call id(1), args( Qubit(0), ) - Call id(2), args( Qubit(0), ) - Call id(3), args( Integer(0), Pointer, ) - Return"#]], + Block: + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), ) + Call id(3), args( Qubit(0), ) + Call id(4), args( Integer(0), EmptyTag, ) + Return"#]], ); } @@ -312,11 +314,10 @@ fn calls_to_unitary_that_conditionally_calls_intrinsic_with_dynamic_bool() { measure_callable_id, &expect![[r#" Callable: - name: __quantum__qis__m__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -325,26 +326,27 @@ fn calls_to_unitary_that_conditionally_calls_intrinsic_with_dynamic_bool() { &program, read_result_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__m__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let op_a_callable_id = CallableId(3); assert_callable( &program, op_a_callable_id, &expect![[r#" - Callable: - name: OpA - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); let op_b_callable_id = CallableId(4); assert_callable( @@ -352,7 +354,7 @@ fn calls_to_unitary_that_conditionally_calls_intrinsic_with_dynamic_bool() { op_b_callable_id, &expect![[r#" Callable: - name: OpB + name: OpA call_type: Regular input_type: [0]: Qubit @@ -365,11 +367,10 @@ fn calls_to_unitary_that_conditionally_calls_intrinsic_with_dynamic_bool() { output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__tuple_record_output - call_type: OutputRecording + name: OpB + call_type: Regular input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit output_type: body: "#]], ); @@ -378,18 +379,19 @@ fn calls_to_unitary_that_conditionally_calls_intrinsic_with_dynamic_bool() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Store Variable(0, Boolean) Branch Variable(1, Boolean), 2, 3 Block 1:Block: - Call id(5), args( Integer(0), Pointer, ) + Call id(6), args( Integer(0), EmptyTag, ) Return Block 2:Block: - Call id(3), args( Qubit(1), ) + Call id(4), args( Qubit(1), ) Jump(1) Block 3:Block: - Call id(4), args( Qubit(1), ) + Call id(5), args( Qubit(1), ) Jump(1)"#]], ); } @@ -415,24 +417,24 @@ fn call_to_unitary_rotation_unitary_with_computation() { &program, rotation_callable_id, &expect![[r#" - Callable: - name: Rotation - call_type: Regular - input_type: - [0]: Double - [1]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" - Block: - Call id(1), args( Double(4), Qubit(0), ) - Call id(1), args( Double(6), Qubit(0), ) - Call id(2), args( Integer(0), Pointer, ) - Return"#]], + Block: + Call id(1), args( Pointer, ) + Call id(2), args( Double(4), Qubit(0), ) + Call id(2), args( Double(6), Qubit(0), ) + Call id(3), args( Integer(0), EmptyTag, ) + Return"#]], ); } @@ -456,11 +458,10 @@ fn call_to_operation_that_returns_measurement_result() { measure_callable_id, &expect![[r#" Callable: - name: __quantum__qis__m__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -469,23 +470,24 @@ fn call_to_operation_that_returns_measurement_result() { &program, output_recording_callable_id, &expect![[r#" - Callable: - name: __quantum__rt__result_record_output - call_type: OutputRecording - input_type: - [0]: Result - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__qis__m__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" - Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(2), args( Result(0), Pointer, ) - Return"#]], + Block: + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(3), args( Result(0), Tag(0, 3), ) + Return"#]], ); } @@ -510,11 +512,10 @@ fn call_to_operation_that_returns_dynamic_bool() { measure_callable_id, &expect![[r#" Callable: - name: __quantum__qis__m__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -523,13 +524,14 @@ fn call_to_operation_that_returns_dynamic_bool() { &program, read_result_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__m__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_recording_callable_id = CallableId(3); assert_callable( @@ -537,12 +539,11 @@ fn call_to_operation_that_returns_dynamic_bool() { output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Boolean - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_block_instructions( @@ -550,11 +551,12 @@ fn call_to_operation_that_returns_dynamic_bool() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Variable(2, Boolean) = Store Variable(1, Boolean) - Call id(3), args( Variable(2, Boolean), Pointer, ) + Call id(4), args( Variable(2, Boolean), Tag(0, 3), ) Return"#]], ); } @@ -585,13 +587,13 @@ fn call_to_boolean_function_using_result_literal_as_argument_yields_constant() { &program, op_callable_id, &expect![[r#" - Callable: - name: Op - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let output_recording_callable_id = CallableId(2); assert_callable( @@ -599,11 +601,10 @@ fn call_to_boolean_function_using_result_literal_as_argument_yields_constant() { output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__tuple_record_output - call_type: OutputRecording + name: Op + call_type: Regular input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit output_type: body: "#]], ); @@ -612,8 +613,9 @@ fn call_to_boolean_function_using_result_literal_as_argument_yields_constant() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -644,11 +646,10 @@ fn call_to_boolean_function_using_dynamic_result_as_argument_generates_branches( measure_callable_id, &expect![[r#" Callable: - name: __quantum__qis__m__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -657,26 +658,27 @@ fn call_to_boolean_function_using_dynamic_result_as_argument_generates_branches( &program, read_result_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__m__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let op_callable_id = CallableId(3); assert_callable( &program, op_callable_id, &expect![[r#" - Callable: - name: Op - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); let output_recording_callable_id = CallableId(4); assert_callable( @@ -684,11 +686,10 @@ fn call_to_boolean_function_using_dynamic_result_as_argument_generates_branches( output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__tuple_record_output - call_type: OutputRecording + name: Op + call_type: Regular input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit output_type: body: "#]], ); @@ -697,15 +698,16 @@ fn call_to_boolean_function_using_dynamic_result_as_argument_generates_branches( &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Store Variable(0, Boolean) Branch Variable(1, Boolean), 2, 1 Block 1:Block: - Call id(4), args( Integer(0), Pointer, ) + Call id(5), args( Integer(0), EmptyTag, ) Return Block 2:Block: - Call id(3), args( Qubit(1), ) + Call id(4), args( Qubit(1), ) Jump(1)"#]], ); } @@ -737,27 +739,26 @@ fn call_to_unitary_operation_with_one_qubit_argument_using_one_control_qubit() { &program, intrinsic_a_callable_id, &expect![[r#" - Callable: - name: IntrinsicA - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let intrinsic_b_callable_id = CallableId(2); assert_callable( &program, intrinsic_b_callable_id, &expect![[r#" - Callable: - name: IntrinsicB - call_type: Regular - input_type: - [0]: Qubit - [1]: Qubit - output_type: - body: "#]], + Callable: + name: IntrinsicA + call_type: Regular + input_type: + [0]: Qubit + output_type: + body: "#]], ); let output_recording_callable_id = CallableId(3); assert_callable( @@ -765,11 +766,11 @@ fn call_to_unitary_operation_with_one_qubit_argument_using_one_control_qubit() { output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__tuple_record_output - call_type: OutputRecording + name: IntrinsicB + call_type: Regular input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit + [1]: Qubit output_type: body: "#]], ); @@ -778,9 +779,10 @@ fn call_to_unitary_operation_with_one_qubit_argument_using_one_control_qubit() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(1), ) - Call id(2), args( Qubit(0), Qubit(1), ) - Call id(3), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(1), ) + Call id(3), args( Qubit(0), Qubit(1), ) + Call id(4), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -812,13 +814,13 @@ fn call_to_unitary_operation_with_one_qubit_argument_using_mutiple_control_qubit &program, intrinsic_a_callable_id, &expect![[r#" - Callable: - name: IntrinsicA - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let intrinsic_b_callable_id = CallableId(2); assert_callable( @@ -826,12 +828,10 @@ fn call_to_unitary_operation_with_one_qubit_argument_using_mutiple_control_qubit intrinsic_b_callable_id, &expect![[r#" Callable: - name: IntrinsicB + name: IntrinsicA call_type: Regular input_type: [0]: Qubit - [1]: Qubit - [2]: Qubit output_type: body: "#]], ); @@ -841,11 +841,12 @@ fn call_to_unitary_operation_with_one_qubit_argument_using_mutiple_control_qubit output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__tuple_record_output - call_type: OutputRecording + name: IntrinsicB + call_type: Regular input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit + [1]: Qubit + [2]: Qubit output_type: body: "#]], ); @@ -854,9 +855,10 @@ fn call_to_unitary_operation_with_one_qubit_argument_using_mutiple_control_qubit BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(2), ) - Call id(2), args( Qubit(0), Qubit(1), Qubit(2), ) - Call id(3), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(2), ) + Call id(3), args( Qubit(0), Qubit(1), Qubit(2), ) + Call id(4), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -889,11 +891,10 @@ fn call_to_unitary_operation_with_two_qubit_arguments_using_one_control_qubit() intrinsic_a_callable_id, &expect![[r#" Callable: - name: IntrinsicA + name: __quantum__rt__initialize call_type: Regular input_type: - [0]: Qubit - [1]: Qubit + [0]: Pointer output_type: body: "#]], ); @@ -903,12 +904,11 @@ fn call_to_unitary_operation_with_two_qubit_arguments_using_one_control_qubit() intrinsic_b_callable_id, &expect![[r#" Callable: - name: IntrinsicB + name: IntrinsicA call_type: Regular input_type: [0]: Qubit [1]: Qubit - [2]: Qubit output_type: body: "#]], ); @@ -918,11 +918,12 @@ fn call_to_unitary_operation_with_two_qubit_arguments_using_one_control_qubit() output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__tuple_record_output - call_type: OutputRecording + name: IntrinsicB + call_type: Regular input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit + [1]: Qubit + [2]: Qubit output_type: body: "#]], ); @@ -931,9 +932,10 @@ fn call_to_unitary_operation_with_two_qubit_arguments_using_one_control_qubit() BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(1), Qubit(2), ) - Call id(2), args( Qubit(0), Qubit(1), Qubit(2), ) - Call id(3), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(1), Qubit(2), ) + Call id(3), args( Qubit(0), Qubit(1), Qubit(2), ) + Call id(4), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -977,10 +979,10 @@ fn call_to_unitary_operation_using_multiple_controlled_functors() { intrinsic_a1_callable_id, &expect![[r#" Callable: - name: IntrinsicA1 + name: __quantum__rt__initialize call_type: Regular input_type: - [0]: Qubit + [0]: Pointer output_type: body: "#]], ); @@ -990,11 +992,10 @@ fn call_to_unitary_operation_using_multiple_controlled_functors() { intrinsic_b_callable_id, &expect![[r#" Callable: - name: IntrinsicB + name: IntrinsicA1 call_type: Regular input_type: [0]: Qubit - [1]: Qubit output_type: body: "#]], ); @@ -1004,12 +1005,11 @@ fn call_to_unitary_operation_using_multiple_controlled_functors() { intrinsic_c_callable_id, &expect![[r#" Callable: - name: IntrinsicC + name: IntrinsicB call_type: Regular input_type: [0]: Qubit [1]: Qubit - [2]: Qubit output_type: body: "#]], ); @@ -1019,10 +1019,12 @@ fn call_to_unitary_operation_using_multiple_controlled_functors() { intrinsic_a2_callable_id, &expect![[r#" Callable: - name: IntrinsicA2 + name: IntrinsicC call_type: Regular input_type: [0]: Qubit + [1]: Qubit + [2]: Qubit output_type: body: "#]], ); @@ -1032,11 +1034,10 @@ fn call_to_unitary_operation_using_multiple_controlled_functors() { output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__tuple_record_output - call_type: OutputRecording + name: IntrinsicA2 + call_type: Regular input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit output_type: body: "#]], ); @@ -1045,11 +1046,12 @@ fn call_to_unitary_operation_using_multiple_controlled_functors() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), ) - Call id(2), args( Qubit(1), Qubit(0), ) - Call id(3), args( Qubit(1), Qubit(2), Qubit(0), ) - Call id(4), args( Qubit(3), ) - Call id(5), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), ) + Call id(3), args( Qubit(1), Qubit(0), ) + Call id(4), args( Qubit(1), Qubit(2), Qubit(0), ) + Call id(5), args( Qubit(3), ) + Call id(6), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -1072,22 +1074,23 @@ fn call_to_closue_with_no_bound_locals() { &program, CallableId(1), &expect![[r#" - Callable: - name: __quantum__qis__x__body - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" - Block: - Call id(1), args( Qubit(0), ) - Call id(2), args( Integer(0), Pointer, ) - Return"#]], + Block: + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), ) + Call id(3), args( Integer(0), EmptyTag, ) + Return"#]], ); } @@ -1110,11 +1113,10 @@ fn call_to_closue_with_one_bound_local() { CallableId(1), &expect![[r#" Callable: - name: __quantum__qis__rx__body + name: __quantum__rt__initialize call_type: Regular input_type: - [0]: Double - [1]: Qubit + [0]: Pointer output_type: body: "#]], ); @@ -1123,8 +1125,9 @@ fn call_to_closue_with_one_bound_local() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Double(1), Qubit(0), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Double(1), Qubit(0), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -1148,11 +1151,10 @@ fn call_to_closue_with_two_bound_locals() { CallableId(1), &expect![[r#" Callable: - name: __quantum__qis__rx__body + name: __quantum__rt__initialize call_type: Regular input_type: - [0]: Double - [1]: Qubit + [0]: Pointer output_type: body: "#]], ); @@ -1161,8 +1163,9 @@ fn call_to_closue_with_two_bound_locals() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Double(1), Qubit(0), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Double(1), Qubit(0), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -1186,11 +1189,10 @@ fn call_to_closue_with_one_bound_local_two_unbound() { CallableId(1), &expect![[r#" Callable: - name: __quantum__qis__rx__body + name: __quantum__rt__initialize call_type: Regular input_type: - [0]: Double - [1]: Qubit + [0]: Pointer output_type: body: "#]], ); @@ -1199,8 +1201,9 @@ fn call_to_closue_with_one_bound_local_two_unbound() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Double(1), Qubit(0), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Double(1), Qubit(0), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -1228,10 +1231,11 @@ fn call_to_unresolved_callee_with_classical_arg_allowed() { &program, BlockId(0), &expect![[r#" - Block: - Call id(1), args( Double(1), Qubit(0), ) - Call id(2), args( Integer(0), Pointer, ) - Return"#]], + Block: + Call id(1), args( Pointer, ) + Call id(2), args( Double(1), Qubit(0), ) + Call id(3), args( Integer(0), EmptyTag, ) + Return"#]], ); } @@ -1341,9 +1345,10 @@ fn call_to_unresolved_callee_with_static_arg_and_entry_return_value_succeeds() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Double(1), Qubit(0), ) - Call id(2), args( Qubit(0), Result(0), ) - Call id(3), args( Result(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Double(1), Qubit(0), ) + Call id(3), args( Qubit(0), Result(0), ) + Call id(4), args( Result(0), Tag(0, 3), ) Return"#]], ); } diff --git a/source/compiler/qsc_partial_eval/src/tests/classical_args.rs b/source/compiler/qsc_partial_eval/src/tests/classical_args.rs index c8dfa2376d..288adf07aa 100644 --- a/source/compiler/qsc_partial_eval/src/tests/classical_args.rs +++ b/source/compiler/qsc_partial_eval/src/tests/classical_args.rs @@ -22,21 +22,22 @@ fn call_to_intrinsic_operation_using_double_literal() { &program, op_callable_id, &expect![[r#" - Callable: - name: op - call_type: Regular - input_type: - [0]: Double - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: - Call id(1), args( Double(1), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Double(1), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -60,23 +61,24 @@ fn calls_to_intrinsic_operation_using_inline_expressions() { &program, op_callable_id, &expect![[r#" - Callable: - name: op - call_type: Regular - input_type: - [0]: Double - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: - Call id(1), args( Double(0), ) - Call id(1), args( Double(1), ) - Call id(1), args( Double(1), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Double(0), ) + Call id(2), args( Double(1), ) + Call id(2), args( Double(1), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -103,25 +105,26 @@ fn calls_to_intrinsic_operation_using_variables() { &program, op_callable_id, &expect![[r#" - Callable: - name: op - call_type: Regular - input_type: - [0]: Double - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: - Call id(1), args( Double(2), ) + Call id(1), args( Pointer, ) + Call id(2), args( Double(2), ) Variable(0, Double) = Store Double(4) - Call id(1), args( Double(4), ) + Call id(2), args( Double(4), ) Variable(0, Double) = Store Double(8) - Call id(1), args( Double(8), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(2), args( Double(8), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } diff --git a/source/compiler/qsc_partial_eval/src/tests/dynamic_vars.rs b/source/compiler/qsc_partial_eval/src/tests/dynamic_vars.rs index 4c3d0d9295..61dd2b0a2c 100644 --- a/source/compiler/qsc_partial_eval/src/tests/dynamic_vars.rs +++ b/source/compiler/qsc_partial_eval/src/tests/dynamic_vars.rs @@ -29,27 +29,27 @@ fn dynamic_int_from_if_expression_with_single_measurement_comparison_and_classic &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let read_result_callable_id = CallableId(2); assert_callable( &program, read_result_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); assert_blocks( @@ -57,13 +57,14 @@ fn dynamic_int_from_if_expression_with_single_measurement_comparison_and_classic &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Integer) = Store Variable(2, Integer) - Call id(3), args( Integer(0), Pointer, ) + Call id(4), args( Integer(0), EmptyTag, ) Return Block 2:Block: Variable(2, Integer) = Store Integer(0) @@ -103,40 +104,40 @@ fn dynamic_int_from_if_expression_with_single_measurement_comparison_and_non_cla &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let read_result_callable_id = CallableId(2); assert_callable( &program, read_result_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let op_a_callable_id = CallableId(3); assert_callable( &program, op_a_callable_id, &expect![[r#" - Callable: - name: OpA - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); let op_b_callable_id = CallableId(4); assert_callable( @@ -144,7 +145,7 @@ fn dynamic_int_from_if_expression_with_single_measurement_comparison_and_non_cla op_b_callable_id, &expect![[r#" Callable: - name: OpB + name: OpA call_type: Regular input_type: [0]: Qubit @@ -156,20 +157,21 @@ fn dynamic_int_from_if_expression_with_single_measurement_comparison_and_non_cla &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Integer) = Store Variable(2, Integer) - Call id(5), args( Integer(0), Pointer, ) + Call id(6), args( Integer(0), EmptyTag, ) Return Block 2:Block: - Call id(3), args( Qubit(1), ) + Call id(4), args( Qubit(1), ) Variable(2, Integer) = Store Integer(0) Jump(1) Block 3:Block: - Call id(4), args( Qubit(1), ) + Call id(5), args( Qubit(1), ) Variable(2, Integer) = Store Integer(1) Jump(1)"#]], ); @@ -198,22 +200,23 @@ fn dynamic_var_across_if_else_static_in_both_branches_constant_folded() { assert_blocks( &program, &expect![[r#" - Blocks: - Block 0:Block: - Variable(0, Integer) = Store Integer(0) - Call id(1), args( Qubit(0), Result(0), ) - Variable(1, Boolean) = Call id(2), args( Result(0), ) - Variable(2, Boolean) = Icmp Eq, Variable(1, Boolean), Bool(false) - Branch Variable(2, Boolean), 2, 3 - Block 1:Block: - Call id(3), args( Integer(0), Pointer, ) - Return - Block 2:Block: - Variable(0, Integer) = Store Integer(-1) - Jump(1) - Block 3:Block: - Variable(0, Integer) = Store Integer(1) - Jump(1)"#]], + Blocks: + Block 0:Block: + Call id(1), args( Pointer, ) + Variable(0, Integer) = Store Integer(0) + Call id(2), args( Qubit(0), Result(0), ) + Variable(1, Boolean) = Call id(3), args( Result(0), ) + Variable(2, Boolean) = Icmp Eq, Variable(1, Boolean), Bool(false) + Branch Variable(2, Boolean), 2, 3 + Block 1:Block: + Call id(4), args( Integer(0), EmptyTag, ) + Return + Block 2:Block: + Variable(0, Integer) = Store Integer(-1) + Jump(1) + Block 3:Block: + Variable(0, Integer) = Store Integer(1) + Jump(1)"#]], ); } @@ -242,37 +245,38 @@ fn dynamic_var_across_if_else_in_loop_constant_folded_in_first_iteration() { assert_blocks( &program, &expect![[r#" - Blocks: - Block 0:Block: - Variable(0, Integer) = Store Integer(0) - Call id(1), args( Qubit(0), Result(0), ) - Variable(1, Integer) = Store Integer(0) - Variable(2, Boolean) = Call id(2), args( Result(0), ) - Variable(3, Boolean) = Icmp Eq, Variable(2, Boolean), Bool(false) - Branch Variable(3, Boolean), 2, 3 - Block 1:Block: - Variable(1, Integer) = Store Integer(1) - Variable(4, Boolean) = Call id(2), args( Result(0), ) - Variable(5, Boolean) = Icmp Eq, Variable(4, Boolean), Bool(false) - Branch Variable(5, Boolean), 5, 6 - Block 2:Block: - Variable(0, Integer) = Store Integer(-1) - Jump(1) - Block 3:Block: - Variable(0, Integer) = Store Integer(1) - Jump(1) - Block 4:Block: - Variable(1, Integer) = Store Integer(2) - Call id(3), args( Integer(0), Pointer, ) - Return - Block 5:Block: - Variable(6, Integer) = Sub Variable(0, Integer), Integer(1) - Variable(0, Integer) = Store Variable(6, Integer) - Jump(4) - Block 6:Block: - Variable(7, Integer) = Add Variable(0, Integer), Integer(1) - Variable(0, Integer) = Store Variable(7, Integer) - Jump(4)"#]], + Blocks: + Block 0:Block: + Call id(1), args( Pointer, ) + Variable(0, Integer) = Store Integer(0) + Call id(2), args( Qubit(0), Result(0), ) + Variable(1, Integer) = Store Integer(0) + Variable(2, Boolean) = Call id(3), args( Result(0), ) + Variable(3, Boolean) = Icmp Eq, Variable(2, Boolean), Bool(false) + Branch Variable(3, Boolean), 2, 3 + Block 1:Block: + Variable(1, Integer) = Store Integer(1) + Variable(4, Boolean) = Call id(3), args( Result(0), ) + Variable(5, Boolean) = Icmp Eq, Variable(4, Boolean), Bool(false) + Branch Variable(5, Boolean), 5, 6 + Block 2:Block: + Variable(0, Integer) = Store Integer(-1) + Jump(1) + Block 3:Block: + Variable(0, Integer) = Store Integer(1) + Jump(1) + Block 4:Block: + Variable(1, Integer) = Store Integer(2) + Call id(4), args( Integer(0), EmptyTag, ) + Return + Block 5:Block: + Variable(6, Integer) = Sub Variable(0, Integer), Integer(1) + Variable(0, Integer) = Store Variable(6, Integer) + Jump(4) + Block 6:Block: + Variable(7, Integer) = Add Variable(0, Integer), Integer(1) + Variable(0, Integer) = Store Variable(7, Integer) + Jump(4)"#]], ); } @@ -303,16 +307,17 @@ fn dynamic_var_within_if_else_in_loop_constant_folded_in_every_iteration() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) Variable(0, Integer) = Store Integer(0) Variable(1, Integer) = Store Integer(0) - Variable(2, Boolean) = Call id(2), args( Result(0), ) + Variable(2, Boolean) = Call id(3), args( Result(0), ) Variable(3, Boolean) = Icmp Eq, Variable(2, Boolean), Bool(false) Branch Variable(3, Boolean), 2, 3 Block 1:Block: Variable(0, Integer) = Store Integer(1) Variable(4, Integer) = Store Integer(0) - Variable(5, Boolean) = Call id(2), args( Result(0), ) + Variable(5, Boolean) = Call id(3), args( Result(0), ) Variable(6, Boolean) = Icmp Eq, Variable(5, Boolean), Bool(false) Branch Variable(6, Boolean), 5, 6 Block 2:Block: @@ -323,7 +328,7 @@ fn dynamic_var_within_if_else_in_loop_constant_folded_in_every_iteration() { Jump(1) Block 4:Block: Variable(0, Integer) = Store Integer(2) - Call id(3), args( Integer(0), Pointer, ) + Call id(4), args( Integer(0), EmptyTag, ) Return Block 5:Block: Variable(4, Integer) = Store Integer(-1) @@ -361,13 +366,14 @@ fn dynamic_var_updated_twice_in_same_branch_constant_folded() { &expect![[r#" Blocks: Block 0:Block: + Call id(1), args( Pointer, ) Variable(0, Integer) = Store Integer(0) - Call id(1), args( Qubit(0), Result(0), ) - Variable(1, Boolean) = Call id(2), args( Result(0), ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(1, Boolean) = Call id(3), args( Result(0), ) Variable(2, Boolean) = Icmp Eq, Variable(1, Boolean), Bool(false) Branch Variable(2, Boolean), 2, 3 Block 1:Block: - Call id(3), args( Integer(0), Pointer, ) + Call id(4), args( Integer(0), EmptyTag, ) Return Block 2:Block: Variable(0, Integer) = Store Integer(-1) @@ -406,25 +412,26 @@ fn dynamic_var_updated_to_same_value_in_different_branches_constant_folded_after assert_blocks( &program, &expect![[r#" - Blocks: - Block 0:Block: - Variable(0, Integer) = Store Integer(0) - Call id(1), args( Qubit(0), Result(0), ) - Variable(1, Boolean) = Call id(2), args( Result(0), ) - Variable(2, Boolean) = Icmp Eq, Variable(1, Boolean), Bool(false) - Branch Variable(2, Boolean), 2, 3 - Block 1:Block: - Variable(0, Integer) = Store Integer(2) - Call id(3), args( Integer(0), Pointer, ) - Return - Block 2:Block: - Variable(0, Integer) = Store Integer(-1) - Variable(0, Integer) = Store Integer(1) - Jump(1) - Block 3:Block: - Variable(0, Integer) = Store Integer(1) - Variable(0, Integer) = Store Integer(1) - Jump(1)"#]], + Blocks: + Block 0:Block: + Call id(1), args( Pointer, ) + Variable(0, Integer) = Store Integer(0) + Call id(2), args( Qubit(0), Result(0), ) + Variable(1, Boolean) = Call id(3), args( Result(0), ) + Variable(2, Boolean) = Icmp Eq, Variable(1, Boolean), Bool(false) + Branch Variable(2, Boolean), 2, 3 + Block 1:Block: + Variable(0, Integer) = Store Integer(2) + Call id(4), args( Integer(0), EmptyTag, ) + Return + Block 2:Block: + Variable(0, Integer) = Store Integer(-1) + Variable(0, Integer) = Store Integer(1) + Jump(1) + Block 3:Block: + Variable(0, Integer) = Store Integer(1) + Variable(0, Integer) = Store Integer(1) + Jump(1)"#]], ); } @@ -468,17 +475,18 @@ fn dynamic_var_updated_in_nested_branches_constant_folded_when_value_matches_acr &expect![[r#" Blocks: Block 0:Block: + Call id(1), args( Pointer, ) Variable(0, Integer) = Store Integer(0) - Call id(1), args( Qubit(0), Result(0), ) - Variable(1, Boolean) = Call id(2), args( Result(0), ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(1, Boolean) = Call id(3), args( Result(0), ) Variable(2, Boolean) = Icmp Eq, Variable(1, Boolean), Bool(false) Branch Variable(2, Boolean), 2, 6 Block 1:Block: - Call id(3), args( Integer(1), Pointer, ) + Call id(4), args( Integer(1), Tag(0, 3), ) Return Block 2:Block: Variable(0, Integer) = Store Integer(-1) - Variable(3, Boolean) = Call id(2), args( Result(0), ) + Variable(3, Boolean) = Call id(3), args( Result(0), ) Variable(4, Boolean) = Icmp Eq, Variable(3, Boolean), Bool(false) Branch Variable(4, Boolean), 4, 5 Block 3:Block: @@ -493,7 +501,7 @@ fn dynamic_var_updated_in_nested_branches_constant_folded_when_value_matches_acr Jump(3) Block 6:Block: Variable(0, Integer) = Store Integer(1) - Variable(5, Boolean) = Call id(2), args( Result(0), ) + Variable(5, Boolean) = Call id(3), args( Result(0), ) Variable(6, Boolean) = Icmp Eq, Variable(5, Boolean), Bool(false) Branch Variable(6, Boolean), 8, 9 Block 7:Block: @@ -535,9 +543,10 @@ fn dynamic_var_set_to_static_after_dynamism_still_constant_folded() { &expect![[r#" Blocks: Block 0:Block: + Call id(1), args( Pointer, ) Variable(0, Integer) = Store Integer(0) - Call id(1), args( Qubit(0), Result(0), ) - Variable(1, Boolean) = Call id(2), args( Result(0), ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(1, Boolean) = Call id(3), args( Result(0), ) Variable(2, Boolean) = Icmp Eq, Variable(1, Boolean), Bool(false) Branch Variable(2, Boolean), 2, 1 Block 1:Block: @@ -545,7 +554,7 @@ fn dynamic_var_set_to_static_after_dynamism_still_constant_folded() { Variable(0, Integer) = Store Variable(3, Integer) Variable(0, Integer) = Store Integer(3) Variable(0, Integer) = Store Integer(4) - Call id(3), args( Integer(0), Pointer, ) + Call id(4), args( Integer(0), EmptyTag, ) Return Block 2:Block: Variable(0, Integer) = Store Integer(-1) @@ -583,16 +592,17 @@ fn dynamic_var_updated_in_loop_constant_folded_when_every_iteration_results_in_s &expect![[r#" Blocks: Block 0:Block: + Call id(1), args( Pointer, ) Variable(0, Integer) = Store Integer(0) - Call id(1), args( Qubit(0), Result(0), ) + Call id(2), args( Qubit(0), Result(0), ) Variable(1, Integer) = Store Integer(0) - Variable(2, Boolean) = Call id(2), args( Result(0), ) + Variable(2, Boolean) = Call id(3), args( Result(0), ) Variable(3, Boolean) = Icmp Eq, Variable(2, Boolean), Bool(false) Branch Variable(3, Boolean), 2, 3 Block 1:Block: Variable(0, Integer) = Store Integer(0) Variable(1, Integer) = Store Integer(1) - Variable(4, Boolean) = Call id(2), args( Result(0), ) + Variable(4, Boolean) = Call id(3), args( Result(0), ) Variable(5, Boolean) = Icmp Eq, Variable(4, Boolean), Bool(false) Branch Variable(5, Boolean), 5, 6 Block 2:Block: @@ -605,7 +615,7 @@ fn dynamic_var_updated_in_loop_constant_folded_when_every_iteration_results_in_s Block 4:Block: Variable(0, Integer) = Store Integer(0) Variable(1, Integer) = Store Integer(2) - Call id(3), args( Integer(0), Pointer, ) + Call id(4), args( Integer(0), Tag(0, 3), ) Return Block 5:Block: Variable(0, Integer) = Store Integer(-1) @@ -643,18 +653,19 @@ fn immutable_bind_of_dynamic_var_should_be_point_in_time_copy() { &expect![[r#" Blocks: Block 0:Block: + Call id(1), args( Pointer, ) Variable(0, Integer) = Store Integer(0) - Call id(1), args( Qubit(0), Result(0), ) - Variable(1, Boolean) = Call id(2), args( Result(0), ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(1, Boolean) = Call id(3), args( Result(0), ) Variable(2, Boolean) = Icmp Eq, Variable(1, Boolean), Bool(false) Branch Variable(2, Boolean), 2, 1 Block 1:Block: Variable(3, Integer) = Store Variable(0, Integer) Variable(4, Integer) = Add Variable(0, Integer), Integer(1) Variable(0, Integer) = Store Variable(4, Integer) - Call id(3), args( Integer(2), Pointer, ) - Call id(4), args( Variable(3, Integer), Pointer, ) - Call id(4), args( Variable(0, Integer), Pointer, ) + Call id(4), args( Integer(2), EmptyTag, ) + Call id(5), args( Variable(3, Integer), Tag(0, 5), ) + Call id(5), args( Variable(0, Integer), Tag(1, 5), ) Return Block 2:Block: Variable(0, Integer) = Store Integer(-1) @@ -683,27 +694,27 @@ fn dynamic_double_from_if_expression_with_single_measurement_comparison_and_clas &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let read_result_callable_id = CallableId(2); assert_callable( &program, read_result_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); assert_blocks( @@ -711,13 +722,14 @@ fn dynamic_double_from_if_expression_with_single_measurement_comparison_and_clas &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Double) = Store Variable(2, Double) - Call id(3), args( Integer(0), Pointer, ) + Call id(4), args( Integer(0), EmptyTag, ) Return Block 2:Block: Variable(2, Double) = Store Double(0.1) @@ -757,40 +769,40 @@ fn dynamic_double_from_if_expression_with_single_measurement_comparison_and_non_ &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let read_result_callable_id = CallableId(2); assert_callable( &program, read_result_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let op_a_callable_id = CallableId(3); assert_callable( &program, op_a_callable_id, &expect![[r#" - Callable: - name: OpA - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); let op_b_callable_id = CallableId(4); assert_callable( @@ -798,7 +810,7 @@ fn dynamic_double_from_if_expression_with_single_measurement_comparison_and_non_ op_b_callable_id, &expect![[r#" Callable: - name: OpB + name: OpA call_type: Regular input_type: [0]: Qubit @@ -810,20 +822,21 @@ fn dynamic_double_from_if_expression_with_single_measurement_comparison_and_non_ &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Double) = Store Variable(2, Double) - Call id(5), args( Integer(0), Pointer, ) + Call id(6), args( Integer(0), EmptyTag, ) Return Block 2:Block: - Call id(3), args( Qubit(1), ) + Call id(4), args( Qubit(1), ) Variable(2, Double) = Store Double(0.1) Jump(1) Block 3:Block: - Call id(4), args( Qubit(1), ) + Call id(5), args( Qubit(1), ) Variable(2, Double) = Store Double(1.1) Jump(1)"#]], ); @@ -857,27 +870,27 @@ fn dynamic_double_from_if_expression_with_single_measurement_comparison_pass_dyn &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let read_result_callable_id = CallableId(2); assert_callable( &program, read_result_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let op_a_callable_id = CallableId(3); assert_callable( @@ -885,12 +898,11 @@ fn dynamic_double_from_if_expression_with_single_measurement_comparison_pass_dyn op_a_callable_id, &expect![[r#" Callable: - name: OpA - call_type: Regular + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Double - [1]: Qubit - output_type: + [0]: Result + output_type: Boolean body: "#]], ); let op_b_callable_id = CallableId(4); @@ -899,11 +911,11 @@ fn dynamic_double_from_if_expression_with_single_measurement_comparison_pass_dyn op_b_callable_id, &expect![[r#" Callable: - name: __quantum__rt__tuple_record_output - call_type: OutputRecording + name: OpA + call_type: Regular input_type: - [0]: Integer - [1]: Pointer + [0]: Double + [1]: Qubit output_type: body: "#]], ); @@ -912,14 +924,15 @@ fn dynamic_double_from_if_expression_with_single_measurement_comparison_pass_dyn &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Double) = Store Variable(2, Double) - Call id(3), args( Variable(3, Double), Qubit(1), ) - Call id(4), args( Integer(0), Pointer, ) + Call id(4), args( Variable(3, Double), Qubit(1), ) + Call id(5), args( Integer(0), EmptyTag, ) Return Block 2:Block: Variable(2, Double) = Store Double(0.1) diff --git a/source/compiler/qsc_partial_eval/src/tests/intrinsics.rs b/source/compiler/qsc_partial_eval/src/tests/intrinsics.rs index 9d94d31aec..94def74fd4 100644 --- a/source/compiler/qsc_partial_eval/src/tests/intrinsics.rs +++ b/source/compiler/qsc_partial_eval/src/tests/intrinsics.rs @@ -137,16 +137,17 @@ fn call_to_intrinsic_h_adds_callable_and_generates_instruction() { "__quantum__qis__h__body", &expect![[r#" Callable: - name: __quantum__qis__h__body + name: __quantum__rt__initialize call_type: Regular input_type: - [0]: Qubit + [0]: Pointer output_type: body: "#]], &expect![[r#" Block: - Call id(1), args( Qubit(0), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -157,16 +158,17 @@ fn call_to_intrinsic_s_adds_callable_and_generates_instruction() { "__quantum__qis__s__body", &expect![[r#" Callable: - name: __quantum__qis__s__body + name: __quantum__rt__initialize call_type: Regular input_type: - [0]: Qubit + [0]: Pointer output_type: body: "#]], &expect![[r#" Block: - Call id(1), args( Qubit(0), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -177,16 +179,17 @@ fn call_to_intrinsic_adjoint_s_adds_callable_and_generates_instruction() { "__quantum__qis__s__adj", &expect![[r#" Callable: - name: __quantum__qis__s__adj + name: __quantum__rt__initialize call_type: Regular input_type: - [0]: Qubit + [0]: Pointer output_type: body: "#]], &expect![[r#" Block: - Call id(1), args( Qubit(0), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -197,16 +200,17 @@ fn call_to_intrinsic_sx_adds_callable_and_generates_instruction() { "__quantum__qis__sx__body", &expect![[r#" Callable: - name: __quantum__qis__sx__body + name: __quantum__rt__initialize call_type: Regular input_type: - [0]: Qubit + [0]: Pointer output_type: body: "#]], &expect![[r#" Block: - Call id(1), args( Qubit(0), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -217,16 +221,17 @@ fn call_to_intrinsic_t_adds_callable_and_generates_instruction() { "__quantum__qis__t__body", &expect![[r#" Callable: - name: __quantum__qis__t__body + name: __quantum__rt__initialize call_type: Regular input_type: - [0]: Qubit + [0]: Pointer output_type: body: "#]], &expect![[r#" Block: - Call id(1), args( Qubit(0), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -237,16 +242,17 @@ fn call_to_intrinsic_adjoint_t_adds_callable_and_generates_instruction() { "__quantum__qis__t__adj", &expect![[r#" Callable: - name: __quantum__qis__t__adj + name: __quantum__rt__initialize call_type: Regular input_type: - [0]: Qubit + [0]: Pointer output_type: body: "#]], &expect![[r#" Block: - Call id(1), args( Qubit(0), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -257,16 +263,17 @@ fn call_to_intrinsic_x_adds_callable_and_generates_instruction() { "__quantum__qis__x__body", &expect![[r#" Callable: - name: __quantum__qis__x__body + name: __quantum__rt__initialize call_type: Regular input_type: - [0]: Qubit + [0]: Pointer output_type: body: "#]], &expect![[r#" Block: - Call id(1), args( Qubit(0), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -277,16 +284,17 @@ fn call_to_intrinsic_y_adds_callable_and_generates_instruction() { "__quantum__qis__y__body", &expect![[r#" Callable: - name: __quantum__qis__y__body + name: __quantum__rt__initialize call_type: Regular input_type: - [0]: Qubit + [0]: Pointer output_type: body: "#]], &expect![[r#" Block: - Call id(1), args( Qubit(0), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -297,16 +305,17 @@ fn call_to_intrinsic_z_adds_callable_and_generates_instruction() { "__quantum__qis__z__body", &expect![[r#" Callable: - name: __quantum__qis__z__body + name: __quantum__rt__initialize call_type: Regular input_type: - [0]: Qubit + [0]: Pointer output_type: body: "#]], &expect![[r#" Block: - Call id(1), args( Qubit(0), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -317,17 +326,17 @@ fn call_to_intrinsic_swap_adds_callable_and_generates_instruction() { "__quantum__qis__swap__body", &expect![[r#" Callable: - name: __quantum__qis__swap__body + name: __quantum__rt__initialize call_type: Regular input_type: - [0]: Qubit - [1]: Qubit + [0]: Pointer output_type: body: "#]], &expect![[r#" Block: - Call id(1), args( Qubit(0), Qubit(1), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Qubit(1), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -338,17 +347,17 @@ fn call_to_intrinsic_cx_adds_callable_and_generates_instruction() { "__quantum__qis__cx__body", &expect![[r#" Callable: - name: __quantum__qis__cx__body + name: __quantum__rt__initialize call_type: Regular input_type: - [0]: Qubit - [1]: Qubit + [0]: Pointer output_type: body: "#]], &expect![[r#" Block: - Call id(1), args( Qubit(0), Qubit(1), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Qubit(1), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -359,17 +368,17 @@ fn call_to_intrinsic_cy_adds_callable_and_generates_instruction() { "__quantum__qis__cy__body", &expect![[r#" Callable: - name: __quantum__qis__cy__body + name: __quantum__rt__initialize call_type: Regular input_type: - [0]: Qubit - [1]: Qubit + [0]: Pointer output_type: body: "#]], &expect![[r#" Block: - Call id(1), args( Qubit(0), Qubit(1), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Qubit(1), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -380,17 +389,17 @@ fn call_to_intrinsic_cz_adds_callable_and_generates_instruction() { "__quantum__qis__cz__body", &expect![[r#" Callable: - name: __quantum__qis__cz__body + name: __quantum__rt__initialize call_type: Regular input_type: - [0]: Qubit - [1]: Qubit + [0]: Pointer output_type: body: "#]], &expect![[r#" Block: - Call id(1), args( Qubit(0), Qubit(1), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Qubit(1), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -401,18 +410,17 @@ fn call_to_intrinsic_ccx_adds_callable_and_generates_instruction() { "__quantum__qis__ccx__body", &expect![[r#" Callable: - name: __quantum__qis__ccx__body + name: __quantum__rt__initialize call_type: Regular input_type: - [0]: Qubit - [1]: Qubit - [2]: Qubit + [0]: Pointer output_type: body: "#]], &expect![[r#" Block: - Call id(1), args( Qubit(0), Qubit(1), Qubit(2), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Qubit(1), Qubit(2), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -423,17 +431,17 @@ fn call_to_intrinsic_rx_adds_callable_and_generates_instruction() { "__quantum__qis__rx__body", &expect![[r#" Callable: - name: __quantum__qis__rx__body + name: __quantum__rt__initialize call_type: Regular input_type: - [0]: Double - [1]: Qubit + [0]: Pointer output_type: body: "#]], &expect![[r#" Block: - Call id(1), args( Double(0), Qubit(0), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Double(0), Qubit(0), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -444,18 +452,17 @@ fn call_to_intrinsic_rxx_adds_callable_and_generates_instruction() { "__quantum__qis__rxx__body", &expect![[r#" Callable: - name: __quantum__qis__rxx__body + name: __quantum__rt__initialize call_type: Regular input_type: - [0]: Double - [1]: Qubit - [2]: Qubit + [0]: Pointer output_type: body: "#]], &expect![[r#" Block: - Call id(1), args( Double(0), Qubit(0), Qubit(1), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Double(0), Qubit(0), Qubit(1), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -466,17 +473,17 @@ fn call_to_intrinsic_ry_adds_callable_and_generates_instruction() { "__quantum__qis__ry__body", &expect![[r#" Callable: - name: __quantum__qis__ry__body + name: __quantum__rt__initialize call_type: Regular input_type: - [0]: Double - [1]: Qubit + [0]: Pointer output_type: body: "#]], &expect![[r#" Block: - Call id(1), args( Double(0), Qubit(0), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Double(0), Qubit(0), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -487,18 +494,17 @@ fn call_to_intrinsic_ryy_adds_callable_and_generates_instruction() { "__quantum__qis__ryy__body", &expect![[r#" Callable: - name: __quantum__qis__ryy__body + name: __quantum__rt__initialize call_type: Regular input_type: - [0]: Double - [1]: Qubit - [2]: Qubit + [0]: Pointer output_type: body: "#]], &expect![[r#" Block: - Call id(1), args( Double(0), Qubit(0), Qubit(1), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Double(0), Qubit(0), Qubit(1), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -509,17 +515,17 @@ fn call_to_intrinsic_rz_adds_callable_and_generates_instruction() { "__quantum__qis__rz__body", &expect![[r#" Callable: - name: __quantum__qis__rz__body + name: __quantum__rt__initialize call_type: Regular input_type: - [0]: Double - [1]: Qubit + [0]: Pointer output_type: body: "#]], &expect![[r#" Block: - Call id(1), args( Double(0), Qubit(0), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Double(0), Qubit(0), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -530,18 +536,17 @@ fn call_to_intrinsic_rzz_adds_callable_and_generates_instruction() { "__quantum__qis__rzz__body", &expect![[r#" Callable: - name: __quantum__qis__rzz__body + name: __quantum__rt__initialize call_type: Regular input_type: - [0]: Double - [1]: Qubit - [2]: Qubit + [0]: Pointer output_type: body: "#]], &expect![[r#" Block: - Call id(1), args( Double(0), Qubit(0), Qubit(1), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Double(0), Qubit(0), Qubit(1), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -564,21 +569,22 @@ fn check_partial_eval_for_call_to_reset() { &program, op_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__reset__body - call_type: Reset - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -602,11 +608,10 @@ fn call_to_intrinsic_m_adds_callable_and_generates_instruction() { op_callable_id, &expect![[r#" Callable: - name: __quantum__qis__m__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -615,8 +620,9 @@ fn call_to_intrinsic_m_adds_callable_and_generates_instruction() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -639,22 +645,22 @@ fn call_to_intrinsic_mresetz_adds_callable_and_generates_instruction() { &program, op_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -684,22 +690,23 @@ fn calls_to_intrinsic_begin_estimate_caching_with_classical_values_always_yield_ &program, op_callable_id, &expect![[r#" - Callable: - name: Op - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), ) - Call id(1), args( Qubit(0), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), ) + Call id(2), args( Qubit(0), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -729,11 +736,10 @@ fn call_to_intrinsic_begin_estimate_caching_with_dynamic_values_yields_true() { measure_callable_id, &expect![[r#" Callable: - name: __quantum__qis__m__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -742,26 +748,27 @@ fn call_to_intrinsic_begin_estimate_caching_with_dynamic_values_yields_true() { &program, read_result_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__m__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let op_callable_id = CallableId(3); assert_callable( &program, op_callable_id, &expect![[r#" - Callable: - name: Op - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); let output_recording_callable_id = CallableId(4); assert_callable( @@ -769,11 +776,10 @@ fn call_to_intrinsic_begin_estimate_caching_with_dynamic_values_yields_true() { output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__tuple_record_output - call_type: OutputRecording + name: Op + call_type: Regular input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit output_type: body: "#]], ); @@ -782,14 +788,15 @@ fn call_to_intrinsic_begin_estimate_caching_with_dynamic_values_yields_true() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Integer) = Store Variable(2, Integer) - Call id(3), args( Qubit(0), ) - Call id(4), args( Integer(0), Pointer, ) + Call id(4), args( Qubit(0), ) + Call id(5), args( Integer(0), EmptyTag, ) Return Block 2:Block: Variable(2, Integer) = Store Integer(0) @@ -817,9 +824,10 @@ fn call_to_intrinsic_end_estimate_caching_does_not_generate_instructions() { &program, BlockId(0), &expect![[r#" - Block: - Call id(1), args( Integer(0), Pointer, ) - Return"#]], + Block: + Call id(1), args( Pointer, ) + Call id(2), args( Integer(0), EmptyTag, ) + Return"#]], ); } @@ -841,9 +849,10 @@ fn call_to_account_for_estimates_does_not_generate_instructions() { &program, BlockId(0), &expect![[r#" - Block: - Call id(1), args( Integer(0), Pointer, ) - Return"#]], + Block: + Call id(1), args( Pointer, ) + Call id(2), args( Integer(0), EmptyTag, ) + Return"#]], ); } @@ -865,9 +874,10 @@ fn call_to_begin_repeat_estimates_does_not_generate_instructions() { &program, BlockId(0), &expect![[r#" - Block: - Call id(1), args( Integer(0), Pointer, ) - Return"#]], + Block: + Call id(1), args( Pointer, ) + Call id(2), args( Integer(0), EmptyTag, ) + Return"#]], ); } @@ -889,9 +899,10 @@ fn call_to_end_repeat_estimates_does_not_generate_instructions() { &program, BlockId(0), &expect![[r#" - Block: - Call id(1), args( Integer(0), Pointer, ) - Return"#]], + Block: + Call id(1), args( Pointer, ) + Call id(2), args( Integer(0), EmptyTag, ) + Return"#]], ); } @@ -912,9 +923,10 @@ fn call_to_dump_machine_does_not_generate_instructions() { &program, BlockId(0), &expect![[r#" - Block: - Call id(1), args( Integer(0), Pointer, ) - Return"#]], + Block: + Call id(1), args( Pointer, ) + Call id(2), args( Integer(0), EmptyTag, ) + Return"#]], ); } @@ -936,9 +948,10 @@ fn call_to_dump_register_does_not_generate_instructions() { &program, BlockId(0), &expect![[r#" - Block: - Call id(1), args( Integer(0), Pointer, ) - Return"#]], + Block: + Call id(1), args( Pointer, ) + Call id(2), args( Integer(0), EmptyTag, ) + Return"#]], ); } @@ -962,7 +975,8 @@ fn use_of_noise_does_not_generate_instructions() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -1059,11 +1073,10 @@ fn call_to_length_in_inner_function_succeeds() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -1073,11 +1086,11 @@ fn call_to_length_in_inner_function_succeeds() { output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit + [1]: Result output_type: body: "#]], ); @@ -1086,8 +1099,9 @@ fn call_to_length_in_inner_function_succeeds() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(2), args( Integer(1), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(3), args( Integer(1), Tag(0, 3), ) Return"#]], ); } @@ -1109,9 +1123,10 @@ fn call_to_pauli_i_rotation_for_global_phase_is_noop() { &program, BlockId(0), &expect![[r#" - Block: - Call id(1), args( Integer(0), Pointer, ) - Return"#]], + Block: + Call id(1), args( Pointer, ) + Call id(2), args( Integer(0), EmptyTag, ) + Return"#]], ); } @@ -1144,9 +1159,10 @@ fn call_to_operation_with_codegen_intrinsic_override_should_skip_impl() { op1_callable_id, &expect![[r#" Callable: - name: Op1 + name: __quantum__rt__initialize call_type: Regular - input_type: + input_type: + [0]: Pointer output_type: body: "#]], ); @@ -1156,7 +1172,7 @@ fn call_to_operation_with_codegen_intrinsic_override_should_skip_impl() { op2_callable_id, &expect![[r#" Callable: - name: Op2 + name: Op1 call_type: Regular input_type: output_type: @@ -1166,12 +1182,13 @@ fn call_to_operation_with_codegen_intrinsic_override_should_skip_impl() { &program, BlockId(0), &expect![[r#" - Block: - Call id(1), args( ) - Call id(2), args( ) - Call id(1), args( ) - Call id(3), args( Integer(0), Pointer, ) - Return"#]], + Block: + Call id(1), args( Pointer, ) + Call id(2), args( ) + Call id(3), args( ) + Call id(2), args( ) + Call id(4), args( Integer(0), EmptyTag, ) + Return"#]], ); } @@ -1195,10 +1212,11 @@ fn call_to_intrinsic_operation_that_returns_bool_value_should_produce_variable_u op1_callable_id, &expect![[r#" Callable: - name: Op1 + name: __quantum__rt__initialize call_type: Regular - input_type: - output_type: Boolean + input_type: + [0]: Pointer + output_type: body: "#]], ); assert_block_instructions( @@ -1206,8 +1224,9 @@ fn call_to_intrinsic_operation_that_returns_bool_value_should_produce_variable_u BlockId(0), &expect![[r#" Block: - Variable(0, Boolean) = Call id(1), args( ) - Call id(2), args( Variable(0, Boolean), Pointer, ) + Call id(1), args( Pointer, ) + Variable(0, Boolean) = Call id(2), args( ) + Call id(3), args( Variable(0, Boolean), Tag(0, 3), ) Return"#]], ); } @@ -1232,10 +1251,11 @@ fn call_to_intrinsic_operation_that_returns_int_value_should_produce_variable_us op1_callable_id, &expect![[r#" Callable: - name: Op1 + name: __quantum__rt__initialize call_type: Regular - input_type: - output_type: Integer + input_type: + [0]: Pointer + output_type: body: "#]], ); assert_block_instructions( @@ -1243,8 +1263,9 @@ fn call_to_intrinsic_operation_that_returns_int_value_should_produce_variable_us BlockId(0), &expect![[r#" Block: - Variable(0, Integer) = Call id(1), args( ) - Call id(2), args( Variable(0, Integer), Pointer, ) + Call id(1), args( Pointer, ) + Variable(0, Integer) = Call id(2), args( ) + Call id(3), args( Variable(0, Integer), Tag(0, 3), ) Return"#]], ); } @@ -1269,10 +1290,11 @@ fn call_to_intrinsic_operation_that_returns_double_value_should_produce_variable op1_callable_id, &expect![[r#" Callable: - name: Op1 + name: __quantum__rt__initialize call_type: Regular - input_type: - output_type: Double + input_type: + [0]: Pointer + output_type: body: "#]], ); assert_block_instructions( @@ -1280,8 +1302,9 @@ fn call_to_intrinsic_operation_that_returns_double_value_should_produce_variable BlockId(0), &expect![[r#" Block: - Variable(0, Double) = Call id(1), args( ) - Call id(2), args( Variable(0, Double), Pointer, ) + Call id(1), args( Pointer, ) + Variable(0, Double) = Call id(2), args( ) + Call id(3), args( Variable(0, Double), Tag(0, 3), ) Return"#]], ); } diff --git a/source/compiler/qsc_partial_eval/src/tests/loops.rs b/source/compiler/qsc_partial_eval/src/tests/loops.rs index ef2d9852a5..61039b78a7 100644 --- a/source/compiler/qsc_partial_eval/src/tests/loops.rs +++ b/source/compiler/qsc_partial_eval/src/tests/loops.rs @@ -28,27 +28,28 @@ fn unitary_call_within_a_for_loop() { &program, op_callable_id, &expect![[r#" - Callable: - name: op - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: + Call id(1), args( Pointer, ) Variable(0, Integer) = Store Integer(1) - Call id(1), args( Qubit(0), ) + Call id(2), args( Qubit(0), ) Variable(0, Integer) = Store Integer(2) - Call id(1), args( Qubit(0), ) + Call id(2), args( Qubit(0), ) Variable(0, Integer) = Store Integer(3) - Call id(1), args( Qubit(0), ) + Call id(2), args( Qubit(0), ) Variable(0, Integer) = Store Integer(4) - Call id(2), args( Integer(0), Pointer, ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -77,27 +78,28 @@ fn unitary_call_within_a_while_loop() { &program, rotation_callable_id, &expect![[r#" - Callable: - name: op - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: + Call id(1), args( Pointer, ) Variable(0, Integer) = Store Integer(0) - Call id(1), args( Qubit(0), ) + Call id(2), args( Qubit(0), ) Variable(0, Integer) = Store Integer(1) - Call id(1), args( Qubit(0), ) + Call id(2), args( Qubit(0), ) Variable(0, Integer) = Store Integer(2) - Call id(1), args( Qubit(0), ) + Call id(2), args( Qubit(0), ) Variable(0, Integer) = Store Integer(3) - Call id(2), args( Integer(0), Pointer, ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -126,31 +128,32 @@ fn unitary_call_within_a_repeat_until_loop() { &program, op_callable_id, &expect![[r#" - Callable: - name: op - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: + Call id(1), args( Pointer, ) Variable(0, Integer) = Store Integer(0) Variable(1, Boolean) = Store Bool(true) - Call id(1), args( Qubit(0), ) + Call id(2), args( Qubit(0), ) Variable(0, Integer) = Store Integer(1) Variable(1, Boolean) = Store Bool(true) - Call id(1), args( Qubit(0), ) + Call id(2), args( Qubit(0), ) Variable(0, Integer) = Store Integer(2) Variable(1, Boolean) = Store Bool(true) - Call id(1), args( Qubit(0), ) + Call id(2), args( Qubit(0), ) Variable(0, Integer) = Store Integer(3) Variable(1, Boolean) = Store Bool(false) - Call id(2), args( Integer(0), Pointer, ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -177,28 +180,28 @@ fn rotation_call_within_a_for_loop() { &program, rotation_callable_id, &expect![[r#" - Callable: - name: rotation - call_type: Regular - input_type: - [0]: Double - [1]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: + Call id(1), args( Pointer, ) Variable(0, Integer) = Store Integer(0) - Call id(1), args( Double(0), Qubit(0), ) + Call id(2), args( Double(0), Qubit(0), ) Variable(0, Integer) = Store Integer(1) - Call id(1), args( Double(1), Qubit(0), ) + Call id(2), args( Double(1), Qubit(0), ) Variable(0, Integer) = Store Integer(2) - Call id(1), args( Double(2), Qubit(0), ) + Call id(2), args( Double(2), Qubit(0), ) Variable(0, Integer) = Store Integer(3) - Call id(2), args( Integer(0), Pointer, ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -228,28 +231,28 @@ fn rotation_call_within_a_while_loop() { &program, op_callable_id, &expect![[r#" - Callable: - name: rotation - call_type: Regular - input_type: - [0]: Double - [1]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: + Call id(1), args( Pointer, ) Variable(0, Integer) = Store Integer(0) - Call id(1), args( Double(0), Qubit(0), ) + Call id(2), args( Double(0), Qubit(0), ) Variable(0, Integer) = Store Integer(1) - Call id(1), args( Double(1), Qubit(0), ) + Call id(2), args( Double(1), Qubit(0), ) Variable(0, Integer) = Store Integer(2) - Call id(1), args( Double(2), Qubit(0), ) + Call id(2), args( Double(2), Qubit(0), ) Variable(0, Integer) = Store Integer(3) - Call id(2), args( Integer(0), Pointer, ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -279,32 +282,32 @@ fn rotation_call_within_a_repeat_until_loop() { &program, rotation_callable_id, &expect![[r#" - Callable: - name: rotation - call_type: Regular - input_type: - [0]: Double - [1]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: + Call id(1), args( Pointer, ) Variable(0, Integer) = Store Integer(0) Variable(1, Boolean) = Store Bool(true) - Call id(1), args( Double(0), Qubit(0), ) + Call id(2), args( Double(0), Qubit(0), ) Variable(0, Integer) = Store Integer(1) Variable(1, Boolean) = Store Bool(true) - Call id(1), args( Double(1), Qubit(0), ) + Call id(2), args( Double(1), Qubit(0), ) Variable(0, Integer) = Store Integer(2) Variable(1, Boolean) = Store Bool(true) - Call id(1), args( Double(2), Qubit(0), ) + Call id(2), args( Double(2), Qubit(0), ) Variable(0, Integer) = Store Integer(3) Variable(1, Boolean) = Store Bool(false) - Call id(2), args( Integer(0), Pointer, ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -333,10 +336,11 @@ fn mutable_bool_updated_in_loop() { BlockId(0), &expect![[r#" Block: + Call id(1), args( Pointer, ) Variable(0, Boolean) = Store Bool(false) Variable(1, Integer) = Store Integer(1) - Call id(1), args( Qubit(0), Result(0), ) - Variable(2, Boolean) = Call id(2), args( Result(0), ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(2, Boolean) = Call id(3), args( Result(0), ) Variable(3, Boolean) = Store Variable(2, Boolean) Variable(0, Boolean) = Store Variable(3, Boolean) Variable(1, Integer) = Store Integer(2) @@ -369,10 +373,11 @@ fn mutable_int_updated_in_loop() { BlockId(0), &expect![[r#" Block: + Call id(1), args( Pointer, ) Variable(0, Integer) = Store Integer(1) Variable(1, Integer) = Store Integer(1) - Call id(1), args( Qubit(0), Result(0), ) - Variable(2, Boolean) = Call id(2), args( Result(0), ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(2, Boolean) = Call id(3), args( Result(0), ) Variable(3, Boolean) = Store Variable(2, Boolean) Branch Variable(3, Boolean), 2, 1"#]], ); @@ -403,10 +408,11 @@ fn mutable_double_updated_in_loop() { &expect![[r#" Blocks: Block 0:Block: + Call id(1), args( Pointer, ) Variable(0, Double) = Store Double(1.1) Variable(1, Integer) = Store Integer(1) - Call id(1), args( Qubit(0), Result(0), ) - Variable(2, Boolean) = Call id(2), args( Result(0), ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(2, Boolean) = Call id(3), args( Result(0), ) Variable(3, Boolean) = Store Variable(2, Boolean) Branch Variable(3, Boolean), 2, 1 Block 1:Block: @@ -420,8 +426,8 @@ fn mutable_double_updated_in_loop() { Block 3:Block: Branch Variable(5, Boolean), 6, 5 Block 4:Block: - Call id(1), args( Qubit(0), Result(1), ) - Variable(6, Boolean) = Call id(2), args( Result(1), ) + Call id(2), args( Qubit(0), Result(1), ) + Variable(6, Boolean) = Call id(3), args( Result(1), ) Variable(7, Boolean) = Store Variable(6, Boolean) Variable(5, Boolean) = Store Variable(7, Boolean) Jump(3) @@ -437,14 +443,14 @@ fn mutable_double_updated_in_loop() { Block 7:Block: Branch Variable(10, Boolean), 10, 9 Block 8:Block: - Call id(1), args( Qubit(0), Result(2), ) - Variable(11, Boolean) = Call id(2), args( Result(2), ) + Call id(2), args( Qubit(0), Result(2), ) + Variable(11, Boolean) = Call id(3), args( Result(2), ) Variable(12, Boolean) = Store Variable(11, Boolean) Variable(10, Boolean) = Store Variable(12, Boolean) Jump(7) Block 9:Block: Variable(1, Integer) = Store Integer(4) - Call id(3), args( Integer(0), Pointer, ) + Call id(4), args( Integer(0), EmptyTag, ) Return Block 10:Block: Variable(13, Double) = Fmul Double(-1), Variable(0, Double) diff --git a/source/compiler/qsc_partial_eval/src/tests/misc.rs b/source/compiler/qsc_partial_eval/src/tests/misc.rs index b416e4ae2d..14645a1baf 100644 --- a/source/compiler/qsc_partial_eval/src/tests/misc.rs +++ b/source/compiler/qsc_partial_eval/src/tests/misc.rs @@ -35,30 +35,31 @@ fn unitary_call_within_an_if_with_classical_condition_within_a_for_loop() { &program, op_callable_id, &expect![[r#" - Callable: - name: op - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: + Call id(1), args( Pointer, ) Variable(0, Integer) = Store Integer(0) - Call id(1), args( Qubit(0), ) + Call id(2), args( Qubit(0), ) Variable(0, Integer) = Store Integer(1) Variable(0, Integer) = Store Integer(2) - Call id(1), args( Qubit(0), ) + Call id(2), args( Qubit(0), ) Variable(0, Integer) = Store Integer(3) Variable(0, Integer) = Store Integer(4) - Call id(1), args( Qubit(0), ) + Call id(2), args( Qubit(0), ) Variable(0, Integer) = Store Integer(5) Variable(0, Integer) = Store Integer(6) - Call id(2), args( Integer(0), Pointer, ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -89,30 +90,31 @@ fn unitary_call_within_an_if_with_classical_condition_within_a_while_loop() { &program, op_callable_id, &expect![[r#" - Callable: - name: op - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: + Call id(1), args( Pointer, ) Variable(0, Integer) = Store Integer(0) - Call id(1), args( Qubit(0), ) + Call id(2), args( Qubit(0), ) Variable(0, Integer) = Store Integer(1) Variable(0, Integer) = Store Integer(2) - Call id(1), args( Qubit(0), ) + Call id(2), args( Qubit(0), ) Variable(0, Integer) = Store Integer(3) Variable(0, Integer) = Store Integer(4) - Call id(1), args( Qubit(0), ) + Call id(2), args( Qubit(0), ) Variable(0, Integer) = Store Integer(5) Variable(0, Integer) = Store Integer(6) - Call id(2), args( Integer(0), Pointer, ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -143,37 +145,38 @@ fn unitary_call_within_an_if_with_classical_condition_within_a_repeat_until_loop &program, op_callable_id, &expect![[r#" - Callable: - name: op - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: + Call id(1), args( Pointer, ) Variable(0, Integer) = Store Integer(0) Variable(1, Boolean) = Store Bool(true) - Call id(1), args( Qubit(0), ) + Call id(2), args( Qubit(0), ) Variable(0, Integer) = Store Integer(1) Variable(1, Boolean) = Store Bool(true) Variable(0, Integer) = Store Integer(2) Variable(1, Boolean) = Store Bool(true) - Call id(1), args( Qubit(0), ) + Call id(2), args( Qubit(0), ) Variable(0, Integer) = Store Integer(3) Variable(1, Boolean) = Store Bool(true) Variable(0, Integer) = Store Integer(4) Variable(1, Boolean) = Store Bool(true) - Call id(1), args( Qubit(0), ) + Call id(2), args( Qubit(0), ) Variable(0, Integer) = Store Integer(5) Variable(1, Boolean) = Store Bool(true) Variable(0, Integer) = Store Integer(6) Variable(1, Boolean) = Store Bool(false) - Call id(2), args( Integer(0), Pointer, ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); } @@ -200,14 +203,15 @@ fn boolean_assign_and_update_with_classical_value_within_an_if_with_dynamic_cond &expect![[r#" Blocks: Block 0:Block: + Call id(1), args( Pointer, ) Variable(0, Boolean) = Store Bool(true) - Call id(1), args( Qubit(0), Result(0), ) - Variable(1, Boolean) = Call id(2), args( Result(0), ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(1, Boolean) = Call id(3), args( Result(0), ) Variable(2, Boolean) = Store Variable(1, Boolean) Branch Variable(2, Boolean), 2, 1 Block 1:Block: Variable(3, Boolean) = Store Variable(0, Boolean) - Call id(3), args( Variable(3, Boolean), Pointer, ) + Call id(4), args( Variable(3, Boolean), Tag(0, 3), ) Return Block 2:Block: Variable(0, Boolean) = Store Bool(false) @@ -237,14 +241,15 @@ fn integer_assign_and_update_with_classical_value_within_an_if_with_dynamic_cond &expect![[r#" Blocks: Block 0:Block: + Call id(1), args( Pointer, ) Variable(0, Integer) = Store Integer(1) - Call id(1), args( Qubit(0), Result(0), ) - Variable(1, Boolean) = Call id(2), args( Result(0), ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(1, Boolean) = Call id(3), args( Result(0), ) Variable(2, Boolean) = Store Variable(1, Boolean) Branch Variable(2, Boolean), 2, 1 Block 1:Block: Variable(3, Integer) = Store Variable(0, Integer) - Call id(3), args( Variable(3, Integer), Pointer, ) + Call id(4), args( Variable(3, Integer), Tag(0, 3), ) Return Block 2:Block: Variable(0, Integer) = Store Integer(5) @@ -277,11 +282,10 @@ fn integer_assign_with_hybrid_value_within_an_if_with_dynamic_condition() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -290,13 +294,14 @@ fn integer_assign_with_hybrid_value_within_an_if_with_dynamic_condition() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -304,12 +309,11 @@ fn integer_assign_with_hybrid_value_within_an_if_with_dynamic_condition() { output_record_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -317,16 +321,17 @@ fn integer_assign_with_hybrid_value_within_an_if_with_dynamic_condition() { &expect![[r#" Blocks: Block 0:Block: + Call id(1), args( Pointer, ) Variable(0, Integer) = Store Integer(0) Variable(1, Integer) = Store Integer(0) - Call id(1), args( Qubit(0), Result(0), ) - Variable(2, Boolean) = Call id(2), args( Result(0), ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(2, Boolean) = Call id(3), args( Result(0), ) Variable(3, Boolean) = Store Variable(2, Boolean) Branch Variable(3, Boolean), 2, 1 Block 1:Block: Variable(1, Integer) = Store Integer(1) - Call id(1), args( Qubit(0), Result(1), ) - Variable(4, Boolean) = Call id(2), args( Result(1), ) + Call id(2), args( Qubit(0), Result(1), ) + Variable(4, Boolean) = Call id(3), args( Result(1), ) Variable(5, Boolean) = Store Variable(4, Boolean) Branch Variable(5, Boolean), 4, 3 Block 2:Block: @@ -335,7 +340,7 @@ fn integer_assign_with_hybrid_value_within_an_if_with_dynamic_condition() { Block 3:Block: Variable(1, Integer) = Store Integer(2) Variable(7, Integer) = Store Variable(0, Integer) - Call id(3), args( Variable(7, Integer), Pointer, ) + Call id(4), args( Variable(7, Integer), Tag(0, 3), ) Return Block 4:Block: Variable(6, Integer) = BitwiseOr Variable(0, Integer), Integer(2) @@ -376,7 +381,7 @@ fn large_loop_with_inner_if_completes_eval_and_transform() { Block: Variable(1, Integer) = Store Integer(100) Variable(400, Integer) = Store Variable(0, Integer) - Call id(3), args( Variable(400, Integer), Pointer, ) + Call id(4), args( Variable(400, Integer), Tag(0, 3), ) Return"#]], ); } @@ -407,53 +412,53 @@ fn if_else_expression_with_dynamic_logical_and_condition() { &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let read_result_callable_id = CallableId(2); assert_callable( &program, read_result_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let op_a_callable_id = CallableId(3); assert_callable( &program, op_a_callable_id, &expect![[r#" - Callable: - name: opA - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); let op_b_callable_id = CallableId(4); assert_callable( &program, op_b_callable_id, &expect![[r#" - Callable: - name: opB - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: opA + call_type: Regular + input_type: + [0]: Qubit + output_type: + body: "#]], ); assert_blocks( @@ -461,27 +466,28 @@ fn if_else_expression_with_dynamic_logical_and_condition() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Store Variable(0, Boolean) Variable(2, Boolean) = Store Bool(false) Branch Variable(1, Boolean), 2, 1 Block 1:Block: Branch Variable(2, Boolean), 4, 5 Block 2:Block: - Call id(1), args( Qubit(1), Result(1), ) - Variable(3, Boolean) = Call id(2), args( Result(1), ) + Call id(2), args( Qubit(1), Result(1), ) + Variable(3, Boolean) = Call id(3), args( Result(1), ) Variable(4, Boolean) = Store Variable(3, Boolean) Variable(2, Boolean) = Store Variable(4, Boolean) Jump(1) Block 3:Block: - Call id(5), args( Integer(0), Pointer, ) + Call id(6), args( Integer(0), EmptyTag, ) Return Block 4:Block: - Call id(3), args( Qubit(2), ) + Call id(4), args( Qubit(2), ) Jump(3) Block 5:Block: - Call id(4), args( Qubit(2), ) + Call id(5), args( Qubit(2), ) Jump(3)"#]], ); } @@ -512,53 +518,53 @@ fn if_else_expression_with_dynamic_logical_or_condition() { &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let read_result_callable_id = CallableId(2); assert_callable( &program, read_result_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let op_a_callable_id = CallableId(3); assert_callable( &program, op_a_callable_id, &expect![[r#" - Callable: - name: opA - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); let op_b_callable_id = CallableId(4); assert_callable( &program, op_b_callable_id, &expect![[r#" - Callable: - name: opB - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: opA + call_type: Regular + input_type: + [0]: Qubit + output_type: + body: "#]], ); assert_blocks( @@ -566,27 +572,28 @@ fn if_else_expression_with_dynamic_logical_or_condition() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Store Variable(0, Boolean) Variable(2, Boolean) = Store Bool(true) Branch Variable(1, Boolean), 1, 2 Block 1:Block: Branch Variable(2, Boolean), 4, 5 Block 2:Block: - Call id(1), args( Qubit(1), Result(1), ) - Variable(3, Boolean) = Call id(2), args( Result(1), ) + Call id(2), args( Qubit(1), Result(1), ) + Variable(3, Boolean) = Call id(3), args( Result(1), ) Variable(4, Boolean) = Store Variable(3, Boolean) Variable(2, Boolean) = Store Variable(4, Boolean) Jump(1) Block 3:Block: - Call id(5), args( Integer(0), Pointer, ) + Call id(6), args( Integer(0), EmptyTag, ) Return Block 4:Block: - Call id(3), args( Qubit(2), ) + Call id(4), args( Qubit(2), ) Jump(3) Block 5:Block: - Call id(4), args( Qubit(2), ) + Call id(5), args( Qubit(2), ) Jump(3)"#]], ); } diff --git a/source/compiler/qsc_partial_eval/src/tests/operators.rs b/source/compiler/qsc_partial_eval/src/tests/operators.rs index 5608ce8e42..5e733ebb5b 100644 --- a/source/compiler/qsc_partial_eval/src/tests/operators.rs +++ b/source/compiler/qsc_partial_eval/src/tests/operators.rs @@ -26,27 +26,27 @@ fn leading_positive_unary_operator_on_integer_does_not_generate_rir_instruction( &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let readout_callable_id = CallableId(2); assert_callable( &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_recording_callable_id = CallableId(3); assert_callable( @@ -54,12 +54,11 @@ fn leading_positive_unary_operator_on_integer_does_not_generate_rir_instruction( output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -67,14 +66,15 @@ fn leading_positive_unary_operator_on_integer_does_not_generate_rir_instruction( &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Integer) = Store Variable(2, Integer) Variable(4, Integer) = Store Variable(3, Integer) - Call id(3), args( Variable(4, Integer), Pointer, ) + Call id(4), args( Variable(4, Integer), Tag(0, 3), ) Return Block 2:Block: Variable(2, Integer) = Store Integer(0) @@ -102,27 +102,27 @@ fn leading_negative_unary_operator_on_integer_generates_rir_instruction() { &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let readout_callable_id = CallableId(2); assert_callable( &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_recording_callable_id = CallableId(3); assert_callable( @@ -130,12 +130,11 @@ fn leading_negative_unary_operator_on_integer_generates_rir_instruction() { output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -143,15 +142,16 @@ fn leading_negative_unary_operator_on_integer_generates_rir_instruction() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Integer) = Store Variable(2, Integer) Variable(4, Integer) = Mul Integer(-1), Variable(3, Integer) Variable(5, Integer) = Store Variable(4, Integer) - Call id(3), args( Variable(5, Integer), Pointer, ) + Call id(4), args( Variable(5, Integer), Tag(0, 3), ) Return Block 2:Block: Variable(2, Integer) = Store Integer(0) @@ -179,27 +179,27 @@ fn bitwise_not_unary_operator_generates_rir_instruction() { &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let readout_callable_id = CallableId(2); assert_callable( &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_recording_callable_id = CallableId(3); assert_callable( @@ -207,12 +207,11 @@ fn bitwise_not_unary_operator_generates_rir_instruction() { output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -220,15 +219,16 @@ fn bitwise_not_unary_operator_generates_rir_instruction() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Integer) = Store Variable(2, Integer) Variable(4, Integer) = BitwiseNot Variable(3, Integer) Variable(5, Integer) = Store Variable(4, Integer) - Call id(3), args( Variable(5, Integer), Pointer, ) + Call id(4), args( Variable(5, Integer), Tag(0, 3), ) Return Block 2:Block: Variable(2, Integer) = Store Integer(0) @@ -256,27 +256,27 @@ fn logical_not_unary_operator_generates_logical_not_rir_instruction() { &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let readout_callable_id = CallableId(2); assert_callable( &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_recording_callable_id = CallableId(3); assert_callable( @@ -284,12 +284,11 @@ fn logical_not_unary_operator_generates_logical_not_rir_instruction() { output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Boolean - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_block_instructions( @@ -297,13 +296,14 @@ fn logical_not_unary_operator_generates_logical_not_rir_instruction() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Variable(2, Boolean) = Store Variable(1, Boolean) Variable(3, Boolean) = LogicalNot Variable(2, Boolean) Variable(4, Boolean) = Store Variable(3, Boolean) - Call id(3), args( Variable(4, Boolean), Pointer, ) + Call id(4), args( Variable(4, Boolean), Tag(0, 3), ) Return"#]], ); } @@ -329,11 +329,10 @@ fn comparing_measurement_results_for_equality_adds_read_result_and_comparison_in measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -342,40 +341,41 @@ fn comparing_measurement_results_for_equality_adds_read_result_and_comparison_in &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let bool_record_id = CallableId(3); assert_callable( &program, bool_record_id, &expect![[r#" - Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording - input_type: - [0]: Boolean - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(1), args( Qubit(1), Result(1), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) - Variable(1, Boolean) = Call id(2), args( Result(1), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(2), args( Qubit(1), Result(1), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) + Variable(1, Boolean) = Call id(3), args( Result(1), ) Variable(2, Boolean) = Icmp Eq, Variable(0, Boolean), Variable(1, Boolean) Variable(3, Boolean) = Store Variable(2, Boolean) - Call id(3), args( Variable(3, Boolean), Pointer, ) + Call id(4), args( Variable(3, Boolean), Tag(0, 3), ) Return"#]], ); assert_eq!(program.num_qubits, 2); @@ -402,54 +402,54 @@ fn comparing_measurement_results_for_inequality_adds_read_result_and_comparison_ &program, measurement_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let readout_callable_id = CallableId(2); assert_callable( &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let bool_record_id = CallableId(3); assert_callable( &program, bool_record_id, &expect![[r#" - Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording - input_type: - [0]: Boolean - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(1), args( Qubit(1), Result(1), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) - Variable(1, Boolean) = Call id(2), args( Result(1), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(2), args( Qubit(1), Result(1), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) + Variable(1, Boolean) = Call id(3), args( Result(1), ) Variable(2, Boolean) = Icmp Ne, Variable(0, Boolean), Variable(1, Boolean) Variable(3, Boolean) = Store Variable(2, Boolean) - Call id(3), args( Variable(3, Boolean), Pointer, ) + Call id(4), args( Variable(3, Boolean), Tag(0, 3), ) Return"#]], ); assert_eq!(program.num_qubits, 2); @@ -476,52 +476,52 @@ fn comparing_measurement_result_against_result_literal_for_equality_adds_read_re &program, measurement_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let readout_callable_id = CallableId(2); assert_callable( &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let bool_record_id = CallableId(3); assert_callable( &program, bool_record_id, &expect![[r#" - Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording - input_type: - [0]: Boolean - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Variable(2, Boolean) = Store Variable(1, Boolean) - Call id(3), args( Variable(2, Boolean), Pointer, ) + Call id(4), args( Variable(2, Boolean), Tag(0, 3), ) Return"#]], ); assert_eq!(program.num_qubits, 1); @@ -548,52 +548,52 @@ fn comparing_measurement_result_against_result_literal_for_inequality_adds_read_ &program, measurement_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let readout_callable_id = CallableId(2); assert_callable( &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let bool_record_id = CallableId(3); assert_callable( &program, bool_record_id, &expect![[r#" - Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording - input_type: - [0]: Boolean - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Ne, Variable(0, Boolean), Bool(true) Variable(2, Boolean) = Store Variable(1, Boolean) - Call id(3), args( Variable(2, Boolean), Pointer, ) + Call id(4), args( Variable(2, Boolean), Tag(0, 3), ) Return"#]], ); assert_eq!(program.num_qubits, 1); @@ -620,11 +620,10 @@ fn comparing_lhs_classical_boolean_against_rhs_dynamic_boolean_for_equality() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -633,40 +632,41 @@ fn comparing_lhs_classical_boolean_against_rhs_dynamic_boolean_for_equality() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( &program, output_record_id, &expect![[r#" - Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording - input_type: - [0]: Boolean - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Store Variable(0, Boolean) Variable(2, Boolean) = Store Variable(1, Boolean) Variable(3, Boolean) = Icmp Eq, Bool(false), Variable(2, Boolean) Variable(4, Boolean) = Store Variable(3, Boolean) - Call id(3), args( Variable(4, Boolean), Pointer, ) + Call id(4), args( Variable(4, Boolean), Tag(0, 3), ) Return"#]], ); } @@ -690,11 +690,10 @@ fn comparing_lhs_dynamic_boolean_against_rhs_dynamic_boolean_for_equality() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -703,42 +702,43 @@ fn comparing_lhs_dynamic_boolean_against_rhs_dynamic_boolean_for_equality() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( &program, output_record_id, &expect![[r#" - Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording - input_type: - [0]: Boolean - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) - Call id(1), args( Qubit(0), Result(1), ) - Variable(2, Boolean) = Call id(2), args( Result(1), ) + Call id(2), args( Qubit(0), Result(1), ) + Variable(2, Boolean) = Call id(3), args( Result(1), ) Variable(3, Boolean) = Icmp Eq, Variable(2, Boolean), Bool(false) Variable(4, Boolean) = Icmp Eq, Variable(1, Boolean), Variable(3, Boolean) Variable(5, Boolean) = Store Variable(4, Boolean) - Call id(3), args( Variable(5, Boolean), Pointer, ) + Call id(4), args( Variable(5, Boolean), Tag(0, 3), ) Return"#]], ); } @@ -763,11 +763,10 @@ fn comparing_lhs_classical_boolean_against_rhs_dynamic_boolean_for_inequality() measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -776,40 +775,41 @@ fn comparing_lhs_classical_boolean_against_rhs_dynamic_boolean_for_inequality() &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( &program, output_record_id, &expect![[r#" - Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording - input_type: - [0]: Boolean - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Store Variable(0, Boolean) Variable(2, Boolean) = Store Variable(1, Boolean) Variable(3, Boolean) = Icmp Ne, Bool(true), Variable(2, Boolean) Variable(4, Boolean) = Store Variable(3, Boolean) - Call id(3), args( Variable(4, Boolean), Pointer, ) + Call id(4), args( Variable(4, Boolean), Tag(0, 3), ) Return"#]], ); } @@ -833,11 +833,10 @@ fn comparing_lhs_dynamic_boolean_against_rhs_dynamic_boolean_for_inequality() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -846,42 +845,43 @@ fn comparing_lhs_dynamic_boolean_against_rhs_dynamic_boolean_for_inequality() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( &program, output_record_id, &expect![[r#" - Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording - input_type: - [0]: Boolean - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) - Call id(1), args( Qubit(0), Result(1), ) - Variable(2, Boolean) = Call id(2), args( Result(1), ) + Call id(2), args( Qubit(0), Result(1), ) + Variable(2, Boolean) = Call id(3), args( Result(1), ) Variable(3, Boolean) = Icmp Eq, Variable(2, Boolean), Bool(false) Variable(4, Boolean) = Icmp Ne, Variable(1, Boolean), Variable(3, Boolean) Variable(5, Boolean) = Store Variable(4, Boolean) - Call id(3), args( Variable(5, Boolean), Pointer, ) + Call id(4), args( Variable(5, Boolean), Tag(0, 3), ) Return"#]], ); } @@ -906,11 +906,10 @@ fn logical_and_with_lhs_classical_true_is_optimized_as_store() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -919,39 +918,40 @@ fn logical_and_with_lhs_classical_true_is_optimized_as_store() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( &program, output_record_id, &expect![[r#" - Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording - input_type: - [0]: Boolean - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Store Variable(0, Boolean) Variable(2, Boolean) = Store Variable(1, Boolean) Variable(3, Boolean) = Store Variable(2, Boolean) - Call id(3), args( Variable(3, Boolean), Pointer, ) + Call id(4), args( Variable(3, Boolean), Tag(0, 3), ) Return"#]], ); } @@ -976,11 +976,10 @@ fn logical_and_with_lhs_classical_false_short_circuits_evaluation() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -989,38 +988,39 @@ fn logical_and_with_lhs_classical_false_short_circuits_evaluation() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( &program, output_record_id, &expect![[r#" - Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording - input_type: - [0]: Boolean - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Store Variable(0, Boolean) Variable(2, Boolean) = Store Variable(1, Boolean) - Call id(3), args( Bool(false), Pointer, ) + Call id(4), args( Bool(false), Tag(0, 3), ) Return"#]], ); } @@ -1044,11 +1044,10 @@ fn logical_and_with_dynamic_lhs_and_dynamic_rhs_short_circuits_when_lhs_is_false measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -1057,45 +1056,46 @@ fn logical_and_with_dynamic_lhs_and_dynamic_rhs_short_circuits_when_lhs_is_false &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( &program, output_record_id, &expect![[r#" - Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording - input_type: - [0]: Boolean - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); assert_blocks( &program, &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Variable(2, Boolean) = Store Bool(false) Branch Variable(1, Boolean), 2, 1 Block 1:Block: Variable(5, Boolean) = Store Variable(2, Boolean) - Call id(3), args( Variable(5, Boolean), Pointer, ) + Call id(4), args( Variable(5, Boolean), Tag(0, 3), ) Return Block 2:Block: - Call id(1), args( Qubit(0), Result(1), ) - Variable(3, Boolean) = Call id(2), args( Result(1), ) + Call id(2), args( Qubit(0), Result(1), ) + Variable(3, Boolean) = Call id(3), args( Result(1), ) Variable(4, Boolean) = Icmp Eq, Variable(3, Boolean), Bool(false) Variable(2, Boolean) = Store Variable(4, Boolean) Jump(1)"#]], @@ -1122,11 +1122,10 @@ fn logical_or_with_lhs_classical_true_short_circuits_evaluation() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -1135,38 +1134,39 @@ fn logical_or_with_lhs_classical_true_short_circuits_evaluation() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( &program, output_record_id, &expect![[r#" - Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording - input_type: - [0]: Boolean - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Store Variable(0, Boolean) Variable(2, Boolean) = Store Variable(1, Boolean) - Call id(3), args( Bool(true), Pointer, ) + Call id(4), args( Bool(true), Tag(0, 3), ) Return"#]], ); } @@ -1191,11 +1191,10 @@ fn logical_or_with_lhs_classical_false_is_optimized_as_store() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -1204,39 +1203,40 @@ fn logical_or_with_lhs_classical_false_is_optimized_as_store() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( &program, output_record_id, &expect![[r#" - Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording - input_type: - [0]: Boolean - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Store Variable(0, Boolean) Variable(2, Boolean) = Store Variable(1, Boolean) Variable(3, Boolean) = Store Variable(2, Boolean) - Call id(3), args( Variable(3, Boolean), Pointer, ) + Call id(4), args( Variable(3, Boolean), Tag(0, 3), ) Return"#]], ); } @@ -1260,11 +1260,10 @@ fn logical_or_with_dynamic_lhs_and_dynamic_rhs_short_circuits_when_rhs_is_true() measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -1273,45 +1272,46 @@ fn logical_or_with_dynamic_lhs_and_dynamic_rhs_short_circuits_when_rhs_is_true() &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( &program, output_record_id, &expect![[r#" - Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording - input_type: - [0]: Boolean - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); assert_blocks( &program, &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Ne, Variable(0, Boolean), Bool(true) Variable(2, Boolean) = Store Bool(true) Branch Variable(1, Boolean), 1, 2 Block 1:Block: Variable(5, Boolean) = Store Variable(2, Boolean) - Call id(3), args( Variable(5, Boolean), Pointer, ) + Call id(4), args( Variable(5, Boolean), Tag(0, 3), ) Return Block 2:Block: - Call id(1), args( Qubit(0), Result(1), ) - Variable(3, Boolean) = Call id(2), args( Result(1), ) + Call id(2), args( Qubit(0), Result(1), ) + Variable(3, Boolean) = Call id(3), args( Result(1), ) Variable(4, Boolean) = Icmp Ne, Variable(3, Boolean), Bool(true) Variable(2, Boolean) = Store Variable(4, Boolean) Jump(1)"#]], @@ -1337,11 +1337,10 @@ fn logical_and_and_sequence_with_dynamic_operands() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -1350,35 +1349,36 @@ fn logical_and_and_sequence_with_dynamic_operands() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( &program, output_record_id, &expect![[r#" - Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording - input_type: - [0]: Boolean - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); assert_blocks( &program, &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Ne, Variable(0, Boolean), Bool(true) Variable(2, Boolean) = Store Bool(false) Branch Variable(1, Boolean), 2, 1 @@ -1386,18 +1386,18 @@ fn logical_and_and_sequence_with_dynamic_operands() { Variable(5, Boolean) = Store Bool(false) Branch Variable(2, Boolean), 4, 3 Block 2:Block: - Call id(1), args( Qubit(1), Result(1), ) - Variable(3, Boolean) = Call id(2), args( Result(1), ) + Call id(2), args( Qubit(1), Result(1), ) + Variable(3, Boolean) = Call id(3), args( Result(1), ) Variable(4, Boolean) = Icmp Ne, Variable(3, Boolean), Bool(true) Variable(2, Boolean) = Store Variable(4, Boolean) Jump(1) Block 3:Block: Variable(8, Boolean) = Store Variable(5, Boolean) - Call id(3), args( Variable(8, Boolean), Pointer, ) + Call id(4), args( Variable(8, Boolean), Tag(0, 3), ) Return Block 4:Block: - Call id(1), args( Qubit(2), Result(2), ) - Variable(6, Boolean) = Call id(2), args( Result(2), ) + Call id(2), args( Qubit(2), Result(2), ) + Variable(6, Boolean) = Call id(3), args( Result(2), ) Variable(7, Boolean) = Icmp Ne, Variable(6, Boolean), Bool(true) Variable(5, Boolean) = Store Variable(7, Boolean) Jump(3)"#]], @@ -1423,11 +1423,10 @@ fn logical_and_or_sequence_with_dynamic_operands() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -1436,35 +1435,36 @@ fn logical_and_or_sequence_with_dynamic_operands() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( &program, output_record_id, &expect![[r#" - Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording - input_type: - [0]: Boolean - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); assert_blocks( &program, &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Ne, Variable(0, Boolean), Bool(true) Variable(2, Boolean) = Store Bool(false) Branch Variable(1, Boolean), 2, 1 @@ -1472,18 +1472,18 @@ fn logical_and_or_sequence_with_dynamic_operands() { Variable(5, Boolean) = Store Bool(true) Branch Variable(2, Boolean), 3, 4 Block 2:Block: - Call id(1), args( Qubit(1), Result(1), ) - Variable(3, Boolean) = Call id(2), args( Result(1), ) + Call id(2), args( Qubit(1), Result(1), ) + Variable(3, Boolean) = Call id(3), args( Result(1), ) Variable(4, Boolean) = Icmp Ne, Variable(3, Boolean), Bool(true) Variable(2, Boolean) = Store Variable(4, Boolean) Jump(1) Block 3:Block: Variable(8, Boolean) = Store Variable(5, Boolean) - Call id(3), args( Variable(8, Boolean), Pointer, ) + Call id(4), args( Variable(8, Boolean), Tag(0, 3), ) Return Block 4:Block: - Call id(1), args( Qubit(2), Result(2), ) - Variable(6, Boolean) = Call id(2), args( Result(2), ) + Call id(2), args( Qubit(2), Result(2), ) + Variable(6, Boolean) = Call id(3), args( Result(2), ) Variable(7, Boolean) = Icmp Ne, Variable(6, Boolean), Bool(true) Variable(5, Boolean) = Store Variable(7, Boolean) Jump(3)"#]], @@ -1509,11 +1509,10 @@ fn logical_or_and_sequence_with_dynamic_operands() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -1522,45 +1521,46 @@ fn logical_or_and_sequence_with_dynamic_operands() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( &program, output_record_id, &expect![[r#" - Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording - input_type: - [0]: Boolean - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); assert_blocks( &program, &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Ne, Variable(0, Boolean), Bool(true) Variable(2, Boolean) = Store Bool(true) Branch Variable(1, Boolean), 1, 2 Block 1:Block: Variable(8, Boolean) = Store Variable(2, Boolean) - Call id(3), args( Variable(8, Boolean), Pointer, ) + Call id(4), args( Variable(8, Boolean), Tag(0, 3), ) Return Block 2:Block: - Call id(1), args( Qubit(1), Result(1), ) - Variable(3, Boolean) = Call id(2), args( Result(1), ) + Call id(2), args( Qubit(1), Result(1), ) + Variable(3, Boolean) = Call id(3), args( Result(1), ) Variable(4, Boolean) = Icmp Ne, Variable(3, Boolean), Bool(true) Variable(5, Boolean) = Store Bool(false) Branch Variable(4, Boolean), 4, 3 @@ -1568,8 +1568,8 @@ fn logical_or_and_sequence_with_dynamic_operands() { Variable(2, Boolean) = Store Variable(5, Boolean) Jump(1) Block 4:Block: - Call id(1), args( Qubit(2), Result(2), ) - Variable(6, Boolean) = Call id(2), args( Result(2), ) + Call id(2), args( Qubit(2), Result(2), ) + Variable(6, Boolean) = Call id(3), args( Result(2), ) Variable(7, Boolean) = Icmp Ne, Variable(6, Boolean), Bool(true) Variable(5, Boolean) = Store Variable(7, Boolean) Jump(3)"#]], @@ -1595,11 +1595,10 @@ fn logical_or_or_sequence_with_dynamic_operands() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -1608,35 +1607,36 @@ fn logical_or_or_sequence_with_dynamic_operands() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( &program, output_record_id, &expect![[r#" - Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording - input_type: - [0]: Boolean - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); assert_blocks( &program, &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Ne, Variable(0, Boolean), Bool(true) Variable(2, Boolean) = Store Bool(true) Branch Variable(1, Boolean), 1, 2 @@ -1644,18 +1644,18 @@ fn logical_or_or_sequence_with_dynamic_operands() { Variable(5, Boolean) = Store Bool(true) Branch Variable(2, Boolean), 3, 4 Block 2:Block: - Call id(1), args( Qubit(1), Result(1), ) - Variable(3, Boolean) = Call id(2), args( Result(1), ) + Call id(2), args( Qubit(1), Result(1), ) + Variable(3, Boolean) = Call id(3), args( Result(1), ) Variable(4, Boolean) = Icmp Ne, Variable(3, Boolean), Bool(true) Variable(2, Boolean) = Store Variable(4, Boolean) Jump(1) Block 3:Block: Variable(8, Boolean) = Store Variable(5, Boolean) - Call id(3), args( Variable(8, Boolean), Pointer, ) + Call id(4), args( Variable(8, Boolean), Tag(0, 3), ) Return Block 4:Block: - Call id(1), args( Qubit(2), Result(2), ) - Variable(6, Boolean) = Call id(2), args( Result(2), ) + Call id(2), args( Qubit(2), Result(2), ) + Variable(6, Boolean) = Call id(3), args( Result(2), ) Variable(7, Boolean) = Icmp Ne, Variable(6, Boolean), Bool(true) Variable(5, Boolean) = Store Variable(7, Boolean) Jump(3)"#]], @@ -1682,11 +1682,10 @@ fn integer_add_with_lhs_classical_integer_and_rhs_dynamic_integer() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -1695,13 +1694,14 @@ fn integer_add_with_lhs_classical_integer_and_rhs_dynamic_integer() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -1709,12 +1709,11 @@ fn integer_add_with_lhs_classical_integer_and_rhs_dynamic_integer() { output_record_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -1722,15 +1721,16 @@ fn integer_add_with_lhs_classical_integer_and_rhs_dynamic_integer() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Integer) = Store Variable(2, Integer) Variable(4, Integer) = Add Integer(1), Variable(3, Integer) Variable(5, Integer) = Store Variable(4, Integer) - Call id(3), args( Variable(5, Integer), Pointer, ) + Call id(4), args( Variable(5, Integer), Tag(0, 3), ) Return Block 2:Block: Variable(2, Integer) = Store Integer(0) @@ -1761,11 +1761,10 @@ fn integer_sub_with_lhs_dynamic_integer_and_rhs_classical_integer() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -1774,13 +1773,14 @@ fn integer_sub_with_lhs_dynamic_integer_and_rhs_classical_integer() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -1788,12 +1788,11 @@ fn integer_sub_with_lhs_dynamic_integer_and_rhs_classical_integer() { output_record_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -1801,15 +1800,16 @@ fn integer_sub_with_lhs_dynamic_integer_and_rhs_classical_integer() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Integer) = Store Variable(2, Integer) Variable(4, Integer) = Sub Variable(3, Integer), Integer(1) Variable(5, Integer) = Store Variable(4, Integer) - Call id(3), args( Variable(5, Integer), Pointer, ) + Call id(4), args( Variable(5, Integer), Tag(0, 3), ) Return Block 2:Block: Variable(2, Integer) = Store Integer(0) @@ -1841,11 +1841,10 @@ fn integer_mul_with_lhs_dynamic_integer_and_rhs_dynamic_integer() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -1854,13 +1853,14 @@ fn integer_mul_with_lhs_dynamic_integer_and_rhs_dynamic_integer() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -1868,12 +1868,11 @@ fn integer_mul_with_lhs_dynamic_integer_and_rhs_dynamic_integer() { output_record_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -1881,14 +1880,15 @@ fn integer_mul_with_lhs_dynamic_integer_and_rhs_dynamic_integer() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Integer) = Store Variable(2, Integer) - Call id(1), args( Qubit(0), Result(1), ) - Variable(4, Boolean) = Call id(2), args( Result(1), ) + Call id(2), args( Qubit(0), Result(1), ) + Variable(4, Boolean) = Call id(3), args( Result(1), ) Variable(5, Boolean) = Icmp Eq, Variable(4, Boolean), Bool(false) Branch Variable(5, Boolean), 5, 6 Block 2:Block: @@ -1901,7 +1901,7 @@ fn integer_mul_with_lhs_dynamic_integer_and_rhs_dynamic_integer() { Variable(7, Integer) = Store Variable(6, Integer) Variable(8, Integer) = Mul Variable(3, Integer), Variable(7, Integer) Variable(9, Integer) = Store Variable(8, Integer) - Call id(3), args( Variable(9, Integer), Pointer, ) + Call id(4), args( Variable(9, Integer), Tag(0, 3), ) Return Block 5:Block: Variable(6, Integer) = Store Integer(1) @@ -1932,11 +1932,10 @@ fn integer_div_with_lhs_classical_integer_and_rhs_dynamic_integer() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -1945,13 +1944,14 @@ fn integer_div_with_lhs_classical_integer_and_rhs_dynamic_integer() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -1959,12 +1959,11 @@ fn integer_div_with_lhs_classical_integer_and_rhs_dynamic_integer() { output_record_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -1972,15 +1971,16 @@ fn integer_div_with_lhs_classical_integer_and_rhs_dynamic_integer() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Integer) = Store Variable(2, Integer) Variable(4, Integer) = Sdiv Integer(1), Variable(3, Integer) Variable(5, Integer) = Store Variable(4, Integer) - Call id(3), args( Variable(5, Integer), Pointer, ) + Call id(4), args( Variable(5, Integer), Tag(0, 3), ) Return Block 2:Block: Variable(2, Integer) = Store Integer(0) @@ -2033,11 +2033,10 @@ fn integer_mod_with_lhs_dynamic_integer_and_rhs_classical_integer() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -2046,13 +2045,14 @@ fn integer_mod_with_lhs_dynamic_integer_and_rhs_classical_integer() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -2060,12 +2060,11 @@ fn integer_mod_with_lhs_dynamic_integer_and_rhs_classical_integer() { output_record_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -2073,15 +2072,16 @@ fn integer_mod_with_lhs_dynamic_integer_and_rhs_classical_integer() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Integer) = Store Variable(2, Integer) Variable(4, Integer) = Srem Variable(3, Integer), Integer(1) Variable(5, Integer) = Store Variable(4, Integer) - Call id(3), args( Variable(5, Integer), Pointer, ) + Call id(4), args( Variable(5, Integer), Tag(0, 3), ) Return Block 2:Block: Variable(2, Integer) = Store Integer(0) @@ -2157,11 +2157,10 @@ fn integer_exponentiation_with_lhs_dynamic_integer_and_rhs_classical_zero_intege measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -2170,13 +2169,14 @@ fn integer_exponentiation_with_lhs_dynamic_integer_and_rhs_classical_zero_intege &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -2184,12 +2184,11 @@ fn integer_exponentiation_with_lhs_dynamic_integer_and_rhs_classical_zero_intege output_record_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -2197,15 +2196,16 @@ fn integer_exponentiation_with_lhs_dynamic_integer_and_rhs_classical_zero_intege &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Integer) = Store Variable(2, Integer) Variable(4, Integer) = Store Integer(1) Variable(5, Integer) = Store Variable(4, Integer) - Call id(3), args( Variable(5, Integer), Pointer, ) + Call id(4), args( Variable(5, Integer), Tag(0, 3), ) Return Block 2:Block: Variable(2, Integer) = Store Integer(0) @@ -2236,11 +2236,10 @@ fn integer_exponentiation_with_lhs_dynamic_integer_and_rhs_classical_positive_in measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -2249,13 +2248,14 @@ fn integer_exponentiation_with_lhs_dynamic_integer_and_rhs_classical_positive_in &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -2263,12 +2263,11 @@ fn integer_exponentiation_with_lhs_dynamic_integer_and_rhs_classical_positive_in output_record_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -2276,8 +2275,9 @@ fn integer_exponentiation_with_lhs_dynamic_integer_and_rhs_classical_positive_in &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: @@ -2287,7 +2287,7 @@ fn integer_exponentiation_with_lhs_dynamic_integer_and_rhs_classical_positive_in Variable(6, Integer) = Mul Variable(5, Integer), Variable(3, Integer) Variable(7, Integer) = Mul Variable(6, Integer), Variable(3, Integer) Variable(8, Integer) = Store Variable(7, Integer) - Call id(3), args( Variable(8, Integer), Pointer, ) + Call id(4), args( Variable(8, Integer), Tag(0, 3), ) Return Block 2:Block: Variable(2, Integer) = Store Integer(0) @@ -2342,11 +2342,10 @@ fn integer_bitwise_and_with_lhs_dynamic_integer_and_rhs_dynamic_integer() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -2355,13 +2354,14 @@ fn integer_bitwise_and_with_lhs_dynamic_integer_and_rhs_dynamic_integer() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -2369,12 +2369,11 @@ fn integer_bitwise_and_with_lhs_dynamic_integer_and_rhs_dynamic_integer() { output_record_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -2382,14 +2381,15 @@ fn integer_bitwise_and_with_lhs_dynamic_integer_and_rhs_dynamic_integer() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Integer) = Store Variable(2, Integer) - Call id(1), args( Qubit(0), Result(1), ) - Variable(4, Boolean) = Call id(2), args( Result(1), ) + Call id(2), args( Qubit(0), Result(1), ) + Variable(4, Boolean) = Call id(3), args( Result(1), ) Variable(5, Boolean) = Icmp Eq, Variable(4, Boolean), Bool(false) Branch Variable(5, Boolean), 5, 6 Block 2:Block: @@ -2402,7 +2402,7 @@ fn integer_bitwise_and_with_lhs_dynamic_integer_and_rhs_dynamic_integer() { Variable(7, Integer) = Store Variable(6, Integer) Variable(8, Integer) = BitwiseAnd Variable(3, Integer), Variable(7, Integer) Variable(9, Integer) = Store Variable(8, Integer) - Call id(3), args( Variable(9, Integer), Pointer, ) + Call id(4), args( Variable(9, Integer), Tag(0, 3), ) Return Block 5:Block: Variable(6, Integer) = Store Integer(1) @@ -2433,11 +2433,10 @@ fn integer_bitwise_or_with_lhs_classical_integer_and_rhs_dynamic_integer() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -2446,13 +2445,14 @@ fn integer_bitwise_or_with_lhs_classical_integer_and_rhs_dynamic_integer() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -2460,12 +2460,11 @@ fn integer_bitwise_or_with_lhs_classical_integer_and_rhs_dynamic_integer() { output_record_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -2473,15 +2472,16 @@ fn integer_bitwise_or_with_lhs_classical_integer_and_rhs_dynamic_integer() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Integer) = Store Variable(2, Integer) Variable(4, Integer) = BitwiseOr Integer(1), Variable(3, Integer) Variable(5, Integer) = Store Variable(4, Integer) - Call id(3), args( Variable(5, Integer), Pointer, ) + Call id(4), args( Variable(5, Integer), Tag(0, 3), ) Return Block 2:Block: Variable(2, Integer) = Store Integer(0) @@ -2512,11 +2512,10 @@ fn integer_bitwise_xor_with_lhs_dynamic_integer_and_rhs_classical_integer() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -2525,13 +2524,14 @@ fn integer_bitwise_xor_with_lhs_dynamic_integer_and_rhs_classical_integer() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -2539,12 +2539,11 @@ fn integer_bitwise_xor_with_lhs_dynamic_integer_and_rhs_classical_integer() { output_record_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -2552,15 +2551,16 @@ fn integer_bitwise_xor_with_lhs_dynamic_integer_and_rhs_classical_integer() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Integer) = Store Variable(2, Integer) Variable(4, Integer) = BitwiseXor Variable(3, Integer), Integer(1) Variable(5, Integer) = Store Variable(4, Integer) - Call id(3), args( Variable(5, Integer), Pointer, ) + Call id(4), args( Variable(5, Integer), Tag(0, 3), ) Return Block 2:Block: Variable(2, Integer) = Store Integer(0) @@ -2589,7 +2589,20 @@ fn integer_bitwise_left_shif_with_lhs_dynamic_integer_and_rhs_dynamic_integer() let measurement_callable_id = CallableId(1); assert_callable( &program, - measurement_callable_id, + measurement_callable_id, + &expect![[r#" + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], + ); + let readout_callable_id = CallableId(2); + assert_callable( + &program, + readout_callable_id, &expect![[r#" Callable: name: __quantum__qis__mresetz__body @@ -2600,31 +2613,17 @@ fn integer_bitwise_left_shif_with_lhs_dynamic_integer_and_rhs_dynamic_integer() output_type: body: "#]], ); - let readout_callable_id = CallableId(2); - assert_callable( - &program, - readout_callable_id, - &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], - ); let output_record_id = CallableId(3); assert_callable( &program, output_record_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -2632,14 +2631,15 @@ fn integer_bitwise_left_shif_with_lhs_dynamic_integer_and_rhs_dynamic_integer() &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Integer) = Store Variable(2, Integer) - Call id(1), args( Qubit(0), Result(1), ) - Variable(4, Boolean) = Call id(2), args( Result(1), ) + Call id(2), args( Qubit(0), Result(1), ) + Variable(4, Boolean) = Call id(3), args( Result(1), ) Variable(5, Boolean) = Icmp Eq, Variable(4, Boolean), Bool(false) Branch Variable(5, Boolean), 5, 6 Block 2:Block: @@ -2652,7 +2652,7 @@ fn integer_bitwise_left_shif_with_lhs_dynamic_integer_and_rhs_dynamic_integer() Variable(7, Integer) = Store Variable(6, Integer) Variable(8, Integer) = Shl Variable(3, Integer), Variable(7, Integer) Variable(9, Integer) = Store Variable(8, Integer) - Call id(3), args( Variable(9, Integer), Pointer, ) + Call id(4), args( Variable(9, Integer), Tag(0, 3), ) Return Block 5:Block: Variable(6, Integer) = Store Integer(1) @@ -2683,11 +2683,10 @@ fn integer_bitwise_right_shift_with_lhs_classical_integer_and_rhs_dynamic_intege measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -2696,13 +2695,14 @@ fn integer_bitwise_right_shift_with_lhs_classical_integer_and_rhs_dynamic_intege &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -2710,12 +2710,11 @@ fn integer_bitwise_right_shift_with_lhs_classical_integer_and_rhs_dynamic_intege output_record_id, &expect![[r#" Callable: - name: __quantum__rt__int_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Integer - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -2723,15 +2722,16 @@ fn integer_bitwise_right_shift_with_lhs_classical_integer_and_rhs_dynamic_intege &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Integer) = Store Variable(2, Integer) Variable(4, Integer) = Ashr Integer(1), Variable(3, Integer) Variable(5, Integer) = Store Variable(4, Integer) - Call id(3), args( Variable(5, Integer), Pointer, ) + Call id(4), args( Variable(5, Integer), Tag(0, 3), ) Return Block 2:Block: Variable(2, Integer) = Store Integer(0) @@ -2762,11 +2762,10 @@ fn integer_equality_comparison_with_lhs_dynamic_integer_and_rhs_classical_intege measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -2775,13 +2774,14 @@ fn integer_equality_comparison_with_lhs_dynamic_integer_and_rhs_classical_intege &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -2789,12 +2789,11 @@ fn integer_equality_comparison_with_lhs_dynamic_integer_and_rhs_classical_intege output_record_id, &expect![[r#" Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Boolean - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -2802,15 +2801,16 @@ fn integer_equality_comparison_with_lhs_dynamic_integer_and_rhs_classical_intege &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Integer) = Store Variable(2, Integer) Variable(4, Boolean) = Icmp Eq, Variable(3, Integer), Integer(1) Variable(5, Boolean) = Store Variable(4, Boolean) - Call id(3), args( Variable(5, Boolean), Pointer, ) + Call id(4), args( Variable(5, Boolean), Tag(0, 3), ) Return Block 2:Block: Variable(2, Integer) = Store Integer(0) @@ -2842,11 +2842,10 @@ fn integer_inequality_comparison_with_lhs_dynamic_integer_and_rhs_dynamic_intege measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -2855,13 +2854,14 @@ fn integer_inequality_comparison_with_lhs_dynamic_integer_and_rhs_dynamic_intege &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -2869,12 +2869,11 @@ fn integer_inequality_comparison_with_lhs_dynamic_integer_and_rhs_dynamic_intege output_record_id, &expect![[r#" Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Boolean - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -2882,14 +2881,15 @@ fn integer_inequality_comparison_with_lhs_dynamic_integer_and_rhs_dynamic_intege &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Integer) = Store Variable(2, Integer) - Call id(1), args( Qubit(0), Result(1), ) - Variable(4, Boolean) = Call id(2), args( Result(1), ) + Call id(2), args( Qubit(0), Result(1), ) + Variable(4, Boolean) = Call id(3), args( Result(1), ) Variable(5, Boolean) = Icmp Eq, Variable(4, Boolean), Bool(false) Branch Variable(5, Boolean), 5, 6 Block 2:Block: @@ -2902,7 +2902,7 @@ fn integer_inequality_comparison_with_lhs_dynamic_integer_and_rhs_dynamic_intege Variable(7, Integer) = Store Variable(6, Integer) Variable(8, Boolean) = Icmp Ne, Variable(3, Integer), Variable(7, Integer) Variable(9, Boolean) = Store Variable(8, Boolean) - Call id(3), args( Variable(9, Boolean), Pointer, ) + Call id(4), args( Variable(9, Boolean), Tag(0, 3), ) Return Block 5:Block: Variable(6, Integer) = Store Integer(1) @@ -2933,11 +2933,10 @@ fn integer_greater_than_comparison_with_lhs_classical_integer_and_rhs_dynamic_in measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -2946,13 +2945,14 @@ fn integer_greater_than_comparison_with_lhs_classical_integer_and_rhs_dynamic_in &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -2960,12 +2960,11 @@ fn integer_greater_than_comparison_with_lhs_classical_integer_and_rhs_dynamic_in output_record_id, &expect![[r#" Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Boolean - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -2973,15 +2972,16 @@ fn integer_greater_than_comparison_with_lhs_classical_integer_and_rhs_dynamic_in &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Integer) = Store Variable(2, Integer) Variable(4, Boolean) = Icmp Sgt, Integer(1), Variable(3, Integer) Variable(5, Boolean) = Store Variable(4, Boolean) - Call id(3), args( Variable(5, Boolean), Pointer, ) + Call id(4), args( Variable(5, Boolean), Tag(0, 3), ) Return Block 2:Block: Variable(2, Integer) = Store Integer(0) @@ -3012,11 +3012,10 @@ fn integer_greater_or_equal_than_comparison_with_lhs_dynamic_integer_and_rhs_cla measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -3025,13 +3024,14 @@ fn integer_greater_or_equal_than_comparison_with_lhs_dynamic_integer_and_rhs_cla &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -3039,12 +3039,11 @@ fn integer_greater_or_equal_than_comparison_with_lhs_dynamic_integer_and_rhs_cla output_record_id, &expect![[r#" Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Boolean - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -3052,15 +3051,16 @@ fn integer_greater_or_equal_than_comparison_with_lhs_dynamic_integer_and_rhs_cla &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Integer) = Store Variable(2, Integer) Variable(4, Boolean) = Icmp Sge, Variable(3, Integer), Integer(1) Variable(5, Boolean) = Store Variable(4, Boolean) - Call id(3), args( Variable(5, Boolean), Pointer, ) + Call id(4), args( Variable(5, Boolean), Tag(0, 3), ) Return Block 2:Block: Variable(2, Integer) = Store Integer(0) @@ -3092,11 +3092,10 @@ fn integer_less_than_comparison_with_lhs_dynamic_integer_and_rhs_dynamic_integer measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -3105,13 +3104,14 @@ fn integer_less_than_comparison_with_lhs_dynamic_integer_and_rhs_dynamic_integer &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -3119,12 +3119,11 @@ fn integer_less_than_comparison_with_lhs_dynamic_integer_and_rhs_dynamic_integer output_record_id, &expect![[r#" Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Boolean - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -3132,14 +3131,15 @@ fn integer_less_than_comparison_with_lhs_dynamic_integer_and_rhs_dynamic_integer &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Integer) = Store Variable(2, Integer) - Call id(1), args( Qubit(0), Result(1), ) - Variable(4, Boolean) = Call id(2), args( Result(1), ) + Call id(2), args( Qubit(0), Result(1), ) + Variable(4, Boolean) = Call id(3), args( Result(1), ) Variable(5, Boolean) = Icmp Eq, Variable(4, Boolean), Bool(false) Branch Variable(5, Boolean), 5, 6 Block 2:Block: @@ -3152,7 +3152,7 @@ fn integer_less_than_comparison_with_lhs_dynamic_integer_and_rhs_dynamic_integer Variable(7, Integer) = Store Variable(6, Integer) Variable(8, Boolean) = Icmp Slt, Variable(3, Integer), Variable(7, Integer) Variable(9, Boolean) = Store Variable(8, Boolean) - Call id(3), args( Variable(9, Boolean), Pointer, ) + Call id(4), args( Variable(9, Boolean), Tag(0, 3), ) Return Block 5:Block: Variable(6, Integer) = Store Integer(1) @@ -3183,11 +3183,10 @@ fn integer_less_or_equal_than_comparison_with_lhs_classical_integer_and_rhs_dyna measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -3196,13 +3195,14 @@ fn integer_less_or_equal_than_comparison_with_lhs_classical_integer_and_rhs_dyna &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -3210,12 +3210,11 @@ fn integer_less_or_equal_than_comparison_with_lhs_classical_integer_and_rhs_dyna output_record_id, &expect![[r#" Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Boolean - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -3223,15 +3222,16 @@ fn integer_less_or_equal_than_comparison_with_lhs_classical_integer_and_rhs_dyna &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Integer) = Store Variable(2, Integer) Variable(4, Boolean) = Icmp Sle, Integer(1), Variable(3, Integer) Variable(5, Boolean) = Store Variable(4, Boolean) - Call id(3), args( Variable(5, Boolean), Pointer, ) + Call id(4), args( Variable(5, Boolean), Tag(0, 3), ) Return Block 2:Block: Variable(2, Integer) = Store Integer(0) @@ -3259,27 +3259,27 @@ fn leading_positive_unary_operator_on_double_does_not_generate_rir_instruction() &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let readout_callable_id = CallableId(2); assert_callable( &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_recording_callable_id = CallableId(3); assert_callable( @@ -3287,12 +3287,11 @@ fn leading_positive_unary_operator_on_double_does_not_generate_rir_instruction() output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__double_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Double - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -3300,14 +3299,15 @@ fn leading_positive_unary_operator_on_double_does_not_generate_rir_instruction() &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Double) = Store Variable(2, Double) Variable(4, Double) = Store Variable(3, Double) - Call id(3), args( Variable(4, Double), Pointer, ) + Call id(4), args( Variable(4, Double), Tag(0, 3), ) Return Block 2:Block: Variable(2, Double) = Store Double(0) @@ -3335,27 +3335,27 @@ fn leading_negative_unary_operator_on_double_generates_rir_instruction() { &program, mresetz_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let readout_callable_id = CallableId(2); assert_callable( &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_recording_callable_id = CallableId(3); assert_callable( @@ -3363,12 +3363,11 @@ fn leading_negative_unary_operator_on_double_generates_rir_instruction() { output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__double_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Double - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -3376,15 +3375,16 @@ fn leading_negative_unary_operator_on_double_generates_rir_instruction() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Double) = Store Variable(2, Double) Variable(4, Double) = Fmul Double(-1), Variable(3, Double) Variable(5, Double) = Store Variable(4, Double) - Call id(3), args( Variable(5, Double), Pointer, ) + Call id(4), args( Variable(5, Double), Tag(0, 3), ) Return Block 2:Block: Variable(2, Double) = Store Double(0) @@ -3415,11 +3415,10 @@ fn double_add_with_lhs_classical_double_and_rhs_dynamic_double() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -3428,13 +3427,14 @@ fn double_add_with_lhs_classical_double_and_rhs_dynamic_double() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -3442,12 +3442,11 @@ fn double_add_with_lhs_classical_double_and_rhs_dynamic_double() { output_record_id, &expect![[r#" Callable: - name: __quantum__rt__double_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Double - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -3455,15 +3454,16 @@ fn double_add_with_lhs_classical_double_and_rhs_dynamic_double() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Double) = Store Variable(2, Double) Variable(4, Double) = Fadd Double(1), Variable(3, Double) Variable(5, Double) = Store Variable(4, Double) - Call id(3), args( Variable(5, Double), Pointer, ) + Call id(4), args( Variable(5, Double), Tag(0, 3), ) Return Block 2:Block: Variable(2, Double) = Store Double(0) @@ -3494,11 +3494,10 @@ fn double_sub_with_lhs_dynamic_double_and_rhs_classical_double() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -3507,13 +3506,14 @@ fn double_sub_with_lhs_dynamic_double_and_rhs_classical_double() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -3521,12 +3521,11 @@ fn double_sub_with_lhs_dynamic_double_and_rhs_classical_double() { output_record_id, &expect![[r#" Callable: - name: __quantum__rt__double_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Double - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -3534,15 +3533,16 @@ fn double_sub_with_lhs_dynamic_double_and_rhs_classical_double() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Double) = Store Variable(2, Double) Variable(4, Double) = Fsub Variable(3, Double), Double(1) Variable(5, Double) = Store Variable(4, Double) - Call id(3), args( Variable(5, Double), Pointer, ) + Call id(4), args( Variable(5, Double), Tag(0, 3), ) Return Block 2:Block: Variable(2, Double) = Store Double(0) @@ -3574,11 +3574,10 @@ fn double_mul_with_lhs_dynamic_double_and_rhs_dynamic_double() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -3587,13 +3586,14 @@ fn double_mul_with_lhs_dynamic_double_and_rhs_dynamic_double() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -3601,12 +3601,11 @@ fn double_mul_with_lhs_dynamic_double_and_rhs_dynamic_double() { output_record_id, &expect![[r#" Callable: - name: __quantum__rt__double_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Double - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -3614,14 +3613,15 @@ fn double_mul_with_lhs_dynamic_double_and_rhs_dynamic_double() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Double) = Store Variable(2, Double) - Call id(1), args( Qubit(0), Result(1), ) - Variable(4, Boolean) = Call id(2), args( Result(1), ) + Call id(2), args( Qubit(0), Result(1), ) + Variable(4, Boolean) = Call id(3), args( Result(1), ) Variable(5, Boolean) = Icmp Eq, Variable(4, Boolean), Bool(false) Branch Variable(5, Boolean), 5, 6 Block 2:Block: @@ -3634,7 +3634,7 @@ fn double_mul_with_lhs_dynamic_double_and_rhs_dynamic_double() { Variable(7, Double) = Store Variable(6, Double) Variable(8, Double) = Fmul Variable(3, Double), Variable(7, Double) Variable(9, Double) = Store Variable(8, Double) - Call id(3), args( Variable(9, Double), Pointer, ) + Call id(4), args( Variable(9, Double), Tag(0, 3), ) Return Block 5:Block: Variable(6, Double) = Store Double(1.1) @@ -3665,11 +3665,10 @@ fn double_div_with_lhs_classical_double_and_rhs_dynamic_double() { measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -3678,13 +3677,14 @@ fn double_div_with_lhs_classical_double_and_rhs_dynamic_double() { &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -3692,12 +3692,11 @@ fn double_div_with_lhs_classical_double_and_rhs_dynamic_double() { output_record_id, &expect![[r#" Callable: - name: __quantum__rt__double_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Double - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -3705,15 +3704,16 @@ fn double_div_with_lhs_classical_double_and_rhs_dynamic_double() { &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Double) = Store Variable(2, Double) Variable(4, Double) = Fdiv Double(1), Variable(3, Double) Variable(5, Double) = Store Variable(4, Double) - Call id(3), args( Variable(5, Double), Pointer, ) + Call id(4), args( Variable(5, Double), Tag(0, 3), ) Return Block 2:Block: Variable(2, Double) = Store Double(0) @@ -3766,11 +3766,10 @@ fn double_equality_comparison_with_lhs_dynamic_double_and_rhs_classical_double() measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -3779,13 +3778,14 @@ fn double_equality_comparison_with_lhs_dynamic_double_and_rhs_classical_double() &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -3793,12 +3793,11 @@ fn double_equality_comparison_with_lhs_dynamic_double_and_rhs_classical_double() output_record_id, &expect![[r#" Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Boolean - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -3806,15 +3805,16 @@ fn double_equality_comparison_with_lhs_dynamic_double_and_rhs_classical_double() &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Double) = Store Variable(2, Double) Variable(4, Boolean) = Fcmp Oeq, Variable(3, Double), Double(1) Variable(5, Boolean) = Store Variable(4, Boolean) - Call id(3), args( Variable(5, Boolean), Pointer, ) + Call id(4), args( Variable(5, Boolean), Tag(0, 3), ) Return Block 2:Block: Variable(2, Double) = Store Double(0) @@ -3846,11 +3846,10 @@ fn double_inequality_comparison_with_lhs_dynamic_double_and_rhs_dynamic_double() measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -3859,13 +3858,14 @@ fn double_inequality_comparison_with_lhs_dynamic_double_and_rhs_dynamic_double() &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -3873,12 +3873,11 @@ fn double_inequality_comparison_with_lhs_dynamic_double_and_rhs_dynamic_double() output_record_id, &expect![[r#" Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Boolean - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -3886,14 +3885,15 @@ fn double_inequality_comparison_with_lhs_dynamic_double_and_rhs_dynamic_double() &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Double) = Store Variable(2, Double) - Call id(1), args( Qubit(0), Result(1), ) - Variable(4, Boolean) = Call id(2), args( Result(1), ) + Call id(2), args( Qubit(0), Result(1), ) + Variable(4, Boolean) = Call id(3), args( Result(1), ) Variable(5, Boolean) = Icmp Eq, Variable(4, Boolean), Bool(false) Branch Variable(5, Boolean), 5, 6 Block 2:Block: @@ -3906,7 +3906,7 @@ fn double_inequality_comparison_with_lhs_dynamic_double_and_rhs_dynamic_double() Variable(7, Double) = Store Variable(6, Double) Variable(8, Boolean) = Fcmp One, Variable(3, Double), Variable(7, Double) Variable(9, Boolean) = Store Variable(8, Boolean) - Call id(3), args( Variable(9, Boolean), Pointer, ) + Call id(4), args( Variable(9, Boolean), Tag(0, 3), ) Return Block 5:Block: Variable(6, Double) = Store Double(1.1) @@ -3937,11 +3937,10 @@ fn double_greater_than_comparison_with_lhs_classical_double_and_rhs_dynamic_doub measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -3950,13 +3949,14 @@ fn double_greater_than_comparison_with_lhs_classical_double_and_rhs_dynamic_doub &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -3964,12 +3964,11 @@ fn double_greater_than_comparison_with_lhs_classical_double_and_rhs_dynamic_doub output_record_id, &expect![[r#" Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Boolean - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -3977,15 +3976,16 @@ fn double_greater_than_comparison_with_lhs_classical_double_and_rhs_dynamic_doub &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Double) = Store Variable(2, Double) Variable(4, Boolean) = Fcmp Ogt, Double(1), Variable(3, Double) Variable(5, Boolean) = Store Variable(4, Boolean) - Call id(3), args( Variable(5, Boolean), Pointer, ) + Call id(4), args( Variable(5, Boolean), Tag(0, 3), ) Return Block 2:Block: Variable(2, Double) = Store Double(0) @@ -4016,11 +4016,10 @@ fn double_greater_or_equal_than_comparison_with_lhs_dynamic_double_and_rhs_class measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -4029,13 +4028,14 @@ fn double_greater_or_equal_than_comparison_with_lhs_dynamic_double_and_rhs_class &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -4043,12 +4043,11 @@ fn double_greater_or_equal_than_comparison_with_lhs_dynamic_double_and_rhs_class output_record_id, &expect![[r#" Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Boolean - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -4056,15 +4055,16 @@ fn double_greater_or_equal_than_comparison_with_lhs_dynamic_double_and_rhs_class &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Double) = Store Variable(2, Double) Variable(4, Boolean) = Fcmp Oge, Variable(3, Double), Double(1) Variable(5, Boolean) = Store Variable(4, Boolean) - Call id(3), args( Variable(5, Boolean), Pointer, ) + Call id(4), args( Variable(5, Boolean), Tag(0, 3), ) Return Block 2:Block: Variable(2, Double) = Store Double(0) @@ -4096,11 +4096,10 @@ fn double_less_than_comparison_with_lhs_dynamic_double_and_rhs_dynamic_double() measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -4109,13 +4108,14 @@ fn double_less_than_comparison_with_lhs_dynamic_double_and_rhs_dynamic_double() &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -4123,12 +4123,11 @@ fn double_less_than_comparison_with_lhs_dynamic_double_and_rhs_dynamic_double() output_record_id, &expect![[r#" Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Boolean - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -4136,14 +4135,15 @@ fn double_less_than_comparison_with_lhs_dynamic_double_and_rhs_dynamic_double() &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Double) = Store Variable(2, Double) - Call id(1), args( Qubit(0), Result(1), ) - Variable(4, Boolean) = Call id(2), args( Result(1), ) + Call id(2), args( Qubit(0), Result(1), ) + Variable(4, Boolean) = Call id(3), args( Result(1), ) Variable(5, Boolean) = Icmp Eq, Variable(4, Boolean), Bool(false) Branch Variable(5, Boolean), 5, 6 Block 2:Block: @@ -4156,7 +4156,7 @@ fn double_less_than_comparison_with_lhs_dynamic_double_and_rhs_dynamic_double() Variable(7, Double) = Store Variable(6, Double) Variable(8, Boolean) = Fcmp Olt, Variable(3, Double), Variable(7, Double) Variable(9, Boolean) = Store Variable(8, Boolean) - Call id(3), args( Variable(9, Boolean), Pointer, ) + Call id(4), args( Variable(9, Boolean), Tag(0, 3), ) Return Block 5:Block: Variable(6, Double) = Store Double(1.1) @@ -4187,11 +4187,10 @@ fn double_less_or_equal_than_comparison_with_lhs_classical_double_and_rhs_dynami measurement_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -4200,13 +4199,14 @@ fn double_less_or_equal_than_comparison_with_lhs_classical_double_and_rhs_dynami &program, readout_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let output_record_id = CallableId(3); assert_callable( @@ -4214,12 +4214,11 @@ fn double_less_or_equal_than_comparison_with_lhs_classical_double_and_rhs_dynami output_record_id, &expect![[r#" Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording + name: __quantum__rt__read_result + call_type: Readout input_type: - [0]: Boolean - [1]: Pointer - output_type: + [0]: Result + output_type: Boolean body: "#]], ); assert_blocks( @@ -4227,15 +4226,16 @@ fn double_less_or_equal_than_comparison_with_lhs_classical_double_and_rhs_dynami &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: Variable(3, Double) = Store Variable(2, Double) Variable(4, Boolean) = Fcmp Ole, Double(1), Variable(3, Double) Variable(5, Boolean) = Store Variable(4, Boolean) - Call id(3), args( Variable(5, Boolean), Pointer, ) + Call id(4), args( Variable(5, Boolean), Tag(0, 3), ) Return Block 2:Block: Variable(2, Double) = Store Double(0) diff --git a/source/compiler/qsc_partial_eval/src/tests/output_recording.rs b/source/compiler/qsc_partial_eval/src/tests/output_recording.rs index 6972402fc4..b68902b223 100644 --- a/source/compiler/qsc_partial_eval/src/tests/output_recording.rs +++ b/source/compiler/qsc_partial_eval/src/tests/output_recording.rs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +#![allow(clippy::too_many_lines)] use super::{assert_error, get_partial_evaluation_error, get_rir_program}; use expect_test::expect; use indoc::indoc; @@ -28,9 +29,16 @@ fn output_recording_for_tuple_of_different_types() { name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: + Callable 2: Callable: name: __quantum__qis__mresetz__body call_type: Measurement input_type: @@ -38,14 +46,14 @@ fn output_recording_for_tuple_of_different_types() { [1]: Result output_type: body: - Callable 2: Callable: - name: __quantum__qis__read_result__body + Callable 3: Callable: + name: __quantum__rt__read_result call_type: Readout input_type: [0]: Result output_type: Boolean body: - Callable 3: Callable: + Callable 4: Callable: name: __quantum__rt__tuple_record_output call_type: OutputRecording input_type: @@ -53,7 +61,7 @@ fn output_recording_for_tuple_of_different_types() { [1]: Pointer output_type: body: - Callable 4: Callable: + Callable 5: Callable: name: __quantum__rt__result_record_output call_type: OutputRecording input_type: @@ -61,7 +69,7 @@ fn output_recording_for_tuple_of_different_types() { [1]: Pointer output_type: body: - Callable 5: Callable: + Callable 6: Callable: name: __quantum__rt__bool_record_output call_type: OutputRecording input_type: @@ -71,17 +79,22 @@ fn output_recording_for_tuple_of_different_types() { body: blocks: Block 0: Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) - Call id(3), args( Integer(2), Pointer, ) - Call id(4), args( Result(0), Pointer, ) - Call id(5), args( Variable(1, Boolean), Pointer, ) + Call id(4), args( Integer(2), EmptyTag, ) + Call id(5), args( Result(0), Tag(0, 5), ) + Call id(6), args( Variable(1, Boolean), Tag(1, 5), ) Return config: Config: capabilities: TargetCapabilityFlags(Adaptive | IntegerComputations | FloatingPointComputations | BackwardsBranching | HigherLevelConstructs | QubitReset) num_qubits: 1 - num_results: 1"#]] + num_results: 1 + tags: + [0]: 0_t0r + [1]: 1_t1b + "#]] .assert_eq(&program.to_string()); } @@ -108,9 +121,16 @@ fn output_recording_for_nested_tuples() { name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: + Callable 2: Callable: name: __quantum__qis__mresetz__body call_type: Measurement input_type: @@ -118,14 +138,14 @@ fn output_recording_for_nested_tuples() { [1]: Result output_type: body: - Callable 2: Callable: - name: __quantum__qis__read_result__body + Callable 3: Callable: + name: __quantum__rt__read_result call_type: Readout input_type: [0]: Result output_type: Boolean body: - Callable 3: Callable: + Callable 4: Callable: name: __quantum__rt__tuple_record_output call_type: OutputRecording input_type: @@ -133,7 +153,7 @@ fn output_recording_for_nested_tuples() { [1]: Pointer output_type: body: - Callable 4: Callable: + Callable 5: Callable: name: __quantum__rt__result_record_output call_type: OutputRecording input_type: @@ -141,7 +161,7 @@ fn output_recording_for_nested_tuples() { [1]: Pointer output_type: body: - Callable 5: Callable: + Callable 6: Callable: name: __quantum__rt__bool_record_output call_type: OutputRecording input_type: @@ -151,23 +171,30 @@ fn output_recording_for_nested_tuples() { body: blocks: Block 0: Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) - Variable(2, Boolean) = Call id(2), args( Result(0), ) + Variable(2, Boolean) = Call id(3), args( Result(0), ) Variable(3, Boolean) = Store Variable(2, Boolean) - Call id(3), args( Integer(3), Pointer, ) - Call id(4), args( Result(0), Pointer, ) - Call id(3), args( Integer(2), Pointer, ) - Call id(5), args( Variable(1, Boolean), Pointer, ) - Call id(4), args( Result(0), Pointer, ) - Call id(3), args( Integer(1), Pointer, ) - Call id(5), args( Variable(3, Boolean), Pointer, ) + Call id(4), args( Integer(3), EmptyTag, ) + Call id(5), args( Result(0), Tag(0, 5), ) + Call id(4), args( Integer(2), EmptyTag, ) + Call id(6), args( Variable(1, Boolean), Tag(1, 7), ) + Call id(5), args( Result(0), Tag(2, 7), ) + Call id(4), args( Integer(1), EmptyTag, ) + Call id(6), args( Variable(3, Boolean), Tag(3, 7), ) Return config: Config: capabilities: TargetCapabilityFlags(Adaptive | IntegerComputations | FloatingPointComputations | BackwardsBranching | HigherLevelConstructs | QubitReset) num_qubits: 1 - num_results: 1"#]] + num_results: 1 + tags: + [0]: 0_t0r + [1]: 1_t1t0b + [2]: 2_t1t1r + [3]: 3_t2t0b + "#]] .assert_eq(&program.to_string()); } @@ -196,9 +223,16 @@ fn output_recording_for_tuple_of_arrays() { name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: + Callable 2: Callable: name: __quantum__qis__mresetz__body call_type: Measurement input_type: @@ -206,14 +240,14 @@ fn output_recording_for_tuple_of_arrays() { [1]: Result output_type: body: - Callable 2: Callable: - name: __quantum__qis__read_result__body + Callable 3: Callable: + name: __quantum__rt__read_result call_type: Readout input_type: [0]: Result output_type: Boolean body: - Callable 3: Callable: + Callable 4: Callable: name: __quantum__rt__tuple_record_output call_type: OutputRecording input_type: @@ -221,7 +255,7 @@ fn output_recording_for_tuple_of_arrays() { [1]: Pointer output_type: body: - Callable 4: Callable: + Callable 5: Callable: name: __quantum__rt__result_record_output call_type: OutputRecording input_type: @@ -229,7 +263,7 @@ fn output_recording_for_tuple_of_arrays() { [1]: Pointer output_type: body: - Callable 5: Callable: + Callable 6: Callable: name: __quantum__rt__array_record_output call_type: OutputRecording input_type: @@ -237,7 +271,7 @@ fn output_recording_for_tuple_of_arrays() { [1]: Pointer output_type: body: - Callable 6: Callable: + Callable 7: Callable: name: __quantum__rt__bool_record_output call_type: OutputRecording input_type: @@ -247,21 +281,27 @@ fn output_recording_for_tuple_of_arrays() { body: blocks: Block 0: Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) - Variable(2, Boolean) = Call id(2), args( Result(0), ) + Variable(2, Boolean) = Call id(3), args( Result(0), ) Variable(3, Boolean) = Store Variable(2, Boolean) - Call id(3), args( Integer(2), Pointer, ) - Call id(4), args( Result(0), Pointer, ) - Call id(5), args( Integer(2), Pointer, ) - Call id(6), args( Variable(1, Boolean), Pointer, ) - Call id(6), args( Variable(3, Boolean), Pointer, ) + Call id(4), args( Integer(2), EmptyTag, ) + Call id(5), args( Result(0), Tag(0, 5), ) + Call id(6), args( Integer(2), EmptyTag, ) + Call id(7), args( Variable(1, Boolean), Tag(1, 7), ) + Call id(7), args( Variable(3, Boolean), Tag(2, 7), ) Return config: Config: capabilities: TargetCapabilityFlags(Adaptive | IntegerComputations | FloatingPointComputations | BackwardsBranching | HigherLevelConstructs | QubitReset) num_qubits: 1 - num_results: 1"#]] + num_results: 1 + tags: + [0]: 0_t0r + [1]: 1_t1a0b + [2]: 2_t1a1b + "#]] .assert_eq(&program.to_string()); } @@ -288,9 +328,16 @@ fn output_recording_for_array_of_tuples() { name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: + Callable 2: Callable: name: __quantum__qis__mresetz__body call_type: Measurement input_type: @@ -298,14 +345,14 @@ fn output_recording_for_array_of_tuples() { [1]: Result output_type: body: - Callable 2: Callable: - name: __quantum__qis__read_result__body + Callable 3: Callable: + name: __quantum__rt__read_result call_type: Readout input_type: [0]: Result output_type: Boolean body: - Callable 3: Callable: + Callable 4: Callable: name: __quantum__rt__array_record_output call_type: OutputRecording input_type: @@ -313,7 +360,7 @@ fn output_recording_for_array_of_tuples() { [1]: Pointer output_type: body: - Callable 4: Callable: + Callable 5: Callable: name: __quantum__rt__tuple_record_output call_type: OutputRecording input_type: @@ -321,7 +368,7 @@ fn output_recording_for_array_of_tuples() { [1]: Pointer output_type: body: - Callable 5: Callable: + Callable 6: Callable: name: __quantum__rt__result_record_output call_type: OutputRecording input_type: @@ -329,7 +376,7 @@ fn output_recording_for_array_of_tuples() { [1]: Pointer output_type: body: - Callable 6: Callable: + Callable 7: Callable: name: __quantum__rt__bool_record_output call_type: OutputRecording input_type: @@ -339,23 +386,30 @@ fn output_recording_for_array_of_tuples() { body: blocks: Block 0: Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) - Variable(2, Boolean) = Call id(2), args( Result(0), ) + Variable(2, Boolean) = Call id(3), args( Result(0), ) Variable(3, Boolean) = Store Variable(2, Boolean) - Call id(3), args( Integer(2), Pointer, ) - Call id(4), args( Integer(2), Pointer, ) - Call id(5), args( Result(0), Pointer, ) - Call id(6), args( Variable(1, Boolean), Pointer, ) - Call id(4), args( Integer(2), Pointer, ) - Call id(5), args( Result(0), Pointer, ) - Call id(6), args( Variable(3, Boolean), Pointer, ) + Call id(4), args( Integer(2), EmptyTag, ) + Call id(5), args( Integer(2), EmptyTag, ) + Call id(6), args( Result(0), Tag(0, 7), ) + Call id(7), args( Variable(1, Boolean), Tag(1, 7), ) + Call id(5), args( Integer(2), EmptyTag, ) + Call id(6), args( Result(0), Tag(2, 7), ) + Call id(7), args( Variable(3, Boolean), Tag(3, 7), ) Return config: Config: capabilities: TargetCapabilityFlags(Adaptive | IntegerComputations | FloatingPointComputations | BackwardsBranching | HigherLevelConstructs | QubitReset) num_qubits: 1 - num_results: 1"#]] + num_results: 1 + tags: + [0]: 0_a0t0r + [1]: 1_a0t1b + [2]: 2_a1t0r + [3]: 3_a1t1b + "#]] .assert_eq(&program.to_string()); } @@ -380,9 +434,16 @@ fn output_recording_for_literal_bool() { name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: + Callable 2: Callable: name: __quantum__rt__bool_record_output call_type: OutputRecording input_type: @@ -392,12 +453,16 @@ fn output_recording_for_literal_bool() { body: blocks: Block 0: Block: - Call id(1), args( Bool(true), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Bool(true), Tag(0, 3), ) Return config: Config: capabilities: TargetCapabilityFlags(Adaptive | IntegerComputations | FloatingPointComputations | BackwardsBranching | HigherLevelConstructs | QubitReset) num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + [0]: 0_b + "#]] .assert_eq(&program.to_string()); } @@ -422,9 +487,16 @@ fn output_recording_for_literal_double() { name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: + Callable 2: Callable: name: __quantum__rt__double_record_output call_type: OutputRecording input_type: @@ -434,12 +506,16 @@ fn output_recording_for_literal_double() { body: blocks: Block 0: Block: - Call id(1), args( Double(42.1), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Double(42.1), Tag(0, 3), ) Return config: Config: capabilities: TargetCapabilityFlags(Adaptive | IntegerComputations | FloatingPointComputations | BackwardsBranching | HigherLevelConstructs | QubitReset) num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + [0]: 0_d + "#]] .assert_eq(&program.to_string()); } @@ -464,9 +540,16 @@ fn output_recording_for_literal_int() { name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: + Callable 2: Callable: name: __quantum__rt__int_record_output call_type: OutputRecording input_type: @@ -476,12 +559,16 @@ fn output_recording_for_literal_int() { body: blocks: Block 0: Block: - Call id(1), args( Integer(42), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Integer(42), Tag(0, 3), ) Return config: Config: capabilities: TargetCapabilityFlags(Adaptive | IntegerComputations | FloatingPointComputations | BackwardsBranching | HigherLevelConstructs | QubitReset) num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + [0]: 0_i + "#]] .assert_eq(&program.to_string()); } @@ -508,9 +595,16 @@ fn output_recording_for_mix_of_literal_and_variable() { name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: + Callable 2: Callable: name: __quantum__qis__mresetz__body call_type: Measurement input_type: @@ -518,7 +612,7 @@ fn output_recording_for_mix_of_literal_and_variable() { [1]: Result output_type: body: - Callable 2: Callable: + Callable 3: Callable: name: __quantum__rt__tuple_record_output call_type: OutputRecording input_type: @@ -526,7 +620,7 @@ fn output_recording_for_mix_of_literal_and_variable() { [1]: Pointer output_type: body: - Callable 3: Callable: + Callable 4: Callable: name: __quantum__rt__result_record_output call_type: OutputRecording input_type: @@ -534,7 +628,7 @@ fn output_recording_for_mix_of_literal_and_variable() { [1]: Pointer output_type: body: - Callable 4: Callable: + Callable 5: Callable: name: __quantum__rt__bool_record_output call_type: OutputRecording input_type: @@ -544,15 +638,20 @@ fn output_recording_for_mix_of_literal_and_variable() { body: blocks: Block 0: Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(2), args( Integer(2), Pointer, ) - Call id(3), args( Result(0), Pointer, ) - Call id(4), args( Bool(true), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(3), args( Integer(2), EmptyTag, ) + Call id(4), args( Result(0), Tag(0, 5), ) + Call id(5), args( Bool(true), Tag(1, 5), ) Return config: Config: capabilities: TargetCapabilityFlags(Adaptive | IntegerComputations | FloatingPointComputations | BackwardsBranching | HigherLevelConstructs | QubitReset) num_qubits: 1 - num_results: 1"#]] + num_results: 1 + tags: + [0]: 0_t0r + [1]: 1_t1b + "#]] .assert_eq(&program.to_string()); } diff --git a/source/compiler/qsc_partial_eval/src/tests/qubits.rs b/source/compiler/qsc_partial_eval/src/tests/qubits.rs index 16e95e02df..570f6f7a19 100644 --- a/source/compiler/qsc_partial_eval/src/tests/qubits.rs +++ b/source/compiler/qsc_partial_eval/src/tests/qubits.rs @@ -26,27 +26,27 @@ fn qubit_ids_are_correct_for_allocate_use_release_one_qubit() { }); expect![[r#" Callable: - name: op + name: __quantum__rt__initialize call_type: Regular input_type: - [0]: Qubit + [0]: Pointer output_type: body: "#]] .assert_eq(&program.get_callable(CallableId(1)).to_string()); expect![[r#" Callable: - name: __quantum__rt__tuple_record_output - call_type: OutputRecording + name: op + call_type: Regular input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit output_type: body: "#]] .assert_eq(&program.get_callable(CallableId(2)).to_string()); expect![[r#" Block: - Call id(1), args( Qubit(0), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]] .assert_eq(&program.get_block(BlockId(0)).to_string()); } @@ -77,37 +77,37 @@ fn qubit_ids_are_correct_for_allocate_use_release_multiple_qubits() { &program, op_callable_id, &expect![[r#" - Callable: - name: op - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let tuple_callable_id = CallableId(2); assert_callable( &program, tuple_callable_id, &expect![[r#" - Callable: - name: __quantum__rt__tuple_record_output - call_type: OutputRecording - input_type: - [0]: Integer - [1]: Pointer - output_type: - body: "#]], + Callable: + name: op + call_type: Regular + input_type: + [0]: Qubit + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), ) - Call id(1), args( Qubit(1), ) - Call id(1), args( Qubit(2), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), ) + Call id(2), args( Qubit(1), ) + Call id(2), args( Qubit(2), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); assert_eq!(program.num_qubits, 3); @@ -140,37 +140,37 @@ fn qubit_ids_are_correct_for_allocate_use_release_one_qubit_multiple_times() { &program, op_callable_id, &expect![[r#" - Callable: - name: op - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let tuple_callable_id = CallableId(2); assert_callable( &program, tuple_callable_id, &expect![[r#" - Callable: - name: __quantum__rt__tuple_record_output - call_type: OutputRecording - input_type: - [0]: Integer - [1]: Pointer - output_type: - body: "#]], + Callable: + name: op + call_type: Regular + input_type: + [0]: Qubit + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), ) - Call id(1), args( Qubit(0), ) - Call id(1), args( Qubit(0), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), ) + Call id(2), args( Qubit(0), ) + Call id(2), args( Qubit(0), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); assert_eq!(program.num_qubits, 1); @@ -209,39 +209,39 @@ fn qubit_ids_are_correct_for_allocate_use_release_multiple_qubits_interleaved() &program, op_callable_id, &expect![[r#" - Callable: - name: op - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let tuple_callable_id = CallableId(2); assert_callable( &program, tuple_callable_id, &expect![[r#" - Callable: - name: __quantum__rt__tuple_record_output - call_type: OutputRecording - input_type: - [0]: Integer - [1]: Pointer - output_type: - body: "#]], + Callable: + name: op + call_type: Regular + input_type: + [0]: Qubit + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), ) - Call id(1), args( Qubit(1), ) - Call id(1), args( Qubit(2), ) - Call id(1), args( Qubit(2), ) - Call id(1), args( Qubit(3), ) - Call id(2), args( Integer(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), ) + Call id(2), args( Qubit(1), ) + Call id(2), args( Qubit(2), ) + Call id(2), args( Qubit(2), ) + Call id(2), args( Qubit(3), ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); assert_eq!(program.num_qubits, 4); @@ -270,10 +270,10 @@ fn qubit_array_allocation_and_access() { op_callable_id, &expect![[r#" Callable: - name: Op + name: __quantum__rt__initialize call_type: Regular input_type: - [0]: Qubit + [0]: Pointer output_type: body: "#]], ); @@ -282,32 +282,32 @@ fn qubit_array_allocation_and_access() { &program, tuple_record_callable_id, &expect![[r#" - Callable: - name: __quantum__rt__tuple_record_output - call_type: OutputRecording - input_type: - [0]: Integer - [1]: Pointer - output_type: - body: "#]], + Callable: + name: Op + call_type: Regular + input_type: + [0]: Qubit + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: + Call id(1), args( Pointer, ) Variable(0, Integer) = Store Integer(0) Variable(0, Integer) = Store Integer(1) Variable(0, Integer) = Store Integer(2) Variable(0, Integer) = Store Integer(3) - Call id(1), args( Qubit(0), ) - Call id(1), args( Qubit(1), ) - Call id(1), args( Qubit(2), ) + Call id(2), args( Qubit(0), ) + Call id(2), args( Qubit(1), ) + Call id(2), args( Qubit(2), ) Variable(1, Integer) = Store Integer(0) Variable(1, Integer) = Store Integer(1) Variable(1, Integer) = Store Integer(2) Variable(1, Integer) = Store Integer(3) - Call id(2), args( Integer(0), Pointer, ) + Call id(3), args( Integer(0), EmptyTag, ) Return"#]], ); assert_eq!(program.num_qubits, 3); diff --git a/source/compiler/qsc_partial_eval/src/tests/results.rs b/source/compiler/qsc_partial_eval/src/tests/results.rs index 23d5d0df4c..5664420c84 100644 --- a/source/compiler/qsc_partial_eval/src/tests/results.rs +++ b/source/compiler/qsc_partial_eval/src/tests/results.rs @@ -25,35 +25,35 @@ fn result_ids_are_correct_for_measuring_and_resetting_one_qubit() { &program, op_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement - input_type: - [0]: Qubit - [1]: Result - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); assert_callable( &program, result_record_id, &expect![[r#" - Callable: - name: __quantum__rt__result_record_output - call_type: OutputRecording - input_type: - [0]: Result - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(2), args( Result(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(3), args( Result(0), Tag(0, 3), ) Return"#]], ); assert_eq!(program.num_qubits, 1); @@ -80,11 +80,10 @@ fn result_ids_are_correct_for_measuring_one_qubit() { op_callable_id, &expect![[r#" Callable: - name: __quantum__qis__m__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -92,22 +91,23 @@ fn result_ids_are_correct_for_measuring_one_qubit() { &program, result_record_id, &expect![[r#" - Callable: - name: __quantum__rt__result_record_output - call_type: OutputRecording - input_type: - [0]: Result - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__qis__m__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(2), args( Result(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(3), args( Result(0), Tag(0, 3), ) Return"#]], ); assert_eq!(program.num_qubits, 1); @@ -137,11 +137,10 @@ fn result_ids_are_correct_for_measuring_one_qubit_multiple_times() { op_callable_id, &expect![[r#" Callable: - name: __quantum__qis__m__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -149,40 +148,41 @@ fn result_ids_are_correct_for_measuring_one_qubit_multiple_times() { &program, tuple_record_id, &expect![[r#" - Callable: - name: __quantum__rt__tuple_record_output - call_type: OutputRecording - input_type: - [0]: Integer - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__qis__m__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); assert_callable( &program, result_record_id, &expect![[r#" - Callable: - name: __quantum__rt__result_record_output - call_type: OutputRecording - input_type: - [0]: Result - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__rt__tuple_record_output + call_type: OutputRecording + input_type: + [0]: Integer + [1]: Pointer + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(1), args( Qubit(0), Result(1), ) - Call id(1), args( Qubit(0), Result(2), ) - Call id(2), args( Integer(3), Pointer, ) - Call id(3), args( Result(0), Pointer, ) - Call id(3), args( Result(1), Pointer, ) - Call id(3), args( Result(2), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(2), args( Qubit(0), Result(1), ) + Call id(2), args( Qubit(0), Result(2), ) + Call id(3), args( Integer(3), EmptyTag, ) + Call id(4), args( Result(0), Tag(0, 5), ) + Call id(4), args( Result(1), Tag(1, 5), ) + Call id(4), args( Result(2), Tag(2, 5), ) Return"#]], ); } @@ -210,11 +210,10 @@ fn result_ids_are_correct_for_measuring_one_qubit_multiple_times_into_array() { op_callable_id, &expect![[r#" Callable: - name: __quantum__qis__m__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -222,40 +221,41 @@ fn result_ids_are_correct_for_measuring_one_qubit_multiple_times_into_array() { &program, array_record_id, &expect![[r#" - Callable: - name: __quantum__rt__array_record_output - call_type: OutputRecording - input_type: - [0]: Integer - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__qis__m__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); assert_callable( &program, result_record_id, &expect![[r#" - Callable: - name: __quantum__rt__result_record_output - call_type: OutputRecording - input_type: - [0]: Result - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__rt__array_record_output + call_type: OutputRecording + input_type: + [0]: Integer + [1]: Pointer + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(1), args( Qubit(0), Result(1), ) - Call id(1), args( Qubit(0), Result(2), ) - Call id(2), args( Integer(3), Pointer, ) - Call id(3), args( Result(0), Pointer, ) - Call id(3), args( Result(1), Pointer, ) - Call id(3), args( Result(2), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(2), args( Qubit(0), Result(1), ) + Call id(2), args( Qubit(0), Result(2), ) + Call id(3), args( Integer(3), EmptyTag, ) + Call id(4), args( Result(0), Tag(0, 5), ) + Call id(4), args( Result(1), Tag(1, 5), ) + Call id(4), args( Result(2), Tag(2, 5), ) Return"#]], ); assert_eq!(program.num_qubits, 1); @@ -285,11 +285,10 @@ fn result_ids_are_correct_for_measuring_multiple_qubits() { op_callable_id, &expect![[r#" Callable: - name: __quantum__qis__m__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -297,40 +296,41 @@ fn result_ids_are_correct_for_measuring_multiple_qubits() { &program, tuple_record_id, &expect![[r#" - Callable: - name: __quantum__rt__tuple_record_output - call_type: OutputRecording - input_type: - [0]: Integer - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__qis__m__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); assert_callable( &program, result_record_id, &expect![[r#" - Callable: - name: __quantum__rt__result_record_output - call_type: OutputRecording - input_type: - [0]: Result - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__rt__tuple_record_output + call_type: OutputRecording + input_type: + [0]: Integer + [1]: Pointer + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(1), args( Qubit(1), Result(1), ) - Call id(1), args( Qubit(2), Result(2), ) - Call id(2), args( Integer(3), Pointer, ) - Call id(3), args( Result(0), Pointer, ) - Call id(3), args( Result(1), Pointer, ) - Call id(3), args( Result(2), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(2), args( Qubit(1), Result(1), ) + Call id(2), args( Qubit(2), Result(2), ) + Call id(3), args( Integer(3), EmptyTag, ) + Call id(4), args( Result(0), Tag(0, 5), ) + Call id(4), args( Result(1), Tag(1, 5), ) + Call id(4), args( Result(2), Tag(2, 5), ) Return"#]], ); assert_eq!(program.num_qubits, 3); diff --git a/source/compiler/qsc_partial_eval/src/tests/returns.rs b/source/compiler/qsc_partial_eval/src/tests/returns.rs index 36a6d34883..ef860dd260 100644 --- a/source/compiler/qsc_partial_eval/src/tests/returns.rs +++ b/source/compiler/qsc_partial_eval/src/tests/returns.rs @@ -31,22 +31,22 @@ fn non_classical_entry_point_with_classical_implicit_return() { &program, output_recording_callable_id, &expect![[r#" - Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording - input_type: - [0]: Boolean - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" - Block: - Call id(1), args( Bool(true), Pointer, ) - Return"#]], + Block: + Call id(1), args( Pointer, ) + Call id(2), args( Bool(true), Tag(0, 3), ) + Return"#]], ); } @@ -67,11 +67,10 @@ fn non_classical_entry_point_with_non_classical_implicit_return() { mresetz_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -81,11 +80,11 @@ fn non_classical_entry_point_with_non_classical_implicit_return() { output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__result_record_output - call_type: OutputRecording + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Result - [1]: Pointer + [0]: Qubit + [1]: Result output_type: body: "#]], ); @@ -94,8 +93,9 @@ fn non_classical_entry_point_with_non_classical_implicit_return() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(2), args( Result(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(3), args( Result(0), Tag(0, 3), ) Return"#]], ); } @@ -116,22 +116,22 @@ fn non_classical_entry_point_with_classical_explicit_return() { &program, output_recording_callable_id, &expect![[r#" - Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording - input_type: - [0]: Boolean - [1]: Pointer - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" - Block: - Call id(1), args( Bool(false), Pointer, ) - Return"#]], + Block: + Call id(1), args( Pointer, ) + Call id(2), args( Bool(false), Tag(0, 3), ) + Return"#]], ); } @@ -152,11 +152,10 @@ fn non_classical_entry_point_with_non_classical_explicit_return() { mresetz_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -166,11 +165,11 @@ fn non_classical_entry_point_with_non_classical_explicit_return() { output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__result_record_output - call_type: OutputRecording + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Result - [1]: Pointer + [0]: Qubit + [1]: Result output_type: body: "#]], ); @@ -179,8 +178,9 @@ fn non_classical_entry_point_with_non_classical_explicit_return() { BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(2), args( Result(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(3), args( Result(0), Tag(0, 3), ) Return"#]], ); } @@ -205,36 +205,36 @@ fn non_classical_entry_point_with_classical_inline_early_return_halts_evaluation &program, op_a_callable_id, &expect![[r#" - Callable: - name: OpA - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let output_recording_callable_id = CallableId(2); assert_callable( &program, output_recording_callable_id, &expect![[r#" - Callable: - name: __quantum__rt__tuple_record_output - call_type: OutputRecording - input_type: - [0]: Integer - [1]: Pointer - output_type: - body: "#]], + Callable: + name: OpA + call_type: Regular + input_type: + [0]: Qubit + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" - Block: - Call id(1), args( Qubit(0), ) - Call id(2), args( Integer(0), Pointer, ) - Return"#]], + Block: + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), ) + Call id(3), args( Integer(0), EmptyTag, ) + Return"#]], ); } @@ -256,11 +256,10 @@ fn non_classical_entry_point_with_non_classical_inline_early_return_halts_evalua mresetz_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -270,11 +269,11 @@ fn non_classical_entry_point_with_non_classical_inline_early_return_halts_evalua output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__result_record_output - call_type: OutputRecording + name: __quantum__qis__mresetz__body + call_type: Measurement input_type: - [0]: Result - [1]: Pointer + [0]: Qubit + [1]: Result output_type: body: "#]], ); @@ -283,8 +282,9 @@ fn non_classical_entry_point_with_non_classical_inline_early_return_halts_evalua BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), Result(0), ) - Call id(2), args( Result(0), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Call id(3), args( Result(0), Tag(0, 3), ) Return"#]], ); } @@ -313,13 +313,13 @@ fn non_classical_entry_point_with_classical_early_return_within_classical_branch &program, op_a_callable_id, &expect![[r#" - Callable: - name: OpA - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let output_recording_callable_id = CallableId(2); assert_callable( @@ -327,11 +327,10 @@ fn non_classical_entry_point_with_classical_early_return_within_classical_branch output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__bool_record_output - call_type: OutputRecording + name: OpA + call_type: Regular input_type: - [0]: Boolean - [1]: Pointer + [0]: Qubit output_type: body: "#]], ); @@ -340,8 +339,9 @@ fn non_classical_entry_point_with_classical_early_return_within_classical_branch BlockId(0), &expect![[r#" Block: - Call id(1), args( Qubit(0), ) - Call id(2), args( Bool(true), Pointer, ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), ) + Call id(3), args( Bool(true), Tag(0, 3), ) Return"#]], ); } @@ -423,11 +423,10 @@ fn non_classical_entry_point_with_early_return_after_branching_halts_evaluation( mresetz_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -436,52 +435,53 @@ fn non_classical_entry_point_with_early_return_after_branching_halts_evaluation( &program, read_result_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let op_a_callable_id = CallableId(3); assert_callable( &program, op_a_callable_id, &expect![[r#" - Callable: - name: OpA - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); let op_b_callable_id = CallableId(4); assert_callable( &program, op_b_callable_id, &expect![[r#" - Callable: - name: OpB - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: OpA + call_type: Regular + input_type: + [0]: Qubit + output_type: + body: "#]], ); let op_c_callable_id = CallableId(5); assert_callable( &program, op_c_callable_id, &expect![[r#" - Callable: - name: OpC - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: OpB + call_type: Regular + input_type: + [0]: Qubit + output_type: + body: "#]], ); let output_recording_callable_id = CallableId(6); assert_callable( @@ -489,11 +489,10 @@ fn non_classical_entry_point_with_early_return_after_branching_halts_evaluation( output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__tuple_record_output - call_type: OutputRecording + name: OpC + call_type: Regular input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit output_type: body: "#]], ); @@ -502,19 +501,20 @@ fn non_classical_entry_point_with_early_return_after_branching_halts_evaluation( &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 3 Block 1:Block: - Call id(5), args( Qubit(1), ) - Call id(6), args( Integer(0), Pointer, ) + Call id(6), args( Qubit(1), ) + Call id(7), args( Integer(0), EmptyTag, ) Return Block 2:Block: - Call id(3), args( Qubit(1), ) + Call id(4), args( Qubit(1), ) Jump(1) Block 3:Block: - Call id(4), args( Qubit(1), ) + Call id(5), args( Qubit(1), ) Jump(1)"#]], ); } @@ -548,11 +548,10 @@ fn operation_with_early_return_within_dynamic_branch_halts_evaluation_at_the_cal mresetz_callable_id, &expect![[r#" Callable: - name: __quantum__qis__mresetz__body - call_type: Measurement + name: __quantum__rt__initialize + call_type: Regular input_type: - [0]: Qubit - [1]: Result + [0]: Pointer output_type: body: "#]], ); @@ -561,39 +560,40 @@ fn operation_with_early_return_within_dynamic_branch_halts_evaluation_at_the_cal &program, read_result_callable_id, &expect![[r#" - Callable: - name: __quantum__qis__read_result__body - call_type: Readout - input_type: - [0]: Result - output_type: Boolean - body: "#]], + Callable: + name: __quantum__qis__mresetz__body + call_type: Measurement + input_type: + [0]: Qubit + [1]: Result + output_type: + body: "#]], ); let op_a_callable_id = CallableId(3); assert_callable( &program, op_a_callable_id, &expect![[r#" - Callable: - name: OpA - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__read_result + call_type: Readout + input_type: + [0]: Result + output_type: Boolean + body: "#]], ); let op_b_callable_id = CallableId(4); assert_callable( &program, op_b_callable_id, &expect![[r#" - Callable: - name: OpB - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: OpA + call_type: Regular + input_type: + [0]: Qubit + output_type: + body: "#]], ); let output_recording_callable_id = CallableId(5); assert_callable( @@ -601,11 +601,10 @@ fn operation_with_early_return_within_dynamic_branch_halts_evaluation_at_the_cal output_recording_callable_id, &expect![[r#" Callable: - name: __quantum__rt__tuple_record_output - call_type: OutputRecording + name: OpB + call_type: Regular input_type: - [0]: Integer - [1]: Pointer + [0]: Qubit output_type: body: "#]], ); @@ -614,16 +613,17 @@ fn operation_with_early_return_within_dynamic_branch_halts_evaluation_at_the_cal &expect![[r#" Blocks: Block 0:Block: - Call id(1), args( Qubit(0), Result(0), ) - Variable(0, Boolean) = Call id(2), args( Result(0), ) + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), Result(0), ) + Variable(0, Boolean) = Call id(3), args( Result(0), ) Variable(1, Boolean) = Icmp Eq, Variable(0, Boolean), Bool(false) Branch Variable(1, Boolean), 2, 1 Block 1:Block: - Call id(4), args( Qubit(0), ) - Call id(5), args( Integer(0), Pointer, ) + Call id(5), args( Qubit(0), ) + Call id(6), args( Integer(0), EmptyTag, ) Return Block 2:Block: - Call id(3), args( Qubit(0), ) + Call id(4), args( Qubit(0), ) Jump(1)"#]], ); } @@ -655,37 +655,38 @@ fn default_qubit_management_releases_qubits_when_they_are_out_of_scope_with_impl &program, op_a_callable_id, &expect![[r#" - Callable: - name: OpA - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let op_b_callable_id = CallableId(2); assert_callable( &program, op_b_callable_id, &expect![[r#" - Callable: - name: OpB - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: OpA + call_type: Regular + input_type: + [0]: Qubit + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" - Block: - Call id(1), args( Qubit(0), ) - Call id(2), args( Qubit(1), ) - Call id(1), args( Qubit(1), ) - Call id(3), args( Integer(0), Pointer, ) - Return"#]], + Block: + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), ) + Call id(3), args( Qubit(1), ) + Call id(2), args( Qubit(1), ) + Call id(4), args( Integer(0), EmptyTag, ) + Return"#]], ); assert_eq!(program.num_qubits, 2); assert_eq!(program.num_results, 0); @@ -719,37 +720,38 @@ fn default_qubit_management_releases_qubits_when_they_are_out_of_scope_with_expl &program, op_a_callable_id, &expect![[r#" - Callable: - name: OpA - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let op_b_callable_id = CallableId(2); assert_callable( &program, op_b_callable_id, &expect![[r#" - Callable: - name: OpB - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: OpA + call_type: Regular + input_type: + [0]: Qubit + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" - Block: - Call id(1), args( Qubit(0), ) - Call id(2), args( Qubit(1), ) - Call id(1), args( Qubit(1), ) - Call id(3), args( Integer(0), Pointer, ) - Return"#]], + Block: + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), ) + Call id(3), args( Qubit(1), ) + Call id(2), args( Qubit(1), ) + Call id(4), args( Integer(0), EmptyTag, ) + Return"#]], ); assert_eq!(program.num_qubits, 2); assert_eq!(program.num_results, 0); @@ -785,37 +787,38 @@ fn default_qubit_management_releases_qubits_when_they_are_out_of_scope_with_expl &program, op_a_callable_id, &expect![[r#" - Callable: - name: OpA - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: __quantum__rt__initialize + call_type: Regular + input_type: + [0]: Pointer + output_type: + body: "#]], ); let op_b_callable_id = CallableId(2); assert_callable( &program, op_b_callable_id, &expect![[r#" - Callable: - name: OpB - call_type: Regular - input_type: - [0]: Qubit - output_type: - body: "#]], + Callable: + name: OpA + call_type: Regular + input_type: + [0]: Qubit + output_type: + body: "#]], ); assert_block_instructions( &program, BlockId(0), &expect![[r#" - Block: - Call id(1), args( Qubit(0), ) - Call id(2), args( Qubit(1), ) - Call id(1), args( Qubit(1), ) - Call id(3), args( Integer(0), Pointer, ) - Return"#]], + Block: + Call id(1), args( Pointer, ) + Call id(2), args( Qubit(0), ) + Call id(3), args( Qubit(1), ) + Call id(2), args( Qubit(1), ) + Call id(4), args( Integer(0), EmptyTag, ) + Return"#]], ); assert_eq!(program.num_qubits, 2); assert_eq!(program.num_results, 0); diff --git a/source/compiler/qsc_qasm/src/tests/expression/function_call.rs b/source/compiler/qsc_qasm/src/tests/expression/function_call.rs index 756005618b..5747e7a1d4 100644 --- a/source/compiler/qsc_qasm/src/tests/expression/function_call.rs +++ b/source/compiler/qsc_qasm/src/tests/expression/function_call.rs @@ -315,14 +315,19 @@ fn simulatable_intrinsic_on_def_stmt_generates_correct_qir() -> miette::Result<( %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @my_gate(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - call void @__quantum__rt__tuple_record_output(i64 0, i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @my_gate(%Qubit*) declare void @__quantum__qis__m__body(%Qubit*, %Result*) #1 @@ -340,7 +345,7 @@ fn simulatable_intrinsic_on_def_stmt_generates_correct_qir() -> miette::Result<( !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} - !4 = !{i32 1, !"int_computations", !"i64"} + !4 = !{i32 5, !"int_computations", !{!"i64"}} "#]] .assert_eq(&qsharp); Ok(()) diff --git a/source/compiler/qsc_qasm/src/tests/output.rs b/source/compiler/qsc_qasm/src/tests/output.rs index adb3c65395..440adeab1e 100644 --- a/source/compiler/qsc_qasm/src/tests/output.rs +++ b/source/compiler/qsc_qasm/src/tests/output.rs @@ -253,8 +253,16 @@ c2[2] = measure q[4]; %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [8 x i8] c"0_t0a0r\00" + @1 = internal constant [8 x i8] c"1_t0a1r\00" + @2 = internal constant [8 x i8] c"2_t0a2r\00" + @3 = internal constant [8 x i8] c"3_t1a0r\00" + @4 = internal constant [8 x i8] c"4_t1a1r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__rz__body(double 0.4999999999999997, %Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__cx__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Qubit* inttoptr (i64 1 to %Qubit*)) @@ -266,17 +274,19 @@ c2[2] = measure q[4]; call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 2 to %Qubit*), %Result* inttoptr (i64 2 to %Result*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 3 to %Qubit*), %Result* inttoptr (i64 3 to %Result*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 4 to %Qubit*), %Result* inttoptr (i64 4 to %Result*)) - call void @__quantum__rt__tuple_record_output(i64 2, i8* null) - call void @__quantum__rt__array_record_output(i64 3, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* null) - call void @__quantum__rt__array_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__array_record_output(i64 3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @1, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @2, i64 0, i64 0)) + call void @__quantum__rt__array_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @3, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @4, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__rz__body(double, %Qubit*) declare void @__quantum__qis__h__body(%Qubit*) @@ -306,7 +316,7 @@ c2[2] = measure q[4]; !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} - !4 = !{i32 1, !"int_computations", !"i64"} + !4 = !{i32 5, !"int_computations", !{!"i64"}} "#]] .assert_eq(&qir); diff --git a/source/compiler/qsc_qasm/src/tests/statement/gate_call.rs b/source/compiler/qsc_qasm/src/tests/statement/gate_call.rs index fd871ace73..3867646cdc 100644 --- a/source/compiler/qsc_qasm/src/tests/statement/gate_call.rs +++ b/source/compiler/qsc_qasm/src/tests/statement/gate_call.rs @@ -242,23 +242,28 @@ fn barrier_generates_qir() -> miette::Result<(), Vec> { "#; let qsharp = compile_qasm_to_qir(source, Profile::AdaptiveRI)?; - expect![[ - r#" + expect![[r#" %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [6 x i8] c"0_a0r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__barrier__body() call void @__quantum__qis__barrier__body() call void @__quantum__qis__barrier__body() call void @__quantum__qis__barrier__body() call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - call void @__quantum__rt__array_record_output(i64 1, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - ret void + call void @__quantum__rt__array_record_output(i64 1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__barrier__body() declare void @__quantum__qis__m__body(%Qubit*, %Result*) #1 @@ -278,9 +283,8 @@ fn barrier_generates_qir() -> miette::Result<(), Vec> { !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} - !4 = !{i32 1, !"int_computations", !"i64"} - "# - ]] + !4 = !{i32 5, !"int_computations", !{!"i64"}} + "#]] .assert_eq(&qsharp); Ok(()) } @@ -607,14 +611,19 @@ fn simulatable_intrinsic_on_gate_stmt_generates_correct_qir() -> miette::Result< %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @my_gate(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - call void @__quantum__rt__tuple_record_output(i64 0, i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @my_gate(%Qubit*) declare void @__quantum__qis__m__body(%Qubit*, %Result*) #1 @@ -632,7 +641,7 @@ fn simulatable_intrinsic_on_gate_stmt_generates_correct_qir() -> miette::Result< !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} - !4 = !{i32 1, !"int_computations", !"i64"} + !4 = !{i32 5, !"int_computations", !{!"i64"}} "#]].assert_eq(&qsharp); Ok(()) } @@ -1086,23 +1095,28 @@ fn qasm2_barrier_generates_qir() -> miette::Result<(), Vec> { "#; let qsharp = compile_qasm_to_qir(source, Profile::AdaptiveRI)?; - expect![[ - r#" + expect![[r#" %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [6 x i8] c"0_a0r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__barrier__body() call void @__quantum__qis__barrier__body() call void @__quantum__qis__barrier__body() call void @__quantum__qis__barrier__body() call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - call void @__quantum__rt__array_record_output(i64 1, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - ret void + call void @__quantum__rt__array_record_output(i64 1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__barrier__body() declare void @__quantum__qis__m__body(%Qubit*, %Result*) #1 @@ -1122,9 +1136,8 @@ fn qasm2_barrier_generates_qir() -> miette::Result<(), Vec> { !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} - !4 = !{i32 1, !"int_computations", !"i64"} - "# - ]] + !4 = !{i32 5, !"int_computations", !{!"i64"}} + "#]] .assert_eq(&qsharp); Ok(()) } @@ -1351,15 +1364,21 @@ fn qasm2_simulatable_intrinsic_on_gate_stmt_generates_correct_qir() %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [6 x i8] c"0_a0r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @my_gate(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - call void @__quantum__rt__array_record_output(i64 1, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - ret void + call void @__quantum__rt__array_record_output(i64 1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @my_gate(%Qubit*) declare void @__quantum__qis__m__body(%Qubit*, %Result*) #1 @@ -1379,7 +1398,7 @@ fn qasm2_simulatable_intrinsic_on_gate_stmt_generates_correct_qir() !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} - !4 = !{i32 1, !"int_computations", !"i64"} + !4 = !{i32 5, !"int_computations", !{!"i64"}} "#]].assert_eq(&qsharp); Ok(()) } diff --git a/source/compiler/qsc_qasm/src/tests/statement/reset.rs b/source/compiler/qsc_qasm/src/tests/statement/reset.rs index 1f91838e10..f298dece76 100644 --- a/source/compiler/qsc_qasm/src/tests/statement/reset.rs +++ b/source/compiler/qsc_qasm/src/tests/statement/reset.rs @@ -67,20 +67,25 @@ fn reset_with_base_profile_is_rewritten_without_resets() -> miette::Result<(), V "#; let qir = compile_qasm_to_qir(source, Profile::Base)?; - expect![[ - r#" + expect![[r#" %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [6 x i8] c"0_a0r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - call void @__quantum__rt__array_record_output(i64 1, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - ret void + call void @__quantum__rt__array_record_output(i64 1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__h__body(%Qubit*) declare void @__quantum__qis__m__body(%Qubit*, %Result*) #1 @@ -100,8 +105,7 @@ fn reset_with_base_profile_is_rewritten_without_resets() -> miette::Result<(), V !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} -"# - ]] + "#]] .assert_eq(&qir); Ok(()) @@ -120,21 +124,26 @@ fn reset_with_adaptive_ri_profile_generates_reset_qir() -> miette::Result<(), Ve "#; let qir = compile_qasm_to_qir(source, Profile::AdaptiveRI)?; - expect![ - r#" + expect![[r#" %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\00" + @0 = internal constant [6 x i8] c"0_a0r\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - call void @__quantum__rt__array_record_output(i64 1, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - ret void + call void @__quantum__rt__array_record_output(i64 1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__reset__body(%Qubit*) #1 declare void @__quantum__qis__h__body(%Qubit*) @@ -156,9 +165,8 @@ fn reset_with_adaptive_ri_profile_generates_reset_qir() -> miette::Result<(), Ve !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} - !4 = !{i32 1, !"int_computations", !"i64"} -"# - ] + !4 = !{i32 5, !"int_computations", !{!"i64"}} + "#]] .assert_eq(&qir); Ok(()) diff --git a/source/compiler/qsc_rir/src/builder.rs b/source/compiler/qsc_rir/src/builder.rs index d2ee3a74bf..60d72fb5a5 100644 --- a/source/compiler/qsc_rir/src/builder.rs +++ b/source/compiler/qsc_rir/src/builder.rs @@ -99,7 +99,7 @@ pub fn reset_decl() -> Callable { #[must_use] pub fn read_result_decl() -> Callable { Callable { - name: "__quantum__qis__read_result__body".to_string(), + name: "__quantum__rt__read_result".to_string(), input_type: vec![Ty::Result], output_type: Some(Ty::Boolean), body: None, @@ -107,6 +107,17 @@ pub fn read_result_decl() -> Callable { } } +#[must_use] +pub fn initialize_decl() -> Callable { + Callable { + name: "__quantum__rt__initialize".to_string(), + input_type: vec![Ty::Pointer], + output_type: None, + body: None, + call_type: CallableType::Regular, + } +} + #[must_use] pub fn result_record_decl() -> Callable { Callable { @@ -183,7 +194,7 @@ pub fn new_program() -> Program { Callable { name: "main".to_string(), input_type: Vec::new(), - output_type: None, + output_type: Some(Ty::Integer), body: Some(BlockId(0)), call_type: CallableType::Regular, }, @@ -206,11 +217,12 @@ pub fn bell_program() -> Program { Callable { name: "main".to_string(), input_type: vec![], - output_type: None, + output_type: Some(Ty::Integer), body: Some(BlockId(0)), call_type: CallableType::Regular, }, ); + program.tags = vec!["0_a".to_string(), "1_a0r".to_string(), "2_a1r".to_string()]; program.entry = CallableId(5); program.blocks.insert( BlockId(0), @@ -248,7 +260,7 @@ pub fn bell_program() -> Program { CallableId(3), vec![ Operand::Literal(Literal::Integer(2)), - Operand::Literal(Literal::Pointer), + Operand::Literal(Literal::Tag(0, 3)), ], None, ), @@ -256,7 +268,7 @@ pub fn bell_program() -> Program { CallableId(4), vec![ Operand::Literal(Literal::Result(0)), - Operand::Literal(Literal::Pointer), + Operand::Literal(Literal::Tag(1, 5)), ], None, ), @@ -264,7 +276,7 @@ pub fn bell_program() -> Program { CallableId(4), vec![ Operand::Literal(Literal::Result(1)), - Operand::Literal(Literal::Pointer), + Operand::Literal(Literal::Tag(2, 5)), ], None, ), @@ -295,11 +307,12 @@ pub fn teleport_program() -> Program { Callable { name: "main".to_string(), input_type: vec![], - output_type: None, + output_type: Some(Ty::Integer), body: Some(BlockId(0)), call_type: CallableType::Regular, }, ); + program.tags = vec!["0_r".to_string()]; program.entry = CallableId(7); program.blocks.insert( BlockId(0), @@ -427,7 +440,7 @@ pub fn teleport_program() -> Program { CallableId(6), vec![ Operand::Literal(Literal::Result(2)), - Operand::Literal(Literal::Pointer), + Operand::Literal(Literal::Tag(0, 3)), ], None, ), diff --git a/source/compiler/qsc_rir/src/passes/reindex_qubits/tests.rs b/source/compiler/qsc_rir/src/passes/reindex_qubits/tests.rs index 2d35c23877..0445b249e9 100644 --- a/source/compiler/qsc_rir/src/passes/reindex_qubits/tests.rs +++ b/source/compiler/qsc_rir/src/passes/reindex_qubits/tests.rs @@ -414,7 +414,7 @@ fn qubit_reindexed_across_branches() { output_type: body: Callable 2: Callable: - name: __quantum__qis__read_result__body + name: __quantum__rt__read_result call_type: Readout input_type: [0]: Result @@ -439,7 +439,9 @@ fn qubit_reindexed_across_branches() { config: Config: capabilities: Base num_qubits: 1 - num_results: 3"#]] + num_results: 3 + tags: + "#]] .assert_eq(&program.to_string()); // After diff --git a/source/compiler/qsc_rir/src/passes/remap_block_ids/tests.rs b/source/compiler/qsc_rir/src/passes/remap_block_ids/tests.rs index 2345e2cc53..1dda127506 100644 --- a/source/compiler/qsc_rir/src/passes/remap_block_ids/tests.rs +++ b/source/compiler/qsc_rir/src/passes/remap_block_ids/tests.rs @@ -56,7 +56,9 @@ fn remap_block_ids_no_changes() { config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); remap_block_ids(&mut program); @@ -80,7 +82,9 @@ fn remap_block_ids_no_changes() { config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); } @@ -128,7 +132,9 @@ fn remap_block_ids_out_of_order_no_branches() { config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); remap_block_ids(&mut program); @@ -152,7 +158,9 @@ fn remap_block_ids_out_of_order_no_branches() { config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); } @@ -213,7 +221,9 @@ fn remap_block_ids_out_of_order_with_one_branch() { config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); // After @@ -240,7 +250,9 @@ fn remap_block_ids_out_of_order_with_one_branch() { config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); } @@ -296,7 +308,9 @@ fn remap_block_ids_simple_loop() { config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); // After @@ -321,7 +335,9 @@ fn remap_block_ids_simple_loop() { config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); } @@ -364,7 +380,9 @@ fn remap_block_ids_infinite_loop() { config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); // After @@ -387,7 +405,9 @@ fn remap_block_ids_infinite_loop() { config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); } @@ -451,7 +471,9 @@ fn remap_block_ids_nested_branching_loops() { config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); // After @@ -476,7 +498,9 @@ fn remap_block_ids_nested_branching_loops() { config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); } @@ -579,7 +603,9 @@ fn remap_block_ids_ensures_acyclic_program_gets_topological_ordering() { config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); // After @@ -616,6 +642,8 @@ fn remap_block_ids_ensures_acyclic_program_gets_topological_ordering() { config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); } diff --git a/source/compiler/qsc_rir/src/passes/simplify_control_flow/tests.rs b/source/compiler/qsc_rir/src/passes/simplify_control_flow/tests.rs index 3f58410082..b579b5d709 100644 --- a/source/compiler/qsc_rir/src/passes/simplify_control_flow/tests.rs +++ b/source/compiler/qsc_rir/src/passes/simplify_control_flow/tests.rs @@ -73,7 +73,9 @@ fn simplify_control_flow_removes_single_redundant_block() { config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); // After @@ -90,7 +92,9 @@ fn simplify_control_flow_removes_single_redundant_block() { config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); } @@ -155,7 +159,9 @@ fn simplify_control_flow_removes_multiple_redundant_blocks() { config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); // After @@ -173,7 +179,9 @@ fn simplify_control_flow_removes_multiple_redundant_blocks() { config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); } @@ -293,7 +301,9 @@ fn simplify_control_flow_removes_redundant_blocks_across_branches() { config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); // After @@ -318,7 +328,9 @@ fn simplify_control_flow_removes_redundant_blocks_across_branches() { config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); } @@ -444,7 +456,9 @@ fn simplify_control_flow_removes_redundant_blocks_across_out_of_order_branches() config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); // After @@ -469,6 +483,8 @@ fn simplify_control_flow_removes_redundant_blocks_across_out_of_order_branches() config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); } diff --git a/source/compiler/qsc_rir/src/passes/ssa_transform/tests.rs b/source/compiler/qsc_rir/src/passes/ssa_transform/tests.rs index a1bd6e88bb..1d135b19d0 100644 --- a/source/compiler/qsc_rir/src/passes/ssa_transform/tests.rs +++ b/source/compiler/qsc_rir/src/passes/ssa_transform/tests.rs @@ -97,7 +97,7 @@ fn ssa_transform_removes_store_in_single_block_program() { name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: name: dynamic_bool @@ -114,7 +114,9 @@ fn ssa_transform_removes_store_in_single_block_program() { config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); // After @@ -127,7 +129,7 @@ fn ssa_transform_removes_store_in_single_block_program() { name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: name: dynamic_bool @@ -143,7 +145,9 @@ fn ssa_transform_removes_store_in_single_block_program() { config: Config: capabilities: TargetCapabilityFlags(Adaptive | IntegerComputations | FloatingPointComputations | BackwardsBranching | HigherLevelConstructs | QubitReset) num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); } @@ -245,7 +249,7 @@ fn ssa_transform_removes_multiple_stores_in_single_block_program() { name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: name: dynamic_bool @@ -266,7 +270,9 @@ fn ssa_transform_removes_multiple_stores_in_single_block_program() { config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); // After @@ -279,7 +285,7 @@ fn ssa_transform_removes_multiple_stores_in_single_block_program() { name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: name: dynamic_bool @@ -297,7 +303,9 @@ fn ssa_transform_removes_multiple_stores_in_single_block_program() { config: Config: capabilities: TargetCapabilityFlags(Adaptive | IntegerComputations | FloatingPointComputations | BackwardsBranching | HigherLevelConstructs | QubitReset) num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); } @@ -404,7 +412,7 @@ fn ssa_transform_store_dominating_usage_propagates_to_successor_blocks() { name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: name: dynamic_bool @@ -429,7 +437,9 @@ fn ssa_transform_store_dominating_usage_propagates_to_successor_blocks() { config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); // After @@ -442,7 +452,7 @@ fn ssa_transform_store_dominating_usage_propagates_to_successor_blocks() { name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: name: dynamic_bool @@ -466,7 +476,9 @@ fn ssa_transform_store_dominating_usage_propagates_to_successor_blocks() { config: Config: capabilities: TargetCapabilityFlags(Adaptive | IntegerComputations | FloatingPointComputations | BackwardsBranching | HigherLevelConstructs | QubitReset) num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); } @@ -548,7 +560,7 @@ fn ssa_transform_store_dominating_usage_propagates_to_successor_blocks_without_i name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: name: dynamic_bool @@ -571,7 +583,9 @@ fn ssa_transform_store_dominating_usage_propagates_to_successor_blocks_without_i config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); // After @@ -584,7 +598,7 @@ fn ssa_transform_store_dominating_usage_propagates_to_successor_blocks_without_i name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: name: dynamic_bool @@ -606,7 +620,9 @@ fn ssa_transform_store_dominating_usage_propagates_to_successor_blocks_without_i config: Config: capabilities: TargetCapabilityFlags(Adaptive | IntegerComputations | FloatingPointComputations | BackwardsBranching | HigherLevelConstructs | QubitReset) num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); } @@ -733,7 +749,7 @@ fn ssa_transform_inserts_phi_for_store_not_dominating_usage() { name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: name: dynamic_bool @@ -760,7 +776,9 @@ fn ssa_transform_inserts_phi_for_store_not_dominating_usage() { config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); // After @@ -773,7 +791,7 @@ fn ssa_transform_inserts_phi_for_store_not_dominating_usage() { name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: name: dynamic_bool @@ -798,7 +816,9 @@ fn ssa_transform_inserts_phi_for_store_not_dominating_usage() { config: Config: capabilities: TargetCapabilityFlags(Adaptive | IntegerComputations | FloatingPointComputations | BackwardsBranching | HigherLevelConstructs | QubitReset) num_qubits: 0 - num_results: 0"#]].assert_eq(&program.to_string()); + num_results: 0 + tags: + "#]].assert_eq(&program.to_string()); } #[test] @@ -901,7 +921,7 @@ fn ssa_transform_inserts_phi_for_store_not_dominating_usage_in_one_branch() { name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: name: dynamic_bool @@ -926,7 +946,9 @@ fn ssa_transform_inserts_phi_for_store_not_dominating_usage_in_one_branch() { config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); // After @@ -939,7 +961,7 @@ fn ssa_transform_inserts_phi_for_store_not_dominating_usage_in_one_branch() { name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: name: dynamic_bool @@ -963,7 +985,9 @@ fn ssa_transform_inserts_phi_for_store_not_dominating_usage_in_one_branch() { config: Config: capabilities: TargetCapabilityFlags(Adaptive | IntegerComputations | FloatingPointComputations | BackwardsBranching | HigherLevelConstructs | QubitReset) num_qubits: 0 - num_results: 0"#]].assert_eq(&program.to_string()); + num_results: 0 + tags: + "#]].assert_eq(&program.to_string()); } #[test] @@ -1138,7 +1162,7 @@ fn ssa_transform_inserts_phi_for_node_with_many_predecessors() { name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: name: dynamic_bool @@ -1175,7 +1199,9 @@ fn ssa_transform_inserts_phi_for_node_with_many_predecessors() { config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); // After @@ -1188,7 +1214,7 @@ fn ssa_transform_inserts_phi_for_node_with_many_predecessors() { name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: name: dynamic_bool @@ -1222,7 +1248,9 @@ fn ssa_transform_inserts_phi_for_node_with_many_predecessors() { config: Config: capabilities: TargetCapabilityFlags(Adaptive | IntegerComputations | FloatingPointComputations | BackwardsBranching | HigherLevelConstructs | QubitReset) num_qubits: 0 - num_results: 0"#]].assert_eq(&program.to_string()); + num_results: 0 + tags: + "#]].assert_eq(&program.to_string()); } #[test] @@ -1368,7 +1396,7 @@ fn ssa_transform_inserts_phi_for_multiple_stored_values() { name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: name: dynamic_bool @@ -1397,7 +1425,9 @@ fn ssa_transform_inserts_phi_for_multiple_stored_values() { config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); // After @@ -1410,7 +1440,7 @@ fn ssa_transform_inserts_phi_for_multiple_stored_values() { name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: name: dynamic_bool @@ -1437,7 +1467,9 @@ fn ssa_transform_inserts_phi_for_multiple_stored_values() { config: Config: capabilities: TargetCapabilityFlags(Adaptive | IntegerComputations | FloatingPointComputations | BackwardsBranching | HigherLevelConstructs | QubitReset) num_qubits: 0 - num_results: 0"#]].assert_eq(&program.to_string()); + num_results: 0 + tags: + "#]].assert_eq(&program.to_string()); } #[test] @@ -1674,7 +1706,7 @@ fn ssa_transform_inserts_phi_nodes_in_successive_blocks_for_chained_branches() { name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: name: dynamic_bool @@ -1717,7 +1749,9 @@ fn ssa_transform_inserts_phi_nodes_in_successive_blocks_for_chained_branches() { config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); // After @@ -1730,7 +1764,7 @@ fn ssa_transform_inserts_phi_nodes_in_successive_blocks_for_chained_branches() { name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: name: dynamic_bool @@ -1766,7 +1800,9 @@ fn ssa_transform_inserts_phi_nodes_in_successive_blocks_for_chained_branches() { config: Config: capabilities: TargetCapabilityFlags(Adaptive | IntegerComputations | FloatingPointComputations | BackwardsBranching | HigherLevelConstructs | QubitReset) num_qubits: 0 - num_results: 0"#]].assert_eq(&program.to_string()); + num_results: 0 + tags: + "#]].assert_eq(&program.to_string()); } #[test] @@ -1967,7 +2003,7 @@ fn ssa_transform_inerts_phi_nodes_for_early_return_graph_pattern() { name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: name: dynamic_bool @@ -2005,7 +2041,9 @@ fn ssa_transform_inerts_phi_nodes_for_early_return_graph_pattern() { config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); // After @@ -2018,7 +2056,7 @@ fn ssa_transform_inerts_phi_nodes_for_early_return_graph_pattern() { name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: name: dynamic_bool @@ -2053,7 +2091,9 @@ fn ssa_transform_inerts_phi_nodes_for_early_return_graph_pattern() { config: Config: capabilities: TargetCapabilityFlags(Adaptive | IntegerComputations | FloatingPointComputations | BackwardsBranching | HigherLevelConstructs | QubitReset) num_qubits: 0 - num_results: 0"#]].assert_eq(&program.to_string()); + num_results: 0 + tags: + "#]].assert_eq(&program.to_string()); } #[test] @@ -2156,7 +2196,7 @@ fn ssa_transform_propagates_updates_from_multiple_predecessors_to_later_single_s name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: name: dynamic_bool @@ -2182,7 +2222,9 @@ fn ssa_transform_propagates_updates_from_multiple_predecessors_to_later_single_s config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); // After @@ -2195,7 +2237,7 @@ fn ssa_transform_propagates_updates_from_multiple_predecessors_to_later_single_s name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: name: dynamic_bool @@ -2219,7 +2261,9 @@ fn ssa_transform_propagates_updates_from_multiple_predecessors_to_later_single_s config: Config: capabilities: TargetCapabilityFlags(Adaptive | IntegerComputations | FloatingPointComputations | BackwardsBranching | HigherLevelConstructs | QubitReset) num_qubits: 0 - num_results: 0"#]].assert_eq(&program.to_string()); + num_results: 0 + tags: + "#]].assert_eq(&program.to_string()); } #[test] @@ -2290,7 +2334,7 @@ fn ssa_transform_maps_store_instrs_that_use_values_from_other_store_instrs() { name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: name: dynamic_bool @@ -2308,7 +2352,9 @@ fn ssa_transform_maps_store_instrs_that_use_values_from_other_store_instrs() { config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); // After @@ -2321,7 +2367,7 @@ fn ssa_transform_maps_store_instrs_that_use_values_from_other_store_instrs() { name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: name: dynamic_bool @@ -2337,7 +2383,9 @@ fn ssa_transform_maps_store_instrs_that_use_values_from_other_store_instrs() { config: Config: capabilities: TargetCapabilityFlags(Adaptive | IntegerComputations | FloatingPointComputations | BackwardsBranching | HigherLevelConstructs | QubitReset) num_qubits: 0 - num_results: 0"#]].assert_eq(&program.to_string()); + num_results: 0 + tags: + "#]].assert_eq(&program.to_string()); } #[test] @@ -2434,7 +2482,7 @@ fn ssa_transform_maps_store_with_variable_from_store_in_conditional_to_phi_node( name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: name: dynamic_bool @@ -2457,7 +2505,9 @@ fn ssa_transform_maps_store_with_variable_from_store_in_conditional_to_phi_node( config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); // After @@ -2470,7 +2520,7 @@ fn ssa_transform_maps_store_with_variable_from_store_in_conditional_to_phi_node( name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: name: dynamic_bool @@ -2491,7 +2541,9 @@ fn ssa_transform_maps_store_with_variable_from_store_in_conditional_to_phi_node( config: Config: capabilities: TargetCapabilityFlags(Adaptive | IntegerComputations | FloatingPointComputations | BackwardsBranching | HigherLevelConstructs | QubitReset) num_qubits: 0 - num_results: 0"#]].assert_eq(&program.to_string()); + num_results: 0 + tags: + "#]].assert_eq(&program.to_string()); } #[test] @@ -2592,7 +2644,7 @@ fn ssa_transform_allows_point_in_time_copy_of_dynamic_variable() { name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: name: dynamic_bool @@ -2613,7 +2665,9 @@ fn ssa_transform_allows_point_in_time_copy_of_dynamic_variable() { config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); // After @@ -2626,7 +2680,7 @@ fn ssa_transform_allows_point_in_time_copy_of_dynamic_variable() { name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: name: dynamic_bool @@ -2644,7 +2698,9 @@ fn ssa_transform_allows_point_in_time_copy_of_dynamic_variable() { config: Config: capabilities: TargetCapabilityFlags(Adaptive | IntegerComputations | FloatingPointComputations | BackwardsBranching | HigherLevelConstructs | QubitReset) num_qubits: 0 - num_results: 0"#]].assert_eq(&program.to_string()); + num_results: 0 + tags: + "#]].assert_eq(&program.to_string()); } #[test] @@ -2776,7 +2832,7 @@ fn ssa_transform_propagates_phi_var_to_successor_blocks_across_sequential_branch name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: name: dynamic_bool @@ -2813,7 +2869,9 @@ fn ssa_transform_propagates_phi_var_to_successor_blocks_across_sequential_branch config: Config: capabilities: Base num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); // After @@ -2826,7 +2884,7 @@ fn ssa_transform_propagates_phi_var_to_successor_blocks_across_sequential_branch name: main call_type: Regular input_type: - output_type: + output_type: Integer body: 0 Callable 1: Callable: name: dynamic_bool @@ -2861,6 +2919,8 @@ fn ssa_transform_propagates_phi_var_to_successor_blocks_across_sequential_branch config: Config: capabilities: TargetCapabilityFlags(Adaptive | IntegerComputations | FloatingPointComputations | BackwardsBranching | HigherLevelConstructs | QubitReset) num_qubits: 0 - num_results: 0"#]] + num_results: 0 + tags: + "#]] .assert_eq(&program.to_string()); } diff --git a/source/compiler/qsc_rir/src/rir.rs b/source/compiler/qsc_rir/src/rir.rs index 1a1ffe1301..5b2af6bea9 100644 --- a/source/compiler/qsc_rir/src/rir.rs +++ b/source/compiler/qsc_rir/src/rir.rs @@ -14,6 +14,7 @@ pub struct Program { pub config: Config, pub num_qubits: u32, pub num_results: u32, + pub tags: Vec, } impl Display for Program { @@ -37,6 +38,11 @@ impl Display for Program { write!(indent, "\nconfig: {}", self.config)?; write!(indent, "\nnum_qubits: {}", self.num_qubits)?; write!(indent, "\nnum_results: {}", self.num_results)?; + writeln!(indent, "\ntags:")?; + indent = set_indentation(indent, 2); + for (idx, tag) in self.tags.iter().enumerate() { + writeln!(indent, "[{idx}]: {tag}")?; + } Ok(()) } } @@ -607,7 +613,7 @@ impl Operand { Literal::Bool(_) => Ty::Boolean, Literal::Integer(_) => Ty::Integer, Literal::Double(_) => Ty::Double, - Literal::Pointer => Ty::Pointer, + Literal::Pointer | Literal::Tag(..) | Literal::EmptyTag => Ty::Pointer, }, Operand::Variable(var) => var.ty, } @@ -621,6 +627,8 @@ pub enum Literal { Bool(bool), Integer(i64), Double(f64), + Tag(usize, usize), + EmptyTag, Pointer, } @@ -632,6 +640,8 @@ impl Display for Literal { Self::Bool(b) => write!(f, "Bool({b})")?, Self::Integer(i) => write!(f, "Integer({i})")?, Self::Double(d) => write!(f, "Double({d})")?, + Self::Tag(idx, len) => write!(f, "Tag({idx}, {len})")?, + Self::EmptyTag => write!(f, "EmptyTag")?, Self::Pointer => write!(f, "Pointer")?, } Ok(()) @@ -679,6 +689,14 @@ impl PartialEq for Literal { false } } + Self::Tag(self_tag_idx, self_tag_len) => { + if let Self::Tag(other_tag_idx, other_tag_len) = other { + self_tag_idx == other_tag_idx && self_tag_len == other_tag_len + } else { + false + } + } + Self::EmptyTag => *other == Self::EmptyTag, } } } diff --git a/source/pip/tests-integration/interop_qiskit/resources/custom_intrinsics.ll b/source/pip/tests-integration/interop_qiskit/resources/custom_intrinsics.ll index ec42527787..71bc1f9838 100644 --- a/source/pip/tests-integration/interop_qiskit/resources/custom_intrinsics.ll +++ b/source/pip/tests-integration/interop_qiskit/resources/custom_intrinsics.ll @@ -1,15 +1,21 @@ %Result = type opaque %Qubit = type opaque -define void @ENTRYPOINT__main() #0 { +@empty_tag = internal constant [1 x i8] c"\00" +@0 = internal constant [6 x i8] c"0_a0r\00" + +define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @my_gate(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - call void @__quantum__rt__array_record_output(i64 1, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - ret void + call void @__quantum__rt__array_record_output(i64 1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + ret i64 0 } +declare void @__quantum__rt__initialize(i8*) + declare void @my_gate(%Qubit*) declare void @__quantum__qis__m__body(%Qubit*, %Result*) #1 @@ -29,4 +35,4 @@ attributes #1 = { "irreversible" } !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} -!4 = !{i32 1, !"int_computations", !"i64"} +!4 = !{i32 5, !"int_computations", !{!"i64"}} diff --git a/source/pip/tests-integration/interop_qiskit/test_qir.py b/source/pip/tests-integration/interop_qiskit/test_qir.py index 40fbcebc3d..a8b8b06db3 100644 --- a/source/pip/tests-integration/interop_qiskit/test_qir.py +++ b/source/pip/tests-integration/interop_qiskit/test_qir.py @@ -230,5 +230,5 @@ def test_qir_re_output_single_unit_tuple() -> None: res = backend.qir(circuit, output_semantics=output_semantics) assert res is not None - call = "call void @__quantum__rt__tuple_record_output(i64 0, i8* null)" + call = "call void @__quantum__rt__tuple_record_output(i64 0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0))" assert call in res diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/ArithmeticOps.ll b/source/pip/tests-integration/resources/adaptive_ri/output/ArithmeticOps.ll index 48cb6e99ca..efa6cecefd 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/ArithmeticOps.ll +++ b/source/pip/tests-integration/resources/adaptive_ri/output/ArithmeticOps.ll @@ -1,8 +1,15 @@ %Result = type opaque %Qubit = type opaque -define void @ENTRYPOINT__main() #0 { +@empty_tag = internal constant [1 x i8] c"\00" +@0 = internal constant [6 x i8] c"0_t0i\00" +@1 = internal constant [6 x i8] c"1_t1i\00" +@2 = internal constant [6 x i8] c"2_t2i\00" +@3 = internal constant [6 x i8] c"3_t3i\00" + +define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 2 to %Qubit*)) @@ -13,7 +20,7 @@ block_0: call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 2 to %Qubit*), %Result* inttoptr (i64 2 to %Result*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 3 to %Qubit*), %Result* inttoptr (i64 3 to %Result*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 4 to %Qubit*), %Result* inttoptr (i64 4 to %Result*)) - %var_8 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 0 to %Result*)) + %var_8 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 0 to %Result*)) br i1 %var_8, label %block_1, label %block_2 block_1: br label %block_2 @@ -22,7 +29,7 @@ block_2: %var_38 = phi i64 [10, %block_0], [8, %block_1] %var_37 = phi i64 [0, %block_0], [5, %block_1] %var_36 = phi i64 [0, %block_0], [1, %block_1] - %var_10 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 1 to %Result*)) + %var_10 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 1 to %Result*)) br i1 %var_10, label %block_3, label %block_4 block_3: %var_12 = add i64 %var_36, 1 @@ -35,7 +42,7 @@ block_4: %var_42 = phi i64 [%var_38, %block_2], [%var_14, %block_3] %var_41 = phi i64 [%var_37, %block_2], [%var_13, %block_3] %var_40 = phi i64 [%var_36, %block_2], [%var_12, %block_3] - %var_16 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 2 to %Result*)) + %var_16 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 2 to %Result*)) br i1 %var_16, label %block_5, label %block_6 block_5: %var_18 = add i64 %var_40, 1 @@ -48,7 +55,7 @@ block_6: %var_46 = phi i64 [%var_42, %block_4], [%var_20, %block_5] %var_45 = phi i64 [%var_41, %block_4], [%var_19, %block_5] %var_44 = phi i64 [%var_40, %block_4], [%var_18, %block_5] - %var_22 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 3 to %Result*)) + %var_22 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 3 to %Result*)) br i1 %var_22, label %block_7, label %block_8 block_7: %var_24 = add i64 %var_44, 1 @@ -61,7 +68,7 @@ block_8: %var_50 = phi i64 [%var_46, %block_6], [%var_26, %block_7] %var_49 = phi i64 [%var_45, %block_6], [%var_25, %block_7] %var_48 = phi i64 [%var_44, %block_6], [%var_24, %block_7] - %var_28 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 4 to %Result*)) + %var_28 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 4 to %Result*)) br i1 %var_28, label %block_9, label %block_10 block_9: %var_30 = add i64 %var_48, 1 @@ -79,19 +86,21 @@ block_10: call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 2 to %Qubit*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 3 to %Qubit*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 4 to %Qubit*)) - call void @__quantum__rt__tuple_record_output(i64 4, i8* null) - call void @__quantum__rt__int_record_output(i64 %var_52, i8* null) - call void @__quantum__rt__int_record_output(i64 %var_53, i8* null) - call void @__quantum__rt__int_record_output(i64 %var_54, i8* null) - call void @__quantum__rt__int_record_output(i64 %var_55, i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 4, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__int_record_output(i64 %var_52, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__int_record_output(i64 %var_53, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + call void @__quantum__rt__int_record_output(i64 %var_54, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @2, i64 0, i64 0)) + call void @__quantum__rt__int_record_output(i64 %var_55, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @3, i64 0, i64 0)) + ret i64 0 } +declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__x__body(%Qubit*) declare void @__quantum__qis__m__body(%Qubit*, %Result*) #1 -declare i1 @__quantum__qis__read_result__body(%Result*) +declare i1 @__quantum__rt__read_result(%Result*) declare void @__quantum__qis__reset__body(%Qubit*) #1 @@ -110,4 +119,4 @@ attributes #1 = { "irreversible" } !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} -!4 = !{i32 1, !"int_computations", !"i64"} +!4 = !{i32 5, !"int_computations", !{!"i64"}} diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/ArithmeticOps.out b/source/pip/tests-integration/resources/adaptive_ri/output/ArithmeticOps.out index 963ba77ac9..af47c80431 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/ArithmeticOps.out +++ b/source/pip/tests-integration/resources/adaptive_ri/output/ArithmeticOps.out @@ -4,9 +4,9 @@ METADATA output_labeling_schema METADATA qir_profiles adaptive_profile METADATA required_num_qubits 5 METADATA required_num_results 5 -OUTPUT TUPLE 4 -OUTPUT INT 5 -OUTPUT INT 25 -OUTPUT INT 0 -OUTPUT INT 243 +OUTPUT TUPLE 4 +OUTPUT INT 5 0_t0i +OUTPUT INT 25 1_t1i +OUTPUT INT 0 2_t2i +OUTPUT INT 243 3_t3i END 0 diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/BernsteinVaziraniNISQ.ll b/source/pip/tests-integration/resources/adaptive_ri/output/BernsteinVaziraniNISQ.ll index 69cf1cc955..d3616516e9 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/BernsteinVaziraniNISQ.ll +++ b/source/pip/tests-integration/resources/adaptive_ri/output/BernsteinVaziraniNISQ.ll @@ -1,8 +1,16 @@ %Result = type opaque %Qubit = type opaque -define void @ENTRYPOINT__main() #0 { +@empty_tag = internal constant [1 x i8] c"\00" +@0 = internal constant [6 x i8] c"0_a0r\00" +@1 = internal constant [6 x i8] c"1_a1r\00" +@2 = internal constant [6 x i8] c"2_a2r\00" +@3 = internal constant [6 x i8] c"3_a3r\00" +@4 = internal constant [6 x i8] c"4_a4r\00" + +define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 5 to %Qubit*)) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 1 to %Qubit*)) @@ -24,15 +32,17 @@ block_0: call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 3 to %Qubit*), %Result* inttoptr (i64 3 to %Result*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 4 to %Qubit*), %Result* inttoptr (i64 4 to %Result*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 5 to %Qubit*)) - call void @__quantum__rt__array_record_output(i64 5, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* null) - ret void + call void @__quantum__rt__array_record_output(i64 5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @2, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @3, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @4, i64 0, i64 0)) + ret i64 0 } +declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__x__body(%Qubit*) declare void @__quantum__qis__h__body(%Qubit*) @@ -58,4 +68,4 @@ attributes #1 = { "irreversible" } !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} -!4 = !{i32 1, !"int_computations", !"i64"} +!4 = !{i32 5, !"int_computations", !{!"i64"}} diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/BernsteinVaziraniNISQ.out b/source/pip/tests-integration/resources/adaptive_ri/output/BernsteinVaziraniNISQ.out index 79d40f1a26..f38ac80bb3 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/BernsteinVaziraniNISQ.out +++ b/source/pip/tests-integration/resources/adaptive_ri/output/BernsteinVaziraniNISQ.out @@ -4,10 +4,10 @@ METADATA output_labeling_schema METADATA qir_profiles adaptive_profile METADATA required_num_qubits 6 METADATA required_num_results 5 -OUTPUT ARRAY 5 -OUTPUT RESULT 1 -OUTPUT RESULT 0 -OUTPUT RESULT 1 -OUTPUT RESULT 0 -OUTPUT RESULT 1 +OUTPUT ARRAY 5 +OUTPUT RESULT 1 0_a0r +OUTPUT RESULT 0 1_a1r +OUTPUT RESULT 1 2_a2r +OUTPUT RESULT 0 3_a3r +OUTPUT RESULT 1 4_a4r END 0 diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/ConstantFolding.ll b/source/pip/tests-integration/resources/adaptive_ri/output/ConstantFolding.ll index 27f3219d4c..0a084401a1 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/ConstantFolding.ll +++ b/source/pip/tests-integration/resources/adaptive_ri/output/ConstantFolding.ll @@ -1,8 +1,15 @@ %Result = type opaque %Qubit = type opaque -define void @ENTRYPOINT__main() #0 { +@empty_tag = internal constant [1 x i8] c"\00" +@0 = internal constant [6 x i8] c"0_a0r\00" +@1 = internal constant [6 x i8] c"1_a1r\00" +@2 = internal constant [6 x i8] c"2_a2r\00" +@3 = internal constant [6 x i8] c"3_a3r\00" + +define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__cx__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__cx__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Qubit* inttoptr (i64 2 to %Qubit*)) @@ -31,14 +38,16 @@ block_0: call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 2 to %Qubit*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 3 to %Qubit*)) - call void @__quantum__rt__array_record_output(i64 4, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* null) - ret void + call void @__quantum__rt__array_record_output(i64 4, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @2, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @3, i64 0, i64 0)) + ret i64 0 } +declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__x__body(%Qubit*) declare void @__quantum__qis__cx__body(%Qubit*, %Qubit*) @@ -64,4 +73,4 @@ attributes #1 = { "irreversible" } !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} -!4 = !{i32 1, !"int_computations", !"i64"} +!4 = !{i32 5, !"int_computations", !{!"i64"}} diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/ConstantFolding.out b/source/pip/tests-integration/resources/adaptive_ri/output/ConstantFolding.out index 6540306d87..68a2353638 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/ConstantFolding.out +++ b/source/pip/tests-integration/resources/adaptive_ri/output/ConstantFolding.out @@ -4,9 +4,9 @@ METADATA output_labeling_schema METADATA qir_profiles adaptive_profile METADATA required_num_qubits 4 METADATA required_num_results 4 -OUTPUT ARRAY 4 -OUTPUT RESULT 1 -OUTPUT RESULT 1 -OUTPUT RESULT 1 -OUTPUT RESULT 1 +OUTPUT ARRAY 4 +OUTPUT RESULT 1 0_a0r +OUTPUT RESULT 1 1_a1r +OUTPUT RESULT 1 2_a2r +OUTPUT RESULT 1 3_a3r END 0 diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/CopyAndUpdateExpressions.ll b/source/pip/tests-integration/resources/adaptive_ri/output/CopyAndUpdateExpressions.ll index d41ab82173..899d0cde86 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/CopyAndUpdateExpressions.ll +++ b/source/pip/tests-integration/resources/adaptive_ri/output/CopyAndUpdateExpressions.ll @@ -1,8 +1,16 @@ %Result = type opaque %Qubit = type opaque -define void @ENTRYPOINT__main() #0 { +@empty_tag = internal constant [1 x i8] c"\00" +@0 = internal constant [8 x i8] c"0_t0a0r\00" +@1 = internal constant [8 x i8] c"1_t1a0r\00" +@2 = internal constant [8 x i8] c"2_t2a0r\00" +@3 = internal constant [8 x i8] c"3_t2a1r\00" +@4 = internal constant [8 x i8] c"4_t2a2r\00" + +define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) @@ -14,18 +22,20 @@ block_0: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 4 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 3 to %Qubit*), %Result* inttoptr (i64 5 to %Result*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 4 to %Qubit*), %Result* inttoptr (i64 6 to %Result*)) - call void @__quantum__rt__tuple_record_output(i64 3, i8* null) - call void @__quantum__rt__array_record_output(i64 1, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__array_record_output(i64 1, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - call void @__quantum__rt__array_record_output(i64 3, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 5 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 6 to %Result*), i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__array_record_output(i64 1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__array_record_output(i64 1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @1, i64 0, i64 0)) + call void @__quantum__rt__array_record_output(i64 3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @2, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 5 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @3, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 6 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @4, i64 0, i64 0)) + ret i64 0 } +declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__x__body(%Qubit*) declare void @__quantum__qis__mresetz__body(%Qubit*, %Result*) #1 @@ -49,4 +59,4 @@ attributes #1 = { "irreversible" } !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} -!4 = !{i32 1, !"int_computations", !"i64"} +!4 = !{i32 5, !"int_computations", !{!"i64"}} diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/CopyAndUpdateExpressions.out b/source/pip/tests-integration/resources/adaptive_ri/output/CopyAndUpdateExpressions.out index 81cb73fa43..3d3021c19a 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/CopyAndUpdateExpressions.out +++ b/source/pip/tests-integration/resources/adaptive_ri/output/CopyAndUpdateExpressions.out @@ -4,13 +4,13 @@ METADATA output_labeling_schema METADATA qir_profiles adaptive_profile METADATA required_num_qubits 5 METADATA required_num_results 7 -OUTPUT TUPLE 3 -OUTPUT ARRAY 1 -OUTPUT RESULT 1 -OUTPUT ARRAY 1 -OUTPUT RESULT 0 -OUTPUT ARRAY 3 -OUTPUT RESULT 1 -OUTPUT RESULT 1 -OUTPUT RESULT 1 +OUTPUT TUPLE 3 +OUTPUT ARRAY 1 +OUTPUT RESULT 1 0_t0a0r +OUTPUT ARRAY 1 +OUTPUT RESULT 0 1_t1a0r +OUTPUT ARRAY 3 +OUTPUT RESULT 1 2_t2a0r +OUTPUT RESULT 1 3_t2a1r +OUTPUT RESULT 1 4_t2a2r END 0 diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/DeutschJozsaNISQ.ll b/source/pip/tests-integration/resources/adaptive_ri/output/DeutschJozsaNISQ.ll index 4f038c599c..1d82a7b434 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/DeutschJozsaNISQ.ll +++ b/source/pip/tests-integration/resources/adaptive_ri/output/DeutschJozsaNISQ.ll @@ -1,8 +1,19 @@ %Result = type opaque %Qubit = type opaque -define void @ENTRYPOINT__main() #0 { +@empty_tag = internal constant [1 x i8] c"\00" +@0 = internal constant [8 x i8] c"0_t0a0r\00" +@1 = internal constant [8 x i8] c"1_t0a1r\00" +@2 = internal constant [8 x i8] c"2_t0a2r\00" +@3 = internal constant [8 x i8] c"3_t0a3r\00" +@4 = internal constant [8 x i8] c"4_t1a0r\00" +@5 = internal constant [8 x i8] c"5_t1a1r\00" +@6 = internal constant [8 x i8] c"6_t1a2r\00" +@7 = internal constant [8 x i8] c"7_t1a3r\00" + +define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 4 to %Qubit*)) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 4 to %Qubit*)) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 0 to %Qubit*)) @@ -43,20 +54,22 @@ block_0: call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 2 to %Qubit*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 3 to %Qubit*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 4 to %Qubit*)) - call void @__quantum__rt__tuple_record_output(i64 2, i8* null) - call void @__quantum__rt__array_record_output(i64 4, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* null) - call void @__quantum__rt__array_record_output(i64 4, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 5 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 6 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 7 to %Result*), i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__array_record_output(i64 4, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @1, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @2, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @3, i64 0, i64 0)) + call void @__quantum__rt__array_record_output(i64 4, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @4, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 5 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @5, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 6 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @6, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 7 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @7, i64 0, i64 0)) + ret i64 0 } +declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__x__body(%Qubit*) declare void @__quantum__qis__h__body(%Qubit*) @@ -84,4 +97,4 @@ attributes #1 = { "irreversible" } !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} -!4 = !{i32 1, !"int_computations", !"i64"} +!4 = !{i32 5, !"int_computations", !{!"i64"}} diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/DeutschJozsaNISQ.out b/source/pip/tests-integration/resources/adaptive_ri/output/DeutschJozsaNISQ.out index ffc1eae653..78defd7849 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/DeutschJozsaNISQ.out +++ b/source/pip/tests-integration/resources/adaptive_ri/output/DeutschJozsaNISQ.out @@ -4,15 +4,15 @@ METADATA output_labeling_schema METADATA qir_profiles adaptive_profile METADATA required_num_qubits 5 METADATA required_num_results 8 -OUTPUT TUPLE 2 -OUTPUT ARRAY 4 -OUTPUT RESULT 1 -OUTPUT RESULT 0 -OUTPUT RESULT 0 -OUTPUT RESULT 0 -OUTPUT ARRAY 4 -OUTPUT RESULT 0 -OUTPUT RESULT 0 -OUTPUT RESULT 0 -OUTPUT RESULT 0 +OUTPUT TUPLE 2 +OUTPUT ARRAY 4 +OUTPUT RESULT 1 0_t0a0r +OUTPUT RESULT 0 1_t0a1r +OUTPUT RESULT 0 2_t0a2r +OUTPUT RESULT 0 3_t0a3r +OUTPUT ARRAY 4 +OUTPUT RESULT 0 4_t1a0r +OUTPUT RESULT 0 5_t1a1r +OUTPUT RESULT 0 6_t1a2r +OUTPUT RESULT 0 7_t1a3r END 0 diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/ExpandedTests.ll b/source/pip/tests-integration/resources/adaptive_ri/output/ExpandedTests.ll index 4794a9960c..0d964329b8 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/ExpandedTests.ll +++ b/source/pip/tests-integration/resources/adaptive_ri/output/ExpandedTests.ll @@ -1,8 +1,14 @@ %Result = type opaque %Qubit = type opaque -define void @ENTRYPOINT__main() #0 { +@empty_tag = internal constant [1 x i8] c"\00" +@0 = internal constant [8 x i8] c"0_t0a0r\00" +@1 = internal constant [8 x i8] c"1_t0a1r\00" +@2 = internal constant [6 x i8] c"2_t1r\00" + +define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 2 to %Qubit*)) @@ -36,14 +42,16 @@ block_0: call void @__quantum__qis__cx__body(%Qubit* inttoptr (i64 2 to %Qubit*), %Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 2 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 2 to %Result*)) - call void @__quantum__rt__tuple_record_output(i64 2, i8* null) - call void @__quantum__rt__array_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__array_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @1, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @2, i64 0, i64 0)) + ret i64 0 } +declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__h__body(%Qubit*) declare void @__quantum__qis__x__body(%Qubit*) @@ -81,4 +89,4 @@ attributes #1 = { "irreversible" } !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} -!4 = !{i32 1, !"int_computations", !"i64"} +!4 = !{i32 5, !"int_computations", !{!"i64"}} diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/ExpandedTests.out b/source/pip/tests-integration/resources/adaptive_ri/output/ExpandedTests.out index 31695a48c4..f101117099 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/ExpandedTests.out +++ b/source/pip/tests-integration/resources/adaptive_ri/output/ExpandedTests.out @@ -4,9 +4,9 @@ METADATA output_labeling_schema METADATA qir_profiles adaptive_profile METADATA required_num_qubits 3 METADATA required_num_results 3 -OUTPUT TUPLE 2 -OUTPUT ARRAY 2 -OUTPUT RESULT 0 -OUTPUT RESULT 1 -OUTPUT RESULT 0 +OUTPUT TUPLE 2 +OUTPUT ARRAY 2 +OUTPUT RESULT 0 0_t0a0r +OUTPUT RESULT 1 1_t0a1r +OUTPUT RESULT 0 2_t1r END 0 diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/Functors.ll b/source/pip/tests-integration/resources/adaptive_ri/output/Functors.ll index 7901410523..aeaed7e33e 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/Functors.ll +++ b/source/pip/tests-integration/resources/adaptive_ri/output/Functors.ll @@ -1,8 +1,17 @@ %Result = type opaque %Qubit = type opaque -define void @ENTRYPOINT__main() #0 { +@empty_tag = internal constant [1 x i8] c"\00" +@0 = internal constant [8 x i8] c"0_t0a0r\00" +@1 = internal constant [8 x i8] c"1_t0a1r\00" +@2 = internal constant [8 x i8] c"2_t1a0r\00" +@3 = internal constant [8 x i8] c"3_t1a1r\00" +@4 = internal constant [8 x i8] c"4_t2a0r\00" +@5 = internal constant [8 x i8] c"5_t2a1r\00" + +define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__z__body(%Qubit* inttoptr (i64 1 to %Qubit*)) @@ -64,19 +73,21 @@ block_0: call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 5 to %Qubit*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 6 to %Qubit*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 7 to %Qubit*)) - call void @__quantum__rt__tuple_record_output(i64 3, i8* null) - call void @__quantum__rt__array_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - call void @__quantum__rt__array_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* null) - call void @__quantum__rt__array_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 5 to %Result*), i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__array_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @1, i64 0, i64 0)) + call void @__quantum__rt__array_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @2, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @3, i64 0, i64 0)) + call void @__quantum__rt__array_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @4, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 5 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @5, i64 0, i64 0)) + ret i64 0 } +declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__x__body(%Qubit*) declare void @__quantum__qis__h__body(%Qubit*) @@ -114,4 +125,4 @@ attributes #1 = { "irreversible" } !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} -!4 = !{i32 1, !"int_computations", !"i64"} +!4 = !{i32 5, !"int_computations", !{!"i64"}} diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/Functors.out b/source/pip/tests-integration/resources/adaptive_ri/output/Functors.out index 31048cb0c7..898c34efb4 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/Functors.out +++ b/source/pip/tests-integration/resources/adaptive_ri/output/Functors.out @@ -4,14 +4,14 @@ METADATA output_labeling_schema METADATA qir_profiles adaptive_profile METADATA required_num_qubits 8 METADATA required_num_results 6 -OUTPUT TUPLE 3 -OUTPUT ARRAY 2 -OUTPUT RESULT 0 -OUTPUT RESULT 0 -OUTPUT ARRAY 2 -OUTPUT RESULT 1 -OUTPUT RESULT 1 -OUTPUT ARRAY 2 -OUTPUT RESULT 0 -OUTPUT RESULT 0 +OUTPUT TUPLE 3 +OUTPUT ARRAY 2 +OUTPUT RESULT 0 0_t0a0r +OUTPUT RESULT 0 1_t0a1r +OUTPUT ARRAY 2 +OUTPUT RESULT 1 2_t1a0r +OUTPUT RESULT 1 3_t1a1r +OUTPUT ARRAY 2 +OUTPUT RESULT 0 4_t2a0r +OUTPUT RESULT 0 5_t2a1r END 0 diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/HiddenShiftNISQ.ll b/source/pip/tests-integration/resources/adaptive_ri/output/HiddenShiftNISQ.ll index 8bc3b5d4d0..9c339676ae 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/HiddenShiftNISQ.ll +++ b/source/pip/tests-integration/resources/adaptive_ri/output/HiddenShiftNISQ.ll @@ -1,8 +1,17 @@ %Result = type opaque %Qubit = type opaque -define void @ENTRYPOINT__main() #0 { +@empty_tag = internal constant [1 x i8] c"\00" +@0 = internal constant [6 x i8] c"0_a0r\00" +@1 = internal constant [6 x i8] c"1_a1r\00" +@2 = internal constant [6 x i8] c"2_a2r\00" +@3 = internal constant [6 x i8] c"3_a3r\00" +@4 = internal constant [6 x i8] c"4_a4r\00" +@5 = internal constant [6 x i8] c"5_a5r\00" + +define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 2 to %Qubit*)) @@ -37,16 +46,18 @@ block_0: call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 3 to %Qubit*), %Result* inttoptr (i64 3 to %Result*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 4 to %Qubit*), %Result* inttoptr (i64 4 to %Result*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 5 to %Qubit*), %Result* inttoptr (i64 5 to %Result*)) - call void @__quantum__rt__array_record_output(i64 6, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 5 to %Result*), i8* null) - ret void + call void @__quantum__rt__array_record_output(i64 6, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @2, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @3, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @4, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 5 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @5, i64 0, i64 0)) + ret i64 0 } +declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__h__body(%Qubit*) declare void @__quantum__qis__x__body(%Qubit*) @@ -70,4 +81,4 @@ attributes #1 = { "irreversible" } !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} -!4 = !{i32 1, !"int_computations", !"i64"} +!4 = !{i32 5, !"int_computations", !{!"i64"}} diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/HiddenShiftNISQ.out b/source/pip/tests-integration/resources/adaptive_ri/output/HiddenShiftNISQ.out index 6e2f4aea5a..7240d2a55a 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/HiddenShiftNISQ.out +++ b/source/pip/tests-integration/resources/adaptive_ri/output/HiddenShiftNISQ.out @@ -4,11 +4,11 @@ METADATA output_labeling_schema METADATA qir_profiles adaptive_profile METADATA required_num_qubits 6 METADATA required_num_results 6 -OUTPUT ARRAY 6 -OUTPUT RESULT 1 -OUTPUT RESULT 0 -OUTPUT RESULT 0 -OUTPUT RESULT 0 -OUTPUT RESULT 0 -OUTPUT RESULT 1 +OUTPUT ARRAY 6 +OUTPUT RESULT 1 0_a0r +OUTPUT RESULT 0 1_a1r +OUTPUT RESULT 0 2_a2r +OUTPUT RESULT 0 3_a3r +OUTPUT RESULT 0 4_a4r +OUTPUT RESULT 1 5_a5r END 0 diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/IntegerComparison.ll b/source/pip/tests-integration/resources/adaptive_ri/output/IntegerComparison.ll index 95e95a7e64..683a0c2cae 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/IntegerComparison.ll +++ b/source/pip/tests-integration/resources/adaptive_ri/output/IntegerComparison.ll @@ -1,11 +1,17 @@ %Result = type opaque %Qubit = type opaque -define void @ENTRYPOINT__main() #0 { +@empty_tag = internal constant [1 x i8] c"\00" +@0 = internal constant [6 x i8] c"0_t0b\00" +@1 = internal constant [6 x i8] c"1_t1b\00" +@2 = internal constant [6 x i8] c"2_t2b\00" + +define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - %var_2 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 0 to %Result*)) + %var_2 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 0 to %Result*)) br i1 %var_2, label %block_1, label %block_2 block_1: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) @@ -14,7 +20,7 @@ block_2: %var_34 = phi i64 [0, %block_0], [1, %block_1] call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - %var_4 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 1 to %Result*)) + %var_4 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 1 to %Result*)) br i1 %var_4, label %block_3, label %block_4 block_3: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) @@ -24,7 +30,7 @@ block_4: %var_35 = phi i64 [%var_34, %block_2], [%var_6, %block_3] call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 2 to %Result*)) - %var_7 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 2 to %Result*)) + %var_7 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 2 to %Result*)) br i1 %var_7, label %block_5, label %block_6 block_5: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) @@ -34,7 +40,7 @@ block_6: %var_36 = phi i64 [%var_35, %block_4], [%var_9, %block_5] call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 3 to %Result*)) - %var_10 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 3 to %Result*)) + %var_10 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 3 to %Result*)) br i1 %var_10, label %block_7, label %block_8 block_7: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) @@ -44,7 +50,7 @@ block_8: %var_37 = phi i64 [%var_36, %block_6], [%var_12, %block_7] call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 4 to %Result*)) - %var_13 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 4 to %Result*)) + %var_13 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 4 to %Result*)) br i1 %var_13, label %block_9, label %block_10 block_9: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) @@ -54,7 +60,7 @@ block_10: %var_38 = phi i64 [%var_37, %block_8], [%var_15, %block_9] call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 5 to %Result*)) - %var_16 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 5 to %Result*)) + %var_16 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 5 to %Result*)) br i1 %var_16, label %block_11, label %block_12 block_11: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) @@ -64,7 +70,7 @@ block_12: %var_39 = phi i64 [%var_38, %block_10], [%var_18, %block_11] call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 6 to %Result*)) - %var_19 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 6 to %Result*)) + %var_19 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 6 to %Result*)) br i1 %var_19, label %block_13, label %block_14 block_13: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) @@ -74,7 +80,7 @@ block_14: %var_40 = phi i64 [%var_39, %block_12], [%var_21, %block_13] call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 7 to %Result*)) - %var_22 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 7 to %Result*)) + %var_22 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 7 to %Result*)) br i1 %var_22, label %block_15, label %block_16 block_15: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) @@ -84,7 +90,7 @@ block_16: %var_41 = phi i64 [%var_40, %block_14], [%var_24, %block_15] call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 8 to %Result*)) - %var_25 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 8 to %Result*)) + %var_25 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 8 to %Result*)) br i1 %var_25, label %block_17, label %block_18 block_17: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) @@ -94,7 +100,7 @@ block_18: %var_42 = phi i64 [%var_41, %block_16], [%var_27, %block_17] call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 9 to %Result*)) - %var_28 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 9 to %Result*)) + %var_28 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 9 to %Result*)) br i1 %var_28, label %block_19, label %block_20 block_19: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) @@ -106,18 +112,20 @@ block_20: %var_31 = icmp sgt i64 %var_43, 5 %var_32 = icmp slt i64 %var_43, 5 %var_33 = icmp eq i64 %var_43, 10 - call void @__quantum__rt__tuple_record_output(i64 3, i8* null) - call void @__quantum__rt__bool_record_output(i1 %var_31, i8* null) - call void @__quantum__rt__bool_record_output(i1 %var_32, i8* null) - call void @__quantum__rt__bool_record_output(i1 %var_33, i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__bool_record_output(i1 %var_31, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__bool_record_output(i1 %var_32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + call void @__quantum__rt__bool_record_output(i1 %var_33, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @2, i64 0, i64 0)) + ret i64 0 } +declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__x__body(%Qubit*) declare void @__quantum__qis__m__body(%Qubit*, %Result*) #1 -declare i1 @__quantum__qis__read_result__body(%Result*) +declare i1 @__quantum__rt__read_result(%Result*) declare void @__quantum__qis__reset__body(%Qubit*) #1 @@ -136,4 +144,4 @@ attributes #1 = { "irreversible" } !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} -!4 = !{i32 1, !"int_computations", !"i64"} +!4 = !{i32 5, !"int_computations", !{!"i64"}} diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/IntegerComparison.out b/source/pip/tests-integration/resources/adaptive_ri/output/IntegerComparison.out index 90b9dc4529..813e1b5ab5 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/IntegerComparison.out +++ b/source/pip/tests-integration/resources/adaptive_ri/output/IntegerComparison.out @@ -4,8 +4,8 @@ METADATA output_labeling_schema METADATA qir_profiles adaptive_profile METADATA required_num_qubits 1 METADATA required_num_results 10 -OUTPUT TUPLE 3 -OUTPUT BOOL true -OUTPUT BOOL false -OUTPUT BOOL true +OUTPUT TUPLE 3 +OUTPUT BOOL true 0_t0b +OUTPUT BOOL false 1_t1b +OUTPUT BOOL true 2_t2b END 0 diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicCCNOT.ll b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicCCNOT.ll index bb5df300ae..1483c0c6b5 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicCCNOT.ll +++ b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicCCNOT.ll @@ -1,8 +1,20 @@ %Result = type opaque %Qubit = type opaque -define void @ENTRYPOINT__main() #0 { +@empty_tag = internal constant [1 x i8] c"\00" +@0 = internal constant [8 x i8] c"0_t0a0r\00" +@1 = internal constant [8 x i8] c"1_t0a1r\00" +@2 = internal constant [8 x i8] c"2_t0a2r\00" +@3 = internal constant [8 x i8] c"3_t1a0r\00" +@4 = internal constant [8 x i8] c"4_t1a1r\00" +@5 = internal constant [8 x i8] c"5_t1a2r\00" +@6 = internal constant [8 x i8] c"6_t2a0r\00" +@7 = internal constant [8 x i8] c"7_t2a1r\00" +@8 = internal constant [8 x i8] c"8_t2a2r\00" + +define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__ccx__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Qubit* inttoptr (i64 1 to %Qubit*), %Qubit* inttoptr (i64 2 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) @@ -27,22 +39,24 @@ block_0: call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 6 to %Qubit*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 7 to %Qubit*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 8 to %Qubit*)) - call void @__quantum__rt__tuple_record_output(i64 3, i8* null) - call void @__quantum__rt__array_record_output(i64 3, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* null) - call void @__quantum__rt__array_record_output(i64 3, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 5 to %Result*), i8* null) - call void @__quantum__rt__array_record_output(i64 3, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 6 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 7 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 8 to %Result*), i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__array_record_output(i64 3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @1, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @2, i64 0, i64 0)) + call void @__quantum__rt__array_record_output(i64 3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @3, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @4, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 5 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @5, i64 0, i64 0)) + call void @__quantum__rt__array_record_output(i64 3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 6 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @6, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 7 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @7, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 8 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @8, i64 0, i64 0)) + ret i64 0 } +declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__ccx__body(%Qubit*, %Qubit*, %Qubit*) declare void @__quantum__qis__m__body(%Qubit*, %Result*) #1 @@ -68,4 +82,4 @@ attributes #1 = { "irreversible" } !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} -!4 = !{i32 1, !"int_computations", !"i64"} +!4 = !{i32 5, !"int_computations", !{!"i64"}} diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicCCNOT.out b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicCCNOT.out index 749e4a40b0..7992145354 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicCCNOT.out +++ b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicCCNOT.out @@ -4,17 +4,17 @@ METADATA output_labeling_schema METADATA qir_profiles adaptive_profile METADATA required_num_qubits 9 METADATA required_num_results 9 -OUTPUT TUPLE 3 -OUTPUT ARRAY 3 -OUTPUT RESULT 0 -OUTPUT RESULT 0 -OUTPUT RESULT 0 -OUTPUT ARRAY 3 -OUTPUT RESULT 1 -OUTPUT RESULT 0 -OUTPUT RESULT 0 -OUTPUT ARRAY 3 -OUTPUT RESULT 1 -OUTPUT RESULT 1 -OUTPUT RESULT 1 +OUTPUT TUPLE 3 +OUTPUT ARRAY 3 +OUTPUT RESULT 0 0_t0a0r +OUTPUT RESULT 0 1_t0a1r +OUTPUT RESULT 0 2_t0a2r +OUTPUT ARRAY 3 +OUTPUT RESULT 1 3_t1a0r +OUTPUT RESULT 0 4_t1a1r +OUTPUT RESULT 0 5_t1a2r +OUTPUT ARRAY 3 +OUTPUT RESULT 1 6_t2a0r +OUTPUT RESULT 1 7_t2a1r +OUTPUT RESULT 1 8_t2a2r END 0 diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicCNOT.ll b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicCNOT.ll index cd0a097c28..80f9dbc05e 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicCNOT.ll +++ b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicCNOT.ll @@ -1,8 +1,15 @@ %Result = type opaque %Qubit = type opaque -define void @ENTRYPOINT__main() #0 { +@empty_tag = internal constant [1 x i8] c"\00" +@0 = internal constant [8 x i8] c"0_t0a0r\00" +@1 = internal constant [8 x i8] c"1_t0a1r\00" +@2 = internal constant [8 x i8] c"2_t1a0r\00" +@3 = internal constant [8 x i8] c"3_t1a1r\00" + +define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__cx__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) @@ -14,16 +21,18 @@ block_0: call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 3 to %Qubit*), %Result* inttoptr (i64 3 to %Result*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 2 to %Qubit*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 3 to %Qubit*)) - call void @__quantum__rt__tuple_record_output(i64 2, i8* null) - call void @__quantum__rt__array_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - call void @__quantum__rt__array_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__array_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @1, i64 0, i64 0)) + call void @__quantum__rt__array_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @2, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @3, i64 0, i64 0)) + ret i64 0 } +declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__cx__body(%Qubit*, %Qubit*) declare void @__quantum__qis__m__body(%Qubit*, %Result*) #1 @@ -49,4 +58,4 @@ attributes #1 = { "irreversible" } !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} -!4 = !{i32 1, !"int_computations", !"i64"} +!4 = !{i32 5, !"int_computations", !{!"i64"}} diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicCNOT.out b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicCNOT.out index 7eaf5aef5b..76b6ee28a5 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicCNOT.out +++ b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicCNOT.out @@ -4,11 +4,11 @@ METADATA output_labeling_schema METADATA qir_profiles adaptive_profile METADATA required_num_qubits 4 METADATA required_num_results 4 -OUTPUT TUPLE 2 -OUTPUT ARRAY 2 -OUTPUT RESULT 0 -OUTPUT RESULT 0 -OUTPUT ARRAY 2 -OUTPUT RESULT 1 -OUTPUT RESULT 1 +OUTPUT TUPLE 2 +OUTPUT ARRAY 2 +OUTPUT RESULT 0 0_t0a0r +OUTPUT RESULT 0 1_t0a1r +OUTPUT ARRAY 2 +OUTPUT RESULT 1 2_t1a0r +OUTPUT RESULT 1 3_t1a1r END 0 diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicHIXYZ.ll b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicHIXYZ.ll index 7572e852f8..ca0af6c04d 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicHIXYZ.ll +++ b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicHIXYZ.ll @@ -1,8 +1,17 @@ %Result = type opaque %Qubit = type opaque -define void @ENTRYPOINT__main() #0 { +@empty_tag = internal constant [1 x i8] c"\00" +@0 = internal constant [6 x i8] c"0_t0r\00" +@1 = internal constant [6 x i8] c"1_t1r\00" +@2 = internal constant [6 x i8] c"2_t2r\00" +@3 = internal constant [6 x i8] c"3_t3r\00" +@4 = internal constant [6 x i8] c"4_t4r\00" +@5 = internal constant [6 x i8] c"5_t5r\00" + +define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__z__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 0 to %Qubit*)) @@ -21,16 +30,18 @@ block_0: call void @__quantum__qis__z__body(%Qubit* inttoptr (i64 5 to %Qubit*)) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 5 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 5 to %Qubit*), %Result* inttoptr (i64 5 to %Result*)) - call void @__quantum__rt__tuple_record_output(i64 6, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 5 to %Result*), i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 6, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @2, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @3, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @4, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 5 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @5, i64 0, i64 0)) + ret i64 0 } +declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__h__body(%Qubit*) declare void @__quantum__qis__z__body(%Qubit*) @@ -56,4 +67,4 @@ attributes #1 = { "irreversible" } !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} -!4 = !{i32 1, !"int_computations", !"i64"} +!4 = !{i32 5, !"int_computations", !{!"i64"}} diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicHIXYZ.out b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicHIXYZ.out index 158d94e405..c607476ce0 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicHIXYZ.out +++ b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicHIXYZ.out @@ -4,11 +4,11 @@ METADATA output_labeling_schema METADATA qir_profiles adaptive_profile METADATA required_num_qubits 6 METADATA required_num_results 6 -OUTPUT TUPLE 6 -OUTPUT RESULT 1 -OUTPUT RESULT 1 -OUTPUT RESULT 1 -OUTPUT RESULT 1 -OUTPUT RESULT 1 -OUTPUT RESULT 1 +OUTPUT TUPLE 6 +OUTPUT RESULT 1 0_t0r +OUTPUT RESULT 1 1_t1r +OUTPUT RESULT 1 2_t2r +OUTPUT RESULT 1 3_t3r +OUTPUT RESULT 1 4_t4r +OUTPUT RESULT 1 5_t5r END 0 diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicM.ll b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicM.ll index 26915f37e2..aed01fa2ad 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicM.ll +++ b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicM.ll @@ -1,19 +1,26 @@ %Result = type opaque %Qubit = type opaque -define void @ENTRYPOINT__main() #0 { +@empty_tag = internal constant [1 x i8] c"\00" +@0 = internal constant [6 x i8] c"0_t0r\00" +@1 = internal constant [6 x i8] c"1_t1r\00" + +define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 1 to %Qubit*)) - call void @__quantum__rt__tuple_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + ret i64 0 } +declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__m__body(%Qubit*, %Result*) #1 declare void @__quantum__qis__x__body(%Qubit*) @@ -35,4 +42,4 @@ attributes #1 = { "irreversible" } !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} -!4 = !{i32 1, !"int_computations", !"i64"} +!4 = !{i32 5, !"int_computations", !{!"i64"}} diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicM.out b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicM.out index 9726cf796d..4c9a278947 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicM.out +++ b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicM.out @@ -4,7 +4,7 @@ METADATA output_labeling_schema METADATA qir_profiles adaptive_profile METADATA required_num_qubits 2 METADATA required_num_results 2 -OUTPUT TUPLE 2 -OUTPUT RESULT 0 -OUTPUT RESULT 1 +OUTPUT TUPLE 2 +OUTPUT RESULT 0 0_t0r +OUTPUT RESULT 1 1_t1r END 0 diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicMeasureWithBitFlipCode.ll b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicMeasureWithBitFlipCode.ll index f7b45de39a..477d7780d0 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicMeasureWithBitFlipCode.ll +++ b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicMeasureWithBitFlipCode.ll @@ -1,8 +1,18 @@ %Result = type opaque %Qubit = type opaque -define void @ENTRYPOINT__main() #0 { +@empty_tag = internal constant [1 x i8] c"\00" +@0 = internal constant [8 x i8] c"0_t0a0r\00" +@1 = internal constant [8 x i8] c"1_t0a1r\00" +@2 = internal constant [8 x i8] c"2_t1a0r\00" +@3 = internal constant [8 x i8] c"3_t1a1r\00" +@4 = internal constant [8 x i8] c"4_t2a0r\00" +@5 = internal constant [8 x i8] c"5_t2a1r\00" +@6 = internal constant [8 x i8] c"6_t2a2r\00" + +define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__cx__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__cx__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Qubit* inttoptr (i64 2 to %Qubit*)) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 3 to %Qubit*)) @@ -31,20 +41,22 @@ block_0: call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 4 to %Result*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 5 to %Result*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 2 to %Qubit*), %Result* inttoptr (i64 6 to %Result*)) - call void @__quantum__rt__tuple_record_output(i64 3, i8* null) - call void @__quantum__rt__array_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - call void @__quantum__rt__array_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* null) - call void @__quantum__rt__array_record_output(i64 3, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 5 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 6 to %Result*), i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__array_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @1, i64 0, i64 0)) + call void @__quantum__rt__array_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @2, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @3, i64 0, i64 0)) + call void @__quantum__rt__array_record_output(i64 3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @4, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 5 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @5, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 6 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @6, i64 0, i64 0)) + ret i64 0 } +declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__cx__body(%Qubit*, %Qubit*) declare void @__quantum__qis__h__body(%Qubit*) @@ -72,4 +84,4 @@ attributes #1 = { "irreversible" } !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} -!4 = !{i32 1, !"int_computations", !"i64"} +!4 = !{i32 5, !"int_computations", !{!"i64"}} diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicMeasureWithBitFlipCode.out b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicMeasureWithBitFlipCode.out index e7d56532b1..d9ce7d1330 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicMeasureWithBitFlipCode.out +++ b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicMeasureWithBitFlipCode.out @@ -4,15 +4,15 @@ METADATA output_labeling_schema METADATA qir_profiles adaptive_profile METADATA required_num_qubits 4 METADATA required_num_results 7 -OUTPUT TUPLE 3 -OUTPUT ARRAY 2 -OUTPUT RESULT 0 -OUTPUT RESULT 0 -OUTPUT ARRAY 2 -OUTPUT RESULT 0 -OUTPUT RESULT 1 -OUTPUT ARRAY 3 -OUTPUT RESULT 0 -OUTPUT RESULT 0 -OUTPUT RESULT 1 +OUTPUT TUPLE 3 +OUTPUT ARRAY 2 +OUTPUT RESULT 0 0_t0a0r +OUTPUT RESULT 0 1_t0a1r +OUTPUT ARRAY 2 +OUTPUT RESULT 0 2_t1a0r +OUTPUT RESULT 1 3_t1a1r +OUTPUT ARRAY 3 +OUTPUT RESULT 0 4_t2a0r +OUTPUT RESULT 0 5_t2a1r +OUTPUT RESULT 1 6_t2a2r END 0 diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicMeasureWithPhaseFlipCode.ll b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicMeasureWithPhaseFlipCode.ll index f537083df5..f51b97987b 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicMeasureWithPhaseFlipCode.ll +++ b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicMeasureWithPhaseFlipCode.ll @@ -1,8 +1,18 @@ %Result = type opaque %Qubit = type opaque -define void @ENTRYPOINT__main() #0 { +@empty_tag = internal constant [1 x i8] c"\00" +@0 = internal constant [8 x i8] c"0_t0a0r\00" +@1 = internal constant [8 x i8] c"1_t0a1r\00" +@2 = internal constant [8 x i8] c"2_t1a0r\00" +@3 = internal constant [8 x i8] c"3_t1a1r\00" +@4 = internal constant [8 x i8] c"4_t2a0r\00" +@5 = internal constant [8 x i8] c"5_t2a1r\00" +@6 = internal constant [8 x i8] c"6_t2a2r\00" + +define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__cx__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__cx__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Qubit* inttoptr (i64 2 to %Qubit*)) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 0 to %Qubit*)) @@ -37,20 +47,22 @@ block_0: call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 4 to %Result*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 5 to %Result*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 2 to %Qubit*), %Result* inttoptr (i64 6 to %Result*)) - call void @__quantum__rt__tuple_record_output(i64 3, i8* null) - call void @__quantum__rt__array_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - call void @__quantum__rt__array_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* null) - call void @__quantum__rt__array_record_output(i64 3, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 5 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 6 to %Result*), i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__array_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @1, i64 0, i64 0)) + call void @__quantum__rt__array_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @2, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @3, i64 0, i64 0)) + call void @__quantum__rt__array_record_output(i64 3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @4, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 5 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @5, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 6 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @6, i64 0, i64 0)) + ret i64 0 } +declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__cx__body(%Qubit*, %Qubit*) declare void @__quantum__qis__h__body(%Qubit*) @@ -76,4 +88,4 @@ attributes #1 = { "irreversible" } !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} -!4 = !{i32 1, !"int_computations", !"i64"} +!4 = !{i32 5, !"int_computations", !{!"i64"}} diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicMeasureWithPhaseFlipCode.out b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicMeasureWithPhaseFlipCode.out index ffad183cb9..433f7ce017 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicMeasureWithPhaseFlipCode.out +++ b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicMeasureWithPhaseFlipCode.out @@ -4,15 +4,15 @@ METADATA output_labeling_schema METADATA qir_profiles adaptive_profile METADATA required_num_qubits 4 METADATA required_num_results 7 -OUTPUT TUPLE 3 -OUTPUT ARRAY 2 -OUTPUT RESULT 0 -OUTPUT RESULT 0 -OUTPUT ARRAY 2 -OUTPUT RESULT 1 -OUTPUT RESULT 1 -OUTPUT ARRAY 3 -OUTPUT RESULT 0 -OUTPUT RESULT 1 -OUTPUT RESULT 0 +OUTPUT TUPLE 3 +OUTPUT ARRAY 2 +OUTPUT RESULT 0 0_t0a0r +OUTPUT RESULT 0 1_t0a1r +OUTPUT ARRAY 2 +OUTPUT RESULT 1 2_t1a0r +OUTPUT RESULT 1 3_t1a1r +OUTPUT ARRAY 3 +OUTPUT RESULT 0 4_t2a0r +OUTPUT RESULT 1 5_t2a1r +OUTPUT RESULT 0 6_t2a2r END 0 diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicRotationsWithPeriod.ll b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicRotationsWithPeriod.ll index e8a9984785..e978945f7e 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicRotationsWithPeriod.ll +++ b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicRotationsWithPeriod.ll @@ -1,8 +1,17 @@ %Result = type opaque %Qubit = type opaque -define void @ENTRYPOINT__main() #0 { +@empty_tag = internal constant [1 x i8] c"\00" +@0 = internal constant [8 x i8] c"0_t0a0r\00" +@1 = internal constant [8 x i8] c"1_t0a1r\00" +@2 = internal constant [8 x i8] c"2_t1a0r\00" +@3 = internal constant [8 x i8] c"3_t1a1r\00" +@4 = internal constant [8 x i8] c"4_t2a0r\00" +@5 = internal constant [8 x i8] c"5_t2a1r\00" + +define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__y__body(%Qubit* inttoptr (i64 2 to %Qubit*)) @@ -67,19 +76,21 @@ block_0: call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 3 to %Qubit*), %Result* inttoptr (i64 3 to %Result*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 4 to %Qubit*), %Result* inttoptr (i64 4 to %Result*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 5 to %Qubit*), %Result* inttoptr (i64 5 to %Result*)) - call void @__quantum__rt__tuple_record_output(i64 3, i8* null) - call void @__quantum__rt__array_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - call void @__quantum__rt__array_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* null) - call void @__quantum__rt__array_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 5 to %Result*), i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__array_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @1, i64 0, i64 0)) + call void @__quantum__rt__array_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @2, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @3, i64 0, i64 0)) + call void @__quantum__rt__array_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @4, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 5 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @5, i64 0, i64 0)) + ret i64 0 } +declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__x__body(%Qubit*) declare void @__quantum__qis__y__body(%Qubit*) @@ -113,4 +124,4 @@ attributes #1 = { "irreversible" } !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} -!4 = !{i32 1, !"int_computations", !"i64"} +!4 = !{i32 5, !"int_computations", !{!"i64"}} diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicRotationsWithPeriod.out b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicRotationsWithPeriod.out index ad57e6aa7f..4875b8166f 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicRotationsWithPeriod.out +++ b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicRotationsWithPeriod.out @@ -4,14 +4,14 @@ METADATA output_labeling_schema METADATA qir_profiles adaptive_profile METADATA required_num_qubits 6 METADATA required_num_results 6 -OUTPUT TUPLE 3 -OUTPUT ARRAY 2 -OUTPUT RESULT 1 -OUTPUT RESULT 1 -OUTPUT ARRAY 2 -OUTPUT RESULT 1 -OUTPUT RESULT 1 -OUTPUT ARRAY 2 -OUTPUT RESULT 1 -OUTPUT RESULT 1 +OUTPUT TUPLE 3 +OUTPUT ARRAY 2 +OUTPUT RESULT 1 0_t0a0r +OUTPUT RESULT 1 1_t0a1r +OUTPUT ARRAY 2 +OUTPUT RESULT 1 2_t1a0r +OUTPUT RESULT 1 3_t1a1r +OUTPUT ARRAY 2 +OUTPUT RESULT 1 4_t2a0r +OUTPUT RESULT 1 5_t2a1r END 0 diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicSTSWAP.ll b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicSTSWAP.ll index 6dc5de3e4b..f532ab1f2e 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicSTSWAP.ll +++ b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicSTSWAP.ll @@ -1,8 +1,15 @@ %Result = type opaque %Qubit = type opaque -define void @ENTRYPOINT__main() #0 { +@empty_tag = internal constant [1 x i8] c"\00" +@0 = internal constant [6 x i8] c"0_t0r\00" +@1 = internal constant [6 x i8] c"1_t1r\00" +@2 = internal constant [8 x i8] c"2_t2a0r\00" +@3 = internal constant [8 x i8] c"3_t2a1r\00" + +define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__s__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__s__body(%Qubit* inttoptr (i64 0 to %Qubit*)) @@ -19,15 +26,17 @@ block_0: call void @__quantum__qis__swap__body(%Qubit* inttoptr (i64 2 to %Qubit*), %Qubit* inttoptr (i64 3 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 2 to %Qubit*), %Result* inttoptr (i64 2 to %Result*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 3 to %Qubit*), %Result* inttoptr (i64 3 to %Result*)) - call void @__quantum__rt__tuple_record_output(i64 3, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - call void @__quantum__rt__array_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + call void @__quantum__rt__array_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @2, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @3, i64 0, i64 0)) + ret i64 0 } +declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__h__body(%Qubit*) declare void @__quantum__qis__s__body(%Qubit*) @@ -57,4 +66,4 @@ attributes #1 = { "irreversible" } !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} -!4 = !{i32 1, !"int_computations", !"i64"} +!4 = !{i32 5, !"int_computations", !{!"i64"}} diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicSTSWAP.out b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicSTSWAP.out index 5fd0c3c05f..45697e381a 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicSTSWAP.out +++ b/source/pip/tests-integration/resources/adaptive_ri/output/IntrinsicSTSWAP.out @@ -4,10 +4,10 @@ METADATA output_labeling_schema METADATA qir_profiles adaptive_profile METADATA required_num_qubits 4 METADATA required_num_results 4 -OUTPUT TUPLE 3 -OUTPUT RESULT 1 -OUTPUT RESULT 1 -OUTPUT ARRAY 2 -OUTPUT RESULT 1 -OUTPUT RESULT 0 +OUTPUT TUPLE 3 +OUTPUT RESULT 1 0_t0r +OUTPUT RESULT 1 1_t1r +OUTPUT ARRAY 2 +OUTPUT RESULT 1 2_t2a0r +OUTPUT RESULT 0 3_t2a1r END 0 diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/MeasureAndReuse.ll b/source/pip/tests-integration/resources/adaptive_ri/output/MeasureAndReuse.ll index b13143b88d..40e2975aa8 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/MeasureAndReuse.ll +++ b/source/pip/tests-integration/resources/adaptive_ri/output/MeasureAndReuse.ll @@ -1,8 +1,16 @@ %Result = type opaque %Qubit = type opaque -define void @ENTRYPOINT__main() #0 { +@empty_tag = internal constant [1 x i8] c"\00" +@0 = internal constant [6 x i8] c"0_t0r\00" +@1 = internal constant [6 x i8] c"1_t1r\00" +@2 = internal constant [6 x i8] c"2_t2r\00" +@3 = internal constant [6 x i8] c"3_t3r\00" +@4 = internal constant [6 x i8] c"4_t4r\00" + +define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) @@ -16,15 +24,17 @@ block_0: call void @__quantum__qis__s__adj(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 4 to %Result*)) - call void @__quantum__rt__tuple_record_output(i64 5, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @2, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @3, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @4, i64 0, i64 0)) + ret i64 0 } +declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__m__body(%Qubit*, %Result*) #1 declare void @__quantum__qis__x__body(%Qubit*) @@ -50,4 +60,4 @@ attributes #1 = { "irreversible" } !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} -!4 = !{i32 1, !"int_computations", !"i64"} +!4 = !{i32 5, !"int_computations", !{!"i64"}} diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/MeasureAndReuse.out b/source/pip/tests-integration/resources/adaptive_ri/output/MeasureAndReuse.out index 815422033b..0c193f621c 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/MeasureAndReuse.out +++ b/source/pip/tests-integration/resources/adaptive_ri/output/MeasureAndReuse.out @@ -4,10 +4,10 @@ METADATA output_labeling_schema METADATA qir_profiles adaptive_profile METADATA required_num_qubits 1 METADATA required_num_results 5 -OUTPUT TUPLE 5 -OUTPUT RESULT 0 -OUTPUT RESULT 1 -OUTPUT RESULT 1 -OUTPUT RESULT 0 -OUTPUT RESULT 0 +OUTPUT TUPLE 5 +OUTPUT RESULT 0 0_t0r +OUTPUT RESULT 1 1_t1r +OUTPUT RESULT 1 2_t2r +OUTPUT RESULT 0 3_t3r +OUTPUT RESULT 0 4_t4r END 0 diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/MeasurementComparison.ll b/source/pip/tests-integration/resources/adaptive_ri/output/MeasurementComparison.ll index a3fb0c09a6..327c3f59b5 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/MeasurementComparison.ll +++ b/source/pip/tests-integration/resources/adaptive_ri/output/MeasurementComparison.ll @@ -1,21 +1,28 @@ %Result = type opaque %Qubit = type opaque -define void @ENTRYPOINT__main() #0 { +@empty_tag = internal constant [1 x i8] c"\00" +@0 = internal constant [6 x i8] c"0_t0b\00" +@1 = internal constant [6 x i8] c"1_t1b\00" +@2 = internal constant [6 x i8] c"2_t2b\00" +@3 = internal constant [6 x i8] c"3_t3b\00" + +define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__cx__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 1 to %Qubit*)) - %var_0 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 0 to %Result*)) - %var_2 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 1 to %Result*)) + %var_0 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 0 to %Result*)) + %var_2 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 1 to %Result*)) %var_3 = icmp eq i1 %var_2, false - %var_4 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 0 to %Result*)) - %var_5 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 1 to %Result*)) + %var_4 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 0 to %Result*)) + %var_5 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 1 to %Result*)) %var_6 = icmp eq i1 %var_4, %var_5 - %var_7 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 0 to %Result*)) + %var_7 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 0 to %Result*)) %var_8 = icmp eq i1 %var_7, false br i1 %var_8, label %block_1, label %block_2 block_1: @@ -24,14 +31,16 @@ block_2: br label %block_3 block_3: %var_10 = phi i1 [false, %block_1], [true, %block_2] - call void @__quantum__rt__tuple_record_output(i64 4, i8* null) - call void @__quantum__rt__bool_record_output(i1 %var_0, i8* null) - call void @__quantum__rt__bool_record_output(i1 %var_3, i8* null) - call void @__quantum__rt__bool_record_output(i1 %var_6, i8* null) - call void @__quantum__rt__bool_record_output(i1 %var_10, i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 4, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__bool_record_output(i1 %var_0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__bool_record_output(i1 %var_3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + call void @__quantum__rt__bool_record_output(i1 %var_6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @2, i64 0, i64 0)) + call void @__quantum__rt__bool_record_output(i1 %var_10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @3, i64 0, i64 0)) + ret i64 0 } +declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__x__body(%Qubit*) declare void @__quantum__qis__cx__body(%Qubit*, %Qubit*) @@ -40,7 +49,7 @@ declare void @__quantum__qis__m__body(%Qubit*, %Result*) #1 declare void @__quantum__qis__reset__body(%Qubit*) #1 -declare i1 @__quantum__qis__read_result__body(%Result*) +declare i1 @__quantum__rt__read_result(%Result*) declare void @__quantum__rt__tuple_record_output(i64, i8*) @@ -57,4 +66,4 @@ attributes #1 = { "irreversible" } !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} -!4 = !{i32 1, !"int_computations", !"i64"} +!4 = !{i32 5, !"int_computations", !{!"i64"}} diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/MeasurementComparison.out b/source/pip/tests-integration/resources/adaptive_ri/output/MeasurementComparison.out index 1aa28a26da..331b678fca 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/MeasurementComparison.out +++ b/source/pip/tests-integration/resources/adaptive_ri/output/MeasurementComparison.out @@ -4,9 +4,9 @@ METADATA output_labeling_schema METADATA qir_profiles adaptive_profile METADATA required_num_qubits 2 METADATA required_num_results 2 -OUTPUT TUPLE 4 -OUTPUT BOOL true -OUTPUT BOOL false -OUTPUT BOOL true -OUTPUT BOOL true +OUTPUT TUPLE 4 +OUTPUT BOOL true 0_t0b +OUTPUT BOOL false 1_t1b +OUTPUT BOOL true 2_t2b +OUTPUT BOOL true 3_t3b END 0 diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/NestedBranching.ll b/source/pip/tests-integration/resources/adaptive_ri/output/NestedBranching.ll index 760f3c737e..dc2febeb7a 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/NestedBranching.ll +++ b/source/pip/tests-integration/resources/adaptive_ri/output/NestedBranching.ll @@ -1,30 +1,42 @@ %Result = type opaque %Qubit = type opaque -define void @ENTRYPOINT__main() #0 { +@empty_tag = internal constant [1 x i8] c"\00" +@0 = internal constant [10 x i8] c"0_t0t0a0r\00" +@1 = internal constant [10 x i8] c"1_t0t0a1r\00" +@2 = internal constant [10 x i8] c"2_t0t0a2r\00" +@3 = internal constant [8 x i8] c"3_t0t1i\00" +@4 = internal constant [10 x i8] c"4_t1t0a0r\00" +@5 = internal constant [10 x i8] c"5_t1t0a1r\00" +@6 = internal constant [10 x i8] c"6_t1t0a2r\00" +@7 = internal constant [10 x i8] c"7_t1t0a3r\00" +@8 = internal constant [8 x i8] c"8_t1t1b\00" + +define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 2 to %Qubit*), %Result* inttoptr (i64 2 to %Result*)) - %var_3 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 0 to %Result*)) + %var_3 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 0 to %Result*)) %var_4 = icmp eq i1 %var_3, false br i1 %var_4, label %block_1, label %block_2 block_1: - %var_5 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 1 to %Result*)) + %var_5 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 1 to %Result*)) %var_6 = icmp eq i1 %var_5, false br i1 %var_6, label %block_3, label %block_5 block_2: - %var_20 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 1 to %Result*)) + %var_20 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 1 to %Result*)) %var_21 = icmp eq i1 %var_20, false br i1 %var_21, label %block_4, label %block_6 block_3: - %var_8 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 2 to %Result*)) + %var_8 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 2 to %Result*)) %var_9 = icmp eq i1 %var_8, false br label %block_5 block_4: - %var_23 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 2 to %Result*)) + %var_23 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 2 to %Result*)) %var_24 = icmp eq i1 %var_23, false br label %block_6 block_5: @@ -36,20 +48,20 @@ block_6: block_7: br label %block_31 block_8: - %var_10 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 1 to %Result*)) + %var_10 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 1 to %Result*)) %var_11 = icmp eq i1 %var_10, false br i1 %var_11, label %block_11, label %block_13 block_9: br label %block_32 block_10: - %var_25 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 1 to %Result*)) + %var_25 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 1 to %Result*)) %var_26 = icmp eq i1 %var_25, false br i1 %var_26, label %block_12, label %block_14 block_11: - %var_13 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 2 to %Result*)) + %var_13 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 2 to %Result*)) br label %block_13 block_12: - %var_28 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 2 to %Result*)) + %var_28 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 2 to %Result*)) br label %block_14 block_13: %var_83 = phi i1 [false, %block_8], [%var_13, %block_11] @@ -60,19 +72,19 @@ block_14: block_15: br label %block_29 block_16: - %var_15 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 1 to %Result*)) + %var_15 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 1 to %Result*)) br i1 %var_15, label %block_19, label %block_21 block_17: br label %block_30 block_18: - %var_30 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 1 to %Result*)) + %var_30 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 1 to %Result*)) br i1 %var_30, label %block_20, label %block_22 block_19: - %var_18 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 2 to %Result*)) + %var_18 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 2 to %Result*)) %var_19 = icmp eq i1 %var_18, false br label %block_21 block_20: - %var_33 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 2 to %Result*)) + %var_33 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 2 to %Result*)) %var_34 = icmp eq i1 %var_33, false br label %block_22 block_21: @@ -120,27 +132,27 @@ block_33: call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 4 to %Qubit*), %Result* inttoptr (i64 4 to %Result*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 5 to %Qubit*), %Result* inttoptr (i64 5 to %Result*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 6 to %Qubit*), %Result* inttoptr (i64 6 to %Result*)) - %var_40 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 3 to %Result*)) + %var_40 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 3 to %Result*)) %var_41 = icmp eq i1 %var_40, false br i1 %var_41, label %block_34, label %block_35 block_34: - %var_42 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 4 to %Result*)) + %var_42 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 4 to %Result*)) %var_43 = icmp eq i1 %var_42, false br i1 %var_43, label %block_36, label %block_37 block_35: - %var_48 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 3 to %Result*)) + %var_48 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 3 to %Result*)) %var_49 = icmp eq i1 %var_48, false br i1 %var_49, label %block_38, label %block_43 block_36: - %var_44 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 5 to %Result*)) + %var_44 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 5 to %Result*)) %var_45 = icmp eq i1 %var_44, false br i1 %var_45, label %block_39, label %block_40 block_37: - %var_46 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 5 to %Result*)) + %var_46 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 5 to %Result*)) %var_47 = icmp eq i1 %var_46, false br i1 %var_47, label %block_41, label %block_42 block_38: - %var_51 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 4 to %Result*)) + %var_51 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 4 to %Result*)) br label %block_43 block_39: br label %block_44 @@ -164,24 +176,24 @@ block_44: block_45: br label %block_48 block_46: - %var_53 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 4 to %Result*)) + %var_53 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 4 to %Result*)) %var_54 = icmp eq i1 %var_53, false br i1 %var_54, label %block_49, label %block_50 block_47: - %var_59 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 3 to %Result*)) + %var_59 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 3 to %Result*)) br i1 %var_59, label %block_51, label %block_56 block_48: br label %block_82 block_49: - %var_55 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 5 to %Result*)) + %var_55 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 5 to %Result*)) %var_56 = icmp eq i1 %var_55, false br i1 %var_56, label %block_52, label %block_53 block_50: - %var_57 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 5 to %Result*)) + %var_57 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 5 to %Result*)) %var_58 = icmp eq i1 %var_57, false br i1 %var_58, label %block_54, label %block_55 block_51: - %var_62 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 4 to %Result*)) + %var_62 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 4 to %Result*)) %var_63 = icmp eq i1 %var_62, false br label %block_56 block_52: @@ -206,29 +218,29 @@ block_57: block_58: br label %block_61 block_59: - %var_64 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 4 to %Result*)) + %var_64 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 4 to %Result*)) %var_65 = icmp eq i1 %var_64, false br i1 %var_65, label %block_62, label %block_63 block_60: - %var_70 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 4 to %Result*)) + %var_70 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 4 to %Result*)) %var_71 = icmp eq i1 %var_70, false br i1 %var_71, label %block_64, label %block_65 block_61: br label %block_81 block_62: - %var_66 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 5 to %Result*)) + %var_66 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 5 to %Result*)) %var_67 = icmp eq i1 %var_66, false br i1 %var_67, label %block_66, label %block_67 block_63: - %var_68 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 5 to %Result*)) + %var_68 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 5 to %Result*)) %var_69 = icmp eq i1 %var_68, false br i1 %var_69, label %block_68, label %block_69 block_64: - %var_72 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 5 to %Result*)) + %var_72 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 5 to %Result*)) %var_73 = icmp eq i1 %var_72, false br i1 %var_73, label %block_70, label %block_71 block_65: - %var_74 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 5 to %Result*)) + %var_74 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 5 to %Result*)) %var_75 = icmp eq i1 %var_74, false br i1 %var_75, label %block_72, label %block_73 block_66: @@ -281,29 +293,31 @@ block_82: call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 5 to %Qubit*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 6 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 7 to %Qubit*), %Result* inttoptr (i64 7 to %Result*)) - %var_77 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 7 to %Result*)) - call void @__quantum__rt__tuple_record_output(i64 2, i8* null) - call void @__quantum__rt__tuple_record_output(i64 2, i8* null) - call void @__quantum__rt__array_record_output(i64 3, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* null) - call void @__quantum__rt__int_record_output(i64 %var_93, i8* null) - call void @__quantum__rt__tuple_record_output(i64 2, i8* null) - call void @__quantum__rt__array_record_output(i64 4, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 5 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 6 to %Result*), i8* null) - call void @__quantum__rt__bool_record_output(i1 %var_77, i8* null) - ret void + %var_77 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 7 to %Result*)) + call void @__quantum__rt__tuple_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__tuple_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__array_record_output(i64 3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @1, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @2, i64 0, i64 0)) + call void @__quantum__rt__int_record_output(i64 %var_93, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @3, i64 0, i64 0)) + call void @__quantum__rt__tuple_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__array_record_output(i64 4, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @4, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @5, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 5 to %Result*), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @6, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 6 to %Result*), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @7, i64 0, i64 0)) + call void @__quantum__rt__bool_record_output(i1 %var_77, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @8, i64 0, i64 0)) + ret i64 0 } +declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__x__body(%Qubit*) declare void @__quantum__qis__m__body(%Qubit*, %Result*) #1 -declare i1 @__quantum__qis__read_result__body(%Result*) +declare i1 @__quantum__rt__read_result(%Result*) declare void @__quantum__qis__reset__body(%Qubit*) #1 @@ -334,4 +348,4 @@ attributes #1 = { "irreversible" } !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} -!4 = !{i32 1, !"int_computations", !"i64"} +!4 = !{i32 5, !"int_computations", !{!"i64"}} diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/NestedBranching.out b/source/pip/tests-integration/resources/adaptive_ri/output/NestedBranching.out index 40ebc4f86f..61c83a5737 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/NestedBranching.out +++ b/source/pip/tests-integration/resources/adaptive_ri/output/NestedBranching.out @@ -4,18 +4,18 @@ METADATA output_labeling_schema METADATA qir_profiles adaptive_profile METADATA required_num_qubits 8 METADATA required_num_results 8 -OUTPUT TUPLE 2 -OUTPUT TUPLE 2 -OUTPUT ARRAY 3 -OUTPUT RESULT 1 -OUTPUT RESULT 1 -OUTPUT RESULT 0 -OUTPUT INT 6 -OUTPUT TUPLE 2 -OUTPUT ARRAY 4 -OUTPUT RESULT 1 -OUTPUT RESULT 1 -OUTPUT RESULT 1 -OUTPUT RESULT 0 -OUTPUT BOOL true +OUTPUT TUPLE 2 +OUTPUT TUPLE 2 +OUTPUT ARRAY 3 +OUTPUT RESULT 1 0_t0t0a0r +OUTPUT RESULT 1 1_t0t0a1r +OUTPUT RESULT 0 2_t0t0a2r +OUTPUT INT 6 3_t0t1i +OUTPUT TUPLE 2 +OUTPUT ARRAY 4 +OUTPUT RESULT 1 4_t1t0a0r +OUTPUT RESULT 1 5_t1t0a1r +OUTPUT RESULT 1 6_t1t0a2r +OUTPUT RESULT 0 7_t1t0a3r +OUTPUT BOOL true 8_t1t1b END 0 diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/RandomBit.ll b/source/pip/tests-integration/resources/adaptive_ri/output/RandomBit.ll index c232922cea..09d122a363 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/RandomBit.ll +++ b/source/pip/tests-integration/resources/adaptive_ri/output/RandomBit.ll @@ -1,15 +1,21 @@ %Result = type opaque %Qubit = type opaque -define void @ENTRYPOINT__main() #0 { +@empty_tag = internal constant [1 x i8] c"\00" +@0 = internal constant [4 x i8] c"0_r\00" + +define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 0 to %Qubit*)) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - ret void + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @0, i64 0, i64 0)) + ret i64 0 } +declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__h__body(%Qubit*) declare void @__quantum__qis__m__body(%Qubit*, %Result*) #1 @@ -29,4 +35,4 @@ attributes #1 = { "irreversible" } !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} -!4 = !{i32 1, !"int_computations", !"i64"} +!4 = !{i32 5, !"int_computations", !{!"i64"}} diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/RandomBit.out b/source/pip/tests-integration/resources/adaptive_ri/output/RandomBit.out index 7d0390a819..f3b3a065a9 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/RandomBit.out +++ b/source/pip/tests-integration/resources/adaptive_ri/output/RandomBit.out @@ -4,5 +4,5 @@ METADATA output_labeling_schema METADATA qir_profiles adaptive_profile METADATA required_num_qubits 1 METADATA required_num_results 1 -OUTPUT RESULT 0 +OUTPUT RESULT 0 0_r END 0 diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/SampleTeleport.ll b/source/pip/tests-integration/resources/adaptive_ri/output/SampleTeleport.ll index 558b2e544a..171dfde7a8 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/SampleTeleport.ll +++ b/source/pip/tests-integration/resources/adaptive_ri/output/SampleTeleport.ll @@ -1,8 +1,12 @@ %Result = type opaque %Qubit = type opaque -define void @ENTRYPOINT__main() #0 { +@empty_tag = internal constant [1 x i8] c"\00" +@0 = internal constant [4 x i8] c"0_r\00" + +define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__cx__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 2 to %Qubit*)) @@ -10,14 +14,14 @@ block_0: call void @__quantum__qis__cx__body(%Qubit* inttoptr (i64 2 to %Qubit*), %Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 2 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - %var_1 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 0 to %Result*)) + %var_1 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 0 to %Result*)) br i1 %var_1, label %block_1, label %block_2 block_1: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 1 to %Qubit*)) br label %block_2 block_2: call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 2 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - %var_3 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 1 to %Result*)) + %var_3 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 1 to %Result*)) br i1 %var_3, label %block_3, label %block_4 block_3: call void @__quantum__qis__z__body(%Qubit* inttoptr (i64 1 to %Qubit*)) @@ -28,10 +32,12 @@ block_4: call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 1 to %Qubit*)) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* null) - ret void + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @0, i64 0, i64 0)) + ret i64 0 } +declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__h__body(%Qubit*) declare void @__quantum__qis__cx__body(%Qubit*, %Qubit*) @@ -40,7 +46,7 @@ declare void @__quantum__qis__x__body(%Qubit*) declare void @__quantum__qis__m__body(%Qubit*, %Result*) #1 -declare i1 @__quantum__qis__read_result__body(%Result*) +declare i1 @__quantum__rt__read_result(%Result*) declare void @__quantum__qis__mresetz__body(%Qubit*, %Result*) #1 @@ -61,4 +67,4 @@ attributes #1 = { "irreversible" } !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} -!4 = !{i32 1, !"int_computations", !"i64"} +!4 = !{i32 5, !"int_computations", !{!"i64"}} diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/SampleTeleport.out b/source/pip/tests-integration/resources/adaptive_ri/output/SampleTeleport.out index 566320047b..64b941c5f9 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/SampleTeleport.out +++ b/source/pip/tests-integration/resources/adaptive_ri/output/SampleTeleport.out @@ -4,5 +4,5 @@ METADATA output_labeling_schema METADATA qir_profiles adaptive_profile METADATA required_num_qubits 3 METADATA required_num_results 3 -OUTPUT RESULT 1 +OUTPUT RESULT 1 0_r END 0 diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/ShortcuttingMeasurement.ll b/source/pip/tests-integration/resources/adaptive_ri/output/ShortcuttingMeasurement.ll index 99917a8eca..92746c6b7f 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/ShortcuttingMeasurement.ll +++ b/source/pip/tests-integration/resources/adaptive_ri/output/ShortcuttingMeasurement.ll @@ -1,16 +1,21 @@ %Result = type opaque %Qubit = type opaque -define void @ENTRYPOINT__main() #0 { +@empty_tag = internal constant [1 x i8] c"\00" +@0 = internal constant [6 x i8] c"0_t0r\00" +@1 = internal constant [6 x i8] c"1_t1r\00" + +define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__cx__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - %var_0 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 0 to %Result*)) + %var_0 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 0 to %Result*)) br i1 %var_0, label %block_2, label %block_1 block_1: call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - %var_3 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 1 to %Result*)) + %var_3 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 1 to %Result*)) br label %block_2 block_2: %var_5 = phi i1 [true, %block_0], [%var_3, %block_1] @@ -24,19 +29,21 @@ block_4: call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 3 to %Result*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 1 to %Qubit*)) - call void @__quantum__rt__tuple_record_output(i64 2, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + ret i64 0 } +declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__x__body(%Qubit*) declare void @__quantum__qis__cx__body(%Qubit*, %Qubit*) declare void @__quantum__qis__m__body(%Qubit*, %Result*) #1 -declare i1 @__quantum__qis__read_result__body(%Result*) +declare i1 @__quantum__rt__read_result(%Result*) declare void @__quantum__qis__reset__body(%Qubit*) #1 @@ -55,4 +62,4 @@ attributes #1 = { "irreversible" } !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} -!4 = !{i32 1, !"int_computations", !"i64"} +!4 = !{i32 5, !"int_computations", !{!"i64"}} diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/ShortcuttingMeasurement.out b/source/pip/tests-integration/resources/adaptive_ri/output/ShortcuttingMeasurement.out index 453ce269ff..27d35996c4 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/ShortcuttingMeasurement.out +++ b/source/pip/tests-integration/resources/adaptive_ri/output/ShortcuttingMeasurement.out @@ -4,7 +4,7 @@ METADATA output_labeling_schema METADATA qir_profiles adaptive_profile METADATA required_num_qubits 2 METADATA required_num_results 4 -OUTPUT TUPLE 2 -OUTPUT RESULT 0 -OUTPUT RESULT 0 +OUTPUT TUPLE 2 +OUTPUT RESULT 0 0_t0r +OUTPUT RESULT 0 1_t1r END 0 diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/Slicing.ll b/source/pip/tests-integration/resources/adaptive_ri/output/Slicing.ll index 41f496f2e0..4630c40ac9 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/Slicing.ll +++ b/source/pip/tests-integration/resources/adaptive_ri/output/Slicing.ll @@ -1,8 +1,16 @@ %Result = type opaque %Qubit = type opaque -define void @ENTRYPOINT__main() #0 { +@empty_tag = internal constant [1 x i8] c"\00" +@0 = internal constant [6 x i8] c"0_a0r\00" +@1 = internal constant [6 x i8] c"1_a1r\00" +@2 = internal constant [6 x i8] c"2_a2r\00" +@3 = internal constant [6 x i8] c"3_a3r\00" +@4 = internal constant [6 x i8] c"4_a4r\00" + +define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 9 to %Qubit*)) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 8 to %Qubit*)) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 7 to %Qubit*)) @@ -23,15 +31,17 @@ block_0: call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 7 to %Qubit*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 8 to %Qubit*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 9 to %Qubit*)) - call void @__quantum__rt__array_record_output(i64 5, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* null) - ret void + call void @__quantum__rt__array_record_output(i64 5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @2, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 3 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @3, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @4, i64 0, i64 0)) + ret i64 0 } +declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__x__body(%Qubit*) declare void @__quantum__qis__m__body(%Qubit*, %Result*) #1 @@ -53,4 +63,4 @@ attributes #1 = { "irreversible" } !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} -!4 = !{i32 1, !"int_computations", !"i64"} +!4 = !{i32 5, !"int_computations", !{!"i64"}} diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/Slicing.out b/source/pip/tests-integration/resources/adaptive_ri/output/Slicing.out index 248c4992ba..c877c8b452 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/Slicing.out +++ b/source/pip/tests-integration/resources/adaptive_ri/output/Slicing.out @@ -4,10 +4,10 @@ METADATA output_labeling_schema METADATA qir_profiles adaptive_profile METADATA required_num_qubits 10 METADATA required_num_results 5 -OUTPUT ARRAY 5 -OUTPUT RESULT 1 -OUTPUT RESULT 1 -OUTPUT RESULT 1 -OUTPUT RESULT 1 -OUTPUT RESULT 1 +OUTPUT ARRAY 5 +OUTPUT RESULT 1 0_a0r +OUTPUT RESULT 1 1_a1r +OUTPUT RESULT 1 2_a2r +OUTPUT RESULT 1 3_a3r +OUTPUT RESULT 1 4_a4r END 0 diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/SuperdenseCoding.ll b/source/pip/tests-integration/resources/adaptive_ri/output/SuperdenseCoding.ll index a9a64cb613..dad7b84199 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/SuperdenseCoding.ll +++ b/source/pip/tests-integration/resources/adaptive_ri/output/SuperdenseCoding.ll @@ -1,16 +1,23 @@ %Result = type opaque %Qubit = type opaque -define void @ENTRYPOINT__main() #0 { +@empty_tag = internal constant [1 x i8] c"\00" +@0 = internal constant [8 x i8] c"0_t0t0b\00" +@1 = internal constant [8 x i8] c"1_t0t1b\00" +@2 = internal constant [8 x i8] c"2_t1t0b\00" +@3 = internal constant [8 x i8] c"3_t1t1b\00" + +define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__cx__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 2 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 2 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - %var_0 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 0 to %Result*)) + %var_0 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 0 to %Result*)) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 2 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 2 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - %var_4 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 1 to %Result*)) + %var_4 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 1 to %Result*)) br i1 %var_0, label %block_1, label %block_2 block_1: call void @__quantum__qis__z__body(%Qubit* inttoptr (i64 0 to %Qubit*)) @@ -26,32 +33,34 @@ block_4: call void @__quantum__qis__cx__body(%Qubit* inttoptr (i64 2 to %Qubit*), %Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 2 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 2 to %Qubit*), %Result* inttoptr (i64 2 to %Result*)) - %var_9 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 2 to %Result*)) + %var_9 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 2 to %Result*)) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 2 to %Qubit*)) call void @__quantum__qis__cz__body(%Qubit* inttoptr (i64 2 to %Qubit*), %Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__cz__body(%Qubit* inttoptr (i64 2 to %Qubit*), %Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 2 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 2 to %Qubit*), %Result* inttoptr (i64 3 to %Result*)) - %var_13 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 3 to %Result*)) + %var_13 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 3 to %Result*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 1 to %Qubit*)) - call void @__quantum__rt__tuple_record_output(i64 2, i8* null) - call void @__quantum__rt__tuple_record_output(i64 2, i8* null) - call void @__quantum__rt__bool_record_output(i1 %var_0, i8* null) - call void @__quantum__rt__bool_record_output(i1 %var_4, i8* null) - call void @__quantum__rt__tuple_record_output(i64 2, i8* null) - call void @__quantum__rt__bool_record_output(i1 %var_9, i8* null) - call void @__quantum__rt__bool_record_output(i1 %var_13, i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__tuple_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__bool_record_output(i1 %var_0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__bool_record_output(i1 %var_4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @1, i64 0, i64 0)) + call void @__quantum__rt__tuple_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__bool_record_output(i1 %var_9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @2, i64 0, i64 0)) + call void @__quantum__rt__bool_record_output(i1 %var_13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @3, i64 0, i64 0)) + ret i64 0 } +declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__h__body(%Qubit*) declare void @__quantum__qis__cx__body(%Qubit*, %Qubit*) declare void @__quantum__qis__mresetz__body(%Qubit*, %Result*) #1 -declare i1 @__quantum__qis__read_result__body(%Result*) +declare i1 @__quantum__rt__read_result(%Result*) declare void @__quantum__qis__z__body(%Qubit*) @@ -76,4 +85,4 @@ attributes #1 = { "irreversible" } !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} -!4 = !{i32 1, !"int_computations", !"i64"} +!4 = !{i32 5, !"int_computations", !{!"i64"}} diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/SuperdenseCoding.out b/source/pip/tests-integration/resources/adaptive_ri/output/SuperdenseCoding.out index 0170b7c2ff..e91f019bee 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/SuperdenseCoding.out +++ b/source/pip/tests-integration/resources/adaptive_ri/output/SuperdenseCoding.out @@ -4,11 +4,11 @@ METADATA output_labeling_schema METADATA qir_profiles adaptive_profile METADATA required_num_qubits 3 METADATA required_num_results 4 -OUTPUT TUPLE 2 -OUTPUT TUPLE 2 -OUTPUT BOOL false -OUTPUT BOOL false -OUTPUT TUPLE 2 -OUTPUT BOOL false -OUTPUT BOOL false +OUTPUT TUPLE 2 +OUTPUT TUPLE 2 +OUTPUT BOOL false 0_t0t0b +OUTPUT BOOL false 1_t0t1b +OUTPUT TUPLE 2 +OUTPUT BOOL false 2_t1t0b +OUTPUT BOOL false 3_t1t1b END 0 diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/SwitchHandling.ll b/source/pip/tests-integration/resources/adaptive_ri/output/SwitchHandling.ll index acf58afd49..1e1c5e9e83 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/SwitchHandling.ll +++ b/source/pip/tests-integration/resources/adaptive_ri/output/SwitchHandling.ll @@ -1,20 +1,24 @@ %Result = type opaque %Qubit = type opaque -define void @ENTRYPOINT__main() #0 { +@empty_tag = internal constant [1 x i8] c"\00" +@0 = internal constant [4 x i8] c"0_r\00" + +define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - %var_5 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 0 to %Result*)) + %var_5 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 0 to %Result*)) br i1 %var_5, label %block_1, label %block_2 block_1: br label %block_2 block_2: %var_16 = phi i64 [0, %block_0], [1, %block_1] %var_7 = shl i64 %var_16, 1 - %var_8 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 1 to %Result*)) + %var_8 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 1 to %Result*)) br i1 %var_8, label %block_3, label %block_4 block_3: %var_10 = add i64 %var_7, 1 @@ -48,15 +52,17 @@ block_12: br label %block_13 block_13: call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 2 to %Qubit*), %Result* inttoptr (i64 2 to %Result*)) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* null) - ret void + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @0, i64 0, i64 0)) + ret i64 0 } +declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__x__body(%Qubit*) declare void @__quantum__qis__m__body(%Qubit*, %Result*) #1 -declare i1 @__quantum__qis__read_result__body(%Result*) +declare i1 @__quantum__rt__read_result(%Result*) declare void @__quantum__qis__reset__body(%Qubit*) #1 @@ -81,4 +87,4 @@ attributes #1 = { "irreversible" } !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} -!4 = !{i32 1, !"int_computations", !"i64"} +!4 = !{i32 5, !"int_computations", !{!"i64"}} diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/SwitchHandling.out b/source/pip/tests-integration/resources/adaptive_ri/output/SwitchHandling.out index 566320047b..64b941c5f9 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/SwitchHandling.out +++ b/source/pip/tests-integration/resources/adaptive_ri/output/SwitchHandling.out @@ -4,5 +4,5 @@ METADATA output_labeling_schema METADATA qir_profiles adaptive_profile METADATA required_num_qubits 3 METADATA required_num_results 3 -OUTPUT RESULT 1 +OUTPUT RESULT 1 0_r END 0 diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/ThreeQubitRepetitionCode.ll b/source/pip/tests-integration/resources/adaptive_ri/output/ThreeQubitRepetitionCode.ll index 47fe19769d..4176cc355c 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/ThreeQubitRepetitionCode.ll +++ b/source/pip/tests-integration/resources/adaptive_ri/output/ThreeQubitRepetitionCode.ll @@ -1,8 +1,13 @@ %Result = type opaque %Qubit = type opaque -define void @ENTRYPOINT__main() #0 { +@empty_tag = internal constant [1 x i8] c"\00" +@0 = internal constant [6 x i8] c"0_t0b\00" +@1 = internal constant [6 x i8] c"1_t1i\00" + +define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__z__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__cx__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Qubit* inttoptr (i64 1 to %Qubit*)) @@ -25,13 +30,13 @@ block_0: call void @__quantum__qis__cx__body(%Qubit* inttoptr (i64 2 to %Qubit*), %Qubit* inttoptr (i64 4 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 3 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 4 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - %var_11 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 0 to %Result*)) + %var_11 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 0 to %Result*)) br i1 %var_11, label %block_1, label %block_2 block_1: - %var_13 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 1 to %Result*)) + %var_13 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 1 to %Result*)) br i1 %var_13, label %block_3, label %block_4 block_2: - %var_15 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 1 to %Result*)) + %var_15 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 1 to %Result*)) br i1 %var_15, label %block_5, label %block_6 block_3: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 1 to %Qubit*)) @@ -74,13 +79,13 @@ block_11: call void @__quantum__qis__cx__body(%Qubit* inttoptr (i64 2 to %Qubit*), %Qubit* inttoptr (i64 4 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 3 to %Qubit*), %Result* inttoptr (i64 2 to %Result*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 4 to %Qubit*), %Result* inttoptr (i64 3 to %Result*)) - %var_26 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 2 to %Result*)) + %var_26 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 2 to %Result*)) br i1 %var_26, label %block_12, label %block_13 block_12: - %var_28 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 3 to %Result*)) + %var_28 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 3 to %Result*)) br i1 %var_28, label %block_14, label %block_15 block_13: - %var_30 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 3 to %Result*)) + %var_30 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 3 to %Result*)) br i1 %var_30, label %block_16, label %block_17 block_14: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 1 to %Qubit*)) @@ -124,13 +129,13 @@ block_22: call void @__quantum__qis__cx__body(%Qubit* inttoptr (i64 2 to %Qubit*), %Qubit* inttoptr (i64 4 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 3 to %Qubit*), %Result* inttoptr (i64 4 to %Result*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 4 to %Qubit*), %Result* inttoptr (i64 5 to %Result*)) - %var_42 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 4 to %Result*)) + %var_42 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 4 to %Result*)) br i1 %var_42, label %block_23, label %block_24 block_23: - %var_44 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 5 to %Result*)) + %var_44 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 5 to %Result*)) br i1 %var_44, label %block_25, label %block_26 block_24: - %var_46 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 5 to %Result*)) + %var_46 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 5 to %Result*)) br i1 %var_46, label %block_27, label %block_28 block_25: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 1 to %Qubit*)) @@ -174,13 +179,13 @@ block_33: call void @__quantum__qis__cx__body(%Qubit* inttoptr (i64 2 to %Qubit*), %Qubit* inttoptr (i64 4 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 3 to %Qubit*), %Result* inttoptr (i64 6 to %Result*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 4 to %Qubit*), %Result* inttoptr (i64 7 to %Result*)) - %var_58 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 6 to %Result*)) + %var_58 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 6 to %Result*)) br i1 %var_58, label %block_34, label %block_35 block_34: - %var_60 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 7 to %Result*)) + %var_60 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 7 to %Result*)) br i1 %var_60, label %block_36, label %block_37 block_35: - %var_62 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 7 to %Result*)) + %var_62 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 7 to %Result*)) br i1 %var_62, label %block_38, label %block_39 block_36: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 1 to %Qubit*)) @@ -224,13 +229,13 @@ block_44: call void @__quantum__qis__cx__body(%Qubit* inttoptr (i64 2 to %Qubit*), %Qubit* inttoptr (i64 4 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 3 to %Qubit*), %Result* inttoptr (i64 8 to %Result*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 4 to %Qubit*), %Result* inttoptr (i64 9 to %Result*)) - %var_74 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 8 to %Result*)) + %var_74 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 8 to %Result*)) br i1 %var_74, label %block_45, label %block_46 block_45: - %var_76 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 9 to %Result*)) + %var_76 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 9 to %Result*)) br i1 %var_76, label %block_47, label %block_48 block_46: - %var_78 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 9 to %Result*)) + %var_78 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 9 to %Result*)) br i1 %var_78, label %block_49, label %block_50 block_47: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 1 to %Qubit*)) @@ -260,15 +265,17 @@ block_55: call void @__quantum__qis__cx__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__h__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 10 to %Result*)) - %var_82 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 10 to %Result*)) + %var_82 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 10 to %Result*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 2 to %Qubit*)) - call void @__quantum__rt__tuple_record_output(i64 2, i8* null) - call void @__quantum__rt__bool_record_output(i1 %var_82, i8* null) - call void @__quantum__rt__int_record_output(i64 %var_101, i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__bool_record_output(i1 %var_82, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__int_record_output(i64 %var_101, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + ret i64 0 } +declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__h__body(%Qubit*) declare void @__quantum__qis__z__body(%Qubit*) @@ -279,7 +286,7 @@ declare void @__quantum__qis__rx__body(double, %Qubit*) declare void @__quantum__qis__mresetz__body(%Qubit*, %Result*) #1 -declare i1 @__quantum__qis__read_result__body(%Result*) +declare i1 @__quantum__rt__read_result(%Result*) declare void @__quantum__qis__x__body(%Qubit*) @@ -302,4 +309,4 @@ attributes #1 = { "irreversible" } !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} -!4 = !{i32 1, !"int_computations", !"i64"} +!4 = !{i32 5, !"int_computations", !{!"i64"}} diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/ThreeQubitRepetitionCode.out b/source/pip/tests-integration/resources/adaptive_ri/output/ThreeQubitRepetitionCode.out index 43e53972f4..e6998cc5f2 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/ThreeQubitRepetitionCode.out +++ b/source/pip/tests-integration/resources/adaptive_ri/output/ThreeQubitRepetitionCode.out @@ -4,7 +4,7 @@ METADATA output_labeling_schema METADATA qir_profiles adaptive_profile METADATA required_num_qubits 5 METADATA required_num_results 11 -OUTPUT TUPLE 2 -OUTPUT BOOL true -OUTPUT INT 0 +OUTPUT TUPLE 2 +OUTPUT BOOL true 0_t0b +OUTPUT INT 0 1_t1i END 0 diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/WithinApply.ll b/source/pip/tests-integration/resources/adaptive_ri/output/WithinApply.ll index ff8de72dfe..f534755d98 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/WithinApply.ll +++ b/source/pip/tests-integration/resources/adaptive_ri/output/WithinApply.ll @@ -1,8 +1,14 @@ %Result = type opaque %Qubit = type opaque -define void @ENTRYPOINT__main() #0 { +@empty_tag = internal constant [1 x i8] c"\00" +@0 = internal constant [6 x i8] c"0_a0r\00" +@1 = internal constant [6 x i8] c"1_a1r\00" +@2 = internal constant [6 x i8] c"2_a2r\00" + +define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 2 to %Qubit*)) call void @__quantum__qis__ccx__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Qubit* inttoptr (i64 2 to %Qubit*), %Qubit* inttoptr (i64 0 to %Qubit*)) @@ -14,13 +20,15 @@ block_0: call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 1 to %Qubit*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 2 to %Qubit*)) call void @__quantum__qis__reset__body(%Qubit* inttoptr (i64 0 to %Qubit*)) - call void @__quantum__rt__array_record_output(i64 3, i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* null) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* null) - ret void + call void @__quantum__rt__array_record_output(i64 3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 1 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @2, i64 0, i64 0)) + ret i64 0 } +declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__x__body(%Qubit*) declare void @__quantum__qis__ccx__body(%Qubit*, %Qubit*, %Qubit*) @@ -44,4 +52,4 @@ attributes #1 = { "irreversible" } !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} -!4 = !{i32 1, !"int_computations", !"i64"} +!4 = !{i32 5, !"int_computations", !{!"i64"}} diff --git a/source/pip/tests-integration/resources/adaptive_ri/output/WithinApply.out b/source/pip/tests-integration/resources/adaptive_ri/output/WithinApply.out index dfebae9f19..c33e20d6fe 100644 --- a/source/pip/tests-integration/resources/adaptive_ri/output/WithinApply.out +++ b/source/pip/tests-integration/resources/adaptive_ri/output/WithinApply.out @@ -4,8 +4,8 @@ METADATA output_labeling_schema METADATA qir_profiles adaptive_profile METADATA required_num_qubits 3 METADATA required_num_results 3 -OUTPUT ARRAY 3 -OUTPUT RESULT 0 -OUTPUT RESULT 0 -OUTPUT RESULT 1 +OUTPUT ARRAY 3 +OUTPUT RESULT 0 0_a0r +OUTPUT RESULT 0 1_a1r +OUTPUT RESULT 1 2_a2r END 0 diff --git a/source/pip/tests-integration/resources/adaptive_rif/output/Doubles.ll b/source/pip/tests-integration/resources/adaptive_rif/output/Doubles.ll index 7db8d6c0a4..c02f4592de 100644 --- a/source/pip/tests-integration/resources/adaptive_rif/output/Doubles.ll +++ b/source/pip/tests-integration/resources/adaptive_rif/output/Doubles.ll @@ -1,11 +1,20 @@ %Result = type opaque %Qubit = type opaque -define void @ENTRYPOINT__main() #0 { +@empty_tag = internal constant [1 x i8] c"\00" +@0 = internal constant [6 x i8] c"0_t0d\00" +@1 = internal constant [6 x i8] c"1_t1b\00" +@2 = internal constant [6 x i8] c"2_t2b\00" +@3 = internal constant [6 x i8] c"3_t3b\00" +@4 = internal constant [6 x i8] c"4_t4b\00" +@5 = internal constant [6 x i8] c"5_t5b\00" + +define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - %var_2 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 0 to %Result*)) + %var_2 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 0 to %Result*)) br i1 %var_2, label %block_1, label %block_2 block_1: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) @@ -14,7 +23,7 @@ block_2: %var_72 = phi double [0.0, %block_0], [1.0, %block_1] call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) - %var_4 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 1 to %Result*)) + %var_4 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 1 to %Result*)) br i1 %var_4, label %block_3, label %block_4 block_3: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) @@ -28,7 +37,7 @@ block_4: %var_73 = phi double [%var_72, %block_2], [%var_10, %block_3] call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 2 to %Result*)) - %var_11 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 2 to %Result*)) + %var_11 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 2 to %Result*)) br i1 %var_11, label %block_5, label %block_6 block_5: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) @@ -42,7 +51,7 @@ block_6: %var_74 = phi double [%var_73, %block_4], [%var_17, %block_5] call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 3 to %Result*)) - %var_18 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 3 to %Result*)) + %var_18 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 3 to %Result*)) br i1 %var_18, label %block_7, label %block_8 block_7: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) @@ -56,7 +65,7 @@ block_8: %var_75 = phi double [%var_74, %block_6], [%var_24, %block_7] call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 4 to %Result*)) - %var_25 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 4 to %Result*)) + %var_25 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 4 to %Result*)) br i1 %var_25, label %block_9, label %block_10 block_9: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) @@ -70,7 +79,7 @@ block_10: %var_76 = phi double [%var_75, %block_8], [%var_31, %block_9] call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 5 to %Result*)) - %var_32 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 5 to %Result*)) + %var_32 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 5 to %Result*)) br i1 %var_32, label %block_11, label %block_12 block_11: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) @@ -84,7 +93,7 @@ block_12: %var_77 = phi double [%var_76, %block_10], [%var_38, %block_11] call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 6 to %Result*)) - %var_39 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 6 to %Result*)) + %var_39 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 6 to %Result*)) br i1 %var_39, label %block_13, label %block_14 block_13: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) @@ -98,7 +107,7 @@ block_14: %var_78 = phi double [%var_77, %block_12], [%var_45, %block_13] call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 7 to %Result*)) - %var_46 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 7 to %Result*)) + %var_46 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 7 to %Result*)) br i1 %var_46, label %block_15, label %block_16 block_15: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) @@ -112,7 +121,7 @@ block_16: %var_79 = phi double [%var_78, %block_14], [%var_52, %block_15] call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 8 to %Result*)) - %var_53 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 8 to %Result*)) + %var_53 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 8 to %Result*)) br i1 %var_53, label %block_17, label %block_18 block_17: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) @@ -126,7 +135,7 @@ block_18: %var_80 = phi double [%var_79, %block_16], [%var_59, %block_17] call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 9 to %Result*)) - %var_60 = call i1 @__quantum__qis__read_result__body(%Result* inttoptr (i64 9 to %Result*)) + %var_60 = call i1 @__quantum__rt__read_result(%Result* inttoptr (i64 9 to %Result*)) br i1 %var_60, label %block_19, label %block_20 block_19: call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 0 to %Qubit*)) @@ -144,21 +153,23 @@ block_20: %var_69 = fcmp oge double %var_81, 10.0 %var_70 = fcmp oeq double %var_81, 10.0 %var_71 = fcmp one double %var_81, 10.0 - call void @__quantum__rt__tuple_record_output(i64 6, i8* null) - call void @__quantum__rt__double_record_output(double %var_81, i8* null) - call void @__quantum__rt__bool_record_output(i1 %var_67, i8* null) - call void @__quantum__rt__bool_record_output(i1 %var_68, i8* null) - call void @__quantum__rt__bool_record_output(i1 %var_69, i8* null) - call void @__quantum__rt__bool_record_output(i1 %var_70, i8* null) - call void @__quantum__rt__bool_record_output(i1 %var_71, i8* null) - ret void + call void @__quantum__rt__tuple_record_output(i64 6, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty_tag, i64 0, i64 0)) + call void @__quantum__rt__double_record_output(double %var_81, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i64 0, i64 0)) + call void @__quantum__rt__bool_record_output(i1 %var_67, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @1, i64 0, i64 0)) + call void @__quantum__rt__bool_record_output(i1 %var_68, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @2, i64 0, i64 0)) + call void @__quantum__rt__bool_record_output(i1 %var_69, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @3, i64 0, i64 0)) + call void @__quantum__rt__bool_record_output(i1 %var_70, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @4, i64 0, i64 0)) + call void @__quantum__rt__bool_record_output(i1 %var_71, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @5, i64 0, i64 0)) + ret i64 0 } +declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__x__body(%Qubit*) declare void @__quantum__qis__m__body(%Qubit*, %Result*) #1 -declare i1 @__quantum__qis__read_result__body(%Result*) +declare i1 @__quantum__rt__read_result(%Result*) declare void @__quantum__qis__reset__body(%Qubit*) #1 @@ -179,5 +190,5 @@ attributes #1 = { "irreversible" } !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} -!4 = !{i32 1, !"int_computations", !"i64"} -!5 = !{i32 1, !"float_computations", !"f64"} +!4 = !{i32 5, !"int_computations", !{!"i64"}} +!5 = !{i32 5, !"float_computations", !{!"f64"}} diff --git a/source/pip/tests-integration/resources/adaptive_rif/output/Doubles.out b/source/pip/tests-integration/resources/adaptive_rif/output/Doubles.out index ac07504f19..a2c86b382f 100644 --- a/source/pip/tests-integration/resources/adaptive_rif/output/Doubles.out +++ b/source/pip/tests-integration/resources/adaptive_rif/output/Doubles.out @@ -4,11 +4,11 @@ METADATA output_labeling_schema METADATA qir_profiles adaptive_profile METADATA required_num_qubits 1 METADATA required_num_results 10 -OUTPUT TUPLE 6 -OUTPUT DOUBLE 10.0 -OUTPUT BOOL true -OUTPUT BOOL false -OUTPUT BOOL true -OUTPUT BOOL true -OUTPUT BOOL false +OUTPUT TUPLE 6 +OUTPUT DOUBLE 10.0 0_t0d +OUTPUT BOOL true 1_t1b +OUTPUT BOOL false 2_t2b +OUTPUT BOOL true 3_t3b +OUTPUT BOOL true 4_t4b +OUTPUT BOOL false 5_t5b END 0 diff --git a/source/pip/tests-integration/test_base_qir.py b/source/pip/tests-integration/test_base_qir.py index 0c75677021..7941590f2c 100644 --- a/source/pip/tests-integration/test_base_qir.py +++ b/source/pip/tests-integration/test_base_qir.py @@ -32,23 +32,23 @@ def test_compile_qir_input_data() -> None: qir = operation._repr_qir_() assert isinstance(qir, bytes) module = Module.from_ir(Context(), qir.decode(), "module") - assert len(module.functions) == 3 + assert len(module.functions) == 4 assert module.functions[0].name == "ENTRYPOINT__main" func = module.functions[0] assert len(func.basic_blocks) == 1 - assert len(func.basic_blocks[0].instructions) == 3 - call_m = func.basic_blocks[0].instructions[0] + assert len(func.basic_blocks[0].instructions) == 4 + call_m = func.basic_blocks[0].instructions[1] assert isinstance(call_m, Call) assert call_m.callee.name == "__quantum__qis__m__body" assert len(call_m.args) == 2 assert qubit_id(call_m.args[0]) == 0 assert result_id(call_m.args[1]) == 0 - record_res = func.basic_blocks[0].instructions[1] + record_res = func.basic_blocks[0].instructions[2] assert isinstance(record_res, Call) assert len(record_res.args) == 2 assert record_res.callee.name == "__quantum__rt__result_record_output" assert result_id(record_res.args[0]) == 0 - assert func.basic_blocks[0].instructions[2].opcode == Opcode.RET + assert func.basic_blocks[0].instructions[3].opcode == Opcode.RET @pytest.mark.skipif(not PYQIR_AVAILABLE, reason=SKIP_REASON) @@ -85,14 +85,14 @@ def test_compile_qir_all_gates() -> None: qir = operation._repr_qir_() assert isinstance(qir, bytes) module = Module.from_ir(Context(), qir.decode(), "module") - assert len(module.functions) == 24 + assert len(module.functions) == 25 assert module.functions[0].name == "ENTRYPOINT__main" func = module.functions[0] assert len(func.basic_blocks) == 1 - assert len(func.basic_blocks[0].instructions) == 27 + assert len(func.basic_blocks[0].instructions) == 28 def check_call(i: int, name: str, num_args: int) -> None: - call = func.basic_blocks[0].instructions[i] + call = func.basic_blocks[0].instructions[i + 1] assert isinstance(call, Call) assert call.callee.name == name assert len(call.args) == num_args diff --git a/source/pip/tests-integration/test_requirements.txt b/source/pip/tests-integration/test_requirements.txt index ef5088095f..0347067b37 100644 --- a/source/pip/tests-integration/test_requirements.txt +++ b/source/pip/tests-integration/test_requirements.txt @@ -1,6 +1,6 @@ pytest==8.2.2 qiskit>=1.3.0,<2.0.0 -qirrunner==0.7.1 +qirrunner==0.8.3 pyqir==0.10.2 qiskit-aer==0.14.2 qiskit_qasm3_import==0.5.0 diff --git a/source/pip/tests/test_interpreter.py b/source/pip/tests/test_interpreter.py index 7c8b28ce77..9dfce57844 100644 --- a/source/pip/tests/test_interpreter.py +++ b/source/pip/tests/test_interpreter.py @@ -371,16 +371,22 @@ def test_adaptive_ri_qir_can_be_generated() -> None: %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\\00" + @0 = internal constant [4 x i8] c"0_r\\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__rz__body(double 2.0, %Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__rz__body(double 0.0, %Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__rz__body(double 1.0, %Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__mresetz__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - ret void + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @0, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__rz__body(double, %Qubit*) declare void @__quantum__qis__mresetz__body(%Qubit*, %Result*) #1 @@ -398,7 +404,7 @@ def test_adaptive_ri_qir_can_be_generated() -> None: !1 = !{i32 7, !"qir_minor_version", i32 0} !2 = !{i32 1, !"dynamic_qubit_management", i1 false} !3 = !{i32 1, !"dynamic_result_management", i1 false} - !4 = !{i32 1, !"int_computations", !"i64"} + !4 = !{i32 5, !"int_computations", !{!"i64"}} """ ) @@ -429,16 +435,22 @@ def test_base_qir_can_be_generated() -> None: %Result = type opaque %Qubit = type opaque - define void @ENTRYPOINT__main() #0 { + @empty_tag = internal constant [1 x i8] c"\\00" + @0 = internal constant [4 x i8] c"0_r\\00" + + define i64 @ENTRYPOINT__main() #0 { block_0: + call void @__quantum__rt__initialize(i8* null) call void @__quantum__qis__rz__body(double 2.0, %Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__rz__body(double 0.0, %Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__rz__body(double 1.0, %Qubit* inttoptr (i64 0 to %Qubit*)) call void @__quantum__qis__m__body(%Qubit* inttoptr (i64 0 to %Qubit*), %Result* inttoptr (i64 0 to %Result*)) - call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null) - ret void + call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @0, i64 0, i64 0)) + ret i64 0 } + declare void @__quantum__rt__initialize(i8*) + declare void @__quantum__qis__rz__body(double, %Qubit*) declare void @__quantum__rt__result_record_output(%Result*, i8*) diff --git a/source/pip/tests/test_qasm.py b/source/pip/tests/test_qasm.py index 7fff4eada8..a1e673d1b0 100644 --- a/source/pip/tests/test_qasm.py +++ b/source/pip/tests/test_qasm.py @@ -289,7 +289,7 @@ def test_compile_qir_input_data() -> None: def test_compile_qir_str() -> None: qir = str(compile("qubit q; output bit c; c = measure q;")) - assert "define void @ENTRYPOINT__main()" in qir + assert "define i64 @ENTRYPOINT__main()" in qir assert '"required_num_qubits"="1" "required_num_results"="1"' in qir @@ -321,7 +321,7 @@ def test_compile_qir_str_from_python_callable() -> None: import_openqasm("qubit q; output bit c; c = measure q;", name="Program") operation = compile(code.Program) qir = str(operation) - assert "define void @ENTRYPOINT__main()" in qir + assert "define i64 @ENTRYPOINT__main()" in qir assert '"required_num_qubits"="1" "required_num_results"="1"' in qir @@ -340,13 +340,13 @@ def test_compile_qir_str_from_python_callable_with_single_arg() -> None: operation = compile(code.program, pi) qir = str(operation) - assert "define void @ENTRYPOINT__main()" in qir + assert "define i64 @ENTRYPOINT__main()" in qir assert ( "call void @__quantum__qis__rx__body(double 3.141592653589793, %Qubit* inttoptr (i64 0 to %Qubit*))" in qir ) assert ( - "call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null)" + "call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @0, i64 0, i64 0))" in qir ) assert '"required_num_qubits"="1" "required_num_results"="1"' in qir @@ -368,13 +368,13 @@ def test_compile_qir_str_from_python_callable_with_multiple_args() -> None: ) operation = compile(code.Program, 2 * pi, 2.0) qir = str(operation) - assert "define void @ENTRYPOINT__main()" in qir + assert "define i64 @ENTRYPOINT__main()" in qir assert ( "call void @__quantum__qis__rx__body(double 3.141592653589793, %Qubit* inttoptr (i64 0 to %Qubit*))" in qir ) assert ( - "call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null)" + "call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @0, i64 0, i64 0))" in qir ) assert '"required_num_qubits"="1" "required_num_results"="1"' in qir @@ -399,13 +399,13 @@ def test_compile_qir_str_from_python_callable_with_multiple_args_passed_as_tuple args = (2 * pi, 2.0) operation = compile(code.Program, args) qir = str(operation) - assert "define void @ENTRYPOINT__main()" in qir + assert "define i64 @ENTRYPOINT__main()" in qir assert ( "call void @__quantum__qis__rx__body(double 3.141592653589793, %Qubit* inttoptr (i64 0 to %Qubit*))" in qir ) assert ( - "call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* null)" + "call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 0 to %Result*), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @0, i64 0, i64 0))" in qir ) assert '"required_num_qubits"="1" "required_num_results"="1"' in qir @@ -424,7 +424,7 @@ def test_compile_qir_str_from_callable_with_mresetzchecked() -> None: ) operation = compile(code.Program) qir = str(operation) - assert "define void @ENTRYPOINT__main()" in qir + assert "define i64 @ENTRYPOINT__main()" in qir assert ( "call i1 @__quantum__rt__read_loss(%Result* inttoptr (i64 0 to %Result*))" in qir diff --git a/source/pip/tests/test_qsharp.py b/source/pip/tests/test_qsharp.py index 396794fd13..dc8f06ce0a 100644 --- a/source/pip/tests/test_qsharp.py +++ b/source/pip/tests/test_qsharp.py @@ -330,7 +330,7 @@ def test_compile_qir_str() -> None: qsharp.eval("operation Program() : Result { use q = Qubit(); return MResetZ(q); }") operation = qsharp.compile("Program()") qir = str(operation) - assert "define void @ENTRYPOINT__main()" in qir + assert "define i64 @ENTRYPOINT__main()" in qir assert '"required_num_qubits"="1" "required_num_results"="1"' in qir @@ -339,7 +339,7 @@ def test_compile_qir_str_from_python_callable() -> None: qsharp.eval("operation Program() : Result { use q = Qubit(); return MResetZ(q); }") operation = qsharp.compile(qsharp.code.Program) qir = str(operation) - assert "define void @ENTRYPOINT__main()" in qir + assert "define i64 @ENTRYPOINT__main()" in qir assert '"required_num_qubits"="1" "required_num_results"="1"' in qir @@ -350,9 +350,9 @@ def test_compile_qir_str_from_python_callable_with_single_arg() -> None: ) operation = qsharp.compile(qsharp.code.Program, 5) qir = str(operation) - assert "define void @ENTRYPOINT__main()" in qir + assert "define i64 @ENTRYPOINT__main()" in qir assert ( - "call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* null)" + "call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @4, i64 0, i64 0))" in qir ) assert '"required_num_qubits"="5" "required_num_results"="5"' in qir @@ -365,13 +365,13 @@ def test_compile_qir_str_from_python_callable_with_array_arg() -> None: ) operation = qsharp.compile(qsharp.code.Program, [5, 3]) qir = str(operation) - assert "define void @ENTRYPOINT__main()" in qir + assert "define i64 @ENTRYPOINT__main()" in qir assert ( - "call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* null)" + "call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @2, i64 0, i64 0))" in qir ) assert ( - "call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* null)" + "call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @4, i64 0, i64 0))" not in qir ) assert '"required_num_qubits"="3" "required_num_results"="3"' in qir @@ -384,13 +384,13 @@ def test_compile_qir_str_from_python_callable_with_multiple_args() -> None: ) operation = qsharp.compile(qsharp.code.Program, 5, 3) qir = str(operation) - assert "define void @ENTRYPOINT__main()" in qir + assert "define i64 @ENTRYPOINT__main()" in qir assert ( - "call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* null)" + "call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @2, i64 0, i64 0))" in qir ) assert ( - "call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* null)" + "call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @4, i64 0, i64 0))" not in qir ) assert '"required_num_qubits"="5" "required_num_results"="5"' in qir @@ -406,13 +406,13 @@ def test_compile_qir_str_from_python_callable_with_multiple_args_passed_as_tuple args = (5, 3) operation = qsharp.compile(qsharp.code.Program, args) qir = str(operation) - assert "define void @ENTRYPOINT__main()" in qir + assert "define i64 @ENTRYPOINT__main()" in qir assert ( - "call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* null)" + "call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 2 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @2, i64 0, i64 0))" in qir ) assert ( - "call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* null)" + "call void @__quantum__rt__result_record_output(%Result* inttoptr (i64 4 to %Result*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @4, i64 0, i64 0))" not in qir ) assert '"required_num_qubits"="5" "required_num_results"="5"' in qir