Add f32/f64 support
Floats live in the existing 8-byte stack slots as raw bits and are computed with scalar SSE ops via xmm0/xmm1. Adds consts, loads/stores, comparisons (NaN-correct), abs/neg/copysign, ceil/floor/trunc/nearest (roundss/sd), sqrt, add/sub/mul/div, wasm-semantics min/max (NaN propagating, -0 < +0), int<->float conversions (incl. unsigned 64-bit), demote/promote, reinterpret, and float globals. Trapping truncation traps on NaN (new 'invalid conversion to integer' message) and on out-of-range values. Adds examples/float.wat (52 self-checks) and examples/fptrap.wat. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4c4fa91dc9
commit
f0d996cee9
7 files changed
+438
-44
No files matched your search
+18
@@ -95,3 +95,21 @@ fn Reader::s64(self : Reader) -> Int64 raise CompileError {
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
///|
|
||||
fn Reader::raw32(self : Reader) -> Int raise CompileError {
|
||||
let mut v = 0
|
||||
for i in 0..<4 {
|
||||
v = v | (self.byte() << (8 * i))
|
||||
}
|
||||
v
|
||||
}
|
||||
|
||||
///|
|
||||
fn Reader::raw64(self : Reader) -> Int64 raise CompileError {
|
||||
let mut v = 0L
|
||||
for i in 0..<8 {
|
||||
v = v | (self.byte().to_int64() << (8 * i))
|
||||
}
|
||||
v
|
||||
}
|
||||
Reference in new issue
Block a user