Changes: * Adds a new generic instruction, SELECTIF, that does value selection (a la conditional move) similarly to existing SELECT, except that it is controlled by condition code input and flags-register inputs. * Adds a new Intel x86_64 variant, 'baseline', that supports SSE2 and nothing else. * Adds new Intel x86_64 instructions BSR and BSF. * Implements generic CLZ, CTZ and POPCOUNT on x86_64 'baseline' targets using the new BSR, BSF and SELECTIF instructions. * Implements SELECTIF on x86_64 targets using conditional-moves. * new test filetests/isa/intel/baseline_clz_ctz_popcount.cton (for legalization) * new test filetests/isa/intel/baseline_clz_ctz_popcount_encoding.cton (for encoding) * Allow lib/cretonne/meta/gen_legalizer.py to generate non-snake-caseified Rust without rustc complaining. Fixes #238.
105 lines
1.6 KiB
Plaintext
105 lines
1.6 KiB
Plaintext
|
|
test compile
|
|
set is_64bit
|
|
isa intel baseline
|
|
|
|
|
|
; clz/ctz on 64 bit operands
|
|
|
|
function %i64_clz(i64) -> i64 {
|
|
ebb0(v10: i64):
|
|
v11 = clz v10
|
|
; check: x86_bsr
|
|
; check: selectif.i64
|
|
return v11
|
|
}
|
|
|
|
function %i64_ctz(i64) -> i64 {
|
|
ebb1(v20: i64):
|
|
v21 = ctz v20
|
|
; check: x86_bsf
|
|
; check: selectif.i64
|
|
return v21
|
|
}
|
|
|
|
|
|
; clz/ctz on 32 bit operands
|
|
|
|
function %i32_clz(i32) -> i32 {
|
|
ebb0(v10: i32):
|
|
v11 = clz v10
|
|
; check: x86_bsr
|
|
; check: selectif.i32
|
|
return v11
|
|
}
|
|
|
|
function %i32_ctz(i32) -> i32 {
|
|
ebb1(v20: i32):
|
|
v21 = ctz v20
|
|
; check: x86_bsf
|
|
; check: selectif.i32
|
|
return v21
|
|
}
|
|
|
|
|
|
; popcount on 64 bit operands
|
|
|
|
function %i64_popcount(i64) -> i64 {
|
|
ebb0(v30: i64):
|
|
v31 = popcnt v30;
|
|
; check: iconst.i32
|
|
; check: ushr
|
|
; check: iconst.i64
|
|
; check: band
|
|
; check: isub
|
|
; check: iconst.i32
|
|
; check: ushr
|
|
; check: band
|
|
; check: isub
|
|
; check: iconst.i32
|
|
; check: ushr
|
|
; check: band
|
|
; check: isub
|
|
; check: iconst.i32
|
|
; check: ushr
|
|
; check: iadd
|
|
; check: iconst.i64
|
|
; check: band
|
|
; check: iconst.i64
|
|
; check: imul
|
|
; check: iconst.i32
|
|
; check: ushr
|
|
return v31;
|
|
}
|
|
|
|
|
|
; popcount on 32 bit operands
|
|
|
|
function %i32_popcount(i32) -> i32 {
|
|
ebb0(v40: i32):
|
|
v41 = popcnt v40;
|
|
; check: iconst.i32
|
|
; check: ushr
|
|
; check: iconst.i32
|
|
; check: band
|
|
; check: isub
|
|
; check: iconst.i32
|
|
; check: ushr
|
|
; check: band
|
|
; check: isub
|
|
; check: iconst.i32
|
|
; check: ushr
|
|
; check: band
|
|
; check: isub
|
|
; check: iconst.i32
|
|
; check: ushr
|
|
; check: iadd
|
|
; check: iconst.i32
|
|
; check: band
|
|
; check: iconst.i32
|
|
; check: imul
|
|
; check: iconst.i32
|
|
; check: ushr
|
|
return v41;
|
|
}
|