Materializes any [ContextArgs] as a function argument.
(
sig: &ABISig,
context: &ContextArgs,
masm: &mut M,
)
| 259 | |
| 260 | /// Materializes any [ContextArgs] as a function argument. |
| 261 | fn assign_context_args<M: MacroAssembler>( |
| 262 | sig: &ABISig, |
| 263 | context: &ContextArgs, |
| 264 | masm: &mut M, |
| 265 | ) -> Result<()> { |
| 266 | ensure!( |
| 267 | sig.params().len() >= context.len(), |
| 268 | CodeGenError::vmcontext_arg_expected(), |
| 269 | ); |
| 270 | for (context_arg, operand) in context |
| 271 | .as_slice() |
| 272 | .iter() |
| 273 | .zip(sig.params_without_retptr().iter().take(context.len())) |
| 274 | { |
| 275 | match (context_arg, operand) { |
| 276 | (VMContextLoc::Pinned, ABIOperand::Reg { ty, reg, .. }) => { |
| 277 | masm.mov(writable!(*reg), vmctx!(M).into(), (*ty).try_into()?)?; |
| 278 | } |
| 279 | (VMContextLoc::Pinned, ABIOperand::Stack { ty, offset, .. }) => { |
| 280 | let addr = masm.address_at_sp(SPOffset::from_u32(*offset))?; |
| 281 | masm.store(vmctx!(M).into(), addr, (*ty).try_into()?)?; |
| 282 | } |
| 283 | (VMContextLoc::OffsetFromPinned(offset), ABIOperand::Reg { ty, reg, .. }) => { |
| 284 | let addr = masm.address_at_vmctx(*offset)?; |
| 285 | masm.load(addr, writable!(*reg), (*ty).try_into()?)?; |
| 286 | } |
| 287 | (VMContextLoc::OffsetFromPinned(_), ABIOperand::Stack { .. }) => { |
| 288 | crate::bail!("unimplemented load from vmctx into stack"); |
| 289 | } |
| 290 | |
| 291 | (VMContextLoc::Reg(src), ABIOperand::Reg { ty, reg, .. }) => { |
| 292 | masm.mov(writable!(*reg), (*src).into(), (*ty).try_into()?)?; |
| 293 | } |
| 294 | |
| 295 | (VMContextLoc::Reg(src), ABIOperand::Stack { ty, offset, .. }) => { |
| 296 | let addr = masm.address_at_sp(SPOffset::from_u32(*offset))?; |
| 297 | masm.store((*src).into(), addr, (*ty).try_into()?)?; |
| 298 | } |
| 299 | } |
| 300 | } |
| 301 | Ok(()) |
| 302 | } |
| 303 | |
| 304 | /// Assign arguments for the function call. |
| 305 | fn assign<M: MacroAssembler>( |
nothing calls this directly
no test coverage detected