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

Jakob Stoklund Olesen via llvm-dev llvm-dev at lists.llvm.org
Wed Aug 23 09:35:49 PDT 2017

> On Aug 22, 2017, at 14:15, Hal Finkel via llvm-dev <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 <https://github.com/stoklund/cretonne/blob/master/lib/cretonne/meta/isa/riscv/encodings.py>

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

More information about the llvm-dev mailing list