CLS

Data processing (register)

fixed bit field field the encoding fixes should be

Integer arithmetic cnt

313029282726252423222120191817161514131211109876543210
sf101101011000000000101RnRd
op

x101101011000000000101xxxxxxxxxx

Decode Sail

let 'd = UInt(Rd);
let 'n = UInt(Rn);
let 'datasize = if sf == 0b1 then 64 else 32;
let opcode : CountOp = if op == 0b0 then CountOp_CLZ else CountOp_CLS;
execute_aarch64_instrs_integer_arithmetic_cnt(d, datasize, n, opcode)

Operation Sail

result : int = undefined;
let operand1 : bits('datasize) = X_read(n, datasize);
if opcode == CountOp_CLZ then {
    result = CountLeadingZeroBits(operand1)
} else {
    result = CountLeadingSignBits(operand1)
};
let 'result = result;
X_set(d, datasize) = result[datasize - 1 .. 0]

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.