This is an archive of the discontinued LLVM Phabricator instance.

CodeGen: Use LLT instead of EVT in getRegisterByName
ClosedPublic

Authored by arsenm on Dec 30 2019, 6:45 AM.

Details

Summary

Only PPC seems to be using it, and only checks some simple cases and
doesn't distinguish between FP. Just switch to using LLT to simplify
use from GlobalISel.

Diff Detail

Event Timeline

arsenm created this revision.Dec 30 2019, 6:45 AM
jyknight added inline comments.Jan 6 2020, 9:42 AM
llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
2255–2257

It feels weird to have to go up through IR Type to convert between two lower-level kinds of type representation. Shouldn't there be a function to go directly EVT->LLT?

llvm/lib/Target/PowerPC/PPCISelLowering.cpp
14802–14806

This seems weirdly-worded. How about:

bool is64Bit = isPPC64 && VT == LLT::scalar(64);
if (!is64Bit && VT != LLT::scalar(32)) report_fatal_error...;
arsenm marked an inline comment as done.Jan 6 2020, 10:10 AM
arsenm added inline comments.
llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
2255–2257

Well, the desired end state is for EVT to not exist so I don't really want to put in the (somewhat small) work to write a proper conversion function. I could maybe stick this in a wrapper somewhere. It feels like a layering violation anywhere I could put it, but I suppose putting it in LowLevelType.h would work.

arsenm marked an inline comment as done.Jan 6 2020, 10:13 AM
arsenm added inline comments.
llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
2255–2257

Another problem is you can't really accurately go back from EVT to LLT, as EVT discards pointerness. This isn't solving the problem here, but the lack of a convenient conversion forces you to think about this

arsenm updated this revision to Diff 236408.Jan 6 2020, 10:21 AM

Refactor PPC check

jyknight added inline comments.Jan 6 2020, 1:31 PM
llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
2255–2257

Well, it didn't force me to think about it...how would I have recognized that as a potential problem by reading the series of calls getLLTForType(getTypeForEVT(...))?

It would be more obvious if the nonexistent function "getLLTForEVT" had a docstring noting that it cannot return a pointer LLT, since EVT doesn't represent those, and that if you might need one, you'll need to do something else.

(here it's of course fine, since this function can only be called with integral types.)

arsenm updated this revision to Diff 237098.Jan 9 2020, 8:34 AM

Use util function

jyknight accepted this revision.Jan 9 2020, 9:41 AM
This revision is now accepted and ready to land.Jan 9 2020, 9:41 AM
arsenm closed this revision.Jan 9 2020, 2:06 PM

d15730ab52dd6b7383d179e53ef38cd6bc1fecbc