emit LLVM IR that can be compiled to wasm

This commit is contained in:
Folkert 2021-08-24 20:56:13 +02:00
parent 5a7a9e9520
commit 0a7f7a2772
9 changed files with 33 additions and 25 deletions

View file

@ -370,10 +370,18 @@ impl<'a, 'ctx, 'env> Env<'a, 'ctx, 'env> {
}
}
pub fn module_from_builtins<'ctx>(ctx: &'ctx Context, module_name: &str) -> Module<'ctx> {
pub fn module_from_builtins<'ctx>(
ctx: &'ctx Context,
module_name: &str,
ptr_bytes: u32,
) -> Module<'ctx> {
// In the build script for the builtins module,
// we compile the builtins into LLVM bitcode
let bitcode_bytes: &[u8] = include_bytes!("../../../builtins/bitcode/builtins.bc");
let bitcode_bytes: &[u8] = match ptr_bytes {
8 => include_bytes!("../../../builtins/bitcode/builtins-64bit.bc"),
4 => include_bytes!("../../../builtins/bitcode/builtins-32bit.bc"),
_ => unreachable!(),
};
let memory_buffer = MemoryBuffer::create_from_memory_range(bitcode_bytes, module_name);

View file

@ -133,7 +133,7 @@ fn hash_builtin<'a, 'ctx, 'env>(
// let zig deal with big vs small string
call_bitcode_fn(
env,
&[seed.into(), build_str::str_to_i128(env, val).into()],
&[seed.into(), build_str::str_to_c_abi(env, val).into()],
bitcode::DICT_HASH_STR,
)
.into_int_value()