[PATCH] D44198: TableGen: Only fold when some operand made resolve progress
Nicolai Hähnle via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 7 03:16:55 PST 2018
nhaehnle created this revision.
nhaehnle added reviewers: arsenm, craig.topper, tra, MartinO.
Herald added a subscriber: wdng.
Make sure that we always fold immediately, so there's no point in
attempting to re-fold when nothing changes.
Change-Id: I069e1989455b6f2ca8606152f6adc1a5e817f1c8
Repository:
rL LLVM
https://reviews.llvm.org/D44198
Files:
lib/TableGen/Record.cpp
lib/TableGen/TGParser.cpp
Index: lib/TableGen/TGParser.cpp
===================================================================
--- lib/TableGen/TGParser.cpp
+++ lib/TableGen/TGParser.cpp
@@ -1960,7 +1960,13 @@
}
if (LHS->getType() != StringRecTy::get()) {
- LHS = UnOpInit::get(UnOpInit::CAST, LHS, StringRecTy::get());
+ LHS = dyn_cast<TypedInit>(
+ UnOpInit::get(UnOpInit::CAST, LHS, StringRecTy::get())
+ ->Fold(CurRec));
+ if (!LHS) {
+ Error(PasteLoc, "LHS of paste not typed after cast!");
+ return nullptr;
+ }
}
TypedInit *RHS = nullptr;
@@ -1987,7 +1993,13 @@
}
if (RHS->getType() != StringRecTy::get()) {
- RHS = UnOpInit::get(UnOpInit::CAST, RHS, StringRecTy::get());
+ RHS = dyn_cast<TypedInit>(
+ UnOpInit::get(UnOpInit::CAST, RHS, StringRecTy::get())
+ ->Fold(CurRec));
+ if (!RHS) {
+ Error(PasteLoc, "RHS of paste not typed after cast!");
+ return nullptr;
+ }
}
break;
Index: lib/TableGen/Record.cpp
===================================================================
--- lib/TableGen/Record.cpp
+++ lib/TableGen/Record.cpp
@@ -764,7 +764,7 @@
if (LHS != lhs)
return (UnOpInit::get(getOpcode(), lhs, getType()))
->Fold(R.getCurrentRecord());
- return Fold(R.getCurrentRecord());
+ return const_cast<UnOpInit *>(this);
}
std::string UnOpInit::getAsString() const {
@@ -947,7 +947,7 @@
if (LHS != lhs || RHS != rhs)
return (BinOpInit::get(getOpcode(), lhs, rhs, getType()))
->Fold(R.getCurrentRecord());
- return Fold(R.getCurrentRecord());
+ return const_cast<BinOpInit *>(this);
}
std::string BinOpInit::getAsString() const {
@@ -1172,7 +1172,7 @@
if (LHS != lhs || MHS != mhs || RHS != rhs)
return (TernOpInit::get(getOpcode(), lhs, mhs, rhs, getType()))
->Fold(R.getCurrentRecord());
- return Fold(R.getCurrentRecord());
+ return const_cast<TernOpInit *>(this);
}
std::string TernOpInit::getAsString() const {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44198.137350.patch
Type: text/x-patch
Size: 2104 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180307/1f400240/attachment.bin>
More information about the llvm-commits
mailing list