mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 07:14:46 +00:00
cleanup
This commit is contained in:
parent
2d63e24843
commit
31fc62b7f0
6 changed files with 9 additions and 20 deletions
|
@ -117,9 +117,7 @@ pub fn gen_and_eval(src: &[u8], target: Triple, opt_level: OptLevel) -> Result<R
|
|||
|
||||
let ptr_bytes = target.pointer_width().unwrap().bytes() as u32;
|
||||
|
||||
let module = arena.alloc(roc_gen::llvm::build::module_from_builtins(
|
||||
&context, "", ptr_bytes,
|
||||
));
|
||||
let module = arena.alloc(roc_gen::llvm::build::module_from_builtins(&context, ""));
|
||||
let builder = context.create_builder();
|
||||
|
||||
// mark our zig-defined builtins as internal
|
||||
|
|
|
@ -74,10 +74,8 @@ pub fn gen_from_mono_module(
|
|||
}
|
||||
|
||||
// Generate the binary
|
||||
let ptr_bytes = target.pointer_width().unwrap().bytes() as u32;
|
||||
|
||||
let context = Context::create();
|
||||
let module = arena.alloc(module_from_builtins(&context, "app", ptr_bytes));
|
||||
let module = arena.alloc(module_from_builtins(&context, "app"));
|
||||
|
||||
// strip Zig debug stuff
|
||||
// module.strip_debug_info();
|
||||
|
@ -96,6 +94,7 @@ pub fn gen_from_mono_module(
|
|||
let (mpm, fpm) = roc_gen::llvm::build::construct_optimization_passes(module, opt_level);
|
||||
|
||||
// Compile and add all the Procs before adding main
|
||||
let ptr_bytes = target.pointer_width().unwrap().bytes() as u32;
|
||||
let env = roc_gen::llvm::build::Env {
|
||||
arena: &arena,
|
||||
builder: &builder,
|
||||
|
|
|
@ -247,11 +247,7 @@ impl<'a, 'ctx, 'env> Env<'a, 'ctx, 'env> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn module_from_builtins<'ctx>(
|
||||
ctx: &'ctx Context,
|
||||
module_name: &str,
|
||||
ptr_size: u32,
|
||||
) -> Module<'ctx> {
|
||||
pub fn module_from_builtins<'ctx>(ctx: &'ctx Context, module_name: &str) -> Module<'ctx> {
|
||||
let bitcode_bytes = bitcode::get_bytes();
|
||||
|
||||
let memory_buffer = MemoryBuffer::create_from_memory_range(&bitcode_bytes, module_name);
|
||||
|
@ -260,12 +256,12 @@ pub fn module_from_builtins<'ctx>(
|
|||
.unwrap_or_else(|err| panic!("Unable to import builtins bitcode. LLVM error: {:?}", err));
|
||||
|
||||
// Add LLVM intrinsics.
|
||||
add_intrinsics(ctx, &module, ptr_size);
|
||||
add_intrinsics(ctx, &module);
|
||||
|
||||
module
|
||||
}
|
||||
|
||||
fn add_intrinsics<'ctx>(ctx: &'ctx Context, module: &Module<'ctx>, ptr_size: u32) {
|
||||
fn add_intrinsics<'ctx>(ctx: &'ctx Context, module: &Module<'ctx>) {
|
||||
// List of all supported LLVM intrinsics:
|
||||
//
|
||||
// https://releases.llvm.org/10.0.0/docs/LangRef.html#standard-c-library-intrinsics
|
||||
|
@ -277,9 +273,6 @@ fn add_intrinsics<'ctx>(ctx: &'ctx Context, module: &Module<'ctx>, ptr_size: u32
|
|||
let i8_type = ctx.i8_type();
|
||||
let i8_ptr_type = i8_type.ptr_type(AddressSpace::Generic);
|
||||
|
||||
let byte_slice_type =
|
||||
ctx.struct_type(&[i8_ptr_type.into(), ptr_int(ctx, ptr_size).into()], false);
|
||||
|
||||
add_intrinsic(
|
||||
module,
|
||||
LLVM_MEMSET_I64,
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use crate::llvm::build::call_bitcode_fn;
|
||||
use crate::llvm::build::Env;
|
||||
use crate::llvm::build_list::{load_list, store_list};
|
||||
use crate::llvm::build_str;
|
||||
use crate::llvm::convert::basic_type_from_layout;
|
||||
use inkwell::values::BasicValueEnum;
|
||||
|
@ -54,7 +53,7 @@ pub fn hash<'a, 'ctx, 'env>(
|
|||
|
||||
call_bitcode_fn(
|
||||
env,
|
||||
&[seed.into(), hash_bytes.into(), num_bytes.into()],
|
||||
&[seed.into(), hash_bytes, num_bytes.into()],
|
||||
&bitcode::DICT_HASH,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ mod gen_hash {
|
|||
Dict.hashTestOnly 0 0
|
||||
"#
|
||||
),
|
||||
1,
|
||||
9718519427346233646,
|
||||
u64
|
||||
);
|
||||
}
|
||||
|
|
|
@ -174,7 +174,7 @@ pub fn helper<'a>(
|
|||
),
|
||||
};
|
||||
|
||||
let module = roc_gen::llvm::build::module_from_builtins(context, "app", ptr_bytes);
|
||||
let module = roc_gen::llvm::build::module_from_builtins(context, "app");
|
||||
|
||||
// strip Zig debug stuff
|
||||
module.strip_debug_info();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue