This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAG] Enable target specific vector scalarization of calls and returns
ClosedPublic

Authored by sdardis on Dec 16 2016, 5:34 AM.

Details

Summary

By target hookifying getRegisterType, getNumRegisters, getVectorBreakdown,
backends can request that LLVM to scalarize vector types for calls
and returns.

The MIPS vector ABI requires that vector arguments and returns are passed in
integer registers. With SelectionDAG's new hooks, the MIPS backend can now
handle LLVM-IR with vector types in calls and returns. E.g.
'call @foo(<4 x i32> %4)'.

Previously these cases would be scalarized for the MIPS O32/N32/N64 ABI for
calls and returns if vector types were not legal. If vector types were legal,
a single 128bit vector argument would be assigned to a single 32 bit / 64 bit
integer register.

By teaching the MIPS backend to inspect the original types, it can now
implement the MIPS vector ABI which requires a particular method of
scalarizing vectors.

Previously, the MIPS backend relied on clang to scalarize types such as "call
@foo(<4 x float> %a) into "call @foo(i32 inreg %1, i32 inreg %2, i32 inreg %3,
i32 inreg %4)".

This patch enables the MIPS backend to take either form for vector types.

Event Timeline

sdardis updated this revision to Diff 81743.Dec 16 2016, 5:34 AM
sdardis retitled this revision from to [SelectionDAG] Enable target specific vector scalarization of calls and returns.
sdardis updated this object.
sdardis added reviewers: zoran.jovanovic, jaydeep.
sdardis set the repository for this revision to rL LLVM.
sdardis added a subscriber: llvm-commits.
sdardis updated this revision to Diff 87430.Feb 7 2017, 7:20 AM
sdardis added a reviewer: slthakur.

Update to trunk.

zoran.jovanovic accepted this revision.Mar 13 2017, 12:52 PM

LGTM with few nits.

include/llvm/Target/TargetLowering.h
1013

Line exceeds 80 characters,

1020

Line exceeds 80 characters.

1026

Line exceeds 80 characters.

lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
720

Is it possible to save NumRegs value as a class member and use it in class member functions (e.g. getCopyToRegs)?

824

Is it possible to get undefined value for RegVTs[Value] if value of argument IsABIRegCopy is different from value used in class constructor?

1053

Is additional IsABIRegCopy parameter necessary?
Is it possible to use value passed to RegsForValue constructor instead?

lib/Target/Mips/MipsCCState.h
57

Line exceeds 80 characters.

59

Line exceeds 80 characters.

lib/Target/Mips/MipsCallingConv.td
42

Line exceeds 80 characters.

lib/Target/Mips/MipsISelLowering.cpp
2639

Line exceeds 80 characters.

This revision is now accepted and ready to land.Mar 13 2017, 12:52 PM
sdardis updated this revision to Diff 94053.Apr 4 2017, 5:01 AM
sdardis marked 6 inline comments as done.
sdardis edited the summary of this revision. (Show Details)

Addressed review comments.

I'll commit this in a day or two if there are no further comments.

This revision was automatically updated to reflect the committed changes.