-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
XaccQuantum: Fix broken ccx (Toffoli)
The current handling of ccx has two problems in HEAD: 1. It is defined with two qubit operands instead of three 2. The implementation in XaccQuantum attempts to create an XACC instruction that does not exist Problem #1 manifests as this assertion tripped inside QIR-EE: $ build/bin/qir-xacc -i test/data/bell_ccx.ll --accelerator qpp terminate called after throwing an instance of 'qiree::RuntimeError' what(): /home/austin/Documents/school/gatech/grad/qsvt/qiree/src/qiree/detail/FunctionChecker.hh:116: qir-ee: runtime error: arg_size == irfunc_.arg_size() failed: incorrect QIR binding supplied: '__quantum__qis__ccx__body' has 3 arguments but QIR-EE expected 2 Aborted Problem #2 pops up when XACC throws the following exception: $ build/bin/qir-xacc -i test/data/bell_ccx.ll --accelerator qpp terminate called after throwing an instance of 'std::runtime_error' what(): Invalid instruction name - CCX Aborted This commit fixes both issues.
- Loading branch information
Showing
10 changed files
with
170 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
; ModuleID = 'Bell_ccx' | ||
source_filename = "Bell_ccx" | ||
|
||
%Qubit = type opaque | ||
%Result = type opaque | ||
|
||
define void @main() #0 { | ||
entry: | ||
call void @__quantum__qis__h__body(%Qubit* null) | ||
call void @__quantum__qis__x__body(%Qubit* inttoptr (i64 1 to %Qubit*)) | ||
call void @__quantum__qis__ccx__body(%Qubit* null, %Qubit* inttoptr (i64 1 to %Qubit*), %Qubit* inttoptr (i64 2 to %Qubit*)) | ||
call void @__quantum__qis__mz__body(%Qubit* null, %Result* null) | ||
call void @__quantum__qis__mz__body(%Qubit* inttoptr (i64 1 to %Qubit*), %Result* inttoptr (i64 1 to %Result*)) | ||
call void @__quantum__qis__mz__body(%Qubit* inttoptr (i64 2 to %Qubit*), %Result* inttoptr (i64 2 to %Result*)) | ||
call void @__quantum__rt__array_record_output(i64 3, i8* null) | ||
call void @__quantum__rt__result_record_output(%Result* null, 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 | ||
} | ||
|
||
declare void @__quantum__qis__h__body(%Qubit*) | ||
|
||
declare void @__quantum__qis__x__body(%Qubit*) | ||
|
||
declare void @__quantum__qis__ccx__body(%Qubit*, %Qubit*, %Qubit*) | ||
|
||
declare void @__quantum__qis__mz__body(%Qubit*, %Result* writeonly) #1 | ||
|
||
declare void @__quantum__rt__array_record_output(i64, i8*) | ||
|
||
declare void @__quantum__rt__result_record_output(%Result*, i8*) | ||
|
||
attributes #0 = { "entry_point" "num_required_qubits"="3" "num_required_results"="3" "output_labeling_schema" "qir_profiles"="custom" } | ||
attributes #1 = { "irreversible" } | ||
|
||
!llvm.module.flags = !{!0, !1, !2, !3} | ||
|
||
!0 = !{i32 1, !"qir_major_version", i32 1} | ||
!1 = !{i32 7, !"qir_minor_version", i32 0} | ||
!2 = !{i32 1, !"dynamic_qubit_management", i1 false} | ||
!3 = !{i32 1, !"dynamic_result_management", i1 false} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters