remove F128

This commit is contained in:
Folkert 2022-12-14 23:28:38 +01:00
parent 6f2e14cf18
commit d287eafa3a
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
15 changed files with 7 additions and 73 deletions

View file

@ -21,7 +21,6 @@ pub enum StackMemoryFormat {
/// Record, Str, List, etc.
DataStructure,
Int128,
Float128,
Decimal,
}
@ -71,11 +70,6 @@ impl WasmLayout {
match float_width {
F32 => Self::Primitive(ValueType::F32, size),
F64 => Self::Primitive(ValueType::F64, size),
F128 => Self::StackMemory {
size,
alignment_bytes,
format: StackMemoryFormat::Float128,
},
}
}
@ -156,7 +150,7 @@ impl CallConv {
use ValueType::*;
match format {
Int128 | Float128 | Decimal => &[I64, I64],
Int128 | Decimal => &[I64, I64],
DataStructure => {
if size == 0 {
@ -191,7 +185,7 @@ impl CallConv {
use StackMemoryFormat::*;
match format {
Int128 | Float128 | Decimal => WriteToPointerArg,
Int128 | Decimal => WriteToPointerArg,
DataStructure => {
if size == 0 {

View file

@ -30,7 +30,6 @@ enum CodeGenNumType {
F32, // Supported in Wasm instruction set
F64, // Supported in Wasm instruction set
I128, // Bytes in memory, needs Zig builtins
F128, // Bytes in memory, needs Zig builtins
Decimal, // Bytes in memory, needs Zig builtins
}
@ -66,7 +65,6 @@ impl From<Layout<'_>> for CodeGenNumType {
Builtin::Float(float_width) => match float_width {
FloatWidth::F32 => F32,
FloatWidth::F64 => F64,
FloatWidth::F128 => F128,
},
Builtin::Decimal => Decimal,
_ => not_num_error(),
@ -91,7 +89,6 @@ impl From<StackMemoryFormat> for CodeGenNumType {
fn from(format: StackMemoryFormat) -> CodeGenNumType {
match format {
StackMemoryFormat::Int128 => CodeGenNumType::I128,
StackMemoryFormat::Float128 => CodeGenNumType::F128,
StackMemoryFormat::Decimal => CodeGenNumType::Decimal,
StackMemoryFormat::DataStructure => {
internal_error!("Tried to perform a Num low-level operation on a data structure")
@ -804,7 +801,6 @@ impl<'a> LowLevelCall<'a> {
self.load_args(backend);
backend.code_builder.f64_add()
}
FloatWidth::F128 => todo!("Num.add for f128"),
},
Layout::Builtin(Builtin::Decimal) => {
self.load_args_and_call_zig(backend, bitcode::DEC_ADD_OR_PANIC)
@ -841,7 +837,6 @@ impl<'a> LowLevelCall<'a> {
self.load_args(backend);
backend.code_builder.f64_add()
}
FloatWidth::F128 => todo!("Num.add for f128"),
},
Layout::Builtin(Builtin::Decimal) => {
// TODO: don't panic
@ -897,7 +892,6 @@ impl<'a> LowLevelCall<'a> {
self.load_args(backend);
backend.code_builder.f64_sub()
}
FloatWidth::F128 => todo!("Num.sub for f128"),
},
Layout::Builtin(Builtin::Decimal) => {
self.load_args_and_call_zig(backend, bitcode::DEC_SUB_OR_PANIC)
@ -934,7 +928,6 @@ impl<'a> LowLevelCall<'a> {
self.load_args(backend);
backend.code_builder.f64_sub()
}
FloatWidth::F128 => todo!("Num.sub for f128"),
},
Layout::Builtin(Builtin::Decimal) => {
// TODO: don't panic
@ -988,7 +981,6 @@ impl<'a> LowLevelCall<'a> {
self.load_args(backend);
backend.code_builder.f64_mul()
}
FloatWidth::F128 => todo!("Num.mul for f128"),
},
Layout::Builtin(Builtin::Decimal) => {
self.load_args_and_call_zig(backend, bitcode::DEC_MUL_OR_PANIC)
@ -1024,7 +1016,6 @@ impl<'a> LowLevelCall<'a> {
self.load_args(backend);
backend.code_builder.f64_mul()
}
FloatWidth::F128 => todo!("Num.mul for f128"),
},
Layout::Builtin(Builtin::Decimal) => {
// TODO: don't panic
@ -1466,9 +1457,6 @@ impl<'a> LowLevelCall<'a> {
Layout::Builtin(Builtin::Float(FloatWidth::F64)) => {
backend.code_builder.f64_sqrt()
}
Layout::Builtin(Builtin::Float(FloatWidth::F128)) => {
todo!("sqrt for f128")
}
_ => panic_ret_type(),
}
}
@ -2004,8 +1992,6 @@ impl<'a> LowLevelCall<'a> {
StackMemoryFormat::Int128 => Self::eq_num128_bytes(backend, locations),
StackMemoryFormat::Float128 => todo!("equality for f128"),
StackMemoryFormat::DataStructure => {
internal_error!("Data structure equality is handled elsewhere")
}
@ -2052,7 +2038,6 @@ impl<'a> LowLevelCall<'a> {
FloatWidth::F64 => {
self.load_args_and_call_zig(backend, &bitcode::STR_FROM_FLOAT[width]);
}
FloatWidth::F128 => todo!("F128 to Str"),
},
Layout::Builtin(Builtin::Decimal) => {
self.load_args_and_call_zig(backend, bitcode::DEC_TO_STR)
@ -2090,27 +2075,13 @@ fn num_is_finite(backend: &mut WasmBackend<'_>, argument: Symbol) {
}
}
}
StackMemory {
format, location, ..
} => {
let (local_id, offset) = location.local_and_offset(backend.storage.stack_frame_pointer);
StackMemory { format, .. } => {
match format {
// Integers and fixed-point numbers are always finite. Just return True.
StackMemoryFormat::Int128 | StackMemoryFormat::Decimal => {
backend.code_builder.i32_const(1)
}
// f128 is not supported anywhere else but it's easy to support it here, so why not...
StackMemoryFormat::Float128 => {
backend.code_builder.get_local(local_id);
backend.code_builder.i64_load(Align::Bytes4, offset + 8);
backend.code_builder.i64_const(0x7fff_0000_0000_0000);
backend.code_builder.i64_and();
backend.code_builder.i64_const(0x7fff_0000_0000_0000);
backend.code_builder.i64_ne();
}
StackMemoryFormat::DataStructure => {
internal_error!("Tried to perform NumIsFinite on a data structure")
}

View file

@ -252,7 +252,7 @@ impl<'a> Storage<'a> {
.extend_from_slice(CallConv::C.stack_memory_arg_types(size, format));
let location = match format {
Int128 | Float128 | Decimal => {
Int128 | Decimal => {
// passed as two i64's but stored in the stack frame
wide_number_args.push(local_index);
let loc =