mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
Rename FunctionBuilder back to CodeBuilder
This commit is contained in:
parent
dbe6d195f7
commit
973626fe2d
6 changed files with 20 additions and 20 deletions
|
@ -8,7 +8,7 @@ use roc_module::symbol::Symbol;
|
|||
use roc_mono::ir::{CallType, Expr, JoinPointId, Literal, Proc, Stmt};
|
||||
use roc_mono::layout::{Builtin, Layout};
|
||||
|
||||
use crate::function_builder::{BlockType, FunctionBuilder, ValueType};
|
||||
use crate::code_builder::{BlockType, CodeBuilder, ValueType};
|
||||
use crate::layout::WasmLayout;
|
||||
use crate::storage::{Storage, StoredValue, StoredValueKind};
|
||||
use crate::{copy_memory, CopyMemoryConfig, Env, LocalId, PTR_TYPE};
|
||||
|
@ -32,7 +32,7 @@ pub struct WasmBackend<'a> {
|
|||
proc_symbol_map: MutMap<Symbol, CodeLocation>,
|
||||
|
||||
// Function level
|
||||
code_builder: FunctionBuilder<'a>,
|
||||
code_builder: CodeBuilder<'a>,
|
||||
storage: Storage<'a>,
|
||||
|
||||
/// how many blocks deep are we (used for jumps)
|
||||
|
@ -56,7 +56,7 @@ impl<'a> WasmBackend<'a> {
|
|||
joinpoint_label_map: MutMap::default(),
|
||||
|
||||
// Functions
|
||||
code_builder: FunctionBuilder::new(env.arena),
|
||||
code_builder: CodeBuilder::new(env.arena),
|
||||
storage: Storage::new(env.arena),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ macro_rules! instruction_memargs {
|
|||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct FunctionBuilder<'a> {
|
||||
pub struct CodeBuilder<'a> {
|
||||
/// The main container for the instructions
|
||||
code: Vec<'a, u8>,
|
||||
|
||||
|
@ -128,9 +128,9 @@ pub struct FunctionBuilder<'a> {
|
|||
}
|
||||
|
||||
#[allow(clippy::new_without_default)]
|
||||
impl<'a> FunctionBuilder<'a> {
|
||||
impl<'a> CodeBuilder<'a> {
|
||||
pub fn new(arena: &'a Bump) -> Self {
|
||||
FunctionBuilder {
|
||||
CodeBuilder {
|
||||
code: Vec::with_capacity_in(1024, arena),
|
||||
insertions: Vec::with_capacity_in(32, arena),
|
||||
insertions_byte_len: 0,
|
|
@ -1,6 +1,6 @@
|
|||
use roc_mono::layout::{Layout, UnionLayout};
|
||||
|
||||
use crate::{function_builder::ValueType, PTR_SIZE, PTR_TYPE};
|
||||
use crate::{code_builder::ValueType, PTR_SIZE, PTR_TYPE};
|
||||
|
||||
// See README for background information on Wasm locals, memory and function calls
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
|
@ -4,7 +4,7 @@ mod layout;
|
|||
mod storage;
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub mod function_builder;
|
||||
pub mod code_builder;
|
||||
|
||||
#[allow(dead_code)]
|
||||
mod opcodes;
|
||||
|
@ -20,7 +20,7 @@ use roc_mono::ir::{Proc, ProcLayout};
|
|||
use roc_mono::layout::LayoutIds;
|
||||
|
||||
use crate::backend::WasmBackend;
|
||||
use crate::function_builder::{Align, FunctionBuilder, ValueType};
|
||||
use crate::code_builder::{Align, CodeBuilder, ValueType};
|
||||
|
||||
const PTR_SIZE: u32 = 4;
|
||||
const PTR_TYPE: ValueType = ValueType::I32;
|
||||
|
@ -134,7 +134,7 @@ pub struct CopyMemoryConfig {
|
|||
alignment_bytes: u32,
|
||||
}
|
||||
|
||||
pub fn copy_memory(code_builder: &mut FunctionBuilder, config: CopyMemoryConfig) {
|
||||
pub fn copy_memory(code_builder: &mut CodeBuilder, config: CopyMemoryConfig) {
|
||||
if config.from_ptr == config.to_ptr && config.from_offset == config.to_offset {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ use bumpalo::Bump;
|
|||
use roc_collections::all::MutMap;
|
||||
use roc_module::symbol::Symbol;
|
||||
|
||||
use crate::function_builder::{FunctionBuilder, ValueType, VirtualMachineSymbolState};
|
||||
use crate::code_builder::{CodeBuilder, ValueType, VirtualMachineSymbolState};
|
||||
use crate::layout::WasmLayout;
|
||||
use crate::{copy_memory, round_up_to_alignment, CopyMemoryConfig, LocalId, PTR_SIZE, PTR_TYPE};
|
||||
|
||||
|
@ -188,7 +188,7 @@ impl<'a> Storage<'a> {
|
|||
/// Load symbols to the top of the VM stack
|
||||
/// Avoid calling this method in a loop with one symbol at a time! It will work,
|
||||
/// but it generates very inefficient Wasm code.
|
||||
pub fn load_symbols(&mut self, code_builder: &mut FunctionBuilder, symbols: &[Symbol]) {
|
||||
pub fn load_symbols(&mut self, code_builder: &mut CodeBuilder, symbols: &[Symbol]) {
|
||||
if code_builder.verify_stack_match(symbols) {
|
||||
// The symbols were already at the top of the stack, do nothing!
|
||||
// This should be quite common due to the structure of the Mono IR
|
||||
|
@ -258,7 +258,7 @@ impl<'a> Storage<'a> {
|
|||
/// (defined by a pointer and offset).
|
||||
pub fn copy_value_to_memory(
|
||||
&mut self,
|
||||
code_builder: &mut FunctionBuilder,
|
||||
code_builder: &mut CodeBuilder,
|
||||
to_ptr: LocalId,
|
||||
to_offset: u32,
|
||||
from_symbol: Symbol,
|
||||
|
@ -291,7 +291,7 @@ impl<'a> Storage<'a> {
|
|||
| StoredValue::Local {
|
||||
value_type, size, ..
|
||||
} => {
|
||||
use crate::function_builder::Align::*;
|
||||
use crate::code_builder::Align::*;
|
||||
code_builder.get_local(to_ptr);
|
||||
self.load_symbols(code_builder, &[from_symbol]);
|
||||
match (value_type, size) {
|
||||
|
@ -314,7 +314,7 @@ impl<'a> Storage<'a> {
|
|||
/// Copies the _entire_ value. For struct fields etc., see `copy_value_to_memory`
|
||||
pub fn clone_value(
|
||||
&mut self,
|
||||
code_builder: &mut FunctionBuilder,
|
||||
code_builder: &mut CodeBuilder,
|
||||
to: &StoredValue,
|
||||
from: &StoredValue,
|
||||
from_symbol: Symbol,
|
||||
|
@ -402,7 +402,7 @@ impl<'a> Storage<'a> {
|
|||
/// (In the case of structs in stack memory, we just use the stack frame pointer local)
|
||||
pub fn ensure_value_has_local(
|
||||
&mut self,
|
||||
code_builder: &mut FunctionBuilder,
|
||||
code_builder: &mut CodeBuilder,
|
||||
symbol: Symbol,
|
||||
storage: StoredValue,
|
||||
) -> StoredValue {
|
||||
|
|
|
@ -2,13 +2,13 @@ use parity_wasm::builder;
|
|||
use parity_wasm::builder::ModuleBuilder;
|
||||
|
||||
use roc_gen_wasm::from_wasm32_memory::FromWasm32Memory;
|
||||
use roc_gen_wasm::function_builder::{Align, FunctionBuilder, ValueType};
|
||||
use roc_gen_wasm::code_builder::{Align, CodeBuilder, ValueType};
|
||||
use roc_std::{RocDec, RocList, RocOrder, RocStr};
|
||||
|
||||
pub trait Wasm32TestResult {
|
||||
fn insert_test_wrapper(
|
||||
module_builder: &mut ModuleBuilder,
|
||||
code_builder: &mut FunctionBuilder,
|
||||
code_builder: &mut CodeBuilder,
|
||||
wrapper_name: &str,
|
||||
main_function_index: u32,
|
||||
) {
|
||||
|
@ -26,7 +26,7 @@ pub trait Wasm32TestResult {
|
|||
self.build_wrapper_body(code_builder, main_function_index);
|
||||
}
|
||||
|
||||
fn build_wrapper_body(code_builder: &mut FunctionBuilder, main_function_index: u32);
|
||||
fn build_wrapper_body(code_builder: &mut CodeBuilder, main_function_index: u32);
|
||||
}
|
||||
|
||||
macro_rules! build_wrapper_body_primitive {
|
||||
|
@ -59,7 +59,7 @@ macro_rules! wasm_test_result_primitive {
|
|||
}
|
||||
|
||||
fn build_wrapper_body_stack_memory(
|
||||
code_builder: &mut FunctionBuilder,
|
||||
code_builder: &mut CodeBuilder,
|
||||
main_function_index: u32,
|
||||
size: usize,
|
||||
) -> Vec<Instruction> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue