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

Add int_range_pop_front libfunc. #6286

Merged
merged 1 commit into from
Aug 28, 2024
Merged

Conversation

liorgold2
Copy link
Collaborator

@liorgold2 liorgold2 commented Aug 26, 2024

Stack:

⚠️ Part of a stack created by spr. Do not merge manually using the UI - doing so may have unexpected results.


This change is Reviewable

@liorgold2 liorgold2 force-pushed the pr/liorgold2/lior/range1/12946952 branch from 8f9f142 to a7707f6 Compare August 26, 2024 15:42
@liorgold2 liorgold2 force-pushed the pr/liorgold2/lior/range1/0a594c95 branch from 73962f5 to b3bf2e0 Compare August 26, 2024 15:42
@liorgold2 liorgold2 force-pushed the pr/liorgold2/lior/range1/0a594c95 branch from b3bf2e0 to ac4d054 Compare August 26, 2024 19:09
@liorgold2 liorgold2 force-pushed the pr/liorgold2/lior/range1/12946952 branch from a7707f6 to 95ccbe1 Compare August 26, 2024 19:09
@liorgold2 liorgold2 requested a review from orizi August 27, 2024 10:44
Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

Reviewed 7 of 10 files at r1, all commit messages.
Reviewable status: 7 of 10 files reviewed, 2 unresolved discussions (waiting on @liorgold2)


crates/cairo-lang-sierra-to-casm/src/invocations/range.rs line 35 at r1 (raw file):

        NonEmpty:
        const one = 1;
        let new_start = start + one;

Suggestion:

        let new_start = start + one;
        const one = 1;
        tempvar is_non_empty = end - start;
        jump NonEmpty if is_non_empty != 0;

crates/cairo-lang-sierra-to-casm/src/invocations/range.rs line 43 at r1 (raw file):

            ("Fallthrough", &[&[new_start, end], &[start]], None),
            ("Failure", &[], Some(failure_handle)),
        ],

and change the signature - will require an enum.
(we may consider adding in core::internal::OptionReversed just to help all the "upside-down" libfuncs)

Suggestion:

        [
            ("Fallthrough", &[], None),
            ("NonEmpty", &[&[new_start, end], &[start]], Some(non_empty_handle)),
        ],

@liorgold2 liorgold2 force-pushed the pr/liorgold2/lior/range1/12946952 branch from 95ccbe1 to be1999d Compare August 27, 2024 14:24
@liorgold2 liorgold2 force-pushed the pr/liorgold2/lior/range1/0a594c95 branch from ac4d054 to bbc7800 Compare August 27, 2024 14:24
@liorgold2 liorgold2 changed the title Add range_pop_front libfunc. Add int_range_pop_front libfunc. Aug 27, 2024
Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 6 files at r2, all commit messages.
Reviewable status: 4 of 10 files reviewed, 4 unresolved discussions (waiting on @liorgold2)


crates/cairo-lang-sierra/src/extensions/core.rs line 142 at r2 (raw file):

        Pedersen(PedersenLibfunc),
        Poseidon(PoseidonLibfunc),
        Range(IntRangeLibfunc),

Int at the variant as well


crates/cairo-lang-sierra/src/extensions/modules/range.rs line 91 at r2 (raw file):

        args: &[GenericArg],
    ) -> Result<LibfuncSignature, SpecializationError> {
        let ty = args_as_single_type(args)?;

Probably need to be blocked for large ranges (over 2 pow 128 size)

Copy link
Collaborator Author

@liorgold2 liorgold2 left a comment

Choose a reason for hiding this comment

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

Reviewable status: 4 of 10 files reviewed, 4 unresolved discussions (waiting on @orizi)


crates/cairo-lang-sierra/src/extensions/modules/range.rs line 91 at r2 (raw file):

Previously, orizi wrote…

Probably need to be blocked for large ranges (over 2 pow 128 size)

Not this libfunc, just the construction of Range.

@liorgold2 liorgold2 changed the base branch from pr/liorgold2/lior/range1/0a594c95 to main August 27, 2024 17:03
@liorgold2 liorgold2 force-pushed the pr/liorgold2/lior/range1/12946952 branch from be1999d to c392a11 Compare August 27, 2024 17:03
Copy link
Collaborator Author

@liorgold2 liorgold2 left a comment

Choose a reason for hiding this comment

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

Reviewable status: 2 of 11 files reviewed, 4 unresolved discussions (waiting on @Arcticae, @Draggu, @mkaput, @orizi, and @piotmag769)


crates/cairo-lang-sierra/src/extensions/core.rs line 142 at r2 (raw file):

Previously, orizi wrote…

Int at the variant as well

Done.


crates/cairo-lang-sierra-to-casm/src/invocations/range.rs line 35 at r1 (raw file):

        NonEmpty:
        const one = 1;
        let new_start = start + one;

Done.


crates/cairo-lang-sierra-to-casm/src/invocations/range.rs line 43 at r1 (raw file):

Previously, orizi wrote…

and change the signature - will require an enum.
(we may consider adding in core::internal::OptionReversed just to help all the "upside-down" libfuncs)

Done.

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 6 files at r2.
Reviewable status: 2 of 11 files reviewed, 3 unresolved discussions (waiting on @Arcticae, @Draggu, @mkaput, and @piotmag769)

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 9 of 9 files at r3, 1 of 1 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Arcticae, @Draggu, @mkaput, and @piotmag769)

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Arcticae, @Draggu, @liorgold2, @mkaput, and @piotmag769)


crates/cairo-lang-sierra-to-casm/src/invocations/range.rs line 42 at r4 (raw file):

            ("NonEmpty", &[&[new_start, end], &[start]], Some(non_empty_handle)),
        ],
        Default::default(),

maybe we should return all options?

  • no need for multiple checks for different pops.
  • less libfuncs.

Suggestion:

    };
    casm_build_extend! {casm_builder,
        const one = 1;
        let new_start = start + one;
        let new_end = end - one;
        tempvar is_non_empty = end - start;
        jump NonEmpty if is_non_empty != 0;
    };
    let non_empty_handle = get_non_fallthrough_statement_id(&builder);
    Ok(builder.build_from_casm_builder(
        casm_builder,
        [
            ("Fallthrough", &[], None),
            ("NonEmpty", &[&[new_start, end], &[start, new_end], &[start], &[new_end]], Some(non_empty_handle)),
        ],
        Default::default(),

Copy link
Collaborator Author

@liorgold2 liorgold2 left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Arcticae, @Draggu, @mkaput, @orizi, and @piotmag769)


crates/cairo-lang-sierra-to-casm/src/invocations/range.rs line 42 at r4 (raw file):

Previously, orizi wrote…

maybe we should return all options?

  • no need for multiple checks for different pops.
  • less libfuncs.

Makes sense, but I'll do it in another PR.

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Arcticae, @Draggu, @mkaput, and @piotmag769)

@mkaput mkaput removed their request for review August 28, 2024 07:12
@liorgold2 liorgold2 added this pull request to the merge queue Aug 28, 2024
Merged via the queue into main with commit 546c0d8 Aug 28, 2024
44 checks passed
@orizi orizi deleted the pr/liorgold2/lior/range1/12946952 branch September 5, 2024 12:11
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