Skip to content

Commit

Permalink
Add a hook for PBQP clients to run a custom pre-alloc pass to run pri…
Browse files Browse the repository at this point in the history
…or to PBQP allocation. Patch by Arnaud Allard de Grandmaison.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133249 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
lhames committed Jun 17, 2011
1 parent d589099 commit 8d85766
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion include/llvm/CodeGen/RegAllocPBQP.h
Expand Up @@ -161,7 +161,8 @@ namespace llvm {
PBQP::PBQPNum benefit);
};

FunctionPass* createPBQPRegisterAllocator(std::auto_ptr<PBQPBuilder> builder);
FunctionPass* createPBQPRegisterAllocator(std::auto_ptr<PBQPBuilder> builder,
char *customPassID=0);
}

#endif /* LLVM_CODEGEN_REGALLOCPBQP_H */
13 changes: 9 additions & 4 deletions lib/CodeGen/RegAllocPBQP.cpp
Expand Up @@ -84,8 +84,8 @@ class RegAllocPBQP : public MachineFunctionPass {
static char ID;

/// Construct a PBQP register allocator.
RegAllocPBQP(std::auto_ptr<PBQPBuilder> b)
: MachineFunctionPass(ID), builder(b) {
RegAllocPBQP(std::auto_ptr<PBQPBuilder> b, char *cPassID=0)
: MachineFunctionPass(ID), builder(b), customPassID(cPassID) {
initializeSlotIndexesPass(*PassRegistry::getPassRegistry());
initializeLiveIntervalsPass(*PassRegistry::getPassRegistry());
initializeRegisterCoalescerAnalysisGroup(*PassRegistry::getPassRegistry());
Expand Down Expand Up @@ -122,6 +122,8 @@ class RegAllocPBQP : public MachineFunctionPass {

std::auto_ptr<PBQPBuilder> builder;

char *customPassID;

MachineFunction *mf;
const TargetMachine *tm;
const TargetRegisterInfo *tri;
Expand Down Expand Up @@ -449,6 +451,8 @@ void RegAllocPBQP::getAnalysisUsage(AnalysisUsage &au) const {
au.addRequired<LiveIntervals>();
//au.addRequiredID(SplitCriticalEdgesID);
au.addRequired<RegisterCoalescer>();
if (customPassID)
au.addRequiredID(*customPassID);
au.addRequired<CalculateSpillWeights>();
au.addRequired<LiveStacks>();
au.addPreserved<LiveStacks>();
Expand Down Expand Up @@ -702,8 +706,9 @@ bool RegAllocPBQP::runOnMachineFunction(MachineFunction &MF) {
}

FunctionPass* llvm::createPBQPRegisterAllocator(
std::auto_ptr<PBQPBuilder> builder) {
return new RegAllocPBQP(builder);
std::auto_ptr<PBQPBuilder> builder,
char *customPassID) {
return new RegAllocPBQP(builder, customPassID);
}

FunctionPass* llvm::createDefaultPBQPRegisterAllocator() {
Expand Down

0 comments on commit 8d85766

Please sign in to comment.