-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[TableGen] !subst on a dag should retain name of operator #141195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-tablegen Author: Adam Nemet (anemet) ChangesWithout this patch the !subst in the test drops the name "$frag" from (one_frag:$frag ...) and returns:
Full diff: https://github.com/llvm/llvm-project/pull/141195.diff 2 Files Affected:
diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp
index 12f5ce6175dbf..4c8b41237c604 100644
--- a/llvm/lib/TableGen/Record.cpp
+++ b/llvm/lib/TableGen/Record.cpp
@@ -1688,7 +1688,7 @@ static const Init *ForeachDagApply(const Init *LHS, const DagInit *MHSd,
}
if (Change)
- return DagInit::get(Val, NewArgs);
+ return DagInit::get(Val, MHSd->getName(), NewArgs);
return MHSd;
}
diff --git a/llvm/test/TableGen/dag-subst.td b/llvm/test/TableGen/dag-subst.td
new file mode 100644
index 0000000000000..6e5ca9c509f15
--- /dev/null
+++ b/llvm/test/TableGen/dag-subst.td
@@ -0,0 +1,18 @@
+// RUN: llvm-tblgen %s | FileCheck %s
+
+// Operator name "frag" in one_frag:$frg was not retained during !subst.
+
+def one_frag;
+def FPR32;
+def ops;
+def node;
+def GPR;
+def cond;
+def set;
+def FPR32_NEW;
+def a {
+ dag d = (set FPR32:$dst, (one_frag:$frg FPR32:$a, FPR32:$b));
+ dag n = !foreach(i, d, !subst(FPR32, FPR32_NEW, i));
+}
+
+// CHECK: dag n = (set FPR32_NEW:$dst, (one_frag:$frg FPR32_NEW:$a, FPR32_NEW:$b));
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Nit: this change has nothing to do with backend-related concepts, it is pure tablegen. I would have made the test more "symbolic":
dag d = (set X:$x, (Y:$y X:$a, X:$b));
dag n = !foreach(i, d, !subst(X, Z, i));
Without this patch the !subst in the test drops the name "$frag" from (one_frag:$frag ...) and returns: ``` (set FPR32_NEW:$dst, (one_frag FPR32_NEW:$a, FPR32_NEW:$b)) ```
(set) is still backend concept :). I think it's good to have a connection to real life (backend) so keeping it. |
9879019
to
ee91251
Compare
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/138/builds/13585 Here is the relevant piece of the build log for the reference
|
Without this patch the !subst in the test drops the name "$frag" from (one_frag:$frag ...) and returns: ``` (set FPR32_NEW:$dst, (one_frag FPR32_NEW:$a, FPR32_NEW:$b)) ```
Without this patch the !subst in the test drops the name "$frag" from (one_frag:$frag ...) and returns: