Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git subtree hugr-llvm #1601

Draft
wants to merge 84 commits into
base: main
Choose a base branch
from
Draft

git subtree hugr-llvm #1601

wants to merge 84 commits into from

Conversation

doug-q
Copy link
Collaborator

@doug-q doug-q commented Oct 21, 2024

No description provided.

doug-q and others added 30 commits May 24, 2024 14:52
Co-authored-by: doug-q <141026920+doug-q@users.noreply.github.com>
feat: Emission for Call nodes
chore: Add issue-to-project.yml, enable coverage
They were pointing to an invalid source directory.
fix: sum type tag elision logic reversed
test: add a test for sum type tags
feat: Support `FunctionType` values
Note that this extension is not intended to be complete, just enough to
get started.

We include some simplification of test infrastructure, although it is
not strictly necessary. An earlier approach required these changes.
We take this opportunity to move some auxilliary code out of emit.rs,
and to fix up some docs in fat.rs.

BREAKING CHANGE: `Namer::new` takes an additional parameter.

---------

Co-authored-by: Alec Edgington <54802828+cqc-alec@users.noreply.github.com>
Co-authored-by: Mark Koch <48097969+mark-koch@users.noreply.github.com>
We take the opportunity to tidy up cfg.rs a bit.

`impl Copy for FatNode` will now work, and many other methods now have
more appropriate lifetime constraints. The borrow checker will thank
you.

We add `FatNode::try_new_hierarchy_view`.
mark-koch and others added 27 commits August 27, 2024 15:51
## 🤖 New release
* `hugr-llvm`: 0.2.1 -> 0.3.0

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

## [0.3.0](CQCL/hugr-llvm@v0.2.1...v0.3.0) -
2024-08-27

### New Features
- [**breaking**] Lower string, print, and panic
([#78](CQCL/hugr-llvm#78))
- Lower float operations
([#83](CQCL/hugr-llvm#83))
- Lower logic extension
([#81](CQCL/hugr-llvm#81))
- Lower arrays ([#82](CQCL/hugr-llvm#82))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/MarcoIeni/release-plz/).
Add emission for multiplication, division, remainder and negation ops

Closes #20

---------

Co-authored-by: Agustín Borgna <121866228+aborgna-q@users.noreply.github.com>
## 🤖 New release
* `hugr-llvm`: 0.3.0 -> 0.3.1

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

## [0.3.1](CQCL/hugr-llvm@v0.3.0...v0.3.1) -
2024-08-28

### New Features
- Emit more int operations
([#87](CQCL/hugr-llvm#87))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/MarcoIeni/release-plz/).
We ignore the guppy tests as guppy has not yet been updated for the new
hugr version.

BREAKING CHANGE: Require `hugr-0.12.0`
## 🤖 New release
* `hugr-llvm`: 0.3.1 -> 0.4.0

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

## [0.3.1](CQCL/hugr-llvm@v0.3.0...v0.3.1) -
2024-08-28

### New Features
- Emit more int operations
([#87](CQCL/hugr-llvm#87))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/MarcoIeni/release-plz/).
Co-authored-by: Alec Edgington <54802828+cqc-alec@users.noreply.github.com>
Work towards #22, but since we updated to hugr 0.12.0 there are more
operations in `arithmetic.conversions`. I'll implement those in a
separate PR.

---------

Co-authored-by: Mark Koch <48097969+mark-koch@users.noreply.github.com>
BREAKING CHANGE: `emit_new_array_alloc` is replaced by the more general
`emit_array_op`

---------

Co-authored-by: Craig Roy <croyzor@users.noreply.github.com>
Closes #22

---------

Co-authored-by: Craig Roy <craig.roy@cambridgequantum.com>
Co-authored-by: Craig Roy <croyzor@users.noreply.github.com>
Co-authored-by: Mark Koch <48097969+mark-koch@users.noreply.github.com>
#100)

Co-authored-by: Alec Edgington <54802828+cqc-alec@users.noreply.github.com>
## 🤖 New release
* `hugr-llvm`: 0.4.0 -> 0.5.0

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

## [0.5.0](CQCL/hugr-llvm@v0.4.0...v0.5.0) -
2024-09-16

### New Features

- Add emitters for int <-> float/usize conversions
([#94](CQCL/hugr-llvm#94))
- [**breaking**] array ops
([#96](CQCL/hugr-llvm#96))
- Add conversions itobool, ifrombool
([#101](CQCL/hugr-llvm#101))
- Add `tket2` feature and lowerings for `tket2.rotation` extension
([#100](CQCL/hugr-llvm#100))

### Testing

- Add execution test framework
([#97](CQCL/hugr-llvm#97))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/MarcoIeni/release-plz/).
…#105)

Also sanitizes the READMEs a bit.

The last attempt to publish a crate using release PR #98
[failed](https://github.com/CQCL/hugr-llvm/actions/runs/10886782954/job/30207610938)
with:
```
error: failed to publish to registry at https://crates.io/
    
    Caused by:
      the remote server responded with an error (status 400 Bad Request): wildcard (`*`) dependency constraints are not allowed on crates.io. Crate with this problem: `serde` See https://doc.rust-lang.org/cargo/faq.html#can-libraries-use--as-a-version-for-their-dependencies for more information
```
Co-authored-by: Alec Edgington <54802828+cqc-alec@users.noreply.github.com>
## 🤖 New release
* `hugr-llvm`: 0.5.0 -> 0.5.1 (✓ API compatible changes)

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

## [0.5.1](CQCL/hugr-llvm@v0.5.0...v0.5.1) -
2024-09-23

### New Features

- provide `inline_constant_functions`
([#108](CQCL/hugr-llvm#108))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/MarcoIeni/release-plz/).
BREAKING CHANGE: Remove trait `EmitOp`
`CodegenExtension` is replaced with a new trait of the same name, that
instead of defining extension behaviour provides a convenient interface
for registering a set of extensions. The `prelude` extension gives the
best example, exercising all the features.

Extensions are now registered via methods on `CodegenExtsBuilder`, each
method takes a callback that is stored in the builder. The builder is
consumed by `finish` which returns a collection of "Callback Maps". One
of the big wins here is that the "Type Callback Map" does not depend on
a `H: HugrView` parameter.

The "root" `&'c Context` now lives in `EmitModuleContext`, as well as in
`TypingSession`.

`TypeConverter` is now the "Type Callback Map". This is implemented
using the new `src/utils/type_map.rs`, which we intend to leverage for
computing "def-hooks" and "destructors" for types.
 
We go to some effort to ensure the callbacks are not required to have
`'static` lifetimes, nothing inside `crate::custom` assumes or requires
this. However, we do in several places (e.g. `TypingSession`,
`EmitModuleContext`) fix these lifetimes to `'static`, in lieu of adding
additional lifetime parameters to these types.

We have removed the `guppy.rs` test case, which was ignored, rather than
rework it to use the new interface.
Otherwise, test cases are largely unchanged, and there are no snapshot
changes.

All extensions have been changed to use the new interface, which is
largely just moving code around. In some cases error messages are
consolidated by the new tools providing more appropriate inputs to
extension points. See for example `CodegenExtsBuilder::custom_const`.


At several points we mark TODO refactorings that will be carried out in
the near future.

BREAKING CHANGE: extensions interface in `src/custom.rs` entirely
reworked.

---------

Co-authored-by: Agustín Borgna <121866228+aborgna-q@users.noreply.github.com>
…xtension` (#126)

Closes #121.

BREAKING CHANGE: moved extension modules from `crate::custom` to
`crate::extension`. Moved `crate::fat` to `crate::utils::fat`.
Closes #127.

BREAKING CHANGE: Add a lifetime argument to `TypingSession`,
`EmitModuleContext`, `EmitHugr`, `EmitFuncContext`.
Note that updating `rustc` caused several errors, which are fixed here.
New clippy suggestions are also applied.
The linked bug was resolved a while ago.
Closes #132 

BREAKING CHANGE: `PreludeCodegen::emit_panic` now takes a single
configurable value.
## 🤖 New release
* `hugr-llvm`: 0.5.1 -> 0.6.0 (⚠️ API breaking changes)

### ⚠️ `hugr-llvm` breaking changes

```
--- failure auto_trait_impl_removed: auto trait no longer implemented ---

Description:
A public type has stopped implementing one or more auto traits. This can break downstream code that depends on the traits being implemented.
        ref: https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/auto_trait_impl_removed.ron

Failed in:
  type TypeConverter is no longer UnwindSafe, in /tmp/.tmpGjujM0/hugr-llvm/src/types.rs:59
  type TypeConverter is no longer RefUnwindSafe, in /tmp/.tmpGjujM0/hugr-llvm/src/types.rs:59

--- failure derive_trait_impl_removed: built-in derived trait no longer implemented ---

Description:
A public type has stopped deriving one or more traits. This can break downstream code that depends on those types implementing those traits.
        ref: https://doc.rust-lang.org/reference/attributes/derive.html#derive
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/derive_trait_impl_removed.ron

Failed in:
  type TypeConverter no longer derives Copy, in /tmp/.tmpGjujM0/hugr-llvm/src/types.rs:59
  type TypeConverter no longer derives Clone, in /tmp/.tmpGjujM0/hugr-llvm/src/types.rs:59
  type TypeConverter no longer derives Debug, in /tmp/.tmpGjujM0/hugr-llvm/src/types.rs:59

--- failure function_missing: pub fn removed or renamed ---

Description:
A publicly-visible function cannot be imported by its prior path. A `pub use` may have been removed, or the function itself may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/function_missing.ron

Failed in:
  function hugr_llvm::custom::prelude::array::emit_array_op, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom/prelude/array.rs:51
  function hugr_llvm::custom::int::add_int_extensions, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom/int.rs:226
  function hugr_llvm::custom::rotation::add_rotation_extensions, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom/rotation.rs:196
  function hugr_llvm::custom::prelude::add_prelude_extensions, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom/prelude.rs:295
  function hugr_llvm::custom::float::add_float_extensions, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom/float.rs:186
  function hugr_llvm::custom::conversions::add_conversions_extension, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom/conversions.rs:270
  function hugr_llvm::custom::logic::add_logic_extensions, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom/logic.rs:106
  function hugr_llvm::custom::prelude::add_default_prelude_extensions, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom/prelude.rs:304

--- failure inherent_method_missing: pub method removed or renamed ---

Description:
A publicly-visible method or associated fn is no longer available under its prior name. It may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/inherent_method_missing.ron

Failed in:
  TypeConverter::new, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/types.rs:107
  TypeConverter::iw_context, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/types.rs:112
  CodegenExtsMap::add_float_extensions, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom/float.rs:192
  CodegenExtsMap::add_int_extensions, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom/int.rs:234
  CodegenExtsMap::add_logic_extensions, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom/logic.rs:113
  CodegenExtsMap::add_default_prelude_extensions, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom/prelude.rs:311
  CodegenExtsMap::add_prelude_extensions, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom/prelude.rs:317
  CodegenExtsMap::add_rotation_extensions, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom/rotation.rs:201
  CodegenExtsMap::new, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom.rs:88
  CodegenExtsMap::add_cge, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom.rs:97
  CodegenExtsMap::get, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom.rs:110
  CodegenExtsMap::llvm_type, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom.rs:120
  CodegenExtsMap::emit, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom.rs:130
  CodegenExtsMap::load_constant, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom.rs:145

--- failure module_missing: pub module removed or renamed ---

Description:
A publicly-visible module cannot be imported by its prior path. A `pub use` may have been removed, or the module may have been renamed, removed, or made non-public.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/module_missing.ron

Failed in:
  mod hugr_llvm::custom::conversions, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom/conversions.rs:1
  mod hugr_llvm::custom::logic, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom/logic.rs:1
  mod hugr_llvm::custom::int, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom/int.rs:1
  mod hugr_llvm::custom::prelude, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom/prelude.rs:1
  mod hugr_llvm::fat, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/fat.rs:1
  mod hugr_llvm::custom::float, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom/float.rs:1
  mod hugr_llvm::custom::rotation, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom/rotation.rs:1
  mod hugr_llvm::custom::prelude::array, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom/prelude/array.rs:1

--- failure struct_missing: pub struct removed or renamed ---

Description:
A publicly-visible struct cannot be imported by its prior path. A `pub use` may have been removed, or the struct itself may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/struct_missing.ron

Failed in:
  struct hugr_llvm::custom::logic::LogicCodegenExtension, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom/logic.rs:78
  struct hugr_llvm::fat::FatNode, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/fat.rs:28
  struct hugr_llvm::custom::int::IntOpsCodegenExtension, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom/int.rs:120
  struct hugr_llvm::custom::prelude::PreludeCodegenExtension, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom/prelude.rs:174
  struct hugr_llvm::custom::float::FloatTypesCodegenExtension, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom/float.rs:27
  struct hugr_llvm::emit::NullEmitLlvm, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/emit.rs:52
  struct hugr_llvm::custom::conversions::ConversionsCodegenExtension, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom/conversions.rs:244
  struct hugr_llvm::custom::prelude::DefaultPreludeCodegen, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom/prelude.rs:169
  struct hugr_llvm::custom::int::IntTypesCodegenExtension, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom/int.rs:150
  struct hugr_llvm::custom::rotation::RotationCodegenExtension, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom/rotation.rs:30

--- failure trait_method_added: pub trait method added ---

Description:
A non-sealed public trait added a new method without a default implementation, which breaks downstream implementations of the trait
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#trait-new-item-no-default
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/trait_method_added.ron

Failed in:
  trait method hugr_llvm::custom::CodegenExtension::add_extension in file /tmp/.tmpGjujM0/hugr-llvm/src/custom.rs:41

--- failure trait_method_missing: pub trait method removed or renamed ---

Description:
A trait method is no longer callable, and may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#major-any-change-to-trait-item-signatures
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/trait_method_missing.ron

Failed in:
  method extension of trait CodegenExtension, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom.rs:38
  method supported_consts of trait CodegenExtension, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom.rs:44
  method llvm_type of trait CodegenExtension, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom.rs:50
  method emitter of trait CodegenExtension, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom.rs:58
  method load_constant of trait CodegenExtension, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom.rs:68

--- failure trait_missing: pub trait removed or renamed ---

Description:
A publicly-visible trait cannot be imported by its prior path. A `pub use` may have been removed, or the trait itself may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/trait_missing.ron

Failed in:
  trait hugr_llvm::emit::EmitOp, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/emit.rs:45
  trait hugr_llvm::custom::prelude::PreludeCodegen, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/custom/prelude.rs:52
  trait hugr_llvm::fat::FatExt, previously in file /tmp/.tmpu0X9jI/hugr-llvm/src/fat.rs:313

--- failure trait_no_longer_object_safe: trait no longer object safe ---

Description:
Trait is no longer object safe, which breaks `dyn Trait` usage.
        ref: https://doc.rust-lang.org/stable/reference/items/traits.html#object-safety
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/trait_no_longer_object_safe.ron

Failed in:
  trait CodegenExtension in file /tmp/.tmpGjujM0/hugr-llvm/src/custom.rs:38
```

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

## [0.6.0](CQCL/hugr-llvm@v0.5.1...v0.6.0) -
2024-10-21

### Bug Fixes

- Conversion operations having poison results
([#131](CQCL/hugr-llvm#131))

### New Features

- [**breaking**] Allow extension callbacks to have non-`'static`
lifetimes ([#128](CQCL/hugr-llvm#128))
- [**breaking**] Support `tket2.rotation.from_halfturns_unchecked`
([#133](CQCL/hugr-llvm#133))

### Refactor

- [**breaking**] remove trait emit op
([#104](CQCL/hugr-llvm#104))
- [**breaking**] rework extensions interface
([#119](CQCL/hugr-llvm#119))
- [**breaking**] move packaged extensions from `crate::custom` to
`crate::extension` ([#126](CQCL/hugr-llvm#126))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/MarcoIeni/release-plz/).
git-subtree-dir: hugr-llvm
git-subtree-mainline: c5b597d
git-subtree-split: 2d9bfce
@hugrbot
Copy link
Collaborator

hugrbot commented Oct 21, 2024

Hey there and thank you for opening this pull request! 👋

We require pull request titles to follow the Conventional Commits specification
and it looks like your proposed title needs to be adjusted.

Your title should look like this. The scope field is optional.

<type>(<scope>): <description>

If the PR includes a breaking change, mark it with an exclamation mark:

<type>!: <description>

and include a "BREAKING CHANGE:" footer in the body of the pull request.

Details:

No release type found in pull request title "git subtree hugr-llvm". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:
 - feat
 - fix
 - docs
 - style
 - refactor
 - perf
 - test
 - ci
 - chore
 - revert

Copy link

codecov bot commented Oct 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.72%. Comparing base (c5b597d) to head (491eb33).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1601   +/-   ##
=======================================
  Coverage   85.72%   85.72%           
=======================================
  Files         136      136           
  Lines       24783    24783           
  Branches    21719    21719           
=======================================
  Hits        21244    21244           
  Misses       2437     2437           
  Partials     1102     1102           
Flag Coverage Δ
python 92.68% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hugrbot
Copy link
Collaborator

hugrbot commented Oct 21, 2024

This PR contains breaking changes to the public Rust API.
Please deprecate the old API instead (if possible), or mark the PR with a ! to indicate a breaking change.

cargo-semver-checks summary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants