-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port standard instructions to Rust. (#13486)
* Extend PackedOperation for standard instructions. * WIP * Compiling. * Add missing module registration. * Implement Operation::directive * Add StandardInstructionType enum. * Expose only StandardInstructionType to Python. This way, we can also use this enum to tag the Python classes. * Fix unit access. * Remove no longer needed enum variant parens. * Remove unused stuff. * Fix up packed_instruction docs, add From<StandardInstruction>. * Fix up imports. * Improve comments in circuit_instruction. * Fix typo. * More doc fixes. * Reorganize PackedInstruction mem layout to support 32 bit archs. * Update layout description, cleanup. * Revert "Update layout description, cleanup." This reverts commit b6d8f92. * Revert "Reorganize PackedInstruction mem layout to support 32 bit archs." This reverts commit 6049498. * Use bitfield-struct crate for PackedOperation. Trying out a neat crate for Rust bitfields. The caveats are: * Custom enums used in the bitfield must specify const funcs for bit conversion, and bytemuck's cast functions aren't const. * The bitfield crate implements Clone for you, but does not seem to have a way to disable this. We can't rely on their clone, since for pointer types we need to allocate a new Box. To get around this, PackedOperation is a wrapper around an internal bitfield struct (rather than being a bitfield struct itself). (Note: I'm not yet happy with this. Specifically, I think the abstraction may be cleaner if OpBitField is defined entirely in terms of raw native types and any reinterpretation / transmutation is done from PackedOperation. Consider this a first pass.) * Pivot. * Compiling. * Remove unused bytemuck stuff. * Run format. * Improve static assertion error messages. * Clean up. * Implement delay unit for ImmediateValue. * Finish implementing PointerBits for 32 bit. I can't easily test this on my own machine, but I think it'll work. * More cleanup and documentation updates. * Ensure subclasses of Measure are not treated as standard. * Drop 32-bit support. * Make StandardInstruction::Barrier hold a u32. * Remove static assertion in favor of comment. * Add notes on bitfield macro behavior to structs. * Make immediate a union. This is really what it should be here, since selecting one of its members is inherently unsafe and something the caller should be responsible for doing correctly. * Rewrite to localize bit packing by kind. * Rename 'standard_gate label. * Add backup handling for PyInstruction compare. This shouldn't happen, but if it does, we can handle it gracefully like we do for StandardGate and PyGate. * Use StandardInstruction in BarrierBeforeFinalMeasurements. * Rename OperationRef::StandardGate. * Replace Barrier uses. * Remove _Pointer suffixes. * Merge fixes. * Avoid coercing int to float in Delay duration. * Update Cargo.lock. * Fix lint. * Make impl_packable_pointer operation_type an expr. * Move PackedOperation Drop to root mod. Also uses codegen for From<Box<T>> explicitly for all T, rather than a blanket impl on the private PackablePointer trait to ensure proper docs are generated. * Remove StandardGate pad. * Add #[inline] in a few places. Probably not necessary in most of these cases.
- Loading branch information
1 parent
6274843
commit 73409fb
Showing
25 changed files
with
818 additions
and
357 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Oops, something went wrong.