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

Function unary_arith

cranelift/interpreter/src/step.rs:1552–1564  ·  view source on GitHub ↗

Performs the supplied unary arithmetic `op` on a Value, either Vector or Scalar.

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

Source from the content-addressed store, hash-verified

1550
1551/// Performs the supplied unary arithmetic `op` on a Value, either Vector or Scalar.
1552fn unary_arith<F>(x: DataValue, vector_type: types::Type, op: F) -> ValueResult<DataValue>
1553where
1554 F: Fn(DataValue) -> ValueResult<DataValue>,
1555{
1556 let arg = extractlanes(&x, vector_type)?;
1557
1558 let result = arg
1559 .into_iter()
1560 .map(|arg| Ok(op(arg)?))
1561 .collect::<ValueResult<SimdVec<DataValue>>>()?;
1562
1563 vectorizelanes(&result, vector_type)
1564}
1565
1566/// Performs the supplied binary arithmetic `op` on two values, either vector or scalar.
1567fn binary_arith<F>(

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