This first step adds the assert statement and supports it at top level and in record definitions. Later steps will support it in class definitions and multiclasses.
I described it in the TableGen Programmer's Reference and added a test.
Paths
| Differential D93911
[TableGen] Add the assert statement, step 1 ClosedPublic Authored by Paul-C-Anagnostopoulos on Dec 29 2020, 12:06 PM.
Details Summary This first step adds the assert statement and supports it at top level and in record definitions. Later steps will support it in class definitions and multiclasses. I described it in the TableGen Programmer's Reference and added a test.
Diff Detail Event Timelinecraig.topper added inline comments.
Paul-C-Anagnostopoulos added inline comments. Paul-C-Anagnostopoulos marked 4 inline comments as done. Comment ActionsI made Craig's suggested changes. I also added one more test to the test file.
Comment Actions Looks like a great feature to me! I'd recommend requiring the message, I'd also consider requiring parens around the condition and message. This makes it more C like and makes it look less like a type definition: def Rec14 : Cube<3> { int double_result = !mul(result, 2); assert(!eq(double_result, 53), "double_result should be 54"); }
Comment Actions I understand requiring the message, but I don't understand the parentheses. It makes the 'assert' statement syntactically incompatible with the 'if' and 'foreach' statements. Also, it makes it look like assert is a function. Comment Actions Fair enough, good point. In C, it is a function, whereas in tblgen it is a declaration. I'm ok dropping the parens. This revision is now accepted and ready to land.Jan 6 2021, 5:19 PM Closed by commit rG6e2b6351d2cb: [TableGen] Add the assert statement, step 1 (authored by Paul-C-Anagnostopoulos). · Explain WhyJan 8 2021, 6:48 AM This revision was automatically updated to reflect the committed changes. Paul-C-Anagnostopoulos marked an inline comment as done.
Revision Contents
Diff 314917 llvm/docs/TableGen/ProgRef.rst
llvm/include/llvm/TableGen/Record.h
llvm/lib/TableGen/TGLexer.h
llvm/lib/TableGen/TGLexer.cpp
llvm/lib/TableGen/TGParser.h
llvm/lib/TableGen/TGParser.cpp
llvm/test/TableGen/assert.td
|
Given that we don't have backwards compatibility issues, I'd just require the message.