[PATCH] D82372: [ARM][BFloat] Legalize bf16 type even without fullfp16.

Simon Tatham via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 23 05:49:32 PDT 2020


simon_tatham created this revision.
simon_tatham added reviewers: dmgreen, SjoerdMeijer, stuij, chill, miyuki.
Herald added subscribers: llvm-commits, danielkiss, hiraditya, kristof.beyls.
Herald added a project: LLVM.

This change permits scalar bfloats to be loaded, stored, moved and
used as function call arguments and return values, whenever the bf16
feature is supported by the subtarget.

Previously that was only supported in the presence of the fullfp16
feature, because the code generation strategy depended on instructions
from that extension. This change adds alternative code generation
strategies so that those operations can be done even without fullfp16.

The strategy for loads and stores is to replace VLDRH/VSTRH with
integer LDRH/STRH plus a move between register classes. I've written
isel patterns for those, conditional on //not// having the fullfp16
feature (so that in the fullfp16 case, the existing patterns will
still be used).

(One side effect of that is that we can now use LDRH/STRH to access
stack slots, which meant I had to add frame lowering support for the
addressing mode of those instructions.)

For function arguments and returns, instead of writing isel patterns
to match `VMOVhr` and `VMOVrh`, I've avoided generating those SDNodes
in the first place, by factoring out the code that constructs them
into helper functions `MoveToHPR` and `MoveFromHPR` which have a
fallback for non-fullfp16 subtargets.

The current output code is not especially pretty: in the new test file
you can see unnecessary store/load pairs implementing no-op bitcasts,
and lots of pointless moves back and forth between FP registers and
GPRs. But it at least works, which is an improvement on the previous
situation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82372

Files:
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/lib/Target/ARM/ARMISelLowering.h
  llvm/lib/Target/ARM/ARMInstrVFP.td
  llvm/lib/Target/ARM/ARMPredicates.td
  llvm/lib/Target/ARM/Thumb2InstrInfo.cpp
  llvm/test/CodeGen/ARM/arm-bf16-pcs.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82372.272692.patch
Type: text/x-patch
Size: 23597 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200623/12fb694e/attachment.bin>


More information about the llvm-commits mailing list