[PATCH] D144687: [GlobalISel][NFC] Add some Get{2,3,4,5}RegsFromMI macros to extract regs from MachineInstrs.

Amara Emerson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 23 16:40:53 PST 2023


aemerson created this revision.
aemerson added reviewers: arsenm, paquette, foad, dzhidzhoev.
aemerson added a project: LLVM.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
aemerson requested review of this revision.
Herald added a subscriber: wdng.

These reduce the typing and clutter from:

  Register Dst = MI.getOperand(0).getReg();
  Register Src1 = MI.getOperand(1).getReg();
  Register Src2 = MI.getOperand(2).getReg();
  Register Src3 = MI.getOperand(3).getReg();

To just:

  Get4RegFromMI(Dst, Src1, Src2, Src3, MI)

I'm open to other ideas for implementation. The current patch is a POC,
I haven't used it in all the eligible places yet. Thoughts?

We could also try to add variations for when you also want to extract the types as well.

Is there a better way to implement this except using macros?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144687

Files:
  llvm/include/llvm/CodeGen/GlobalISel/Utils.h
  llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144687.500014.patch
Type: text/x-patch
Size: 19961 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230224/d929d8f1/attachment.bin>


More information about the llvm-commits mailing list