aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/TableGen/TGParser.cpp
diff options
context:
space:
mode:
authorStephen Chou <stephenchouca@users.noreply.github.com>2024-10-01 00:17:00 -0700
committerGitHub <noreply@github.com>2024-10-01 11:17:00 +0400
commitec61311e77b39fc7f9b45ffdb8a29b2d96f67265 (patch)
treeaddce6c6aaec31adb7fd6a5d160ef3eb9b70d4ef /llvm/lib/TableGen/TGParser.cpp
parent2da417e7f6149f0f1079a8162fb25161b8a80332 (diff)
downloadllvm-ec61311e77b39fc7f9b45ffdb8a29b2d96f67265.zip
llvm-ec61311e77b39fc7f9b45ffdb8a29b2d96f67265.tar.gz
llvm-ec61311e77b39fc7f9b45ffdb8a29b2d96f67265.tar.bz2
[LLVM][TableGen] Support type casts of nodes with multiple results (#109728)
Currently, type casts can only be used to pattern match for intrinsics with a single overloaded return value. For instance: ``` def int_foo : Intrinsic<[llvm_anyint_ty], []>; def : Pat<(i32 (int_foo)), ...>; ``` This patch extends type casts to support matching intrinsics with multiple overloaded return values. As an example, the following defines a pattern that matches only if the overloaded intrinsic call returns an `i16` for the first result and an `i32` for the second result: ``` def int_bar : Intrinsic<[llvm_anyint_ty, llvm_anyint_ty], []>; def : Pat<([i16, i32] (int_bar)), ...>; ```
Diffstat (limited to 'llvm/lib/TableGen/TGParser.cpp')
-rw-r--r--llvm/lib/TableGen/TGParser.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp
index e3eed32..5e7b885 100644
--- a/llvm/lib/TableGen/TGParser.cpp
+++ b/llvm/lib/TableGen/TGParser.cpp
@@ -2866,11 +2866,13 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType,
return ListInit::get(Vals, DeducedEltTy);
}
- case tgtok::l_paren: { // Value ::= '(' IDValue DagArgList ')'
+ case tgtok::l_paren: { // Value ::= '(' IDValue DagArgList ')'
+ // Value ::= '(' '[' ValueList ']' DagArgList ')'
Lex.Lex(); // eat the '('
if (Lex.getCode() != tgtok::Id && Lex.getCode() != tgtok::XCast &&
- Lex.getCode() != tgtok::question && Lex.getCode() != tgtok::XGetDagOp) {
- TokError("expected identifier in dag init");
+ Lex.getCode() != tgtok::question && Lex.getCode() != tgtok::XGetDagOp &&
+ Lex.getCode() != tgtok::l_square) {
+ TokError("expected identifier or list of value types in dag init");
return nullptr;
}