[llvm-dev] TableGen: behavior of list subscript

Chris Lattner via llvm-dev llvm-dev at lists.llvm.org
Sun Jan 24 09:47:54 PST 2021



> On Jan 21, 2021, at 7:34 AM, Paul C. Anagnostopoulos via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> TableGen allows subscripting a list:
> 
>  string Foo = SomeList[1];
> 
> The documentation for this feature:
> 
> value[4...7,17,2...3,4] 
> The final value is a new list that is a slice of the list value (note the brackets). The new list contains elements 4, 5, 6, 7, 17, 2, 3, and 4. Elements may be included multiple times and in any order. 
> 
> It turns out that in some contexts a single subscript, as in the example above, does indeed produce a list of element 1, but in most contexts it produces element 1 itself (i.e., it's a typical subscripting operation). In all contexts, multiple subscripts produce a list of the specified elements.
> 
> The most obvious case where it produces a list of the single element is if SomeList were a defvar.
> 
> Ouch. I'm tempted to change the subscripting feature so that a single subscript *always* produces the element itself, not a list of the element. Multiple searches of all the TableGen files did not uncover any reliance on the contexts where a single subscript produces a list.
> 
> Opinions, please.

This makes a lot of sense to me Paul!


More information about the llvm-dev mailing list