mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-09 22:13:07 +00:00
Use a DenseMap for mapping reg->reg. This improves the LiveInterval
analysis running time from 2.7869secs to 2.5226secs on 176.gcc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16244 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
67f9349175
commit
5d0d1e350a
@ -20,6 +20,7 @@
|
|||||||
#ifndef LLVM_CODEGEN_LIVEINTERVAL_ANALYSIS_H
|
#ifndef LLVM_CODEGEN_LIVEINTERVAL_ANALYSIS_H
|
||||||
#define LLVM_CODEGEN_LIVEINTERVAL_ANALYSIS_H
|
#define LLVM_CODEGEN_LIVEINTERVAL_ANALYSIS_H
|
||||||
|
|
||||||
|
#include "llvm/ADT/DenseMap.h"
|
||||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||||
#include "LiveInterval.h"
|
#include "LiveInterval.h"
|
||||||
|
|
||||||
@ -44,7 +45,7 @@ namespace llvm {
|
|||||||
typedef std::map<unsigned, LiveInterval> Reg2IntervalMap;
|
typedef std::map<unsigned, LiveInterval> Reg2IntervalMap;
|
||||||
Reg2IntervalMap r2iMap_;
|
Reg2IntervalMap r2iMap_;
|
||||||
|
|
||||||
typedef std::map<unsigned, unsigned> Reg2RegMap;
|
typedef DenseMap<unsigned> Reg2RegMap;
|
||||||
Reg2RegMap r2rMap_;
|
Reg2RegMap r2rMap_;
|
||||||
|
|
||||||
std::vector<bool> allocatableRegs_;
|
std::vector<bool> allocatableRegs_;
|
||||||
@ -171,11 +172,11 @@ namespace llvm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// rep - returns the representative of this register
|
/// rep - returns the representative of this register
|
||||||
unsigned rep(unsigned reg) {
|
unsigned rep(unsigned Reg) {
|
||||||
Reg2RegMap::iterator it = r2rMap_.find(reg);
|
unsigned Rep = r2rMap_[Reg];
|
||||||
if (it != r2rMap_.end())
|
if (Rep)
|
||||||
return it->second = rep(it->second);
|
return r2rMap_[Reg] = rep(Rep);
|
||||||
return reg;
|
return Reg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void printRegName(unsigned reg) const;
|
void printRegName(unsigned reg) const;
|
||||||
|
@ -619,6 +619,8 @@ namespace {
|
|||||||
|
|
||||||
void LiveIntervals::joinIntervals() {
|
void LiveIntervals::joinIntervals() {
|
||||||
DEBUG(std::cerr << "********** JOINING INTERVALS ***********\n");
|
DEBUG(std::cerr << "********** JOINING INTERVALS ***********\n");
|
||||||
|
// reserve space for the reg2reg map
|
||||||
|
r2rMap_.grow(mf_->getSSARegMap()->getLastVirtReg());
|
||||||
|
|
||||||
const LoopInfo &LI = getAnalysis<LoopInfo>();
|
const LoopInfo &LI = getAnalysis<LoopInfo>();
|
||||||
if (LI.begin() == LI.end()) {
|
if (LI.begin() == LI.end()) {
|
||||||
@ -644,9 +646,9 @@ void LiveIntervals::joinIntervals() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(std::cerr << "*** Register mapping ***\n");
|
DEBUG(std::cerr << "*** Register mapping ***\n");
|
||||||
DEBUG(for (std::map<unsigned, unsigned>::iterator I = r2rMap_.begin(),
|
DEBUG(for (int i = 0, e = r2rMap_.size(); i != e; ++i)
|
||||||
E = r2rMap_.end(); I != E; ++I)
|
if (r2rMap_[i])
|
||||||
std::cerr << " reg " << I->first << " -> reg " << I->second << "\n";);
|
std::cerr << " reg " << i << " -> reg " << r2rMap_[i] << "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return true if the two specified registers belong to different register
|
/// Return true if the two specified registers belong to different register
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#ifndef LLVM_CODEGEN_LIVEINTERVAL_ANALYSIS_H
|
#ifndef LLVM_CODEGEN_LIVEINTERVAL_ANALYSIS_H
|
||||||
#define LLVM_CODEGEN_LIVEINTERVAL_ANALYSIS_H
|
#define LLVM_CODEGEN_LIVEINTERVAL_ANALYSIS_H
|
||||||
|
|
||||||
|
#include "llvm/ADT/DenseMap.h"
|
||||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||||
#include "LiveInterval.h"
|
#include "LiveInterval.h"
|
||||||
|
|
||||||
@ -44,7 +45,7 @@ namespace llvm {
|
|||||||
typedef std::map<unsigned, LiveInterval> Reg2IntervalMap;
|
typedef std::map<unsigned, LiveInterval> Reg2IntervalMap;
|
||||||
Reg2IntervalMap r2iMap_;
|
Reg2IntervalMap r2iMap_;
|
||||||
|
|
||||||
typedef std::map<unsigned, unsigned> Reg2RegMap;
|
typedef DenseMap<unsigned> Reg2RegMap;
|
||||||
Reg2RegMap r2rMap_;
|
Reg2RegMap r2rMap_;
|
||||||
|
|
||||||
std::vector<bool> allocatableRegs_;
|
std::vector<bool> allocatableRegs_;
|
||||||
@ -171,11 +172,11 @@ namespace llvm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// rep - returns the representative of this register
|
/// rep - returns the representative of this register
|
||||||
unsigned rep(unsigned reg) {
|
unsigned rep(unsigned Reg) {
|
||||||
Reg2RegMap::iterator it = r2rMap_.find(reg);
|
unsigned Rep = r2rMap_[Reg];
|
||||||
if (it != r2rMap_.end())
|
if (Rep)
|
||||||
return it->second = rep(it->second);
|
return r2rMap_[Reg] = rep(Rep);
|
||||||
return reg;
|
return Reg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void printRegName(unsigned reg) const;
|
void printRegName(unsigned reg) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user