[PATCH] D42244: [globalisel] Introduce LegalityQuery to better encapsulate the legalizer decisions. NFC.

Daniel Sanders via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 18 08:42:06 PST 2018


dsanders created this revision.
dsanders added reviewers: ab, t.p.northover, qcolombet, rovka, aditya_nandakumar, volkan, reames.
Herald added a subscriber: kristof.beyls.

`getAction(const InstrAspect &) const` breaks encapsulation by exposing
the smaller components that are used to decide how to legalize an
instruction.

This is a problem because we need to change the implementation of
LegalizerInfo so that it's able to describe particular type combinations
rather than just cartesian products of types.

For example, declaring the following

  setAction({..., 0, s32}, Legal)
  setAction({..., 0, s64}, Legal)
  setAction({..., 1, s32}, Legal)
  setAction({..., 1, s64}, Legal)

currently declares these type combinations as legal:

  {s32, s32}
  {s64, s32}
  {s32, s64}
  {s64, s64}

but we currently have no means to say that, for example, {s64, s32} is
not legal. Some operations such as G_INSERT/G_EXTRACT/G_MERGE_VALUES/
G_UNMERGE_VALUES has relationships between the types that are currently
described incorrectly.

Additionally, G_LOAD/G_STORE currently have no means to legalize non-atomics
differently to atomics. The necessary information is in the MMO but we have no
way to use this in the legalizer. Similarly, there is currently no way for the
register type and the memory type to differ so there is no way to cleanly
represent extending-load/truncating-store in a way that can't be broken by
optimizers (resulting in illegal MIR).

This patch introduces LegalityQuery which provides all the information
needed by the legalizer to make a decision on whether something is legal
and how to legalize it.


https://reviews.llvm.org/D42244

Files:
  include/llvm/CodeGen/GlobalISel/LegalizationArtifactCombiner.h
  include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
  lib/CodeGen/GlobalISel/LegalizerHelper.cpp
  lib/CodeGen/GlobalISel/LegalizerInfo.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42244.130422.patch
Type: text/x-patch
Size: 7429 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180118/c02d39b8/attachment.bin>


More information about the llvm-commits mailing list