Move some constants from backend to lib

This commit is contained in:
Brian Carroll 2021-09-10 20:29:37 +01:00
parent 042b175d89
commit b21155f60b
2 changed files with 13 additions and 9 deletions

View file

@ -10,18 +10,12 @@ use roc_module::symbol::Symbol;
use roc_mono::ir::{CallType, Expr, JoinPointId, Literal, Proc, Stmt};
use roc_mono::layout::{Builtin, Layout, UnionLayout};
use crate::*;
// Don't allocate any constant data at address zero or near it. Would be valid, but bug-prone.
// Follow Emscripten's example by using 1kB (4 bytes would probably do)
const UNUSED_DATA_SECTION_BYTES: u32 = 1024;
const PTR_SIZE: u32 = 4;
const PTR_TYPE: ValueType = ValueType::I32;
const ALIGN_1: u32 = 0;
const ALIGN_2: u32 = 1;
const ALIGN_4: u32 = 2;
const ALIGN_8: u32 = 3;
#[derive(Clone, Copy, Debug)]
struct LocalId(u32);

View file

@ -3,7 +3,7 @@ pub mod from_wasm32_memory;
use bumpalo::Bump;
use parity_wasm::builder;
use parity_wasm::elements::Internal;
use parity_wasm::elements::{Internal, ValueType};
use roc_collections::all::{MutMap, MutSet};
use roc_module::symbol::{Interns, Symbol};
@ -12,6 +12,16 @@ use roc_mono::layout::LayoutIds;
use crate::backend::WasmBackend;
const PTR_SIZE: u32 = 4;
const PTR_TYPE: ValueType = ValueType::I32;
pub const ALIGN_1: u32 = 0;
pub const ALIGN_2: u32 = 1;
pub const ALIGN_4: u32 = 2;
pub const ALIGN_8: u32 = 3;
pub const STACK_POINTER_GLOBAL_ID: u32 = 0;
pub struct Env<'a> {
pub arena: &'a Bump, // not really using this much, parity_wasm works with std::vec a lot
pub interns: Interns,