[PATCH] D31761: [globalisel][tablegen] Revise API for ComplexPattern operands to improve flexibility.

Daniel Sanders via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 6 07:20:04 PDT 2017


dsanders created this revision.
Herald added subscribers: igorb, kristof.beyls, dberris.

Some targets need to be able to do more complex rendering than just adding an
operand or two to an instruction. For example, it may need to insert an
instruction to extract a subreg first, or it may need to perform an operation
on the operand.

In SelectionDAG, targets would create SDNode's to achieve the desired effect
during the complex pattern predicate. This worked because SelectionDAG had a
form of garbage collection that would take care of SDNode's that were created
but not used due to a later predicate rejecting a match. This doesn't translate
well to GlobalISel and the churn was wasteful.

The API changes in this patch enable GlobalISel to accomplish the same thing
without the waste. The API is now:
	InstructionSelector::OptionalComplexRendererFn selectArithImmed(MachineOperand &Root) const;
where Root is the root of the match. The return value can be omitted to
indicate that the predicate failed to match, or a function with the signature
ComplexRendererFn can be returned. For example:
	return OptionalComplexRendererFn(

  	       [=](MachineInstrBuilder &MIB) { MIB.addImm(Immed).addImm(ShVal); });

adds two immediate operands to the rendered instruction. Immed and ShVal are
captured from the predicate function.

As an added bonus, this also reduces the amount of information we need to
provide to GIComplexOperandMatcher.

Depends on https://reviews.llvm.org/D31418


https://reviews.llvm.org/D31761

Files:
  include/llvm/CodeGen/GlobalISel/InstructionSelector.h
  include/llvm/Target/GlobalISel/Target.td
  lib/Target/AArch64/AArch64InstrFormats.td
  lib/Target/AArch64/AArch64InstructionSelector.cpp
  test/TableGen/GlobalISelEmitter-GIRule.td
  test/TableGen/GlobalISelEmitter.td
  utils/TableGen/GlobalISelEmitter.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31761.94367.patch
Type: text/x-patch
Size: 23470 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170406/af2a241e/attachment.bin>


More information about the llvm-commits mailing list