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

Method wasm_load

winch/codegen/src/isa/x64/masm.rs:363–424  ·  view source on GitHub ↗
(&mut self, src: Self::Address, dst: WritableReg, kind: LoadKind)

Source from the content-addressed store, hash-verified

361 }
362
363 fn wasm_load(&mut self, src: Self::Address, dst: WritableReg, kind: LoadKind) -> Result<()> {
364 let size = kind.derive_operand_size();
365
366 match kind {
367 LoadKind::ScalarExtend(ext) => match ext {
368 ExtendKind::Signed(ext) => {
369 self.asm.movsx_mr(&src, dst, ext, UNTRUSTED_FLAGS);
370 }
371 ExtendKind::Unsigned(_) => self.load_impl(src, dst, size, UNTRUSTED_FLAGS)?,
372 },
373 LoadKind::Operand(_) | LoadKind::Atomic(_, _) => {
374 // The guarantees of the x86-64 memory model ensure that `SeqCst`
375 // loads are equivalent to normal loads.
376 if kind.is_atomic() && size == OperandSize::S128 {
377 bail!(CodeGenError::unexpected_operand_size());
378 }
379
380 self.load_impl(src, dst, size, UNTRUSTED_FLAGS)?;
381 }
382 LoadKind::VectorExtend(ext) => {
383 self.ensure_has_avx()?;
384 self.asm
385 .xmm_vpmov_mr(&src, dst, ext.into(), UNTRUSTED_FLAGS)
386 }
387 LoadKind::Splat(_) => {
388 self.ensure_has_avx()?;
389
390 if size == OperandSize::S64 {
391 self.asm
392 .xmm_mov_mr(&src, dst, OperandSize::S64, UNTRUSTED_FLAGS);
393 self.asm.xmm_vpshuf_rr(
394 dst.to_reg(),
395 dst,
396 Self::vpshuf_mask_for_64_bit_splats(),
397 OperandSize::S32,
398 );
399 } else {
400 self.asm
401 .xmm_vpbroadcast_mr(&src, dst, size, UNTRUSTED_FLAGS);
402 }
403 }
404 LoadKind::VectorLane(LaneSelector { lane, size }) => {
405 self.ensure_has_avx()?;
406 self.with_scratch::<IntScratch, _>(|masm, byte_tmp| {
407 masm.load_impl(src, byte_tmp.writable(), size, UNTRUSTED_FLAGS)?;
408 masm.asm
409 .xmm_vpinsr_rrr(dst, dst.to_reg(), byte_tmp.inner(), lane, size);
410 wasmtime_environ::error::Ok(())
411 })?;
412 }
413 LoadKind::VectorZero(size) => {
414 self.ensure_has_avx()?;
415 self.with_scratch::<IntScratch, _>(|masm, scratch| {
416 masm.load_impl(src, scratch.writable(), size, UNTRUSTED_FLAGS)?;
417 masm.asm.avx_gpr_to_xmm(scratch.inner(), dst, size);
418 wasmtime_environ::error::Ok(())
419 })?;
420 }

Callers 1

emit_wasm_loadMethod · 0.45

Calls 15

OkFunction · 0.85
derive_operand_sizeMethod · 0.80
movsx_mrMethod · 0.80
load_implMethod · 0.80
is_atomicMethod · 0.80
ensure_has_avxMethod · 0.80
xmm_vpmov_mrMethod · 0.80
xmm_mov_mrMethod · 0.80
xmm_vpshuf_rrMethod · 0.80
to_regMethod · 0.80
xmm_vpbroadcast_mrMethod · 0.80
xmm_vpinsr_rrrMethod · 0.80

Tested by

no test coverage detected