[PATCH] D148915: [WIP][TableGen] Introduce function and lambda
Wang Pengcheng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 21 03:37:35 PDT 2023
pcwang-thead created this revision.
pcwang-thead added reviewers: nhaehnle, tra, simon_tatham, Paul-C-Anagnostopoulos, craig.topper, michaelmaitland, reames.
Herald added a subscriber: hiraditya.
Herald added a project: All.
pcwang-thead requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Earlier discussion: D147131 <https://reviews.llvm.org/D147131>
For function, it is just a grammar sugar of class-based subroutines.
For lambda, it is a anonymous function with captured variables.
Grammar:
`function`
function name(type arg0, ...): type {
assert xxx, "";
defvar xxx = xxx;
return xxx;
}
`lambda`
function(type arg0, ...): type {
...
}
Only `assert`, `defvar` and `return` are allowed. Each function
should return a value.
Function types are represented as `function<rettype[, argtype]*>`,
and `rettype` is mandatory. Function types can be used in field,
arguments or foreach iterator.
Recursive function is supported and we can also return a function
(or lambda) value in a function.
TODO:
- Write a detailed description and document.
- Discuss on Discouse.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D148915
Files:
llvm/docs/TableGen/ProgRef.rst
llvm/include/llvm/TableGen/Record.h
llvm/lib/TableGen/Main.cpp
llvm/lib/TableGen/Parser.cpp
llvm/lib/TableGen/Record.cpp
llvm/lib/TableGen/TGLexer.cpp
llvm/lib/TableGen/TGLexer.h
llvm/lib/TableGen/TGParser.cpp
llvm/lib/TableGen/TGParser.h
llvm/test/TableGen/function.td
llvm/test/TableGen/lambda.td
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148915.515673.patch
Type: text/x-patch
Size: 83030 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230421/529753d7/attachment.bin>
More information about the llvm-commits
mailing list