[llvm-dev] Behavior of TableGen paste operator
Paul C. Anagnostopoulos via llvm-dev
llvm-dev at lists.llvm.org
Sat Oct 31 11:00:45 PDT 2020
I have just discovered a behavior of the TableGen paste operator (#) that I did not expect. I'm wondering if this behavior was intended.
In a record name expression, the expression is parsed in "name mode" so that the name of a defvar is treated verbatim.
def "foo_" # var { ...
Assume var is a defvar. Its value is not used, and the name is foo_var. This allows fragments of record names to be specified without string quotes.
My surprise is that the same rule holds when the paste operator is used in a normal expression.
def ...
string foo = "foo_" # var;
The resulting string is "foo_var", not "foo_<value of var>". This happens because normal expression parsing still forces "name mode" when parsing the right-hand-side of a paste operator.
So, a # b is not identical to !strconcat(a, b) in a normal expression.
Thoughts?
@lattner
@nhaehnle
More information about the llvm-dev
mailing list