mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-07 12:28:24 +00:00
Use vectors instead of hash_maps for issueGaps and conflictLists.
These hash lookups were a major sink of time because they happen so often! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4136 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -245,16 +245,15 @@ public:
|
||||
|
||||
inline int getMinIssueGap (MachineOpCode fromOp,
|
||||
MachineOpCode toOp) const {
|
||||
hash_map<OpCodePair,int>::const_iterator
|
||||
I = issueGaps.find(OpCodePair(fromOp, toOp));
|
||||
return (I == issueGaps.end())? 0 : (*I).second;
|
||||
assert(fromOp < (int) issueGaps.size());
|
||||
const std::vector<int>& toGaps = issueGaps[fromOp];
|
||||
return (toOp < (int) toGaps.size())? toGaps[toOp] : 0;
|
||||
}
|
||||
|
||||
inline const std::vector<MachineOpCode>*
|
||||
inline const std::vector<MachineOpCode>&
|
||||
getConflictList(MachineOpCode opCode) const {
|
||||
hash_map<MachineOpCode, std::vector<MachineOpCode> >::const_iterator
|
||||
I = conflictLists.find(opCode);
|
||||
return (I == conflictLists.end())? NULL : & (*I).second;
|
||||
assert(opCode < (int) conflictLists.size());
|
||||
return conflictLists[opCode];
|
||||
}
|
||||
|
||||
inline bool isSingleIssue (MachineOpCode opCode) const {
|
||||
@@ -276,6 +275,13 @@ private:
|
||||
void computeInstrResources(const std::vector<InstrRUsage>& instrRUForClasses);
|
||||
void computeIssueGaps(const std::vector<InstrRUsage>& instrRUForClasses);
|
||||
|
||||
void setGap(int gap, MachineOpCode fromOp, MachineOpCode toOp) {
|
||||
std::vector<int>& toGaps = issueGaps[fromOp];
|
||||
if (toOp >= (int) toGaps.size())
|
||||
toGaps.resize(toOp+1);
|
||||
toGaps[toOp] = gap;
|
||||
}
|
||||
|
||||
protected:
|
||||
int numSchedClasses;
|
||||
const MachineInstrInfo* mii;
|
||||
@@ -285,10 +291,10 @@ protected:
|
||||
unsigned numUsageDeltas;
|
||||
unsigned numIssueDeltas;
|
||||
|
||||
std::vector<InstrRUsage> instrRUsages; // indexed by opcode
|
||||
hash_map<OpCodePair,int> issueGaps; // indexed by opcode pair
|
||||
hash_map<MachineOpCode, std::vector<MachineOpCode> >
|
||||
conflictLists; // indexed by opcode
|
||||
std::vector<InstrRUsage> instrRUsages; // indexed by opcode
|
||||
std::vector<std::vector<int> > issueGaps; // indexed by [opcode1][opcode2]
|
||||
std::vector<std::vector<MachineOpCode> >
|
||||
conflictLists; // indexed by [opcode]
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -151,7 +151,8 @@ MachineSchedInfo::computeIssueGaps(const std::vector<InstrRUsage>&
|
||||
instrRUForClasses)
|
||||
{
|
||||
int numOpCodes = mii->getNumRealOpCodes();
|
||||
instrRUsages.resize(numOpCodes);
|
||||
issueGaps.resize(numOpCodes);
|
||||
conflictLists.resize(numOpCodes);
|
||||
|
||||
assert(numOpCodes < (1 << MAX_OPCODE_SIZE) - 1
|
||||
&& "numOpCodes invalid for implementation of class OpCodePair!");
|
||||
@@ -178,17 +179,17 @@ MachineSchedInfo::computeIssueGaps(const std::vector<InstrRUsage>&
|
||||
for (MachineOpCode fromOp=0; fromOp < numOpCodes; fromOp++)
|
||||
for (MachineOpCode toOp=0; toOp < numOpCodes; toOp++)
|
||||
{
|
||||
int instrPairGap =
|
||||
(instrRUsages[fromOp].sameAsClass && instrRUsages[toOp].sameAsClass)
|
||||
? classPairGaps[getSchedClass(fromOp)][getSchedClass(toOp)]
|
||||
: ComputeMinGap(instrRUsages[fromOp], instrRUsages[toOp]);
|
||||
int instrPairGap =
|
||||
(instrRUsages[fromOp].sameAsClass && instrRUsages[toOp].sameAsClass)
|
||||
? classPairGaps[getSchedClass(fromOp)][getSchedClass(toOp)]
|
||||
: ComputeMinGap(instrRUsages[fromOp], instrRUsages[toOp]);
|
||||
|
||||
if (instrPairGap > 0)
|
||||
{
|
||||
issueGaps[OpCodePair(fromOp,toOp)] = instrPairGap;
|
||||
conflictLists[fromOp].push_back(toOp);
|
||||
longestIssueConflict = std::max(longestIssueConflict, instrPairGap);
|
||||
}
|
||||
if (instrPairGap > 0)
|
||||
{
|
||||
this->setGap(instrPairGap, fromOp, toOp);
|
||||
conflictLists[fromOp].push_back(toOp);
|
||||
longestIssueConflict=std::max(longestIssueConflict, instrPairGap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user