This is an archive of the discontinued LLVM Phabricator instance.

GlobalISel/TableGen: Handle setcc patterns
ClosedPublic

Authored by arsenm on Aug 20 2019, 11:17 PM.

Details

Summary

This is a special case because one node maps to two different G_
instructions, and the operand order is changed.

This mostly enables G_FCMP for AMDPGPU. G_ICMP is still manually
selected for now since it has the SALU and VALU complication to deal
with.

Diff Detail

Event Timeline

arsenm created this revision.Aug 20 2019, 11:17 PM
arsenm updated this revision to Diff 216409.Aug 21 2019, 8:15 AM

Comment and whitespace fixes

I've only skimmed part of the patch so far but I had a couple comments:

This requires duplicating the Predicate enum to avoid a circular build
dependency between TableGen and the IR library. I have a patch which
moves it to support, but it's rather disruptive.

It looks like you only need the enum to convert between ISD::CondCode and CmpInst::Predicate. One way of avoiding the duplication is to emit something like getICmpPredicate(ISD::SETOEQ) to the table or similar. If the conversion function is a constexpr then it should be as efficient as converting in/before tablegen and not turn the state machine into a static initializer. Another way would be to embed the conversion result in the tablegen defs:

def SETOEQ: CondCode<"FCMP_OEQ", "ICMP_OEQ">

and have tablegen pick between the two results.

include/llvm/Target/GlobalISel/SelectionDAGCompat.td
116–117

The way we've handled one to many mappings elsewhere is to include the distinguishing information in GINodeEquiv (e.g. IfSignExtend). It's not strictly necessary but it's nice to be able to read these declarations and see the conditions.

arsenm updated this revision to Diff 216652.Aug 22 2019, 9:49 AM

Move instruction switch and predicate name mapping into tablegen

paquette added inline comments.Aug 23 2019, 1:25 PM
utils/TableGen/GlobalISelEmitter.cpp
3534

Pull out DI->getDef() into a variable?

3534–3535

Can we test this?

arsenm updated this revision to Diff 217030.Aug 24 2019, 2:33 PM
arsenm marked 2 inline comments as done.

Use variable and add test

arsenm edited the summary of this revision. (Show Details)Aug 24 2019, 2:33 PM
This revision is now accepted and ready to land.Aug 28 2019, 11:13 AM
arsenm closed this revision.Aug 28 2019, 6:12 PM

r370280