This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Support fixed-length vectors in the calling convention
ClosedPublic

Authored by frasercrmck on Mar 4 2021, 8:13 AM.

Details

Summary

This patch adds fixed-length vector support to the calling convention
when RVV is used to lower fixed-length vectors. The scheme follows the
regular vector calling convention for the argument/return registers, but
uses scalable vector container types as the LocVTs, and converts to/from
the fixed-length vector value types as required.

Fixed-length vector types may be split when the combination of minimum
VLEN and the maximum allowable LMUL is not large enough to fully contain
the vector. In this case the behaviour differs between fixed-length
vectors passed as parameters and as return values:

  1. For return values, vectors must be passed entirely via registers or

via the stack.

  1. For parameters, unlike scalar values, split vectors continue to be

passed by value, and are split across multiple registers until there are
no remaining registers. Thus vector parameters may be found partly in
registers and partly on the stack.

As with scalable vectors, the first fixed-length mask vector is passed
via v0. Split mask fixed-length vectors are passed first via v0 and then
via the next available vector register: v8,v9,etc.

The handling of vector return values uses all available argument
registers v8-v23 which does not adhere to the calling convention we're
supposedly implementing, but since this issue affects both fixed-length
and scalable-vector values, it was left as-is.

Diff Detail

Event Timeline

frasercrmck created this revision.Mar 4 2021, 8:13 AM
frasercrmck requested review of this revision.Mar 4 2021, 8:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 4 2021, 8:13 AM
craig.topper added inline comments.Mar 4 2021, 10:55 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
4942–4943

avaiable->available

  • rebase
  • fix typo
frasercrmck marked an inline comment as done.Mar 8 2021, 1:41 AM
frasercrmck added inline comments.
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
4942–4943

Fixed, cheers.

frasercrmck marked an inline comment as done.
  • rebase
craig.topper accepted this revision.Mar 12 2021, 10:36 AM

LGTM other than 1 nit.

llvm/lib/Target/RISCV/RISCVISelLowering.cpp
5154

i know it was there before, but the ".SimpleTy" here is redundant.

This revision is now accepted and ready to land.Mar 12 2021, 10:36 AM
frasercrmck marked an inline comment as done.Mar 15 2021, 3:51 AM
frasercrmck added inline comments.
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
5154

Thanks. I fixed that up prior to pushing.