Add public API to retrieve internal locals

This commit is contained in:
Kirby Linvill 2023-10-25 16:51:18 +01:00
parent 93d1b3e92a
commit f4d80a5f09
No known key found for this signature in database
GPG Key ID: E304CE3F028E6E3F

View File

@ -33,15 +33,21 @@ pub fn new(blocks: Vec<BasicBlock>, locals: LocalDecls, arg_count: usize) -> Sel
Self { blocks, locals, arg_count }
}
/// Gets the function's return local.
/// Return local that holds this function's return value.
pub fn ret_local(&self) -> &LocalDecl {
&self.locals[0]
}
/// Gets the locals in `self` that correspond to the function's arguments.
/// Locals in `self` that correspond to this function's arguments.
pub fn arg_locals(&self) -> &[LocalDecl] {
&self.locals[1..self.arg_count + 1]
}
/// Internal locals for this function. These are the locals that are
/// neither the return local nor the argument locals.
pub fn internal_locals(&self) -> &[LocalDecl] {
&self.locals[self.arg_count + 1..]
}
}
type LocalDecls = Vec<LocalDecl>;