[PATCH] D156429: [TableGen] Add new bang operator !format
Wang Pengcheng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 27 06:44:12 PDT 2023
wangpc created this revision.
wangpc added reviewers: craig.topper, tra, nhaehnle, fpetrogalli, simon_tatham, Paul-C-Anagnostopoulos.
Herald added a subscriber: hiraditya.
Herald added a project: All.
wangpc requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
We can use `#` operator to concatenate strings, but it can be too
tedious sometimes and we can't use it to concatenate code strings.
A new bang operator `!format` is added to format strings (very limited
currently).
!format("{0} {1} ...", arg0, arg1, ...)
Its first operand is a format string, and followings are several
operands (can be none) to format. Currently, `{i}` where `i` is the
i-th format argument is the only placeholder format we support.
This bang operator can be used to format code string, which can
reduce a lot of duplicated code.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D156429
Files:
llvm/docs/TableGen/ProgRef.rst
llvm/include/llvm/TableGen/Record.h
llvm/lib/TableGen/Record.cpp
llvm/lib/TableGen/TGLexer.cpp
llvm/lib/TableGen/TGLexer.h
llvm/lib/TableGen/TGParser.cpp
llvm/test/TableGen/format.td
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156429.544748.patch
Type: text/x-patch
Size: 14903 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230727/db996b3f/attachment.bin>
More information about the llvm-commits
mailing list