Commit f8e97ba
committed
Add const support for float rounding methods
Add const support for the float rounding methods floor, ceil, trunc,
fract, round and round_ties_even.
This works by moving the calculation logic from
src/tools/miri/src/intrinsics/mod.rs
into
compiler/rustc_const_eval/src/interpret/intrinsics.rs.
All relevant method definitions were adjusted to include the `const`
keyword for all supported float types: f16, f32, f64 and f128.
The constness is hidden behind the feature gate
feature(const_float_round_methods)
which is tracked in
#141555
This commit is a squash of the following commits:
- test: add tests that we expect to pass when float rounding becomes const
- feat: make float rounding methods `const`
- fix: replace `rustc_allow_const_fn_unstable(core_intrinsics)` attribute with `#[rustc_const_unstable(feature = "f128", issue = "116909")]` in `library/core/src/num/f128.rs`
- revert: undo update to `library/stdarch`
- refactor: replace multiple `float_<mode>_intrinsic` rounding methods with a single, parametrized one
- fix: add `#[cfg(not(bootstrap))]` to new const method tests
- test: add extra sign tests to check `+0.0` and `-0.0`
- revert: undo accidental changes to `round` docs
- fix: gate `const` float round method behind `const_float_round_methods`
- fix: remove unnecessary `#![feature(const_float_methods)]`
- fix: remove unnecessary `#![feature(const_float_methods)]` [2]
- revert: undo changes to `tests/ui/consts/const-eval/float_methods.rs`
- fix: adjust after rebase
- test: fix float tests
- test: add tests for `fract`
- chore: add commented-out `const_float_round_methods` feature gates to `f16` and `f128`
- fix: adjust NaN when rounding floats
- chore: add FIXME comment for de-duplicating float tests
- test: remove unnecessary test file `tests/ui/consts/const-eval/float_methods.rs`
- test: fix tests after upstream simplification of how float tests are run1 parent 852f15c commit f8e97ba
12 files changed
+333
-117
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
518 | 518 | | |
519 | 519 | | |
520 | 520 | | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
521 | 618 | | |
522 | 619 | | |
523 | 620 | | |
| |||
900 | 997 | | |
901 | 998 | | |
902 | 999 | | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
903 | 1016 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2212 | 2212 | | |
2213 | 2213 | | |
2214 | 2214 | | |
2215 | | - | |
| 2215 | + | |
2216 | 2216 | | |
2217 | 2217 | | |
2218 | 2218 | | |
2219 | 2219 | | |
2220 | 2220 | | |
2221 | 2221 | | |
2222 | | - | |
| 2222 | + | |
2223 | 2223 | | |
2224 | 2224 | | |
2225 | 2225 | | |
2226 | 2226 | | |
2227 | 2227 | | |
2228 | 2228 | | |
2229 | | - | |
| 2229 | + | |
2230 | 2230 | | |
2231 | 2231 | | |
2232 | 2232 | | |
2233 | 2233 | | |
2234 | 2234 | | |
2235 | 2235 | | |
2236 | | - | |
| 2236 | + | |
2237 | 2237 | | |
2238 | 2238 | | |
2239 | 2239 | | |
2240 | 2240 | | |
2241 | 2241 | | |
2242 | 2242 | | |
2243 | 2243 | | |
2244 | | - | |
| 2244 | + | |
2245 | 2245 | | |
2246 | 2246 | | |
2247 | 2247 | | |
2248 | 2248 | | |
2249 | 2249 | | |
2250 | 2250 | | |
2251 | | - | |
| 2251 | + | |
2252 | 2252 | | |
2253 | 2253 | | |
2254 | 2254 | | |
2255 | 2255 | | |
2256 | 2256 | | |
2257 | 2257 | | |
2258 | | - | |
| 2258 | + | |
2259 | 2259 | | |
2260 | 2260 | | |
2261 | 2261 | | |
2262 | 2262 | | |
2263 | 2263 | | |
2264 | 2264 | | |
2265 | | - | |
| 2265 | + | |
2266 | 2266 | | |
2267 | 2267 | | |
2268 | 2268 | | |
2269 | 2269 | | |
2270 | 2270 | | |
2271 | 2271 | | |
2272 | 2272 | | |
2273 | | - | |
| 2273 | + | |
2274 | 2274 | | |
2275 | 2275 | | |
2276 | 2276 | | |
2277 | 2277 | | |
2278 | 2278 | | |
2279 | 2279 | | |
2280 | | - | |
| 2280 | + | |
2281 | 2281 | | |
2282 | 2282 | | |
2283 | 2283 | | |
2284 | 2284 | | |
2285 | 2285 | | |
2286 | 2286 | | |
2287 | | - | |
| 2287 | + | |
2288 | 2288 | | |
2289 | 2289 | | |
2290 | 2290 | | |
2291 | 2291 | | |
2292 | 2292 | | |
2293 | 2293 | | |
2294 | | - | |
| 2294 | + | |
2295 | 2295 | | |
2296 | 2296 | | |
2297 | 2297 | | |
| |||
2300 | 2300 | | |
2301 | 2301 | | |
2302 | 2302 | | |
2303 | | - | |
| 2303 | + | |
2304 | 2304 | | |
2305 | 2305 | | |
2306 | 2306 | | |
| |||
2309 | 2309 | | |
2310 | 2310 | | |
2311 | 2311 | | |
2312 | | - | |
| 2312 | + | |
2313 | 2313 | | |
2314 | 2314 | | |
2315 | 2315 | | |
| |||
2318 | 2318 | | |
2319 | 2319 | | |
2320 | 2320 | | |
2321 | | - | |
| 2321 | + | |
2322 | 2322 | | |
2323 | 2323 | | |
2324 | 2324 | | |
| |||
2327 | 2327 | | |
2328 | 2328 | | |
2329 | 2329 | | |
2330 | | - | |
| 2330 | + | |
2331 | 2331 | | |
2332 | 2332 | | |
2333 | 2333 | | |
2334 | 2334 | | |
2335 | 2335 | | |
2336 | 2336 | | |
2337 | 2337 | | |
2338 | | - | |
| 2338 | + | |
2339 | 2339 | | |
2340 | 2340 | | |
2341 | 2341 | | |
2342 | 2342 | | |
2343 | 2343 | | |
2344 | 2344 | | |
2345 | | - | |
| 2345 | + | |
2346 | 2346 | | |
2347 | 2347 | | |
2348 | 2348 | | |
2349 | 2349 | | |
2350 | 2350 | | |
2351 | 2351 | | |
2352 | | - | |
| 2352 | + | |
2353 | 2353 | | |
2354 | 2354 | | |
2355 | 2355 | | |
2356 | 2356 | | |
2357 | 2357 | | |
2358 | 2358 | | |
2359 | | - | |
| 2359 | + | |
2360 | 2360 | | |
2361 | 2361 | | |
2362 | 2362 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1447 | 1447 | | |
1448 | 1448 | | |
1449 | 1449 | | |
| 1450 | + | |
| 1451 | + | |
1450 | 1452 | | |
1451 | | - | |
| 1453 | + | |
1452 | 1454 | | |
1453 | 1455 | | |
1454 | 1456 | | |
| |||
1477 | 1479 | | |
1478 | 1480 | | |
1479 | 1481 | | |
| 1482 | + | |
| 1483 | + | |
1480 | 1484 | | |
1481 | | - | |
| 1485 | + | |
1482 | 1486 | | |
1483 | 1487 | | |
1484 | 1488 | | |
| |||
1513 | 1517 | | |
1514 | 1518 | | |
1515 | 1519 | | |
| 1520 | + | |
| 1521 | + | |
1516 | 1522 | | |
1517 | | - | |
| 1523 | + | |
1518 | 1524 | | |
1519 | 1525 | | |
1520 | 1526 | | |
| |||
1547 | 1553 | | |
1548 | 1554 | | |
1549 | 1555 | | |
| 1556 | + | |
| 1557 | + | |
1550 | 1558 | | |
1551 | | - | |
| 1559 | + | |
1552 | 1560 | | |
1553 | 1561 | | |
1554 | 1562 | | |
| |||
1579 | 1587 | | |
1580 | 1588 | | |
1581 | 1589 | | |
| 1590 | + | |
| 1591 | + | |
1582 | 1592 | | |
1583 | | - | |
| 1593 | + | |
1584 | 1594 | | |
1585 | 1595 | | |
1586 | 1596 | | |
| |||
1610 | 1620 | | |
1611 | 1621 | | |
1612 | 1622 | | |
| 1623 | + | |
| 1624 | + | |
1613 | 1625 | | |
1614 | | - | |
| 1626 | + | |
1615 | 1627 | | |
1616 | 1628 | | |
1617 | 1629 | | |
| |||
0 commit comments