[llvm-dev] Extending TableGen's 'foreach' to work with 'multiclass' and 'defm'

Hal Finkel via llvm-dev llvm-dev at lists.llvm.org
Wed Aug 23 10:33:29 PDT 2017


On 08/23/2017 12:15 PM, Matthias Braun wrote:
> For what it's worth: I also had very good experiences with python 
> "specifications" to generate code [1].
>
> Of course it's hard to justify switching all the infrastructure just 
> because of one missing tablegen feature...

I agree. As someone who has improved TableGen on occasion over the 
years, however, I suspect that we'll continue to run into these things. 
Plus, given the number of out-of-tree users, at least, auto-generating 
their .td inputs, I think we're actually well past one missing feature 
(although obviously there could be unrelated motivations as well). At 
some point, improving TableGen, at least as an input language, may have 
become a sub-optimal use of our time (even if it does look nicer than 
Python in some cases).

  -Hal

>
> - Matthias
>
> [1] Example spec + template: 
> https://github.com/libfirm/libfirm/blob/master/scripts/ir_spec.py
> https://github.com/libfirm/libfirm/blob/master/scripts/templates/gen_irio.c
>
>> On Aug 23, 2017, at 9:35 AM, Jakob Stoklund Olesen via llvm-dev 
>> <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>> wrote:
>>
>>
>>> On Aug 22, 2017, at 14:15, Hal Finkel via llvm-dev 
>>> <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>> wrote:
>>>
>>> For situations well beyond TableGen's current language capabilities, 
>>> we have a decision to make. We can continue extending TableGen until 
>>> it can meet those needs. Alternatively, we can enable the use of 
>>> some more-powerful input language. For example, we could allow 
>>> TableGen to embed Python, and then use Python in order to generate 
>>> record definitions.
>>
>> For a project that’s not LLVM, I recently had the opportunity to 
>> replace both TableGen and *.td files with Python scripts. I found 
>> that TableGen’s features were easily matched by Python’s for loops 
>> and the ability to define functions. I am pretty happy with the 
>> approach so far. AMA
>>
>> This is a lot easier to do in a green field project than in an old 
>> project like LLVM, of course.
>>
>> Example “.td” file: 
>> https://github.com/stoklund/cretonne/blob/master/lib/cretonne/meta/isa/riscv/encodings.py
>>
>> Thanks,
>> /jakob
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>

-- 
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170823/a9118f73/attachment-0001.html>


More information about the llvm-dev mailing list