[codegen] add encodings for iadd carry variants (#961)

* [codegen] add encodings for iadd carry variants

Add encodings for iadd carry variants (iadd_cout, iadd_cin, iadd_carry)
for x86_32, enabling the legalization for iadd.i64 to work.

* [codegen] remove support for iadd carry variants on riscv

Previously, the carry variants of iadd (iadd_cin, iadd_cout and
iadd_carry) were being legalized for isa/riscv since RISC architectures
lack a flags register.

This forced us to return and accept booleans for these operations, which
proved to be problematic and inconvenient, especially for x86.

This commit removes support for said statements and all dependent
statements for isa/riscv so that we can work on a better legalization
strategy in the future.

* [codegen] change operand type from bool to iflag for iadd carry variants

The type of the carry operands for the carry variants of the iadd
instruction (iadd_cin, iadd_cout, iadd_carry) was bool for compatibility
reasons for isa/riscv. Since support for these instructions on RISC
architectures has been temporarily suspended, we can safely change the
type to iflags.
This commit is contained in:
Ujjwal Sharma
2019-09-05 18:33:13 +05:30
committed by Benjamin Bouvier
parent 7e398af999
commit ea919489ee
9 changed files with 84 additions and 33 deletions

View File

@@ -1,3 +1,6 @@
; 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

View File

@@ -1,3 +1,6 @@
; 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

View File

@@ -469,6 +469,14 @@ ebb0:
; asm: mov %cl,(%eax,%ebx,1)
istore8_complex v601, v521+v522 ; bin: heap_oob 88 0c 18
; Carry Addition
; asm: addl %esi, %ecx
[-,%rcx,%rflags] v701, v702 = iadd_cout v1, v2 ; bin: 01 f1
; asm: adcl %esi, %ecx
[-,%rcx] v703 = iadd_cin v1, v2, v702 ; bin: 11 f1
; asm: adcl %esi, %ecx
[-,%rcx,%rflags] v704, v705 = iadd_carry v1, v2, v702 ; bin: 11 f1
; asm: testl %ecx, %ecx
; asm: je ebb1
brz v1, ebb1 ; bin: 85 c9 74 0e

View File

@@ -0,0 +1,16 @@
; Test the legalization of i64 instructions on x86_32.
test legalizer
target i686 haswell
; regex: V=v\d+
function %iadd(i64, i64) -> i64 {
ebb0(v1: i64, v2: i64):
v10 = iadd v1, v2
; check: v1 = iconcat $(v1_lsb=$V), $(v1_msb=$V)
; check: v2 = iconcat $(v2_lsb=$V), $(v2_msb=$V)
; check: $(v10_lsb=$V), $(carry=$V) = iadd_cout $v1_lsb, $v2_lsb
; check: $(v10_msb=$V) = iadd_cin $v1_msb, $v2_msb, $carry
; check: v10 = iconcat $v10_lsb, $v10_msb
return v10
}