Implemented for the Cranelift interpreter: - `Bitrev` to reverse the order of the bits in an integer. - `Cls` to count the leading bits which are the same as the sign bit in an integer, yielding one less than the size of the integer for 0 and -1. - `Clz` to count the number of leading zeros in the bitwise representation of the integer. - `Ctz` to count the number of trailing zeros in the bitwise representation of the integer. - `Popcnt` to count the number of ones in the bitwise representation of the integer. Copyright (c) 2021, Arm Limited
19 lines
326 B
Plaintext
19 lines
326 B
Plaintext
test interpret
|
|
|
|
function %clz_i8(i8) -> i8 {
|
|
block0(v0: i8):
|
|
v1 = clz v0
|
|
return v1
|
|
}
|
|
; run: %clz_i8(1) == 7
|
|
; run: %clz_i8(0x40) == 1
|
|
; run: %clz_i8(-1) == 0
|
|
|
|
function %clz_i16(i16) -> i16 {
|
|
block0(v0: i16):
|
|
v1 = clz v0
|
|
return v1
|
|
}
|
|
; run: %clz_i16(1) == 15
|
|
; run: %clz_i16(0x4000) == 1
|
|
; run: %clz_i16(-1) == 0 |