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

Migrate APInt attribute arguments to Builtin_IntegerAttr #222

Merged
merged 1 commit into from
Nov 3, 2023

Conversation

j2kun
Copy link
Collaborator

@j2kun j2kun commented Nov 2, 2023

Fixes #221

@j2kun j2kun requested a review from asraa November 2, 2023 22:50
@j2kun
Copy link
Collaborator Author

j2kun commented Nov 3, 2023

Fixes #204

Copy link
Collaborator

@asraa asraa left a comment

Choose a reason for hiding this comment

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

Thanks!


let builders = [
AttrBuilderWithInferredContext<(ins "APInt": $cmod, "Polynomial":$ideal), [{
return $_get(ideal.getContext(), cmod.getBitWidth(), cmod, ideal);
AttrBuilderWithInferredContext<
Copy link
Collaborator

Choose a reason for hiding this comment

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

do you end up using this builder? i was slightly concerned about the use of zextOrTrunc here, so if it's unused (I don't see it in the diff, and it appears different) maybe best to remove it until tested or needed

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, maybe this is used when the parser sees the : i<width> specified?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So the builder can be used without parsing IR at all. It's just a function any old fool can call. If that fool (me) passes an IntegerType that is i32 but an APInt with underlying 64 bits, then I believe anyone who later assk for the APInt back will still have it in 64 bits. This is supposed to ensure that the integer type and the APInt's bit width always match.

I am actually not sure which builders the parser uses...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, yes when fixing my PR just now, I found out the default generated parser uses a builder (with IntegerAttr type param) like

LWEParamsAttr::get(odsParser.getContext(),
      IntegerAttr((*_result_cmod)),
      unsigned((*_result_dimension)));

and it ensured that the _result_cmod was a parser that can gather the type attribute on the int.

This is supposed to ensure that the integer type and the APInt's bit width always match.

I guess what I'm asking is - do you need it right now if you have no callers?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fair enough, I thought I was using it. Removed.

@j2kun j2kun added the pull_ready Indicates whether a PR is ready to pull. The copybara worker will import for internal testing label Nov 3, 2023
@copybara-service copybara-service bot merged commit da3125a into google:main Nov 3, 2023
7 checks passed
@j2kun j2kun deleted the reproduce-apint-failure branch December 12, 2023 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pull_ready Indicates whether a PR is ready to pull. The copybara worker will import for internal testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[cleanup] Migrate APInt's in attributes to APIntAttr
2 participants