This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Refactor how we create separate instructions for F and Zfinx. NFC
ClosedPublic

Authored by craig.topper on Jun 14 2023, 12:35 PM.

Details

Summary

Previously we had a ExtInfo_rr class that was instantiated for
every combination of types that can appear together along with
their predicates, suffixes, and decoder namespace.

This patch replaces this with a new ExtInfo class that contains
predicates, suffix, namespace, and the f16, f32, and f64 DAGOperands
implied by the predicates. The DAGOperand can be unset if
the predicate is not enough to distinquish it.

At every instruction instantiation we know whether the operands
are GPR, f16, f32, or f64 and can ask the ExtInfo for the relevant
DAGOperand.

The foreach loops of ExtInfo have been moved out of the classes to
be at the top level of the 3 files. This allows the file to pick
the f16/f32/f64 DAGOperand per instruction and pass it down to the
classes separately from the ExtInfo. The ExtInfo still needs to be
passed down to get suffix, predicates, and decoder namespace.

Diff Detail

Event Timeline

craig.topper created this revision.Jun 14 2023, 12:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 14 2023, 12:35 PM
craig.topper requested review of this revision.Jun 14 2023, 12:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 14 2023, 12:35 PM
craig.topper retitled this revision from [RISCV] How we create separate instructions for F and Zfinx. NFC to [RISCV] Refactor how we create separate instructions for F and Zfinx. NFC.Jun 14 2023, 12:36 PM

Remove unused list that is needed for a change I'm going to put in a different patch.

Merge two foreachs

sunshaoce added inline comments.Jun 14 2023, 2:32 PM
llvm/lib/Target/RISCV/RISCVInstrInfoF.td
441–446

I have a suggestion that may not be entirely accurate.

We can add a DefaultTy in the class ExtInfo. Then, in PatSetCC_m, we can replace PatSetCC<Reg with PatSetCC<Ext.DefaultTy, so that we don't need to pass Ext and Reg every time.

This approach could be applied to other classes, especially those that only require passing a single Reg.

Rebase and add a PrimaryTy as suggested.

sunshaoce accepted this revision.Jun 15 2023, 6:14 AM

This is a great simplification, which makes the code clearer. LGTM!
Please wait for a day to see if others have any comments.

This revision is now accepted and ready to land.Jun 15 2023, 6:14 AM