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

Refactor bitwise libfuncs to use the BlockExt trait #520

Closed
edg-l opened this issue Apr 18, 2024 · 6 comments
Closed

Refactor bitwise libfuncs to use the BlockExt trait #520

edg-l opened this issue Apr 18, 2024 · 6 comments
Assignees
Labels
good first issue Good for newcomers libfuncs Library Function implementations odhack

Comments

@edg-l
Copy link
Member

edg-l commented Apr 18, 2024

See: #518

Refactor the code implementing the libfuncs to use the trait methods from BlockExt.

@edg-l edg-l added good first issue Good for newcomers libfuncs Library Function implementations odhack labels Apr 18, 2024
@Gerson2102
Copy link
Contributor

Hello, can i work on this one? And btw i still figuring out what i have to do.

@Alvarodb
Copy link

@edg-l I've reviewed the PR and understand the refactor that's being implemented. If this task becomes available, I'm ready to jump in.

@Gerson2102
Copy link
Contributor

@edg-l hello mate. I have a question in this issue. I think that i understand what i have to do. But something that i still dont get it, is the fact that, the functions that can be refactored regards to the PR linked in this issue, they are not part of bitwise libfuncs. So how should I refactor bitwise?

@igaray
Copy link
Collaborator

igaray commented Apr 23, 2024

did you check this PR out? https://github.com/lambdaclass/cairo_native/pull/518/files

it added a file src/block_ext.rs which has a trait, BlockExt, and implements that trait for the melior Block type.
one of the functions it adds is append_op_result, whose implementation does the same thing that the bitwise build function does several times.

so the bitwise libfunc builder should use that trait implementation function to append the operations and get the result

@Gerson2102
Copy link
Contributor

did you check this PR out? https://github.com/lambdaclass/cairo_native/pull/518/files

it added a file src/block_ext.rs which has a trait, BlockExt, and implements that trait for the melior Block type. one of the functions it adds is append_op_result, whose implementation does the same thing that the bitwise build function does several times.

so the bitwise libfunc builder should use that trait implementation function to append the operations and get the result

So this:
let logical_and = entry .append_operation(arith::andi(lhs, rhs, location)) .result(0)? .into();

To something like this right?:
let logical_xor = entry.append_op_result(arith::xori(lhs, rhs, location));

@Gerson2102 Gerson2102 mentioned this issue Apr 23, 2024
4 tasks
@igaray
Copy link
Collaborator

igaray commented May 15, 2024

Closed by #541

@igaray igaray closed this as completed May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers libfuncs Library Function implementations odhack
Projects
None yet
Development

No branches or pull requests

4 participants