Logic to load 128-bit numbers

This commit is contained in:
Brian Carroll 2021-11-21 20:35:46 +00:00
parent ee1c4478da
commit 2e31350010
3 changed files with 58 additions and 14 deletions

View file

@ -2,6 +2,15 @@ use roc_mono::layout::{Layout, UnionLayout};
use crate::{wasm_module::ValueType, PTR_SIZE, PTR_TYPE};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum StackMemoryFormat {
/// Record, Str, List, Dict, etc.
Aggregate,
Int128,
Float128,
Decimal,
}
// See README for background information on Wasm locals, memory and function calls
#[derive(Debug, Clone)]
pub enum WasmLayout {
@ -10,7 +19,11 @@ pub enum WasmLayout {
Primitive(ValueType, u32),
// Local pointer to stack memory
StackMemory { size: u32, alignment_bytes: u32 },
StackMemory {
size: u32,
alignment_bytes: u32,
format: StackMemoryFormat,
},
// Local pointer to heap memory
HeapMemory,
@ -35,23 +48,32 @@ impl WasmLayout {
Layout::Builtin(Float64) => Self::Primitive(F64, size),
Layout::Builtin(
Int128
| Decimal
| Float128
| Str
| Dict(_, _)
| Set(_)
| List(_)
| EmptyStr
| EmptyList
| EmptyDict
| EmptySet,
Str | Dict(_, _) | Set(_) | List(_) | EmptyStr | EmptyList | EmptyDict | EmptySet,
)
| Layout::Struct(_)
| Layout::LambdaSet(_)
| Layout::Union(NonRecursive(_)) => Self::StackMemory {
size,
alignment_bytes,
format: StackMemoryFormat::Aggregate,
},
Layout::Builtin(Int128) => Self::StackMemory {
size,
alignment_bytes,
format: StackMemoryFormat::Int128,
},
Layout::Builtin(Decimal) => Self::StackMemory {
size,
alignment_bytes,
format: StackMemoryFormat::Decimal,
},
Layout::Builtin(Float128) => Self::StackMemory {
size,
alignment_bytes,
format: StackMemoryFormat::Float128,
},
Layout::Union(