cretonne-faerie: add a translation mechanism for LibCalls#321
Conversation
lib/faerie/src/backend.rs
Outdated
| "truncf".to_owned(), | ||
| "trunc".to_owned(), | ||
| "roundf".to_owned(), | ||
| "round".to_owned(), |
There was a problem hiding this comment.
These should use nearbyint/nearbyintf rather than round/roundf, as the latter rounds ties away from zero.
(nearbyint/nearbyintf technically depend on the current rounding mode, but this is true of other floating-point operators as well, so for now we can assume that the rounding mode is set to the usual round-to-nearest, ties-to-even)
There was a problem hiding this comment.
Thanks, I didn't know that.
lib/faerie/src/backend.rs
Outdated
| /// representation. A function by this name is imported into the object as part of the | ||
| /// translation of a `ir::ExternalName::LibCall` variant. Calls to a LibCall should only be | ||
| /// inserted into the IR by the `cretonne_codegen` legalizer pass. | ||
| pub fn default_libcall_names() -> Vec<String> { |
There was a problem hiding this comment.
I know using an array was my suggestion, but looking at it here, I'm worried that it's somewhat fragile, if we ever reorder the libcalls. Would you mind going with your idea, to pass in a closure, instead?
There was a problem hiding this comment.
I made this change. Its the first time I dealt with closure lifetimes like this so I'm not 100% sure I got it right, please let me know.
0a625cc to
0d4696e
Compare
mypy released 0.600 today and even with `--no-strict-optional` flag passed to it (in lib/codegen/meta/check.sh) it fails to infer the type of values that did not need type annotations in the past
|
The installation of |
lib/faerie/src/backend.rs
Outdated
| ir::LibCall::TruncF32 => "truncf".to_owned(), | ||
| ir::LibCall::TruncF64 => "trunc".to_owned(), | ||
| ir::LibCall::NearestF32 => "nearbyint".to_owned(), | ||
| ir::LibCall::NearestF64 => "nearbyintf".to_owned(), |
There was a problem hiding this comment.
Thanks for making this change. As we get more experience with this, it may want to evolve, but this looks good for now.
Exposes a new field
libcall_names: Vec<String>inFaerieBuilder, and a new methodFaerieBuilder::default_libcall_namesto provide sensible default values for those libcalls.The
FaerieTrapSinklooks up any libcall in the names provided, imports that function, and makes a link to it, instead of panicking on encountering a libcall.