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

Support floor division as intrinsic function #2372

Merged
merged 12 commits into from
Oct 8, 2023

Conversation

Shaikh-Ubaid
Copy link
Collaborator

fixes #2349

So it can be used in intrinsic_function_registry
@Shaikh-Ubaid Shaikh-Ubaid force-pushed the intrinsic_floor_div branch 2 times, most recently from b247454 to 4b917cf Compare October 7, 2023 18:52
@Shaikh-Ubaid
Copy link
Collaborator Author

Ready.


ASR::expr_t* perform_casting(ASR::expr_t* expr, ASR::ttype_t* src,
ASR::ttype_t* dest, Allocator& al,
const Location& loc);
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the idea behind these? I think we do not want to do any kind of automatic casting in ASR, nor be responsible for determining what proper casting must be done.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we do not want to do any kind of automatic casting in ASR

It is actually not for automatic casting. The floordiv intrinsic we defined in this PR is generalized so that it can work on any type (from the supported types of int, unsigned int, real, logical). The casting function is used to cast the intermediate temporary variable to the appropriate return type.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is also used to cast the function arguments to the needed intermediate type.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a helper function to make make_Cast_t_value more convenient, but you still tell the initial and final type explicitly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is this a helper function to make make_Cast_t_value more convenient, but you still tell the initial and final type explicitly?

Yes. The way it helps is we need not worry about what type it currently is and just specify what type we want it to be.

@certik
Copy link
Contributor

certik commented Oct 7, 2023

In general the change is good I think, but I want to have good clarity on the casting situation. We should document this in comments, once I understand it.

@Shaikh-Ubaid
Copy link
Collaborator Author

In general the change is good I think, but I want to have good clarity on the casting situation. We should document this in comments, once I understand it.

Sure, I clarified your queries above.

@Shaikh-Ubaid
Copy link
Collaborator Author

Please let me know if you have further doubts in the implementation. I will be happy to clarify them.

Copy link
Contributor

@certik certik left a comment

Choose a reason for hiding this comment

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

I think that this is fine. Would you mind submitting this PR against LFortran as well?

@Shaikh-Ubaid
Copy link
Collaborator Author

Thank you so much for the review.

Would you mind submitting this PR against LFortran as well?

Sure. Is it fine to merge this PR currently?

@certik
Copy link
Contributor

certik commented Oct 7, 2023

Yes, you can merge it.

@Shaikh-Ubaid Shaikh-Ubaid merged commit 670b12f into lcompilers:main Oct 8, 2023
13 checks passed
@Shaikh-Ubaid Shaikh-Ubaid deleted the intrinsic_floor_div branch October 8, 2023 04:44
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.

Const i32 expressions do not support integer div/mod operations
2 participants