Page MenuHomePhabricator

[TableGen] Preserve order of output operands in DAGISelMatcherGen
ClosedPublic

Authored by eush on Nov 29 2018, 8:22 AM.

Details

Summary

This fixes support in DAGISelMatcher backend for DAG nodes with multiple
result values. Previously the order of results in selected DAG nodes always
matched the order of results in ISel patterns. After the change the order of
results matches the order of operands in OutOperandList instead.

For example, given this definition from the attached test case:

def INSTR : Instruction {
  let OutOperandList = (outs GPR:$r1, GPR:$r0);
  let InOperandList = (ins GPR:$t0, GPR:$t1);
  let Pattern = [(set i32:$r0, i32:$r1, (udivrem i32:$t0, i32:$t1))];
}

the DAGISelMatcher backend currently produces a matcher that creates INSTR
nodes with the first result $r0 and the second result $r1, contrary to the
order in the OutOperandList. The order of operands in OutOperandList does not
matter at all, which is unexpected (and unfortunate) because the order of
results of a DAG node does matters, perhaps a lot.

With this change, if the order in OutOperandList does not match the order in
Pattern, DAGISelMatcherGen emits CompleteMatch opcodes with the order of
results taken from OutOperandList. Backend writers can use it to express
result reorderings in TableGen.

If the order in OutOperandList matches the order in Pattern, the result of
DAGISelMatcherGen is unaffected.

Diff Detail

Repository
rL LLVM

Event Timeline

eush created this revision.Nov 29 2018, 8:22 AM
craig.topper accepted this revision.Nov 29 2018, 11:13 AM
craig.topper added a subscriber: craig.topper.

LGTM

This revision is now accepted and ready to land.Nov 29 2018, 11:13 AM
eush added a comment.Dec 3 2018, 6:34 AM

Could you commit this patch on my behalf?

This revision was automatically updated to reflect the committed changes.