<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 1, 2014 at 3:44 PM, Bob Wilson <span dir="ltr"><<a href="mailto:bob.wilson@apple.com" target="_blank">bob.wilson@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: bwilson<br>
Date: Wed Oct  1 17:44:01 2014<br>
New Revision: 218838<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=218838&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=218838&view=rev</a><br>
Log:<br>
PR21101: tablegen's FastISel emitter should filter out unused functions.<br>
<br>
FastISel has a fixed set of virtual functions that are overridden by the<br>
tablegen-generated code for each target. These functions are distinguished by<br>
the kinds of operands, e.g., register + immediate = "ri". The FastISel emitter<br>
has been blindly emitting functions with different combinations of operand<br>
kinds, even for combinations that are completely unused by FastISel, e.g.,<br>
"fastEmit_rrr". Change to filter out functions that will be irrelevant for<br>
FastISel and do not bother generating the code for them. Also add explicit<br>
"override" keywords for the virtual functions that are overridden.<br></blockquote><div><br></div><div>We do seem to have some tests for TableGen under llvm/test/TableGen - is this testable?<br><br>Any data on savings gained by omitting these unused functions?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Modified:<br>
    llvm/trunk/utils/TableGen/FastISelEmitter.cpp<br>
<br>
Modified: llvm/trunk/utils/TableGen/FastISelEmitter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/FastISelEmitter.cpp?rev=218838&r1=218837&r2=218838&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/FastISelEmitter.cpp?rev=218838&r1=218837&r2=218838&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/utils/TableGen/FastISelEmitter.cpp (original)<br>
+++ llvm/trunk/utils/TableGen/FastISelEmitter.cpp Wed Oct  1 17:44:01 2014<br>
@@ -19,6 +19,7 @@<br>
<br>
 #include "CodeGenDAGPatterns.h"<br>
 #include "llvm/ADT/SmallString.h"<br>
+#include "llvm/ADT/StringSwitch.h"<br>
 #include "llvm/Support/Debug.h"<br>
 #include "llvm/Support/ErrorHandling.h"<br>
 #include "llvm/TableGen/Error.h"<br>
@@ -541,6 +542,17 @@ void FastISelMap::collectPatterns(CodeGe<br>
         continue;<br>
     }<br>
<br>
+    // Check if the operands match one of the patterns handled by FastISel.<br>
+    std::string ManglingSuffix;<br>
+    raw_string_ostream SuffixOS(ManglingSuffix);<br>
+    Operands.PrintManglingSuffix(SuffixOS, ImmediatePredicates, true);<br>
+    SuffixOS.flush();<br>
+    if (!StringSwitch<bool>(ManglingSuffix)<br>
+        .Cases("", "r", "rr", "ri", "rf", true)<br>
+        .Cases("rri", "i", "f", true)<br>
+        .Default(false))<br>
+      continue;<br>
+<br>
     // Get the predicate that guards this pattern.<br>
     std::string PredicateCheck = Pattern.getPredicateCheck();<br>
<br>
@@ -803,7 +815,10 @@ void FastISelMap::printFunctionDefinitio<br>
     if (!Operands.empty())<br>
       OS << ", ";<br>
     Operands.PrintParameters(OS);<br>
-    OS << ") {\n";<br>
+    OS << ") ";<br>
+    if (!Operands.hasAnyImmediateCodes())<br>
+      OS << "override ";<br>
+    OS << "{\n";<br>
<br>
     // If there are any forms of this signature available that operate on<br>
     // constrained forms of the immediate (e.g., 32-bit sext immediate in a<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>