Move add_intrinsics back

This commit is contained in:
Richard Feldman 2021-05-23 23:30:23 -04:00
parent fae2aac5f8
commit 6c4ba49086
4 changed files with 8 additions and 17 deletions

View file

@ -8,7 +8,7 @@ use roc_can::builtins::builtin_defs_map;
use roc_collections::all::{MutMap, MutSet}; use roc_collections::all::{MutMap, MutSet};
use roc_fmt::annotation::Formattable; use roc_fmt::annotation::Formattable;
use roc_fmt::annotation::{Newlines, Parens}; use roc_fmt::annotation::{Newlines, Parens};
use roc_gen::llvm::build::{add_intrinsics, build_proc, build_proc_header, OptLevel}; use roc_gen::llvm::build::{build_proc, build_proc_header, OptLevel};
use roc_gen::llvm::externs::add_default_roc_externs; use roc_gen::llvm::externs::add_default_roc_externs;
use roc_load::file::LoadingProblem; use roc_load::file::LoadingProblem;
use roc_parse::parser::SyntaxError; use roc_parse::parser::SyntaxError;
@ -133,12 +133,9 @@ pub fn gen_and_eval<'a>(
let module = arena.alloc(roc_gen::llvm::build::module_from_builtins(&context, "")); let module = arena.alloc(roc_gen::llvm::build::module_from_builtins(&context, ""));
// Add roc_alloc, roc_realloc, and roc_dealloc, since the repl has no // Add roc_alloc, roc_realloc, and roc_dealloc, since the repl has no
// platform to provide them. These must be added *before* adding intrinsics! // platform to provide them.
add_default_roc_externs(&context, module, &builder, ptr_bytes); add_default_roc_externs(&context, module, &builder, ptr_bytes);
// Add LLVM intrinsics.
add_intrinsics(&context, &module);
// mark our zig-defined builtins as internal // mark our zig-defined builtins as internal
for function in FunctionIterator::from_module(module) { for function in FunctionIterator::from_module(module) {
let name = function.get_name().to_str().unwrap(); let name = function.get_name().to_str().unwrap();

View file

@ -3,9 +3,7 @@ use bumpalo::Bump;
use inkwell::context::Context; use inkwell::context::Context;
use inkwell::targets::{CodeModel, FileType, RelocMode}; use inkwell::targets::{CodeModel, FileType, RelocMode};
use inkwell::values::FunctionValue; use inkwell::values::FunctionValue;
use roc_gen::llvm::build::{ use roc_gen::llvm::build::{build_proc, build_proc_header, module_from_builtins, OptLevel, Scope};
add_intrinsics, build_proc, build_proc_header, module_from_builtins, OptLevel, Scope,
};
use roc_load::file::MonomorphizedModule; use roc_load::file::MonomorphizedModule;
use roc_mono::layout::LayoutIds; use roc_mono::layout::LayoutIds;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
@ -86,9 +84,6 @@ pub fn gen_from_mono_module(
let context = Context::create(); let context = Context::create();
let module = arena.alloc(module_from_builtins(&context, "app")); let module = arena.alloc(module_from_builtins(&context, "app"));
// Add LLVM intrinsics.
add_intrinsics(&context, &module);
// strip Zig debug stuff // strip Zig debug stuff
// module.strip_debug_info(); // module.strip_debug_info();

View file

@ -318,10 +318,13 @@ pub fn module_from_builtins<'ctx>(ctx: &'ctx Context, module_name: &str) -> Modu
let module = Module::parse_bitcode_from_buffer(&memory_buffer, ctx) let module = Module::parse_bitcode_from_buffer(&memory_buffer, ctx)
.unwrap_or_else(|err| panic!("Unable to import builtins bitcode. LLVM error: {:?}", err)); .unwrap_or_else(|err| panic!("Unable to import builtins bitcode. LLVM error: {:?}", err));
// Add LLVM intrinsics.
add_intrinsics(ctx, &module);
module module
} }
pub fn add_intrinsics<'ctx>(ctx: &'ctx Context, module: &Module<'ctx>) { fn add_intrinsics<'ctx>(ctx: &'ctx Context, module: &Module<'ctx>) {
// List of all supported LLVM intrinsics: // List of all supported LLVM intrinsics:
// //
// https://releases.llvm.org/10.0.0/docs/LangRef.html#standard-c-library-intrinsics // https://releases.llvm.org/10.0.0/docs/LangRef.html#standard-c-library-intrinsics

View file

@ -4,7 +4,6 @@ use roc_build::program::FunctionIterator;
use roc_can::builtins::builtin_defs_map; use roc_can::builtins::builtin_defs_map;
use roc_can::def::Def; use roc_can::def::Def;
use roc_collections::all::{MutMap, MutSet}; use roc_collections::all::{MutMap, MutSet};
use roc_gen::llvm::build::add_intrinsics;
use roc_gen::llvm::externs::add_default_roc_externs; use roc_gen::llvm::externs::add_default_roc_externs;
use roc_module::symbol::Symbol; use roc_module::symbol::Symbol;
use roc_types::subs::VarStore; use roc_types::subs::VarStore;
@ -185,12 +184,9 @@ pub fn helper<'a>(
let module = roc_gen::llvm::build::module_from_builtins(context, "app"); let module = roc_gen::llvm::build::module_from_builtins(context, "app");
// Add roc_alloc, roc_realloc, and roc_dealloc, since the repl has no // Add roc_alloc, roc_realloc, and roc_dealloc, since the repl has no
// platform to provide them. These must be added *before* adding intrinsics! // platform to provide them.
add_default_roc_externs(context, &module, &builder, ptr_bytes); add_default_roc_externs(context, &module, &builder, ptr_bytes);
// Add LLVM intrinsics.
add_intrinsics(context, &module);
// strip Zig debug stuff // strip Zig debug stuff
module.strip_debug_info(); module.strip_debug_info();