[LLVMdev] TableGen Operator Names

David Greene dag at cray.com
Fri Jan 7 09:26:43 PST 2011


I just submitted a change to TableGen to make the lisp-like operator
names more readable (as suggested by Gabor a very long time ago).

I would also like to change the way operators are invoked.  As I keep
adding more functionality, the bang invocation syntax is making things
hard to read.  For example:

!if(!empty(arg),then,else)

Does this mean "if empty," "if not empty" or "not if not empty?"  It's
the first but that's less than obvious.

Would anyone object if I changed the syntax from !operator to &operator?
This is at least consistent with Perl, which is not my favorite language
but is familiar to a lot of people.  Some viable options are:

!operator    (Keep as-is and deal with logical operator confusion)
&operator    (Perl-like, no address-of concept in TableGen so less confusion)
@operator    (Not a common operator)
#operator    (Looks too much like a comment or preprocessor directive)
$operator    (Looks too much like a variable)
%operator    (Or +,-,/,^,*: could be confused with arithmetic, but not likely)
~operator    (Could be confused with logical not)
()operator   (Redundant with parameter parens)
\operator    ("Escape" into metacode?)

There are plenty of other spellings, I've just tried to present my
thoughts on a few.

At the same time I would try to add syntax-highlighting support for
operators so they stand out better when reading .td files.

Is this a good idea?  If so, does anyone have a strong syntax
preference?

                               -Dave



More information about the llvm-dev mailing list