[LLVMdev] TableGen For Loops

David A. Greene greened at obbligato.org
Thu Oct 6 11:56:09 PDT 2011

Jakob Stoklund Olesen <jolesen at apple.com> writes:

>> Che-Liang., would you mind if I played around with changing the multidef
>> parsing to recognize your for syntax?  Your code will work in places
>> that multidefs can't right now (as Jakob noted) and we want to retain
>> that ability.  I would be working on integrating for loops into TableGen
>> proper, not as a preprocessor.
> +1 for not adding a preprocessor.
> There seems to be two use cases for this:
> 1. Generating a sequence of similar top-level defs, for example registers named R0--R15.
> 2. Injecting patterns into multiclasses.

I could also imagine generating class fields:

class blah {
  for i = [1, 2, 3] {
    string Attribute#i#;

Or even iterating base classes, which I've sometimes wanted to do:

class blah<list<SomeType> bases> :
  for c = bases {

That seems much harder, though, primarily because TableGen currently
requires inheritance to be statically known.  So I wouldn't go there
yet.  :)

> It seems to me that the same mechanism could support both.

Yes, I agree.  I'm going to play around with this and see if I can get
something working.

Che-Liang, I don't want to step on your toes, so let me know if I'm
disrupting something.


More information about the llvm-dev mailing list