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

feat: constant folding implemented for core and float extension #758

Merged
merged 40 commits into from
Jan 2, 2024

Conversation

ss2165
Copy link
Member

@ss2165 ss2165 commented Dec 22, 2023

Closes #711
CI will pass after updating MSRV to 1.75 (from end of year)

based on #757

ss2165 and others added 30 commits November 24, 2023 14:23
refactor!: Closes Flatten `Prim(Type/Value)` in to parent enum #665

BREAKING_CHANGES: In serialization, extension and function values no longer
wrapped by "pv".
Bumps
[actions/upload-artifact](https://github.com/actions/upload-artifact)
from 3 to 4.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/actions/upload-artifact/releases">actions/upload-artifact's
releases</a>.</em></p>
<blockquote>
<h2>v4.0.0</h2>
<h2>What's Changed</h2>
<p>The release of upload-artifact@v4 and download-artifact@v4 are major
changes to the backend architecture of Artifacts. They have numerous
performance and behavioral improvements.</p>
<p>For more information, see the <a
href="https://github.com/actions/toolkit/tree/main/packages/artifact"><code>@​actions/artifact</code></a>
documentation.</p>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/vmjoseph"><code>@​vmjoseph</code></a>
made their first contribution in <a
href="https://redirect.github.com/actions/upload-artifact/pull/464">actions/upload-artifact#464</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/actions/upload-artifact/compare/v3...v4.0.0">https://github.com/actions/upload-artifact/compare/v3...v4.0.0</a></p>
<h2>v3.1.3</h2>
<h2>What's Changed</h2>
<ul>
<li>chore(github): remove trailing whitespaces by <a
href="https://github.com/ljmf00"><code>@​ljmf00</code></a> in <a
href="https://redirect.github.com/actions/upload-artifact/pull/313">actions/upload-artifact#313</a></li>
<li>Bump <code>@​actions/artifact</code> version to v1.1.2 by <a
href="https://github.com/bethanyj28"><code>@​bethanyj28</code></a> in <a
href="https://redirect.github.com/actions/upload-artifact/pull/436">actions/upload-artifact#436</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/actions/upload-artifact/compare/v3...v3.1.3">https://github.com/actions/upload-artifact/compare/v3...v3.1.3</a></p>
<h2>v3.1.2</h2>
<ul>
<li>Update all <code>@actions/*</code> NPM packages to their latest
versions- <a
href="https://redirect.github.com/actions/upload-artifact/issues/374">#374</a></li>
<li>Update all dev dependencies to their most recent versions - <a
href="https://redirect.github.com/actions/upload-artifact/issues/375">#375</a></li>
</ul>
<h2>v3.1.1</h2>
<ul>
<li>Update actions/core package to latest version to remove
<code>set-output</code> deprecation warning <a
href="https://redirect.github.com/actions/upload-artifact/issues/351">#351</a></li>
</ul>
<h2>v3.1.0</h2>
<h2>What's Changed</h2>
<ul>
<li>Bump <code>@​actions/artifact</code> to v1.1.0 (<a
href="https://redirect.github.com/actions/upload-artifact/pull/327">actions/upload-artifact#327</a>)
<ul>
<li>Adds checksum headers on artifact upload (<a
href="https://redirect.github.com/actions/toolkit/pull/1095">actions/toolkit#1095</a>)
(<a
href="https://redirect.github.com/actions/toolkit/pull/1063">actions/toolkit#1063</a>)</li>
</ul>
</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/actions/upload-artifact/commit/c7d193f32edcb7bfad88892161225aeda64e9392"><code>c7d193f</code></a>
Merge pull request <a
href="https://redirect.github.com/actions/upload-artifact/issues/466">#466</a>
from actions/v4-beta</li>
<li><a
href="https://github.com/actions/upload-artifact/commit/13131bb095770b4070a7477c3cd2d96e1c16d9f4"><code>13131bb</code></a>
licensed cache</li>
<li><a
href="https://github.com/actions/upload-artifact/commit/4a6c273b9834f66a1d05c170dc3f80f9cdb9def1"><code>4a6c273</code></a>
Merge branch 'main' into v4-beta</li>
<li><a
href="https://github.com/actions/upload-artifact/commit/f391bb91a3d3118aeca171c365bb319ece276b37"><code>f391bb9</code></a>
Merge pull request <a
href="https://redirect.github.com/actions/upload-artifact/issues/465">#465</a>
from actions/robherley/v4-documentation</li>
<li><a
href="https://github.com/actions/upload-artifact/commit/9653d03c4b74c32144e02dae644fea70e079d4b3"><code>9653d03</code></a>
Apply suggestions from code review</li>
<li><a
href="https://github.com/actions/upload-artifact/commit/875b63076402f25ef9d52c294c86ba4f97810575"><code>875b630</code></a>
add limitations section</li>
<li><a
href="https://github.com/actions/upload-artifact/commit/ecb21463e93740a6be75c3116242169bfdbcb15a"><code>ecb2146</code></a>
add compression example</li>
<li><a
href="https://github.com/actions/upload-artifact/commit/5e7604f84a055838f64ed68bb9904751523081ae"><code>5e7604f</code></a>
trim some repeated info</li>
<li><a
href="https://github.com/actions/upload-artifact/commit/d6437d07581fe318a364512e6cf6b1dca6b4f92c"><code>d6437d0</code></a>
naming</li>
<li><a
href="https://github.com/actions/upload-artifact/commit/1b561557037b4957d7d184e9aac02bec86c771eb"><code>1b56155</code></a>
s/v4-beta/v4/g</li>
<li>Additional commits viewable in <a
href="https://github.com/actions/upload-artifact/compare/v3...v4">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/upload-artifact&package-manager=github_actions&previous-version=3&new-version=4)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps
[dawidd6/action-download-artifact](https://github.com/dawidd6/action-download-artifact)
from 2 to 3.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/dawidd6/action-download-artifact/releases">dawidd6/action-download-artifact's
releases</a>.</em></p>
<blockquote>
<h2>v3.0.0</h2>
<p>Node was updated from 16 to 20.
Node 20 requires <code>glibc&gt;=2.28</code>.</p>
<h2>v2.28.0</h2>
<p>No release notes provided.</p>
<h2>v2.27.0</h2>
<p>No release notes provided.</p>
<h2>v2.26.1</h2>
<p>No release notes provided.</p>
<h2>v2.26.0</h2>
<p>No release notes provided.</p>
<h2>v2.25.0</h2>
<p>No release notes provided.</p>
<h2>v2.24.4</h2>
<p>No release notes provided.</p>
<h2>v2.24.3</h2>
<p>No release notes provided.</p>
<h2>v2.24.2</h2>
<p>No release notes provided.</p>
<h2>v2.24.0</h2>
<p>No release notes provided.</p>
<h2>v2.23.0</h2>
<p>No release notes provided.</p>
<h2>v2.22.0</h2>
<p>No release notes provided.</p>
<h2>v2.21.1</h2>
<p>No release notes provided.</p>
<h2>v2.21.0</h2>
<p>No release notes provided.</p>
<h2>v2.20.0</h2>
<p>No release notes provided.</p>
<h2>v2.19.0</h2>
<p>No release notes provided.</p>
<h2>v2.18.0</h2>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/dawidd6/action-download-artifact/commit/e7466d1a7587ed14867642c2ca74b5bcc1e19a2d"><code>e7466d1</code></a>
build(deps): bump <code>@​actions/artifact</code> from 1.1.2 to 2.0.0
(<a
href="https://redirect.github.com/dawidd6/action-download-artifact/issues/260">#260</a>)</li>
<li><a
href="https://github.com/dawidd6/action-download-artifact/commit/f29d1b6a8930683e80acedfbe6baa2930cd646b4"><code>f29d1b6</code></a>
node_modules: upgrade</li>
<li><a
href="https://github.com/dawidd6/action-download-artifact/commit/587cee61f534dd8254d0baad7d7c511335afca24"><code>587cee6</code></a>
action: node16 -&gt; node20 (<a
href="https://redirect.github.com/dawidd6/action-download-artifact/issues/259">#259</a>)</li>
<li><a
href="https://github.com/dawidd6/action-download-artifact/commit/1cf761fba652f5ee1570ccc23e3ab2123370f234"><code>1cf761f</code></a>
build(deps): bump undici from 5.25.4 to 5.28.2 (<a
href="https://redirect.github.com/dawidd6/action-download-artifact/issues/258">#258</a>)</li>
<li><a
href="https://github.com/dawidd6/action-download-artifact/commit/d44631c448e18ab4dc3ebf7dd43489e1afeaee61"><code>d44631c</code></a>
build(deps): bump <code>@​actions/github</code> from 5.1.1 to 6.0.0 (<a
href="https://redirect.github.com/dawidd6/action-download-artifact/issues/252">#252</a>)</li>
<li>See full diff in <a
href="https://github.com/dawidd6/action-download-artifact/compare/v2...v3">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dawidd6/action-download-artifact&package-manager=github_actions&previous-version=2&new-version=3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Previously it was incorrectly reporting the internal signature as the
node signature.

Fixes #750 

Required further fixes to `replace.rs`:
* test was looking for an error that should have been hidden behind
another (that was not previously reported because of #750). Look for the
latter, not the former.
* Fix node indices not being correctly reported from `apply`

---------

Co-authored-by: Alan Lawrence <[email protected]>
BREAKING CHANGES: extension() function replaced with EXTENSION static ref for float_ops and conversions
@ss2165 ss2165 changed the base branch from main to feat/const-rewrites December 22, 2023 15:23
@ss2165 ss2165 requested a review from lmondada December 22, 2023 18:59
Copy link
Contributor

@lmondada lmondada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Seyon, this will be super useful!

@@ -11,6 +11,7 @@ use crate::ops::OpName;
use crate::type_row;
use crate::types::{FunctionType, PolyFuncType};
use crate::utils::collect_array;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity: are you following some style guide regarding newlines here? Would like to know for my own coding if there is a recommended style.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it was just a cargo format update

@@ -0,0 +1,124 @@
use crate::{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider naming this file const_fold.rs to match the extension name?

@@ -307,6 +308,9 @@ pub struct OpDef {
// can only treat them as opaque/black-box ops.
#[serde(flatten)]
lower_funcs: Vec<LowerFunc>,

#[serde(skip)]
constant_folder: Box<dyn ConstFold>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a short docstring here?

}));
}
}
None // could panic
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure the comment is correct, i.e. what would panic and how returning None would help. I suppose you mean that the let if clauses might fail?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i mean that None shouldn't ever be returned here, so it might be clearer to panic

Comment on lines +205 to +208
// if the LoadConst was removed, try removing the Const too.
if h.apply_rewrite(RemoveConst(const_node)).is_err() {
// const cannot be removed - no problem
continue;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it surprising that this is not removed by the rewrite itself. Maybe add a comment about this in the docstring of find_consts?

dependabot bot and others added 3 commits January 2, 2024 08:53
Updates the requirements on
[delegate](https://github.com/kobzol/rust-delegate) to permit the latest
version.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/Kobzol/rust-delegate/blob/main/CHANGELOG.md">delegate's
changelog</a>.</em></p>
<blockquote>
<h1>0.12.0 (22. 12. 2023)</h1>
<ul>
<li>
<p>Add new <code>#[newtype]</code> function parameter modifier (<a
href="https://redirect.github.com/Kobzol/rust-delegate/pull/64">#64</a>).
Implemented by <a href="https://github.com/Techassi">Techassi</a></p>
</li>
<li>
<p>Allow passing arbitrary attributes to delegation segments:</p>
</li>
</ul>
<pre lang="rust"><code>impl Foo {
  delegate! {
    #[inline(always)]
    to self.0 { ... }
  }
}
</code></pre>
<ul>
<li>Change the default inlining mode from <code>#[inline(always)]</code>
to <code>#[inline]</code> (<a
href="https://redirect.github.com/Kobzol/rust-delegate/issues/61">Kobzol/rust-delegate#61</a>).</li>
</ul>
<h1>0.11.0 (4. 12. 2023)</h1>
<ul>
<li>Allow delegating an associated function (not just a method).</li>
</ul>
<pre lang="rust"><code>struct A {}
impl A {
    fn foo(a: u32) -&gt; u32 {
        a + 1
    }
}
<p>struct B;
impl B {
delegate! {
to A {
fn foo(a: u32) -&gt; u32;
}
}
}
</code></pre></p>
<h1>0.10.0 (29. 6. 2023)</h1>
<ul>
<li>Allow specifying certain attributes (e.g. <code>#[into]</code> or
<code>#[unwrap]</code>) on delegated segments.
The attribute will then be applied to all methods in that segment
(unless it is overwritten on the method itself).</li>
</ul>
<pre lang="rust"><code>delegate! {
  #[unwrap]
  to self.inner {
    fn foo(&amp;self) -&gt; u32; // calls self.inner.foo().unwrap()
    fn bar(&amp;self) -&gt; u32; // calls self.inner.bar().unwrap()
  }
}
</code></pre>
<ul>
<li>Add new <code>#[unwrap]</code> method modifier. Adding it on top of
a delegated method will cause the generated
code to <code>.unwrap()</code> the result.</li>
</ul>
<pre lang="rust"><code>&lt;/tr&gt;&lt;/table&gt; 
</code></pre>
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/Kobzol/rust-delegate/commit/ac852be64f3e4b5f9b58be910d09921488d2845d"><code>ac852be</code></a>
Bump version</li>
<li><a
href="https://github.com/Kobzol/rust-delegate/commit/d0101f43db895b5257c0e72dda1f4e37c61f6631"><code>d0101f4</code></a>
Reword <code>newtype</code> in README</li>
<li><a
href="https://github.com/Kobzol/rust-delegate/commit/6d416dd9ddef3c14655c03b3f47b1fbf16097190"><code>6d416dd</code></a>
Update README and changelog</li>
<li><a
href="https://github.com/Kobzol/rust-delegate/commit/d0e8104d570ffde52e988610fdde6b07fab2f779"><code>d0e8104</code></a>
feat: Add <code>newtype</code> parameter attribute modifier</li>
<li><a
href="https://github.com/Kobzol/rust-delegate/commit/1e3278a71dfb92adc90af28faba937dfe2a0363b"><code>1e3278a</code></a>
Fix readme</li>
<li><a
href="https://github.com/Kobzol/rust-delegate/commit/07697a3195fec5cb422b6e89adb9ca7e559c4568"><code>07697a3</code></a>
Change default inlining mode to <code>#[inline]</code></li>
<li><a
href="https://github.com/Kobzol/rust-delegate/commit/81c148340f8d3ff3247d3aeedb8d3d7f0a31d494"><code>81c1483</code></a>
Fix segment attribute propagation</li>
<li><a
href="https://github.com/Kobzol/rust-delegate/commit/69e37d559c9877090ece0e18546ce643d5b14f81"><code>69e37d5</code></a>
Allow passing arbitrary attributes to segments</li>
<li>See full diff in <a
href="https://github.com/kobzol/rust-delegate/compare/v0.11.0...v0.12.0">compare
view</a></li>
</ul>
</details>
<br />


Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@lmondada lmondada merged commit 664fe89 into feat/const-rewrites Jan 2, 2024
@lmondada lmondada deleted the feat/const-fold-floats branch January 2, 2024 11:06
@ss2165 ss2165 restored the feat/const-fold-floats branch January 3, 2024 11:16
ss2165 added a commit that referenced this pull request Jan 3, 2024
github-merge-queue bot pushed a commit that referenced this pull request Jan 3, 2024
Closes #711 

Original review in #758

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alan Lawrence <[email protected]>
Co-authored-by: Luca Mondada <[email protected]>
Co-authored-by: Alec Edgington <[email protected]>
Co-authored-by: Alan Lawrence <[email protected]>
Co-authored-by: Agustín Borgna <[email protected]>
Co-authored-by: Luca Mondada <[email protected]>
ss2165 added a commit that referenced this pull request Jan 3, 2024
Closes #711 

Original review in #758

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alan Lawrence <[email protected]>
Co-authored-by: Luca Mondada <[email protected]>
Co-authored-by: Alec Edgington <[email protected]>
Co-authored-by: Alan Lawrence <[email protected]>
Co-authored-by: Agustín Borgna <[email protected]>
Co-authored-by: Luca Mondada <[email protected]>
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.

2 participants