tablegen keywords


what is the tablegen keyword ‘field’ for?



tl;dr: don’t worry about it.

Essentially, marking a field with “field” makes RecordVal::getPrefix return 1. Otherwise, it returns 0. (RecordVal::getPrefix is in include/llvm/TableGen/Record.h). It effectively is just a way to set a bit on a field. It’s only used in two places:

llvm/utils/TableGen$ git grep ‘\bgetPrefix\b’
CodeEmitterGen.cpp: if (Vals[i].getPrefix() || Vals[i].getValue()->isComplete())
FixedLenDecoderEmitter.cpp: if (Vals[i].getPrefix() || Vals[i].getValue()->isComplete())

The use for it here is something one of the backend people will have to answer, but my understanding is that this “field” feature is entirely historical. I’m pretty sure that its purpose can be accomplished in another way within the rest of the language without too much trouble.

If you can get rid of the use of getPrefix in the lines above (and remove use of “field” from the .td files), you could then remove “field” from the language. The attached (completely untested) patch should remove “field” from the language.

As long as the replacement for “field” isn’t completely insane, I think it would be great to whittle down TableGen’s complexity a tiny bit by removing it.

– Sean Silva

remove-field.patch (4.41 KB)