Resolve value aliases when legalizing instructions.

Since we're deconstructing an instruction anyway, go ahead and resolve
any value aliases on its arguments before we construct the replacement
instructions.
This commit is contained in:
Jakob Stoklund Olesen
2016-11-04 15:54:58 -07:00
parent 453a1b2d17
commit be3577ad7e
2 changed files with 24 additions and 4 deletions

View File

@@ -43,3 +43,23 @@ ebb0(v1: i64, v2: i64):
; check: [R#8c ; check: [R#8c
; sameln: $(v3h=$V) = bxor $v1h, $v2h ; sameln: $(v3h=$V) = bxor $v1h, $v2h
; check: $v3 = iconcat_lohi $v3l, $v3h ; check: $v3 = iconcat_lohi $v3l, $v3h
function arith_add(i64, i64) -> i64 {
; Legalizing iadd.i64 requires two steps:
; 1. Narrow to iadd_cout.i32, then
; 2. Expand iadd_cout.i32 since RISC-V has no carry flag.
ebb0(v1: i64, v2: i64):
v3 = iadd v1, v2
return v3
}
; check: $(v1l=$V), $(v1h=$VX) = isplit_lohi $v1
; check: $(v2l=$V), $(v2h=$VX) = isplit_lohi $v2
; check: [R#0c
; sameln: $(v3l=$V) = iadd $v1l, $v2l
; check: $(c=$V) = icmp ult, $v3l, $v1l
; check: [R#0c
; sameln: $(v3h1=$V) = iadd $v1h, $v2h
; TODO: This doesn't typecheck. We need to convert the b1 result to i32.
; check: [R#0c
; sameln: $(v3h=$V) = iadd $v3h1, $c
; check: $v3 = iconcat_lohi $v3l, $v3h

View File

@@ -63,11 +63,11 @@ def unwrap_inst(iref, node, fmt):
else: else:
# This is a value operand. # This is a value operand.
if nvops == 1: if nvops == 1:
outs.append(prefix + 'arg') arg = prefix + 'arg'
else: else:
outs.append( arg = '{}args[{}]'.format(
'{}args[{}]'.format( prefix, iform.value_operands.index(i))
prefix, iform.value_operands.index(i))) outs.append('dfg.resolve_aliases({})'.format(arg))
fmt.line('({})'.format(', '.join(outs))) fmt.line('({})'.format(', '.join(outs)))
fmt.outdented_line('} else {') fmt.outdented_line('} else {')
fmt.line('unreachable!("bad instruction format")') fmt.line('unreachable!("bad instruction format")')