add alloca as an expression

This commit is contained in:
Folkert 2023-07-29 20:10:52 +02:00
parent 750234f2de
commit cdd2aab217
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
15 changed files with 171 additions and 14 deletions

View file

@ -183,9 +183,14 @@ impl<'a> LastSeenMap<'a> {
Expr::Reset { symbol, .. } | Expr::ResetRef { symbol, .. } => {
self.set_last_seen(*symbol, stmt);
}
Expr::Alloca { initializer, .. } => {
if let Some(initializer) = initializer {
self.set_last_seen(*initializer, stmt);
}
}
Expr::RuntimeErrorFunction(_) => {}
Expr::FunctionPointer { .. } => todo_lambda_erasure!(),
Expr::EmptyArray => {}
Expr::RuntimeErrorFunction(_) => {}
}
self.scan_ast_help(following);
}
@ -895,6 +900,12 @@ trait Backend<'a> {
self.build_expr(sym, &new_expr, &Layout::BOOL)
}
Expr::Alloca {
initializer,
element_layout,
} => {
self.build_alloca(*sym, *initializer, *element_layout);
}
Expr::RuntimeErrorFunction(_) => todo!(),
}
}
@ -1616,7 +1627,7 @@ trait Backend<'a> {
}
LowLevel::Alloca => {
self.build_alloca(*sym, args[0], arg_layouts[0]);
self.build_alloca(*sym, Some(args[0]), arg_layouts[0]);
}
LowLevel::RefCountDecRcPtr => self.build_fn_call(
@ -2259,7 +2270,7 @@ trait Backend<'a> {
fn build_ptr_clear_tag_id(&mut self, sym: Symbol, ptr: Symbol);
fn build_alloca(&mut self, sym: Symbol, value: Symbol, element_layout: InLayout<'a>);
fn build_alloca(&mut self, sym: Symbol, value: Option<Symbol>, element_layout: InLayout<'a>);
/// literal_map gets the map from symbol to literal and layout, used for lazy loading and literal folding.
fn literal_map(&mut self) -> &mut MutMap<Symbol, (*const Literal<'a>, *const InLayout<'a>)>;