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:
@@ -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
|
||||||
|
|||||||
@@ -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")')
|
||||||
|
|||||||
Reference in New Issue
Block a user