Files
wasmtime/cranelift/filetests/filetests/isa/x86/legalize-i64.clif
2020-02-14 13:16:02 -08:00

358 lines
12 KiB
Plaintext

; Test the legalization of i64 instructions on x86_32.
test legalizer
target i686 haswell
; regex: V=v\d+
function %iadd(i64, i64) -> i64 {
block0(v1: i64, v2: i64):
v10 = iadd v1, v2
; check: v1 = iconcat $(v1_lsb=$V), $(v1_msb=$V)
; nextln: v2 = iconcat $(v2_lsb=$V), $(v2_msb=$V)
; nextln: $(v10_lsb=$V), $(carry=$V) = iadd_ifcout $v1_lsb, $v2_lsb
; nextln: $(v10_msb=$V) = iadd_ifcin $v1_msb, $v2_msb, $carry
; nextln: v10 = iconcat $v10_lsb, $v10_msb
return v10
}
function %isub(i64, i64) -> i64 {
block0(v1: i64, v2: i64):
v10 = isub v1, v2
; check: v1 = iconcat $(v1_lsb=$V), $(v1_msb=$V)
; nextln: v2 = iconcat $(v2_lsb=$V), $(v2_msb=$V)
; nextln: $(v10_lsb=$V), $(borrow=$V) = isub_ifbout $v1_lsb, $v2_lsb
; nextln: $(v10_msb=$V) = isub_ifbin $v1_msb, $v2_msb, $borrow
; nextln: v10 = iconcat $v10_lsb, $v10_msb
return v10
}
function %imul(i64, i64) -> i64 {
block0(v1: i64, v2: i64):
v10 = imul v1, v2
; check: v1 = iconcat $(v1_lsb=$V), $(v1_msb=$V)
; nextln: v2 = iconcat $(v2_lsb=$V), $(v2_msb=$V)
; nextln: $(v11=$V) = imul $v1_msb, $v2_lsb
; nextln: $(v12=$V) = imul $v1_lsb, $v2_msb
; nextln: $(v13=$V) = iadd $v11, $v12
; nextln: $(v99=$V), $(v14=$V) = x86_umulx $v1_lsb, $v2_lsb
; nextln: $(v10_msb=$V) = iadd $v13, $v14
; nextln: $(v10_lsb=$V) = imul $v1_lsb, $v2_lsb
; nextln: v10 = iconcat $v10_lsb, $v10_msb
return v10
}
function %icmp_eq(i64, i64) -> b1 {
block0(v1: i64, v2: i64):
v10 = icmp eq v1, v2
; check: v1 = iconcat $(v1_lsb=$V), $(v1_msb=$V)
; nextln: v2 = iconcat $(v2_lsb=$V), $(v2_msb=$V)
; nextln: $(v10_lsb=$V) = icmp eq $v1_lsb, $v2_lsb
; nextln: $(v10_msb=$V) = icmp eq $v1_msb, $v2_msb
; nextln: v10 = band $v10_lsb, $v10_msb
return v10
}
function %icmp_imm_eq(i64) -> b1 {
block0(v1: i64):
v10 = icmp_imm eq v1, 0
; check: $(v1_lsb=$V) -> $(v1_lsb_a=$V)
; nextln: $(v1_msb=$V) -> $(v1_msb_a=$V)
; nextln: v1 = iconcat $(v1_lsb_a=$V), $(v1_msb_a=$V)
; nextln: $(v2_lsb=$V) = iconst.i32 0
; nextln: $(v2_msb=$V) = iconst.i32 0
; nextln: $(v10_lsb=$V) = icmp eq $v1_lsb, $v2_lsb
; nextln: $(v10_msb=$V) = icmp eq $v1_msb, $v2_msb
; nextln: v10 = band $v10_lsb, $v10_msb
return v10
}
function %icmp_ne(i64, i64) -> b1 {
block0(v1: i64, v2: i64):
v10 = icmp ne v1, v2
; check: v1 = iconcat $(v1_lsb=$V), $(v1_msb=$V)
; nextln: v2 = iconcat $(v2_lsb=$V), $(v2_msb=$V)
; nextln: $(v10_lsb=$V) = icmp ne $v1_lsb, $v2_lsb
; nextln: $(v10_msb=$V) = icmp ne $v1_msb, $v2_msb
; nextln: v10 = bor $v10_lsb, $v10_msb
return v10
}
function %icmp_imm_ne(i64) -> b1 {
block0(v1: i64):
v10 = icmp_imm ne v1, 0
; check: $(v1_lsb=$V) -> $(v1_lsb_a=$V)
; nextln: $(v1_msb=$V) -> $(v1_msb_a=$V)
; nextln: v1 = iconcat $(v1_lsb_a=$V), $(v1_msb_a=$V)
; nextln: $(v2_lsb=$V) = iconst.i32 0
; nextln: $(v2_msb=$V) = iconst.i32 0
; nextln: $(v10_lsb=$V) = icmp ne $v1_lsb, $v2_lsb
; nextln: $(v10_msb=$V) = icmp ne $v1_msb, $v2_msb
; nextln: v10 = bor $v10_lsb, $v10_msb
return v10
}
function %icmp_sgt(i64, i64) -> b1 {
block0(v1: i64, v2: i64):
v10 = icmp sgt v1, v2
; check: v1 = iconcat $(v1_lsb=$V), $(v1_msb=$V)
; nextln: v2 = iconcat $(v2_lsb=$V), $(v2_msb=$V)
; nextln: $(b1=$V) = icmp sgt $v1_msb, $v2_msb
; nextln: $(b2=$V) = icmp slt $v1_msb, $v2_msb
; nextln: $(b3=$V) = icmp ugt $v1_lsb, $v2_lsb
; nextln: $(c1=$V) = bnot $b2
; nextln: $(c2=$V) = band $c1, $b3
; nextln: v10 = bor $b1, $c2
return v10
}
function %icmp_imm_sgt(i64) -> b1 {
block0(v1: i64):
v10 = icmp_imm sgt v1, 0
; check: $(v1_lsb=$V) -> $(v1_lsb_a=$V)
; nextln: $(v1_msb=$V) -> $(v1_msb_a=$V)
; nextln: v1 = iconcat $(v1_lsb_a=$V), $(v1_msb_a=$V)
; nextln: $(v2_lsb=$V) = iconst.i32 0
; nextln: $(v2_msb=$V) = iconst.i32 0
; nextln: $(b1=$V) = icmp sgt $v1_msb, $v2_msb
; nextln: $(b2=$V) = icmp slt $v1_msb, $v2_msb
; nextln: $(b3=$V) = icmp ugt $v1_lsb, $v2_lsb
; nextln: $(c1=$V) = bnot $b2
; nextln: $(c2=$V) = band $c1, $b3
; nextln: v10 = bor $b1, $c2
return v10
}
function %icmp_sge(i64, i64) -> b1 {
block0(v1: i64, v2: i64):
v10 = icmp sge v1, v2
; check: v1 = iconcat $(v1_lsb=$V), $(v1_msb=$V)
; nextln: v2 = iconcat $(v2_lsb=$V), $(v2_msb=$V)
; nextln: $(b1=$V) = icmp sgt $v1_msb, $v2_msb
; nextln: $(b2=$V) = icmp slt $v1_msb, $v2_msb
; nextln: $(b3=$V) = icmp uge $v1_lsb, $v2_lsb
; nextln: $(c1=$V) = bnot $b2
; nextln: $(c2=$V) = band $c1, $b3
; nextln: v10 = bor $b1, $c2
return v10
}
function %icmp_imm_sge(i64) -> b1 {
block0(v1: i64):
v10 = icmp_imm sge v1, 0
; check: $(v1_lsb=$V) -> $(v1_lsb_a=$V)
; nextln: $(v1_msb=$V) -> $(v1_msb_a=$V)
; nextln: v1 = iconcat $(v1_lsb_a=$V), $(v1_msb_a=$V)
; nextln: $(v2_lsb=$V) = iconst.i32 0
; nextln: $(v2_msb=$V) = iconst.i32 0
; nextln: $(b1=$V) = icmp sgt $v1_msb, $v2_msb
; nextln: $(b2=$V) = icmp slt $v1_msb, $v2_msb
; nextln: $(b3=$V) = icmp uge $v1_lsb, $v2_lsb
; nextln: $(c1=$V) = bnot $b2
; nextln: $(c2=$V) = band $c1, $b3
; nextln: v10 = bor $b1, $c2
return v10
}
function %icmp_slt(i64, i64) -> b1 {
block0(v1: i64, v2: i64):
v10 = icmp slt v1, v2
; check: v1 = iconcat $(v1_lsb=$V), $(v1_msb=$V)
; nextln: v2 = iconcat $(v2_lsb=$V), $(v2_msb=$V)
; nextln: $(b1=$V) = icmp slt $v1_msb, $v2_msb
; nextln: $(b2=$V) = icmp sgt $v1_msb, $v2_msb
; nextln: $(b3=$V) = icmp ult $v1_lsb, $v2_lsb
; nextln: $(c1=$V) = bnot $b2
; nextln: $(c2=$V) = band $c1, $b3
; nextln: v10 = bor $b1, $c2
return v10
}
function %icmp_imm_slt(i64) -> b1 {
block0(v1: i64):
v10 = icmp_imm slt v1, 0
; check: $(v1_lsb=$V) -> $(v1_lsb_a=$V)
; nextln: $(v1_msb=$V) -> $(v1_msb_a=$V)
; nextln: v1 = iconcat $(v1_lsb_a=$V), $(v1_msb_a=$V)
; nextln: $(v2_lsb=$V) = iconst.i32 0
; nextln: $(v2_msb=$V) = iconst.i32 0
; nextln: $(b1=$V) = icmp slt $v1_msb, $v2_msb
; nextln: $(b2=$V) = icmp sgt $v1_msb, $v2_msb
; nextln: $(b3=$V) = icmp ult $v1_lsb, $v2_lsb
; nextln: $(c1=$V) = bnot $b2
; nextln: $(c2=$V) = band $c1, $b3
; nextln: v10 = bor $b1, $c2
return v10
}
function %icmp_sle(i64, i64) -> b1 {
block0(v1: i64, v2: i64):
v10 = icmp sle v1, v2
; check: v1 = iconcat $(v1_lsb=$V), $(v1_msb=$V)
; nextln: v2 = iconcat $(v2_lsb=$V), $(v2_msb=$V)
; nextln: $(b1=$V) = icmp slt $v1_msb, $v2_msb
; nextln: $(b2=$V) = icmp sgt $v1_msb, $v2_msb
; nextln: $(b3=$V) = icmp ule $v1_lsb, $v2_lsb
; nextln: $(c1=$V) = bnot $b2
; nextln: $(c2=$V) = band $c1, $b3
; nextln: v10 = bor $b1, $c2
return v10
}
function %icmp_imm_sle(i64) -> b1 {
block0(v1: i64):
v10 = icmp_imm sle v1, 0
; check: $(v1_lsb=$V) -> $(v1_lsb_a=$V)
; nextln: $(v1_msb=$V) -> $(v1_msb_a=$V)
; nextln: v1 = iconcat $(v1_lsb_a=$V), $(v1_msb_a=$V)
; nextln: $(v2_lsb=$V) = iconst.i32 0
; nextln: $(v2_msb=$V) = iconst.i32 0
; nextln: $(b1=$V) = icmp slt $v1_msb, $v2_msb
; nextln: $(b2=$V) = icmp sgt $v1_msb, $v2_msb
; nextln: $(b3=$V) = icmp ule $v1_lsb, $v2_lsb
; nextln: $(c1=$V) = bnot $b2
; nextln: $(c2=$V) = band $c1, $b3
; nextln: v10 = bor $b1, $c2
return v10
}
function %icmp_ugt(i64, i64) -> b1 {
block0(v1: i64, v2: i64):
v10 = icmp ugt v1, v2
; check: v1 = iconcat $(v1_lsb=$V), $(v1_msb=$V)
; nextln: v2 = iconcat $(v2_lsb=$V), $(v2_msb=$V)
; nextln: $(b1=$V) = icmp ugt $v1_msb, $v2_msb
; nextln: $(b2=$V) = icmp ult $v1_msb, $v2_msb
; nextln: $(b3=$V) = icmp ugt $v1_lsb, $v2_lsb
; nextln: $(c1=$V) = bnot $b2
; nextln: $(c2=$V) = band $c1, $b3
; nextln: v10 = bor $b1, $c2
return v10
}
function %icmp_imm_ugt(i64) -> b1 {
block0(v1: i64):
v10 = icmp_imm ugt v1, 0
; check: $(v1_lsb=$V) -> $(v1_lsb_a=$V)
; nextln: $(v1_msb=$V) -> $(v1_msb_a=$V)
; nextln: v1 = iconcat $(v1_lsb_a=$V), $(v1_msb_a=$V)
; nextln: $(v2_lsb=$V) = iconst.i32 0
; nextln: $(v2_msb=$V) = iconst.i32 0
; nextln: $(b1=$V) = icmp ugt $v1_msb, $v2_msb
; nextln: $(b2=$V) = icmp ult $v1_msb, $v2_msb
; nextln: $(b3=$V) = icmp ugt $v1_lsb, $v2_lsb
; nextln: $(c1=$V) = bnot $b2
; nextln: $(c2=$V) = band $c1, $b3
; nextln: v10 = bor $b1, $c2
return v10
}
function %icmp_uge(i64, i64) -> b1 {
block0(v1: i64, v2: i64):
v10 = icmp uge v1, v2
; check: v1 = iconcat $(v1_lsb=$V), $(v1_msb=$V)
; nextln: v2 = iconcat $(v2_lsb=$V), $(v2_msb=$V)
; nextln: $(b1=$V) = icmp ugt $v1_msb, $v2_msb
; nextln: $(b2=$V) = icmp ult $v1_msb, $v2_msb
; nextln: $(b3=$V) = icmp uge $v1_lsb, $v2_lsb
; nextln: $(c1=$V) = bnot $b2
; nextln: $(c2=$V) = band $c1, $b3
; nextln: v10 = bor $b1, $c2
return v10
}
function %icmp_imm_uge(i64) -> b1 {
block0(v1: i64):
v10 = icmp_imm uge v1, 0
; check: $(v1_lsb=$V) -> $(v1_lsb_a=$V)
; nextln: $(v1_msb=$V) -> $(v1_msb_a=$V)
; nextln: v1 = iconcat $(v1_lsb_a=$V), $(v1_msb_a=$V)
; nextln: $(v2_lsb=$V) = iconst.i32 0
; nextln: $(v2_msb=$V) = iconst.i32 0
; nextln: $(b1=$V) = icmp ugt $v1_msb, $v2_msb
; nextln: $(b2=$V) = icmp ult $v1_msb, $v2_msb
; nextln: $(b3=$V) = icmp uge $v1_lsb, $v2_lsb
; nextln: $(c1=$V) = bnot $b2
; nextln: $(c2=$V) = band $c1, $b3
; nextln: v10 = bor $b1, $c2
return v10
}
function %icmp_ult(i64, i64) -> b1 {
block0(v1: i64, v2: i64):
v10 = icmp ult v1, v2
; check: v1 = iconcat $(v1_lsb=$V), $(v1_msb=$V)
; nextln: v2 = iconcat $(v2_lsb=$V), $(v2_msb=$V)
; nextln: $(b1=$V) = icmp ult $v1_msb, $v2_msb
; nextln: $(b2=$V) = icmp ugt $v1_msb, $v2_msb
; nextln: $(b3=$V) = icmp ult $v1_lsb, $v2_lsb
; nextln: $(c1=$V) = bnot $b2
; nextln: $(c2=$V) = band $c1, $b3
; nextln: v10 = bor $b1, $c2
return v10
}
function %icmp_imm_ult(i64) -> b1 {
block0(v1: i64):
v10 = icmp_imm ult v1, 0
; check: $(v1_lsb=$V) -> $(v1_lsb_a=$V)
; nextln: $(v1_msb=$V) -> $(v1_msb_a=$V)
; nextln: v1 = iconcat $(v1_lsb_a=$V), $(v1_msb_a=$V)
; nextln: $(v2_lsb=$V) = iconst.i32 0
; nextln: $(v2_msb=$V) = iconst.i32 0
; nextln: $(b1=$V) = icmp ult $v1_msb, $v2_msb
; nextln: $(b2=$V) = icmp ugt $v1_msb, $v2_msb
; nextln: $(b3=$V) = icmp ult $v1_lsb, $v2_lsb
; nextln: $(c1=$V) = bnot $b2
; nextln: $(c2=$V) = band $c1, $b3
; nextln: v10 = bor $b1, $c2
return v10
}
function %icmp_ule(i64, i64) -> b1 {
block0(v1: i64, v2: i64):
v10 = icmp ule v1, v2
; check: v1 = iconcat $(v1_lsb=$V), $(v1_msb=$V)
; nextln: v2 = iconcat $(v2_lsb=$V), $(v2_msb=$V)
; nextln: $(b1=$V) = icmp ult $v1_msb, $v2_msb
; nextln: $(b2=$V) = icmp ugt $v1_msb, $v2_msb
; nextln: $(b3=$V) = icmp ule $v1_lsb, $v2_lsb
; nextln: $(c1=$V) = bnot $b2
; nextln: $(c2=$V) = band $c1, $b3
; nextln: v10 = bor $b1, $c2
return v10
}
function %icmp_imm_ule(i64) -> b1 {
block0(v1: i64):
v10 = icmp_imm ule v1, 0
; check: $(v1_lsb=$V) -> $(v1_lsb_a=$V)
; nextln: $(v1_msb=$V) -> $(v1_msb_a=$V)
; nextln: v1 = iconcat $(v1_lsb_a=$V), $(v1_msb_a=$V)
; nextln: $(v2_lsb=$V) = iconst.i32 0
; nextln: $(v2_msb=$V) = iconst.i32 0
; nextln: $(b1=$V) = icmp ult $v1_msb, $v2_msb
; nextln: $(b2=$V) = icmp ugt $v1_msb, $v2_msb
; nextln: $(b3=$V) = icmp ule $v1_lsb, $v2_lsb
; nextln: $(c1=$V) = bnot $b2
; nextln: $(c2=$V) = band $c1, $b3
; nextln: v10 = bor $b1, $c2
return v10
}
function %ineg_legalized_i64() {
block0:
v0 = iconst.i64 1
v1 = ineg v0
; check: v2 = iconst.i32 1
; nextln: v3 = iconst.i32 0
; nextln: v0 = iconcat v2, v3
; nextln: v5 = iconst.i32 0
; nextln: v6 = iconst.i32 0
; nextln: v4 = iconcat v5, v6
; nextln: v7, v8 = isub_ifbout v5, v2
; nextln: v9 = isub_ifbin v6, v3, v8
; nextln: v1 = iconcat v7, v9
return
}