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
23 lines
391 B
Plaintext
23 lines
391 B
Plaintext
test interpret
|
|
test run
|
|
target aarch64
|
|
target x86_64
|
|
|
|
function %ctz_i32(i32) -> i32 {
|
|
block0(v0: i32):
|
|
v1 = ctz v0
|
|
return v1
|
|
}
|
|
; run: %ctz_i32(1) == 0
|
|
; run: %ctz_i32(0x40000000) == 30
|
|
; run: %ctz_i32(-1) == 0
|
|
|
|
function %ctz_i64(i64) -> i64 {
|
|
block0(v0: i64):
|
|
v1 = ctz v0
|
|
return v1
|
|
}
|
|
; run: %ctz_i64(1) == 0
|
|
; run: %ctz_i64(0x4000000000000000) == 62
|
|
; run: %ctz_i64(-1) == 0
|