For example in ValueTypes.td
(and Intrinsics.td
), there are many numbered defs. I think they could be autonumbered.
TableGen’s defvar
defines immutable variable by design. I wonder whether we could introduce another variable type or just enhance semantics.
Just my idea
defvar index = 1;
def OtherVT : ValueType<0, index++>;
def i1 : VTInt<1, index++>;
def i2 : VTInt<2, index++>;
def i4 : VTInt<4, index++>;
// ...
assert index <= 248, "Unexpected number of defs";
defvar meta_idx = 248; // May be the expression for alignment(index)
def token : ValueType<0, meta_idx++>;
// ...
defvar
is designed as immutable. Could we enhance it mutable or introduce a new type?- The example introduces the new token
++
. I guess it would make the Lexer more weird. Could we introduce yet another token or operator here? - We have to simplify semantics of post increment, or It would cause confusion.
- My suggestion: Vars will be incremented at the stmt delimiter
;
.
- My suggestion: Vars will be incremented at the stmt delimiter
- Could we introduce leap incrementor (like index += 2)?
- Would
defvar
pollute the namespace? OTOH, such a incremental index var should have simple and short name.
Other random ideas
- Could we introduce the special variable to acquire the line number?
- It would make harder readability and reformatting to rely on line numbers.
- Could
defset
provide the current number of elements, or the special counter something, for its elements?