mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 20:28:02 +00:00
switch over to alloca expr
This commit is contained in:
parent
cdd2aab217
commit
44d03eebfa
8 changed files with 9 additions and 67 deletions
|
@ -88,7 +88,6 @@ macro_rules! map_symbol_to_lowlevel_and_arity {
|
|||
LowLevel::PtrStore => unimplemented!(),
|
||||
LowLevel::PtrLoad => unimplemented!(),
|
||||
LowLevel::PtrClearTagId => unimplemented!(),
|
||||
LowLevel::Alloca => unimplemented!(),
|
||||
LowLevel::RefCountIncRcPtr => unimplemented!(),
|
||||
LowLevel::RefCountDecRcPtr=> unimplemented!(),
|
||||
LowLevel::RefCountIncDataPtr => unimplemented!(),
|
||||
|
|
|
@ -1626,10 +1626,6 @@ trait Backend<'a> {
|
|||
self.build_ptr_clear_tag_id(*sym, args[0]);
|
||||
}
|
||||
|
||||
LowLevel::Alloca => {
|
||||
self.build_alloca(*sym, Some(args[0]), arg_layouts[0]);
|
||||
}
|
||||
|
||||
LowLevel::RefCountDecRcPtr => self.build_fn_call(
|
||||
sym,
|
||||
bitcode::UTILS_DECREF_RC_PTR.to_string(),
|
||||
|
|
|
@ -30,8 +30,8 @@ use crate::llvm::{
|
|||
},
|
||||
build::{
|
||||
cast_basic_basic, complex_bitcast_check_size, create_entry_block_alloca,
|
||||
entry_block_alloca_zerofill, function_value_by_func_spec, load_roc_value,
|
||||
roc_function_call, tag_pointer_clear_tag_id, BuilderExt, FuncBorrowSpec, RocReturn,
|
||||
function_value_by_func_spec, load_roc_value, roc_function_call, tag_pointer_clear_tag_id,
|
||||
BuilderExt, FuncBorrowSpec, RocReturn,
|
||||
},
|
||||
build_list::{
|
||||
list_append_unsafe, list_concat, list_drop_at, list_get_unsafe, list_len, list_map,
|
||||
|
@ -1331,16 +1331,6 @@ pub(crate) fn run_low_level<'a, 'ctx>(
|
|||
tag_pointer_clear_tag_id(env, ptr.into_pointer_value()).into()
|
||||
}
|
||||
|
||||
Alloca => {
|
||||
arguments!(initial_value);
|
||||
|
||||
let ptr = entry_block_alloca_zerofill(env, initial_value.get_type(), "stack_value");
|
||||
|
||||
env.builder.build_store(ptr, initial_value);
|
||||
|
||||
ptr.into()
|
||||
}
|
||||
|
||||
RefCountIncRcPtr | RefCountDecRcPtr | RefCountIncDataPtr | RefCountDecDataPtr => {
|
||||
unreachable!("Not used in LLVM backend: {:?}", op);
|
||||
}
|
||||
|
|
|
@ -1992,42 +1992,6 @@ impl<'a> LowLevelCall<'a> {
|
|||
backend.code_builder.i32_const(-4); // 11111111...1100
|
||||
backend.code_builder.i32_and();
|
||||
}
|
||||
Alloca => {
|
||||
// Alloca : a -> Ptr a
|
||||
let arg = self.arguments[0];
|
||||
let arg_layout = backend.storage.symbol_layouts.get(&arg).unwrap();
|
||||
|
||||
let (size, alignment_bytes) = backend
|
||||
.layout_interner
|
||||
.stack_size_and_alignment(*arg_layout);
|
||||
|
||||
let (frame_ptr, offset) = backend
|
||||
.storage
|
||||
.allocate_anonymous_stack_memory(size, alignment_bytes);
|
||||
|
||||
// write the default value into the stack memory
|
||||
backend.storage.copy_value_to_memory(
|
||||
&mut backend.code_builder,
|
||||
frame_ptr,
|
||||
offset,
|
||||
arg,
|
||||
);
|
||||
|
||||
// create a local variable for the pointer
|
||||
let ptr_local_id = match backend.storage.ensure_value_has_local(
|
||||
&mut backend.code_builder,
|
||||
self.ret_symbol,
|
||||
self.ret_storage.clone(),
|
||||
) {
|
||||
StoredValue::Local { local_id, .. } => local_id,
|
||||
_ => internal_error!("A pointer will always be an i32"),
|
||||
};
|
||||
|
||||
backend.code_builder.get_local(frame_ptr);
|
||||
backend.code_builder.i32_const(offset as i32);
|
||||
backend.code_builder.i32_add();
|
||||
backend.code_builder.set_local(ptr_local_id);
|
||||
}
|
||||
|
||||
Hash => todo!("{:?}", self.lowlevel),
|
||||
|
||||
|
|
|
@ -121,7 +121,6 @@ pub enum LowLevel {
|
|||
PtrStore,
|
||||
PtrLoad,
|
||||
PtrClearTagId,
|
||||
Alloca,
|
||||
RefCountIncRcPtr,
|
||||
RefCountDecRcPtr,
|
||||
RefCountIncDataPtr,
|
||||
|
@ -237,7 +236,6 @@ macro_rules! map_symbol_to_lowlevel {
|
|||
LowLevel::PtrStore => unimplemented!(),
|
||||
LowLevel::PtrLoad => unimplemented!(),
|
||||
LowLevel::PtrClearTagId => unimplemented!(),
|
||||
LowLevel::Alloca => unimplemented!(),
|
||||
LowLevel::RefCountIncRcPtr => unimplemented!(),
|
||||
LowLevel::RefCountDecRcPtr=> unimplemented!(),
|
||||
LowLevel::RefCountIncDataPtr => unimplemented!(),
|
||||
|
|
|
@ -1615,7 +1615,6 @@ fn low_level_no_rc(lowlevel: &LowLevel) -> RC {
|
|||
PtrStore => RC::NoRc,
|
||||
PtrLoad => RC::NoRc,
|
||||
PtrCast => RC::NoRc,
|
||||
Alloca => RC::NoRc,
|
||||
|
||||
PtrClearTagId | RefCountIncRcPtr | RefCountDecRcPtr | RefCountIncDataPtr
|
||||
| RefCountDecDataPtr | RefCountIsUnique => {
|
||||
|
|
|
@ -1138,8 +1138,10 @@ fn insert_refcount_operations_binding<'a>(
|
|||
Expr::Reset { .. } | Expr::ResetRef { .. } => {
|
||||
unreachable!("Reset(ref) should not exist at this point")
|
||||
}
|
||||
Expr::Alloca { .. } => {
|
||||
unreachable!("Alloca should not exist at this point")
|
||||
Expr::Alloca { initializer, .. } => {
|
||||
let new_let = new_let!(stmt);
|
||||
|
||||
inc_owned!(initializer.as_ref().copied().into_iter(), new_let)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1367,7 +1369,6 @@ fn lowlevel_borrow_signature(arena: &Bump, op: LowLevel) -> &[Ownership] {
|
|||
PtrStore => arena.alloc_slice_copy(&[owned, owned]),
|
||||
PtrLoad => arena.alloc_slice_copy(&[owned]),
|
||||
PtrCast => arena.alloc_slice_copy(&[owned]),
|
||||
Alloca => arena.alloc_slice_copy(&[owned]),
|
||||
|
||||
SetJmp | LongJmp | SetLongJmpBuffer => {
|
||||
unreachable!("only inserted in dev backend codegen")
|
||||
|
|
|
@ -741,15 +741,10 @@ impl<'a> TrmcEnv<'a> {
|
|||
.interner
|
||||
.insert_direct_no_semantic(LayoutRepr::Ptr(return_layout));
|
||||
|
||||
let call = Call {
|
||||
call_type: CallType::LowLevel {
|
||||
op: LowLevel::Alloca,
|
||||
update_mode: UpdateModeId::BACKEND_DUMMY,
|
||||
},
|
||||
arguments: arena.alloc([null_symbol]),
|
||||
let ptr_null = Expr::Alloca {
|
||||
initializer: Some(null_symbol),
|
||||
element_layout: return_layout,
|
||||
};
|
||||
|
||||
let ptr_null = Expr::Call(call);
|
||||
let let_ptr = |next| Stmt::Let(initial_ptr_symbol, ptr_null, ptr_return_layout, next);
|
||||
|
||||
let joinpoint_id = JoinPointId(env.named_unique_symbol("trmc"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue