Skip to content

Commit

Permalink
PR21101: tablegen's FastISel emitter should filter out unused functions.
Browse files Browse the repository at this point in the history
FastISel has a fixed set of virtual functions that are overridden by the
tablegen-generated code for each target. These functions are distinguished by
the kinds of operands, e.g., register + immediate = "ri". The FastISel emitter
has been blindly emitting functions with different combinations of operand
kinds, even for combinations that are completely unused by FastISel, e.g.,
"fastEmit_rrr". Change to filter out functions that will be irrelevant for
FastISel and do not bother generating the code for them. Also add explicit
"override" keywords for the virtual functions that are overridden.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218838 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
bob-wilson committed Oct 1, 2014
1 parent 959030a commit 52c08fd
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion utils/TableGen/FastISelEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "CodeGenDAGPatterns.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/TableGen/Error.h"
Expand Down Expand Up @@ -541,6 +542,17 @@ void FastISelMap::collectPatterns(CodeGenDAGPatterns &CGP) {
continue;
}

// Check if the operands match one of the patterns handled by FastISel.
std::string ManglingSuffix;
raw_string_ostream SuffixOS(ManglingSuffix);
Operands.PrintManglingSuffix(SuffixOS, ImmediatePredicates, true);
SuffixOS.flush();
if (!StringSwitch<bool>(ManglingSuffix)
.Cases("", "r", "rr", "ri", "rf", true)
.Cases("rri", "i", "f", true)
.Default(false))
continue;

// Get the predicate that guards this pattern.
std::string PredicateCheck = Pattern.getPredicateCheck();

Expand Down Expand Up @@ -803,7 +815,10 @@ void FastISelMap::printFunctionDefinitions(raw_ostream &OS) {
if (!Operands.empty())
OS << ", ";
Operands.PrintParameters(OS);
OS << ") {\n";
OS << ") ";
if (!Operands.hasAnyImmediateCodes())
OS << "override ";
OS << "{\n";

// If there are any forms of this signature available that operate on
// constrained forms of the immediate (e.g., 32-bit sext immediate in a
Expand Down

0 comments on commit 52c08fd

Please sign in to comment.