Executes the provided function, guaranteeing that the specified set of registers, if any, remain unallocatable throughout the function's execution.
(
&mut self,
regs: impl IntoIterator<Item = &'r Reg> + Copy,
masm: &mut M,
mut f: F,
)
| 195 | /// registers, if any, remain unallocatable throughout the function's |
| 196 | /// execution. |
| 197 | pub fn without<'r, T, M, F>( |
| 198 | &mut self, |
| 199 | regs: impl IntoIterator<Item = &'r Reg> + Copy, |
| 200 | masm: &mut M, |
| 201 | mut f: F, |
| 202 | ) -> Result<T> |
| 203 | where |
| 204 | M: MacroAssembler, |
| 205 | F: FnMut(&mut Self, &mut M) -> T, |
| 206 | { |
| 207 | for r in regs { |
| 208 | self.reg(*r, masm)?; |
| 209 | } |
| 210 | |
| 211 | let result = f(self, masm); |
| 212 | |
| 213 | for r in regs { |
| 214 | self.free_reg(*r); |
| 215 | } |
| 216 | |
| 217 | Ok(result) |
| 218 | } |
| 219 | |
| 220 | /// Free the given register. |
| 221 | pub fn free_reg(&mut self, reg: impl Into<Reg>) { |