[PATCH] D90532: [TableGen] [IR] Eliminate unnecessary recursive help class.

Artem Belevich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 4 14:08:23 PST 2020


tra added a comment.

In D90532#2374444 <https://reviews.llvm.org/D90532#2374444>, @Paul-C-Anagnostopoulos wrote:

> 



> It looks like there are some !foreach that can be !listsplat:
>
>   // Instruction input/output arguments for the fragment.
>   list<NVPTXRegClass> ptx_regs = !foreach(tmp, regs, regclass);

Yup.

> The code you mentioned above:
>
>   dag PFOperands = !if(WithStride, (ops node:$src, node:$ldm), (ops node:$src));
>   // Build PatFrag that only matches particular address space.
>   PatFrag IntrFrag = PatFrag<PFOperands,
>                              !foreach(tmp, PFOperands, !subst(ops, Intr, tmp)),
>
> It's more efficient simply to assign the substituted dag first:
>
> dag PFOperandsIntr = !if(WithStride, (Intr node:$src, node:$ldm), (Intr node:$src));

Good catch. That would work in this case. 
Still, I think there are more `!foreach` instances where you'd still need to use `!setdagop` as we're not always constructing the dag from scratch.

DAG manipulation has been one of the trickier things to do in tablegen at the time I was messing with NVPTX tablegen files. 
@nhaehnle has improved tablegen quite a bit since then.

> We can also use the new !sub operator to make things clearer.

SGTM.

Send me a patch and I'll take a look.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90532/new/

https://reviews.llvm.org/D90532



More information about the llvm-commits mailing list