MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / i32_shift

Method i32_shift

winch/codegen/src/codegen/context.rs:51–78  ·  view source on GitHub ↗

Prepares arguments for emitting an i32 shift operation.

(&mut self, masm: &mut M, kind: ShiftKind)

Source from the content-addressed store, hash-verified

49impl<'a> CodeGenContext<'a, Emission> {
50 /// Prepares arguments for emitting an i32 shift operation.
51 pub fn i32_shift<M>(&mut self, masm: &mut M, kind: ShiftKind) -> Result<()>
52 where
53 M: MacroAssembler,
54 {
55 let top = self
56 .stack
57 .peek()
58 .ok_or_else(|| CodeGenError::missing_values_in_stack())?;
59
60 if top.is_i32_const() {
61 let val = self
62 .stack
63 .pop_i32_const()
64 .ok_or_else(|| CodeGenError::missing_values_in_stack())?;
65 let typed_reg = self.pop_to_reg(masm, None)?;
66 masm.shift_ir(
67 writable!(typed_reg.reg),
68 Imm::i32(val),
69 typed_reg.reg,
70 kind,
71 OperandSize::S32,
72 )?;
73 self.stack.push(typed_reg.into());
74 } else {
75 masm.shift(self, kind, OperandSize::S32)?;
76 }
77 Ok(())
78 }
79
80 /// Prepares arguments for emitting an i64 binary operation.
81 pub fn i64_shift<M>(&mut self, masm: &mut M, kind: ShiftKind) -> Result<()>

Callers 5

visit_i32_shlMethod · 0.80
visit_i32_shr_sMethod · 0.80
visit_i32_shr_uMethod · 0.80
visit_i32_rotlMethod · 0.80
visit_i32_rotrMethod · 0.80

Calls 8

OkFunction · 0.85
is_i32_constMethod · 0.80
pop_to_regMethod · 0.80
peekMethod · 0.45
pop_i32_constMethod · 0.45
shift_irMethod · 0.45
pushMethod · 0.45
shiftMethod · 0.45

Tested by

no test coverage detected