Implement bit operations for Cranelift interpreter
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
This commit is contained in:
24
cranelift/filetests/filetests/runtests/cls-aarch64.clif
Normal file
24
cranelift/filetests/filetests/runtests/cls-aarch64.clif
Normal file
@@ -0,0 +1,24 @@
|
||||
test interpret
|
||||
test run
|
||||
target aarch64
|
||||
; not implemented on `x86_64`
|
||||
|
||||
function %cls_i32(i32) -> i32 {
|
||||
block0(v0: i32):
|
||||
v1 = cls v0
|
||||
return v1
|
||||
}
|
||||
; run: %cls_i32(1) == 30
|
||||
; run: %cls_i32(0x40000000) == 0
|
||||
; run: %cls_i32(-1) == 31
|
||||
; run: %cls_i32(0) == 31
|
||||
|
||||
function %cls_i64(i64) -> i64 {
|
||||
block0(v0: i64):
|
||||
v1 = cls v0
|
||||
return v1
|
||||
}
|
||||
; run: %cls_i64(1) == 62
|
||||
; run: %cls_i64(0x4000000000000000) == 0
|
||||
; run: %cls_i64(-1) == 63
|
||||
; run: %cls_i64(0) == 63
|
||||
Reference in New Issue
Block a user