!range(a, b) generates a list [a,b). a is optional and 0 by default.
- !range(-1, 4) generates [-1, 0, 1, 2, 3]
- !range(4) generates [0, 1, 2, 3]
- !range(2, 2) generates []<list<int>>
!range(list) is equivalent to !range(0, !size(list)).
Paths
| Differential D145871
TableGen: Introduce `!range` operator for half-opened interval ClosedPublic Authored by chapuni on Mar 12 2023, 7:44 AM.
Details Summary !range(a, b) generates a list [a,b). a is optional and 0 by default.
!range(list) is equivalent to !range(0, !size(list)).
Diff Detail
Unit TestsFailed Event TimelineComment Actions I'm tempted to suggest that this bang operator should be called !rangelist. The name !range suggests a pair of integers or a sequence of integers not encapsulated in a list. Add a couple of other reviewers so we can get a second opinion. Add some simpler initial tests to range-op.td, such as the examples you gave in the summary. Comment Actions Thanks for your comment. !range(m, n) and !range(n) come from Python. I will accept even if a minimal functionality (m, n) would be landed. Do you think I should drop other syntax sugars?
I will happy if you could nominate anyone, since you ask a second opinion.
I didn't think I could add simpler examples to the test. I will do if it would be better. Comment Actions I've added two reviewers. Could I get a second opinion on the name of this bang operator? I think a few simpler tests first is a good idea. In particular, it helps a future developer understand what is going on. Comment Actions !range makes sense to me because I also see the analogy to Python's range. I have some minor notes inline, apart from that the code looks good to me.
Comment Actions I see the analogy to Python's range(), except that it returns a sequence of numbers, not a list. But I'm not really too worried about this. Comment Actions
chapuni added inline comments. chapuni added a child revision: D146914: Migrate `IIT_Info` into `Intrinsics.td`.Mar 26 2023, 6:58 AM chapuni added a child revision: D146915: Implement TypeSig generator in `Intrinsics.td`.Mar 27 2023, 8:51 AM chapuni removed a child revision: D146914: Migrate `IIT_Info` into `Intrinsics.td`.Mar 27 2023, 8:52 AM This revision is now accepted and ready to land.Apr 24 2023, 12:09 PM Comment Actions Yes, that's the file. You need to add the name to the list in section 1.3.3 and the description to section 1.10. Comment Actions I can't figure out what is going on here. It doesn't look like you added a description of !range.
This revision was landed with ongoing or failed builds.Apr 25 2023, 6:38 AM Closed by commit rGab2187d786a4: TableGen: Introduce `!range` operator for half-opened interval (authored by chapuni). · Explain Why This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 505800 llvm/docs/TableGen/ProgRef.rst
llvm/include/llvm/TableGen/Record.h
llvm/lib/TableGen/Record.cpp
llvm/lib/TableGen/TGLexer.h
llvm/lib/TableGen/TGLexer.cpp
llvm/lib/TableGen/TGParser.cpp
llvm/test/TableGen/range-op-fail.td
llvm/test/TableGen/range-op.td
|
@Paul-C-Anagnostopoulos Is it insufficient or improper?