summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/GlobalISel/MachineLegalizer.cpp
diff options
context:
space:
mode:
authorTim Northover <tnorthover@apple.com>2016-08-29 21:00:00 +0000
committerTim Northover <tnorthover@apple.com>2016-08-29 21:00:00 +0000
commitf8bab1ce0cac4c802372af46cd4c0045eab6fdb4 (patch)
treefd823fb350c7044d853edfe44d714a6f0754a28a /llvm/lib/CodeGen/GlobalISel/MachineLegalizer.cpp
parentb3b5a7362c525c9e195e49cba31f4300aa491443 (diff)
downloadbcm5719-llvm-f8bab1ce0cac4c802372af46cd4c0045eab6fdb4.tar.gz
bcm5719-llvm-f8bab1ce0cac4c802372af46cd4c0045eab6fdb4.zip
GlobalISel: use multi-dimensional arrays for legalize actions.
Instead of putting all possible requests into a single table, we can perform the extremely dense lookup based on opcode and type-index in constant time using multi-dimensional array-like things. This roughly halves the time spent doing legalization, which was dominated by queries against the Actions table. llvm-svn: 280011
Diffstat (limited to 'llvm/lib/CodeGen/GlobalISel/MachineLegalizer.cpp')
-rw-r--r--llvm/lib/CodeGen/GlobalISel/MachineLegalizer.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/MachineLegalizer.cpp b/llvm/lib/CodeGen/GlobalISel/MachineLegalizer.cpp
index 11b04f491ee..baef7657eac 100644
--- a/llvm/lib/CodeGen/GlobalISel/MachineLegalizer.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/MachineLegalizer.cpp
@@ -17,9 +17,9 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/CodeGen/GlobalISel/MachineLegalizer.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/ValueTypes.h"
-#include "llvm/CodeGen/GlobalISel/MachineLegalizer.h"
#include "llvm/IR/Type.h"
#include "llvm/Target/TargetOpcodes.h"
using namespace llvm;
@@ -39,14 +39,18 @@ MachineLegalizer::MachineLegalizer() : TablesInitialized(false) {
}
void MachineLegalizer::computeTables() {
- for (auto &Op : Actions) {
- LLT Ty = Op.first.Type;
- if (!Ty.isVector())
- continue;
-
- auto &Entry = MaxLegalVectorElts[std::make_pair(Op.first.Opcode,
- Ty.getElementType())];
- Entry = std::max(Entry, Ty.getNumElements());
+ for (unsigned Opcode = 0; Opcode <= LastOp - FirstOp; ++Opcode) {
+ for (unsigned Idx = 0; Idx != Actions[Opcode].size(); ++Idx) {
+ for (auto &Action : Actions[Opcode][Idx]) {
+ LLT Ty = Action.first;
+ if (!Ty.isVector())
+ continue;
+
+ auto &Entry = MaxLegalVectorElts[std::make_pair(Opcode + FirstOp,
+ Ty.getElementType())];
+ Entry = std::max(Entry, Ty.getNumElements());
+ }
+ }
}
TablesInitialized = true;
@@ -68,9 +72,9 @@ MachineLegalizer::getAction(const InstrAspect &Aspect) const {
Aspect.Opcode == TargetOpcode::G_EXTRACT)
return std::make_pair(Legal, Aspect.Type);
- auto ActionIt = Actions.find(Aspect);
- if (ActionIt != Actions.end())
- return findLegalAction(Aspect, ActionIt->second);
+ LegalizeAction Action = findInActions(Aspect);
+ if (Action != NotFound)
+ return findLegalAction(Aspect, Action);
unsigned Opcode = Aspect.Opcode;
LLT Ty = Aspect.Type;
OpenPOWER on IntegriCloud