From 8d857660ce194f05eca3e21d149e8cf3101da9e4 Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Fri, 17 Jun 2011 07:09:01 +0000 Subject: [PATCH] Add a hook for PBQP clients to run a custom pre-alloc pass to run prior 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 --- include/llvm/CodeGen/RegAllocPBQP.h | 3 ++- lib/CodeGen/RegAllocPBQP.cpp | 13 +++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/include/llvm/CodeGen/RegAllocPBQP.h b/include/llvm/CodeGen/RegAllocPBQP.h index 8139c65c4b..bce3ec739b 100644 --- a/include/llvm/CodeGen/RegAllocPBQP.h +++ b/include/llvm/CodeGen/RegAllocPBQP.h @@ -161,7 +161,8 @@ namespace llvm { PBQP::PBQPNum benefit); }; - FunctionPass* createPBQPRegisterAllocator(std::auto_ptr builder); + FunctionPass* createPBQPRegisterAllocator(std::auto_ptr builder, + char *customPassID=0); } #endif /* LLVM_CODEGEN_REGALLOCPBQP_H */ diff --git a/lib/CodeGen/RegAllocPBQP.cpp b/lib/CodeGen/RegAllocPBQP.cpp index 605507f014..49f8fb4c16 100644 --- a/lib/CodeGen/RegAllocPBQP.cpp +++ b/lib/CodeGen/RegAllocPBQP.cpp @@ -84,8 +84,8 @@ class RegAllocPBQP : public MachineFunctionPass { static char ID; /// Construct a PBQP register allocator. - RegAllocPBQP(std::auto_ptr b) - : MachineFunctionPass(ID), builder(b) { + RegAllocPBQP(std::auto_ptr b, char *cPassID=0) + : MachineFunctionPass(ID), builder(b), customPassID(cPassID) { initializeSlotIndexesPass(*PassRegistry::getPassRegistry()); initializeLiveIntervalsPass(*PassRegistry::getPassRegistry()); initializeRegisterCoalescerAnalysisGroup(*PassRegistry::getPassRegistry()); @@ -122,6 +122,8 @@ class RegAllocPBQP : public MachineFunctionPass { std::auto_ptr builder; + char *customPassID; + MachineFunction *mf; const TargetMachine *tm; const TargetRegisterInfo *tri; @@ -449,6 +451,8 @@ void RegAllocPBQP::getAnalysisUsage(AnalysisUsage &au) const { au.addRequired(); //au.addRequiredID(SplitCriticalEdgesID); au.addRequired(); + if (customPassID) + au.addRequiredID(*customPassID); au.addRequired(); au.addRequired(); au.addPreserved(); @@ -702,8 +706,9 @@ bool RegAllocPBQP::runOnMachineFunction(MachineFunction &MF) { } FunctionPass* llvm::createPBQPRegisterAllocator( - std::auto_ptr builder) { - return new RegAllocPBQP(builder); + std::auto_ptr builder, + char *customPassID) { + return new RegAllocPBQP(builder, customPassID); } FunctionPass* llvm::createDefaultPBQPRegisterAllocator() {