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
20 lines
327 B
Plaintext
20 lines
327 B
Plaintext
test interpret
|
|
|
|
function %ctz_i8(i8) -> i8 {
|
|
block0(v0: i8):
|
|
v1 = ctz v0
|
|
return v1
|
|
}
|
|
; run: %ctz_i8(1) == 0
|
|
; run: %ctz_i8(0x40) == 6
|
|
; run: %ctz_i8(-1) == 0
|
|
|
|
function %ctz_i16(i16) -> i16 {
|
|
block0(v0: i16):
|
|
v1 = ctz v0
|
|
return v1
|
|
}
|
|
; run: %ctz_i16(1) == 0
|
|
; run: %ctz_i16(0x4000) == 14
|
|
; run: %ctz_i16(-1) == 0
|