Implement complete Floating-Point word set, 70+ float words
Separate float stack with fsp global, IEEE 754 double precision. Stack ops: FDROP FDUP FSWAP FOVER FROT FDEPTH Arithmetic: F+ F- F* F/ FNEGATE FABS FMAX FMIN FSQRT FLOOR FROUND F** Comparisons: F0= F0< F= F< F~ Memory: F@ F! SF@ SF! DF@ DF! FLOAT+ FLOATS FALIGNED FALIGN Conversions: D>F F>D S>F F>S Trig: FSIN FCOS FTAN FASIN FACOS FATAN FATAN2 FSINCOS Exp/Log: FEXP FEXPM1 FLN FLNP1 FLOG FALOG Hyperbolic: FSINH FCOSH FTANH FASINH FACOSH FATANH I/O: F. FE. FS. REPRESENT >FLOAT PRECISION SET-PRECISION Defining: FVARIABLE FCONSTANT FVALUE FLITERAL Float literal parsing (1E, 1.5E2, -3.14E0 format) 299 unit tests + 11 compliance tests, 0 errors on float test suite
This commit is contained in:
@@ -29,6 +29,10 @@ const DSP: u32 = 0;
|
||||
/// Index of the `$rsp` global (return stack pointer).
|
||||
const RSP: u32 = 1;
|
||||
|
||||
/// Index of the `$fsp` global (float stack pointer).
|
||||
#[allow(dead_code)]
|
||||
const FSP: u32 = 2;
|
||||
|
||||
/// Index of the imported function table.
|
||||
const TABLE: u32 = 0;
|
||||
|
||||
@@ -795,6 +799,15 @@ pub fn compile_word(
|
||||
shared: false,
|
||||
}),
|
||||
);
|
||||
imports.import(
|
||||
"env",
|
||||
"fsp",
|
||||
EntityType::Global(GlobalType {
|
||||
val_type: ValType::I32,
|
||||
mutable: true,
|
||||
shared: false,
|
||||
}),
|
||||
);
|
||||
imports.import(
|
||||
"env",
|
||||
"table",
|
||||
@@ -871,7 +884,7 @@ mod tests {
|
||||
use super::*;
|
||||
use crate::dictionary::WordId;
|
||||
use crate::ir::IrOp;
|
||||
use crate::memory::{DATA_STACK_TOP, RETURN_STACK_TOP};
|
||||
use crate::memory::{DATA_STACK_TOP, FLOAT_STACK_TOP, RETURN_STACK_TOP};
|
||||
|
||||
fn default_config() -> CodegenConfig {
|
||||
CodegenConfig {
|
||||
@@ -1133,6 +1146,13 @@ mod tests {
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let fsp = Global::new(
|
||||
&mut store,
|
||||
wasmtime::GlobalType::new(ValType::I32, Mutability::Var),
|
||||
Val::I32(FLOAT_STACK_TOP as i32),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let table = Table::new(
|
||||
&mut store,
|
||||
wasmtime::TableType::new(RefType::FUNCREF, 16, None),
|
||||
@@ -1152,6 +1172,7 @@ mod tests {
|
||||
memory.into(),
|
||||
dsp.into(),
|
||||
rsp.into(),
|
||||
fsp.into(),
|
||||
table.into(),
|
||||
],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user