diff options
author | Craig Topper <craig.topper@intel.com> | 2017-12-17 03:16:23 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@intel.com> | 2017-12-17 03:16:23 +0000 |
commit | 5992535e1afdab9fc02640c95fd97979fe5253aa (patch) | |
tree | 7101541379c4c34d084491656fe31f269a800f44 /llvm/lib/Target/X86/X86DomainReassignment.cpp | |
parent | c27f81b92ba3910dc4d3553f5fb030f618f8d696 (diff) | |
download | bcm5719-llvm-5992535e1afdab9fc02640c95fd97979fe5253aa.tar.gz bcm5719-llvm-5992535e1afdab9fc02640c95fd97979fe5253aa.zip |
[X86DomainReassignment] Store legal domains in a std::bitset instead of using a SmallVector that really only ever has one element as a set.
llvm-svn: 320940
Diffstat (limited to 'llvm/lib/Target/X86/X86DomainReassignment.cpp')
-rw-r--r-- | llvm/lib/Target/X86/X86DomainReassignment.cpp | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/llvm/lib/Target/X86/X86DomainReassignment.cpp b/llvm/lib/Target/X86/X86DomainReassignment.cpp index f9e1ac39425..0a87fb4533c 100644 --- a/llvm/lib/Target/X86/X86DomainReassignment.cpp +++ b/llvm/lib/Target/X86/X86DomainReassignment.cpp @@ -26,6 +26,7 @@ #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/TargetRegisterInfo.h" #include "llvm/Support/Debug.h" +#include <bitset> using namespace llvm; @@ -42,7 +43,7 @@ static cl::opt<bool> DisableX86DomainReassignment( cl::desc("X86: Disable Virtual Register Reassignment."), cl::init(false)); namespace { -enum RegDomain { NoDomain = -1, GPRDomain, MaskDomain, OtherDomain }; +enum RegDomain { NoDomain = -1, GPRDomain, MaskDomain, OtherDomain, NumDomains }; static bool isGPR(const TargetRegisterClass *RC) { return X86::GR64RegClass.hasSubClassEq(RC) || @@ -316,11 +317,7 @@ private: RegDomain Domain; /// Domains which this closure can legally be reassigned to. - SmallVector<RegDomain, 2> LegalDstDomains; - - SmallVector<RegDomain, 2> getLegalDstDomains() const { - return LegalDstDomains; - } + std::bitset<NumDomains> LegalDstDomains; /// Enqueue \p Reg to be considered for addition to the closure. void visitRegister(unsigned Reg, SmallVectorImpl<unsigned> &Worklist); @@ -340,12 +337,14 @@ private: public: Closure(const TargetInstrInfo *TII, MachineRegisterInfo *MRI, const InstrConverterBaseMap &Converters, - const SmallVector<RegDomain, 2> &LegalDstDomains, + std::initializer_list<RegDomain> LegalDstDomainList, DenseSet<unsigned> &EnclosedEdges, DenseMap<MachineInstr *, Closure *> &EnclosedInstrs) : TII(TII), MRI(MRI), Converters(Converters), Domain(NoDomain), - LegalDstDomains(LegalDstDomains), EnclosedEdges(EnclosedEdges), - EnclosedInstrs(EnclosedInstrs) {} + EnclosedEdges(EnclosedEdges), EnclosedInstrs(EnclosedInstrs) { + for (RegDomain D : LegalDstDomainList) + LegalDstDomains.set(D); + } /// Starting from \Reg, expand the closure as much as possible. void buildClosure(unsigned E); @@ -357,13 +356,13 @@ public: void Reassign(RegDomain Domain) const; /// Mark this closure as illegal for reassignment to all domains. - void setAllIllegal() { LegalDstDomains.clear(); } + void setAllIllegal() { LegalDstDomains.reset(); } /// \returns true if this closure has domains which are legal to reassign to. - bool hasLegalDstDomain() const { return !LegalDstDomains.empty(); } + bool hasLegalDstDomain() const { return LegalDstDomains.any(); } /// \returns true if is legal to reassign this closure to domain \p RD. - bool isLegal(RegDomain RD) const { return is_contained(LegalDstDomains, RD); } + bool isLegal(RegDomain RD) const { return LegalDstDomains[RD]; } bool empty() const { return Edges.empty(); } }; @@ -440,10 +439,13 @@ void Closure::encloseInstr(MachineInstr *MI) { // Mark closure as illegal for reassignment to domains, if there is no // converter for the instruction or if the converter cannot convert the // instruction. - erase_if(LegalDstDomains, [&](RegDomain D) { - InstrConverterBase *IC = Converters.lookup({D, MI->getOpcode()}); - return !IC || !IC->isLegal(MI, TII); - }); + for (unsigned i = 0; i != LegalDstDomains.size(); ++i) { + if (LegalDstDomains[i]) { + InstrConverterBase *IC = Converters.lookup({i, MI->getOpcode()}); + if (!IC || !IC->isLegal(MI, TII)) + LegalDstDomains[i] = false; + } + } } double Closure::calculateCost(RegDomain DstDomain) const { |