mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
Add some comments
This commit is contained in:
parent
cd91be678f
commit
3adaacc66e
2 changed files with 15 additions and 14 deletions
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue