summaryrefslogtreecommitdiffstats
path: root/llvm/utils/TableGen
diff options
context:
space:
mode:
authorBob Wilson <bob.wilson@apple.com>2014-10-01 22:44:01 +0000
committerBob Wilson <bob.wilson@apple.com>2014-10-01 22:44:01 +0000
commit650cd8a38079ba1bd4e75ee5e4b623306f0e8407 (patch)
tree8c7ee39dd8761c868841308e4b51c4ec54095a03 /llvm/utils/TableGen
parent5346f884da854e0105c90c512661bc930129f8bb (diff)
downloadbcm5719-llvm-650cd8a38079ba1bd4e75ee5e4b623306f0e8407.tar.gz
bcm5719-llvm-650cd8a38079ba1bd4e75ee5e4b623306f0e8407.zip
PR21101: tablegen's FastISel emitter should filter out unused functions.
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. llvm-svn: 218838
Diffstat (limited to 'llvm/utils/TableGen')
-rw-r--r--llvm/utils/TableGen/FastISelEmitter.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/llvm/utils/TableGen/FastISelEmitter.cpp b/llvm/utils/TableGen/FastISelEmitter.cpp
index 12be6a63bd3..675207d2362 100644
--- a/llvm/utils/TableGen/FastISelEmitter.cpp
+++ b/llvm/utils/TableGen/FastISelEmitter.cpp
@@ -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"
@@ -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();
@@ -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
OpenPOWER on IntegriCloud