[codegen] reintroduce support for carry and borrow instructions in RI… (#1005)
Reintroduce support for iadd carry variants and isub borrow variants for RISC ISAs which had been removed in https://github.com/CraneStation/cranelift/pull/961 and https://github.com/CraneStation/cranelift/pull/962 because of the lack of a proper flags register in RISC architectures.
This commit is contained in:
committed by
Benjamin Bouvier
parent
cadd0ac655
commit
3418fb6e18
@@ -1,6 +1,3 @@
|
||||
; TODO(ryzokuken): figure out a better legalization strategy for platforms that
|
||||
; platforms that don't have flags.
|
||||
|
||||
; Test the legalization of i32 instructions that don't have RISC-V versions.
|
||||
test legalizer
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
; TODO(ryzokuken): figure out a better legalization strategy for platforms that
|
||||
; platforms that don't have flags.
|
||||
|
||||
; Test the legalization of i64 arithmetic instructions.
|
||||
test legalizer
|
||||
target riscv32 supports_m=1
|
||||
@@ -471,19 +471,19 @@ ebb0:
|
||||
|
||||
; Carry Addition
|
||||
; asm: addl %esi, %ecx
|
||||
[-,%rcx,%rflags] v701, v702 = iadd_cout v1, v2 ; bin: 01 f1
|
||||
[-,%rcx,%rflags] v701, v702 = iadd_ifcout v1, v2 ; bin: 01 f1
|
||||
; asm: adcl %esi, %ecx
|
||||
[-,%rcx] v703 = iadd_cin v1, v2, v702 ; bin: 11 f1
|
||||
[-,%rcx] v703 = iadd_ifcin v1, v2, v702 ; bin: 11 f1
|
||||
; asm: adcl %esi, %ecx
|
||||
[-,%rcx,%rflags] v704, v705 = iadd_carry v1, v2, v702 ; bin: 11 f1
|
||||
[-,%rcx,%rflags] v704, v705 = iadd_ifcarry v1, v2, v702 ; bin: 11 f1
|
||||
|
||||
; Borrow Subtraction
|
||||
; asm: subl %esi, %ecx
|
||||
[-,%rcx,%rflags] v706, v707 = isub_bout v1, v2 ; bin: 29 f1
|
||||
[-,%rcx,%rflags] v706, v707 = isub_ifbout v1, v2 ; bin: 29 f1
|
||||
; asm: sbbl %esi, %ecx
|
||||
[-,%rcx] v708 = isub_bin v1, v2, v707 ; bin: 19 f1
|
||||
[-,%rcx] v708 = isub_ifbin v1, v2, v707 ; bin: 19 f1
|
||||
; asm: sbbl %esi, %ecx
|
||||
[-,%rcx,%rflags] v709, v710 = isub_borrow v1, v2, v707 ; bin: 19 f1
|
||||
[-,%rcx,%rflags] v709, v710 = isub_ifborrow v1, v2, v707 ; bin: 19 f1
|
||||
|
||||
; asm: testl %ecx, %ecx
|
||||
; asm: je ebb1
|
||||
|
||||
@@ -9,8 +9,8 @@ ebb0(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_cout $v1_lsb, $v2_lsb
|
||||
; nextln: $(v10_msb=$V) = iadd_cin $v1_msb, $v2_msb, $carry
|
||||
; 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
|
||||
}
|
||||
@@ -20,8 +20,8 @@ ebb0(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_bout $v1_lsb, $v2_lsb
|
||||
; nextln: $(v10_msb=$V) = isub_bin $v1_msb, $v2_msb, $borrow
|
||||
; 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
|
||||
}
|
||||
|
||||
@@ -5,13 +5,13 @@ target i686 haswell
|
||||
function %iadd(i64, i64) -> i64 {
|
||||
ebb0(v1: i64, v2: i64):
|
||||
v10 = iadd v1, v2
|
||||
; check: iadd_cout
|
||||
; check: iadd_ifcout
|
||||
return v10
|
||||
}
|
||||
|
||||
function %isub(i64, i64) -> i64 {
|
||||
ebb0(v1: i64, v2: i64):
|
||||
v10 = isub v1, v2
|
||||
; check: isub_bout
|
||||
; check: isub_ifbout
|
||||
return v10
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user