This is an archive of the discontinued LLVM Phabricator instance.

[RISCV][NFC] Refactor lowerToScalableOp.
ClosedPublic

Authored by jacquesguan on Jun 28 2023, 1:11 AM.

Details

Summary

Refactor lowerToScalableOp to combine switch case code.

Diff Detail

Event Timeline

jacquesguan created this revision.Jun 28 2023, 1:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 28 2023, 1:11 AM
jacquesguan requested review of this revision.Jun 28 2023, 1:11 AM

In general I think this is a good idea, thanks. Whether or not something has a merge or mask is intrinsic to the op itself, not really a codegen choice. So I think this patch makes that more explicit, rather than relying on us specifying the right parameters. Plus it reduces copy/paste so that's a win.

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

This error message could probably be a little more explicit

4631

I wonder if we want stronger checks here so people don't insert an op in the wrong place and have weird stuff happen.

llvm/lib/Target/RISCV/RISCVISelLowering.h
908

I think these can all be static? Or, is there any need for them to be member functions at all?

909

does have -> has

Address comment.

jacquesguan marked 3 inline comments as done.Jun 28 2023, 2:48 AM
jacquesguan added inline comments.
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
4631

change to report_fatal_error?

frasercrmck added inline comments.Jun 29 2023, 4:14 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
4631

I was thinking more along the lines of static_asserts that check that nodes are defined roughly as we expect, or that there are as many nodes in between the ranges as we expect. That way someone can't insert any op in between RISCVISD::VWMUL_VL and RISCVISD::VFWSUB_W_VL (for example) without seeing a compile-time error and having to think about whether it has a merge op and whether the code needs updating.

Add a ISD num check.

jacquesguan added inline comments.Jun 29 2023, 7:24 PM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
4631

I get your idea, thanks. I add an assert to check the number of riscv target specific isd, make sure any change should update these 2 function.

This revision is now accepted and ready to land.Jul 3 2023, 2:26 AM
craig.topper added inline comments.Jul 3 2023, 10:18 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
4635

riscv -> RISC-V

4653

riscv -> RISC-V

Address comment.

This revision was landed with ongoing or failed builds.Jul 3 2023, 11:09 PM
This revision was automatically updated to reflect the committed changes.