You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Most likely this has to be a new expr node, something like RealNearest. Let's first figure out an LLVM (and WASM) instructions to compute it, as well as x86/arm assembly instructions, so that we know how to compute this. And then design a nice ASR node for this.
The text was updated successfully, but these errors were encountered:
This is one way to do it in LLVM, although generated by ChatGPT, it looks reasonably correct.
Edit: Not sure though, will need to dig deeper.
; Declare the function signaturedefinedouble@nearest(double%x, double%s) {
entry:
; Get the sign bit of %s%sign_bit = fcmpoltdouble%s, 0.0; Compute the positive nearest value%positive_nearest = calldouble@llvm.nearbyint.f64(double%x)
; Compute the negative nearest value%negative_nearest = calldouble@llvm.nearbyint.f64(double -%x)
%negative_nearest = fneg double%negative_nearest; Select the result based on the sign of %s%result = selecti1%sign_bit, double%negative_nearest, double%positive_nearest; Return the resultretdouble%result
}
; Declare the LLVM intrinsic function for rounding to the nearest integerdeclaredouble@llvm.nearbyint.f64(double)
Most likely this has to be a new
expr
node, something likeRealNearest
. Let's first figure out an LLVM (and WASM) instructions to compute it, as well as x86/arm assembly instructions, so that we know how to compute this. And then design a nice ASR node for this.The text was updated successfully, but these errors were encountered: