Skip to content

feat(hugr-llvm): Emit rounding operation for FloatOps::fround extension ops#2949

Open
maximilianruesch wants to merge 3 commits intomainfrom
mr/feat/support-emitting-float-round
Open

feat(hugr-llvm): Emit rounding operation for FloatOps::fround extension ops#2949
maximilianruesch wants to merge 3 commits intomainfrom
mr/feat/support-emitting-float-round

Conversation

@maximilianruesch
Copy link
Contributor

@maximilianruesch maximilianruesch commented Mar 16, 2026

Adds FloatOps::fround LLVM lowering support. This is to add support for rounding operations in Selene, connected to Quantinuum/guppylang#1561.

I am a bit unsure how the tests work, but simply adding another test case in line with the existing ones seems to work fine.

@codecov
Copy link

codecov bot commented Mar 16, 2026

Codecov Report

❌ Patch coverage is 80.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.83%. Comparing base (93aac28) to head (cfa51a8).

Files with missing lines Patch % Lines
hugr-llvm/src/extension/float.rs 80.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2949      +/-   ##
==========================================
- Coverage   83.84%   83.83%   -0.01%     
==========================================
  Files         267      267              
  Lines       52923    52933      +10     
  Branches    46854    46864      +10     
==========================================
+ Hits        44371    44379       +8     
  Misses       6283     6283              
- Partials     2269     2271       +2     
Flag Coverage Δ
python 88.76% <ø> (ø)
rust 83.20% <80.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@maximilianruesch maximilianruesch marked this pull request as ready for review March 16, 2026 16:21
@maximilianruesch maximilianruesch requested a review from a team as a code owner March 16, 2026 16:21
Copy link
Contributor

@acl-cqc acl-cqc left a comment

Choose a reason for hiding this comment

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

Generally this looks fine, but I'm trying to understand the connection to Quantinuum/guppylang#1561. This PR implies that the current situation is that we can't compile rounding at all, even without an extra precision argument?

#[case::fmul(FloatOps::fmul)]
#[case::fdiv(FloatOps::fdiv)]
#[case::fpow(FloatOps::fpow)]
#[case::fround(FloatOps::fround)]
Copy link
Contributor

Choose a reason for hiding this comment

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

The thing that worries me here is that fround appears to be unary, whereas all the others seem to be binary (taking two floats)....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not true, fneg is also unary and appears in the test cases.

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