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

Function binary_arith

cranelift/interpreter/src/step.rs:1567–1586  ·  view source on GitHub ↗

Performs the supplied binary arithmetic `op` on two values, either vector or scalar.

(
    x: DataValue,
    y: DataValue,
    vector_type: types::Type,
    op: F,
)

Source from the content-addressed store, hash-verified

1565
1566/// Performs the supplied binary arithmetic `op` on two values, either vector or scalar.
1567fn binary_arith<F>(
1568 x: DataValue,
1569 y: DataValue,
1570 vector_type: types::Type,
1571 op: F,
1572) -> ValueResult<DataValue>
1573where
1574 F: Fn(DataValue, DataValue) -> ValueResult<DataValue>,
1575{
1576 let arg0 = extractlanes(&x, vector_type)?;
1577 let arg1 = extractlanes(&y, vector_type)?;
1578
1579 let result = arg0
1580 .into_iter()
1581 .zip(arg1)
1582 .map(|(lhs, rhs)| Ok(op(lhs, rhs)?))
1583 .collect::<ValueResult<SimdVec<DataValue>>>()?;
1584
1585 vectorizelanes(&result, vector_type)
1586}
1587
1588/// Performs the supplied pairwise arithmetic `op` on two SIMD vectors, where
1589/// pairs are formed from adjacent vector elements and the vectors are

Callers 1

stepFunction · 0.85

Calls 5

extractlanesFunction · 0.85
OkFunction · 0.85
vectorizelanesFunction · 0.85
mapMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected