This is an archive of the discontinued LLVM Phabricator instance.

[Docs] Fix IR and TableGen grammar inconsistencies
ClosedPublic

Authored by sebastian-ne on Jan 5 2022, 9:54 AM.

Details

Summary

IR:

  • globals (and functions, ifuncs, aliases) can have a partition
  • catchret has a to before the label
  • the sint/int types do not exist
  • signext comes after the type
  • a variable was missing its type

TableGen:

  • The second value after a # concatenation is optional See e.g. llvm/lib/Target/X86/X86InstrAVX512.td:L3351
  • IncludeDirective and PreprocessorDirective were never referenced in the grammar
  • Add some missing ;
  • Parent classes of multiclasses can have generic arguments. Reuse the ParentClassList that is already used in other places.

MIR:

  • liveins only allows physical registers, which start with a $

Diff Detail

Unit TestsFailed

Event Timeline

sebastian-ne created this revision.Jan 5 2022, 9:54 AM
sebastian-ne requested review of this revision.Jan 5 2022, 9:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 5 2022, 9:54 AM
nikic added a comment.Jan 6 2022, 1:06 AM

LangRef changes look fine with some nits. Can't comment on the rest.

llvm/docs/LangRef.rst
741–743

I'd move partition next to section here.

840–842

Duplicate section, supposed to be partition?

sebastian-ne marked 2 inline comments as done.

Thanks for taking a look and spotting these, I fixed your comments.

Thanks for making these corrections to the TableGen document. See my comments above.

llvm/docs/TableGen/ProgRef.rst
333

If we are going to specify that the right operand is optional, we should explain elsewhere what that does. I have no idea, but I'm suspicious that the example you cited above is an error.

552

Those two directives are not included in Statement because they are not actually statements. Instead, extend TableGenFile with IncludeDirective and PreprocessorDirective.

890

I'm tempted to leave this alone. It makes it clear that the ParentMultiClassList is composed of MultiClassIDs.

sebastian-ne marked an inline comment as done.

Moved include and preprocessor directive to TableGenFile. Thanks for the review Paul.

llvm/docs/TableGen/ProgRef.rst
333

Looking into the code, it looks like a feature?

// Trailing paste, concat with an empty string.
RHS = StringInit::get("");

https://github.com/llvm/llvm-project/blob/7c19fdd59939249c23384f0900d49aab4a5f0695/llvm/lib/TableGen/TGParser.cpp#L2521-L2522

890

The problem is that ParentMultiClassList is only a list of identifiers, not of identifier + optional generic arguments.
The definition of ParentClassList actually references MultiClassID (and optional generic arguments) and is also used in the defm definition. So I think ParentClassList is correct here?

llvm/docs/TableGen/ProgRef.rst
333

Yep, you are right. What a silly feature. I'm tempted to get rid of it and require # "".

Anyhoo, can you update the description of the paste operator to explain what this does?

890

Oh, what's there now is extraneous and incorrect. Carry on. Thanks!

sebastian-ne marked an inline comment as done.

Add a sentence about trailing # in tablegen.

ProgRef.rst looks good to me.

Thanks, it looks like all changes here should be good to go. Can one of you press the accept button please?

foad added a reviewer: pcc.Jan 10 2022, 3:34 AM
foad added subscribers: pcc, foad.

+ @pcc for the partition stuff. But it all LGTM.

nikic accepted this revision.Jan 13 2022, 2:15 AM
This revision is now accepted and ready to land.Jan 13 2022, 2:15 AM
This revision was landed with ongoing or failed builds.Jan 13 2022, 2:55 AM
This revision was automatically updated to reflect the committed changes.