This is an archive of the discontinued LLVM Phabricator instance.

[llvm-tblgen] Fix parser error when using generic used as index
AbandonedPublic

Authored by GuillaumeGomez on Jun 2 2023, 7:04 AM.

Details

Summary

Using a generic variable as list index was throwing an error

Diff Detail

Event Timeline

GuillaumeGomez created this revision.Jun 2 2023, 7:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 2 2023, 7:04 AM
GuillaumeGomez requested review of this revision.Jun 2 2023, 7:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 2 2023, 7:04 AM

To provide more context: I use this tool to generate the intrinsics list for the rustc_codegen_gcc project to automatically generate the list of intrinsics used by LLVM so they can be translated to GCC's. Currently, when running it, it fails because of this error:

llvm/IR/Intrinsics.td:225:21: error: Variable not defined: 'al'
  int num = Mapping[al];
                    ^
llvm/IR/Intrinsics.td:225:23: error: expected integer or bitrange
  int num = Mapping[al];
                      ^
llvm/IR/Intrinsics.td:225:23: error: expected ';' after declaration
  int num = Mapping[al];
                      ^

This patch fixes this bug.

GuillaumeGomez edited reviewers, added: nikic; removed: darkbuck.Jun 6 2023, 6:19 AM
nikic edited reviewers, added: Paul-C-Anagnostopoulos, hliao, chapuni; removed: nikic.Jun 6 2023, 6:23 AM

@GuillaumeGomez Thanks for catching this. Seems reasonable to me.

I think the test may be put into ListSlices.td.

Excuse me, let me delegate the acceptance.

arsenm added inline comments.Jun 6 2023, 6:51 AM
llvm/test/TableGen/var-index.td
2

Can you add checks for the expanded output?

GuillaumeGomez added inline comments.Jun 6 2023, 7:34 AM
llvm/test/TableGen/var-index.td
2

Sorry but what is the option for doing that? The only two for expansion I see are --print-sets and --instr-info-expand-mi-operand-info and they don't seem to match what you expect.

hliao added a subscriber: wangpc.EditedJun 6 2023, 7:41 AM

I don't see this issue from the main branch. In fact, https://reviews.llvm.org/D149016 solves the issue and should not be "fixed". Could you double-check whether the main branch could reproduce this issue?

Add @pcwang-thead

GuillaumeGomez marked an inline comment as not done.Jun 6 2023, 2:40 PM

Just confirmed locally with latest main that the issue is solved. Thanks!

GuillaumeGomez abandoned this revision.Jun 6 2023, 2:41 PM