From f4d80a5f09afcbe0bd80147a0685be1dfaf81acd Mon Sep 17 00:00:00 2001 From: Kirby Linvill Date: Wed, 25 Oct 2023 16:51:18 +0100 Subject: [PATCH] Add public API to retrieve internal locals --- compiler/stable_mir/src/mir/body.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/compiler/stable_mir/src/mir/body.rs b/compiler/stable_mir/src/mir/body.rs index 8cdc9614db6..f76ad87584f 100644 --- a/compiler/stable_mir/src/mir/body.rs +++ b/compiler/stable_mir/src/mir/body.rs @@ -33,15 +33,21 @@ impl Body { 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;