CLZ (vector)

Data processing (scalar floating-point and Advanced SIMD)

fixed bit field field the encoding fixes should be

Vector arithmetic unary clsz

313029282726252423222120191817161514131211109876543210
0Q101110size100000010010RnRd
U

0x101110xx100000010010xxxxxxxxxx

Decode Sail

let 'd = UInt(Rd);
let 'n = UInt(Rn);
if size == 0b11 then {
    throw(Error_Undefined())
};
let 'esize = (8 << UInt(size));
let 'datasize = if Q == 0b1 then 128 else 64;
let 'elements = DIV(datasize, esize);
let countop : CountOp = if U == 0b1 then CountOp_CLZ else CountOp_CLS;
execute_aarch64_instrs_vector_arithmetic_unary_clsz(countop, d, datasize, elements, esize, n)

Operation Sail

CheckFPAdvSIMDEnabled64();
let operand : bits('datasize) = V_read(n, datasize);
result : bits('datasize) = undefined;
count : int = undefined;
foreach (e from 0 to (elements - 1) by 1 in inc) {
    if countop == CountOp_CLS then {
        count = CountLeadingSignBits(Elem_read(operand, e, esize))
    } else {
        count = CountLeadingZeroBits(Elem_read(operand, e, esize))
    };
    result = Elem_set(result, e, esize, count[esize - 1 .. 0])
};
V_set(d, datasize) = result

Made from ScarletNX's Sail at 166ad3910f80. sail-arm's definitions are Arm's ASL in Sail (BSD 3-Clause Clear, license); ScarletNX's fixups are GPL-3.0-or-later.