diff --git a/compiler/gen_wasm/src/low_level.rs b/compiler/gen_wasm/src/low_level.rs index 7929e1acc3..523864119c 100644 --- a/compiler/gen_wasm/src/low_level.rs +++ b/compiler/gen_wasm/src/low_level.rs @@ -351,8 +351,7 @@ pub fn decode_low_level<'a>( match storage.get(&args[0]) { VirtualMachineStack { value_type, .. } | Local { value_type, .. } => { match value_type { - I32 => code_builder.i32_const(1), - I64 => code_builder.i32_const(1), + I32 | I64 => code_builder.i32_const(1), // always true for integers F32 => { code_builder.i32_reinterpret_f32(); code_builder.i32_const(0x7f80_0000); @@ -591,7 +590,7 @@ pub fn decode_low_level<'a>( And => code_builder.i32_and(), Or => code_builder.i32_or(), Not => code_builder.i32_eqz(), - Hash => return NotImplemented, + Hash => return NotImplemented, // TODO: generated helpers ExpectTrue => return NotImplemented, RefCountGetPtr => { code_builder.i32_const(4); diff --git a/compiler/mono/src/code_gen_help.rs b/compiler/mono/src/code_gen_help.rs index 032917ed19..039686898d 100644 --- a/compiler/mono/src/code_gen_help.rs +++ b/compiler/mono/src/code_gen_help.rs @@ -52,21 +52,23 @@ impl From<&ModifyRc> for RefcountOp { } } -/// Generate mono IR to help with code gen -/// -------------------------------------- +/// Generate specialized helper procs for code gen +/// ---------------------------------------------- /// -/// Some operations, such as refcounting and equality comparison, need -/// specialized helper procs to traverse data structures at runtime. +/// Some low level operations need specialized helper procs to traverse data structures at runtime. +/// This includes refcounting, hashing, and equality checks. /// -/// For example, when checking List equality, we need to visit each element -/// and compare them recursively. Similarly, when incrementing a List refcount, -/// we also increment the elements recursively. -/// This logic is the same for all targets, so we implement it once using mono IR. +/// For example, when checking List equality, we need to visit each element and compare them. +/// Depending on the type of the list elements, we may need to recurse deeper into each element. +/// For tag unions, we may need branches for different tag IDs, etc. +/// +/// This module creates specialized helper procs for all such operations and types used in the program. /// /// The backend drives the process, in two steps: -/// 1) When it sees the relevant node, it calls MonoCodeGen to get the replacement IR. -/// MonoCodeGen generates a call to the helper proc, and remembers it for step 2. -/// 2) After the backend has generated all user procs, it generates the helper procs too. +/// 1) When it sees the relevant node, it calls CodeGenHelp to get the replacement IR. +/// CodeGenHelp returns IR for a call to the helper proc, and remembers the specialization. +/// 2) After the backend has generated code for all user procs, it takes the IR for all of the +/// specialized helpers procs, and generates target code for them too. /// pub struct CodeGenHelp<'a> { arena: &'a Bump,