diff options
author | Jim Laskey <jlaskey@mac.com> | 2006-08-02 12:30:23 +0000 |
---|---|---|
committer | Jim Laskey <jlaskey@mac.com> | 2006-08-02 12:30:23 +0000 |
commit | eb577ba3b815a1fa4627b060dd2345d17abf672d (patch) | |
tree | f5f23cb7f23616cf9f252122da8610cea888ff95 /lib/CodeGen | |
parent | 9b9528d8f6da5e79b8ef060eab941d07e0860f20 (diff) |
Final polish on machine pass registries.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29471 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/MachinePassRegistry.cpp | 32 | ||||
-rw-r--r-- | lib/CodeGen/Passes.cpp | 35 | ||||
-rw-r--r-- | lib/CodeGen/RegAllocLinearScan.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/RegAllocLocal.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/RegAllocSimple.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/ScheduleDAGList.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/ScheduleDAGSimple.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 27 |
9 files changed, 69 insertions, 37 deletions
diff --git a/lib/CodeGen/MachinePassRegistry.cpp b/lib/CodeGen/MachinePassRegistry.cpp index c440992476..a7ba5bb3ca 100644 --- a/lib/CodeGen/MachinePassRegistry.cpp +++ b/lib/CodeGen/MachinePassRegistry.cpp @@ -16,20 +16,26 @@ using namespace llvm; - -//===---------------------------------------------------------------------===// -/// -/// RegisterRegAlloc class - Track the registration of register allocators. + +/// Add - Adds a function pass to the registration list. /// -//===---------------------------------------------------------------------===// -MachinePassRegistry<RegisterRegAlloc::FunctionPassCtor> -RegisterRegAlloc::Registry; +void MachinePassRegistry::Add(MachinePassRegistryNode *Node) { + Node->setNext(List); + List = Node; + if (Listener) Listener->NotifyAdd(Node->getName(), + Node->getCtor(), + Node->getDescription()); +} -//===---------------------------------------------------------------------===// -/// -/// RegisterScheduler class - Track the registration of instruction schedulers. +/// Remove - Removes a function pass from the registration list. /// -//===---------------------------------------------------------------------===// -MachinePassRegistry<RegisterScheduler::FunctionPassCtor> -RegisterScheduler::Registry; +void MachinePassRegistry::Remove(MachinePassRegistryNode *Node) { + for (MachinePassRegistryNode **I = &List; *I; I = (*I)->getNextAddress()) { + if (*I == Node) { + if (Listener) Listener->NotifyRemove(Node->getName()); + *I = (*I)->getNext(); + break; + } + } +} diff --git a/lib/CodeGen/Passes.cpp b/lib/CodeGen/Passes.cpp index a896f83526..4344612f3a 100644 --- a/lib/CodeGen/Passes.cpp +++ b/lib/CodeGen/Passes.cpp @@ -12,31 +12,46 @@ // //===---------------------------------------------------------------------===// -#include "llvm/CodeGen/MachinePassRegistry.h" +#include "llvm/CodeGen/RegAllocRegistry.h" #include "llvm/CodeGen/Passes.h" -#include "llvm/Support/CommandLine.h" #include <iostream> using namespace llvm; +//===---------------------------------------------------------------------===// +/// +/// RegisterRegAlloc class - Track the registration of register allocators. +/// +//===---------------------------------------------------------------------===// +MachinePassRegistry RegisterRegAlloc::Registry; + + +//===---------------------------------------------------------------------===// +/// +/// RegAlloc command line options. +/// +//===---------------------------------------------------------------------===// namespace { - cl::opt<const char *, false, RegisterPassParser<RegisterRegAlloc> > + cl::opt<RegisterRegAlloc::FunctionPassCtor, false, + RegisterPassParser<RegisterRegAlloc> > RegAlloc("regalloc", - cl::init("linearscan"), + cl::init(createLinearScanRegisterAllocator), cl::desc("Register allocator to use: (default = linearscan)")); } + +//===---------------------------------------------------------------------===// +/// +/// createRegisterAllocator - choose the appropriate register allocator. +/// +//===---------------------------------------------------------------------===// FunctionPass *llvm::createRegisterAllocator() { RegisterRegAlloc::FunctionPassCtor Ctor = RegisterRegAlloc::getDefault(); if (!Ctor) { - Ctor = RegisterRegAlloc::FindCtor(RegAlloc); - assert(Ctor && "No register allocator found"); - if (!Ctor) Ctor = RegisterRegAlloc::FirstCtor(); - RegisterRegAlloc::setDefault(Ctor); + Ctor = RegAlloc; + RegisterRegAlloc::setDefault(RegAlloc); } - assert(Ctor && "No register allocator found"); - return Ctor(); } diff --git a/lib/CodeGen/RegAllocLinearScan.cpp b/lib/CodeGen/RegAllocLinearScan.cpp index 5463e4e4b6..b9ae8ac5a7 100644 --- a/lib/CodeGen/RegAllocLinearScan.cpp +++ b/lib/CodeGen/RegAllocLinearScan.cpp @@ -18,8 +18,8 @@ #include "llvm/Function.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstr.h" -#include "llvm/CodeGen/MachinePassRegistry.h" #include "llvm/CodeGen/Passes.h" +#include "llvm/CodeGen/RegAllocRegistry.h" #include "llvm/CodeGen/SSARegMap.h" #include "llvm/Target/MRegisterInfo.h" #include "llvm/Target/TargetMachine.h" diff --git a/lib/CodeGen/RegAllocLocal.cpp b/lib/CodeGen/RegAllocLocal.cpp index 69b944c709..9148d00247 100644 --- a/lib/CodeGen/RegAllocLocal.cpp +++ b/lib/CodeGen/RegAllocLocal.cpp @@ -18,8 +18,8 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/SSARegMap.h" #include "llvm/CodeGen/MachineFrameInfo.h" -#include "llvm/CodeGen/MachinePassRegistry.h" #include "llvm/CodeGen/LiveVariables.h" +#include "llvm/CodeGen/RegAllocRegistry.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Support/CommandLine.h" diff --git a/lib/CodeGen/RegAllocSimple.cpp b/lib/CodeGen/RegAllocSimple.cpp index bd20cd04c5..e807992201 100644 --- a/lib/CodeGen/RegAllocSimple.cpp +++ b/lib/CodeGen/RegAllocSimple.cpp @@ -20,7 +20,7 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/SSARegMap.h" #include "llvm/CodeGen/MachineFrameInfo.h" -#include "llvm/CodeGen/MachinePassRegistry.h" +#include "llvm/CodeGen/RegAllocRegistry.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Support/Debug.h" diff --git a/lib/CodeGen/SelectionDAG/ScheduleDAGList.cpp b/lib/CodeGen/SelectionDAG/ScheduleDAGList.cpp index 8b82197b75..aa62bd49fc 100644 --- a/lib/CodeGen/SelectionDAG/ScheduleDAGList.cpp +++ b/lib/CodeGen/SelectionDAG/ScheduleDAGList.cpp @@ -19,8 +19,8 @@ //===----------------------------------------------------------------------===// #define DEBUG_TYPE "sched" -#include "llvm/CodeGen/MachinePassRegistry.h" #include "llvm/CodeGen/ScheduleDAG.h" +#include "llvm/CodeGen/SchedulerRegistry.h" #include "llvm/CodeGen/SelectionDAGISel.h" #include "llvm/CodeGen/SSARegMap.h" #include "llvm/Target/MRegisterInfo.h" diff --git a/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp b/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp index 6e7ef2e251..5d7fa5fad1 100644 --- a/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp +++ b/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp @@ -16,8 +16,8 @@ //===----------------------------------------------------------------------===// #define DEBUG_TYPE "sched" -#include "llvm/CodeGen/MachinePassRegistry.h" #include "llvm/CodeGen/ScheduleDAG.h" +#include "llvm/CodeGen/SchedulerRegistry.h" #include "llvm/CodeGen/SSARegMap.h" #include "llvm/Target/MRegisterInfo.h" #include "llvm/Target/TargetData.h" diff --git a/lib/CodeGen/SelectionDAG/ScheduleDAGSimple.cpp b/lib/CodeGen/SelectionDAG/ScheduleDAGSimple.cpp index 2b8a754a06..b4c4c3245d 100644 --- a/lib/CodeGen/SelectionDAG/ScheduleDAGSimple.cpp +++ b/lib/CodeGen/SelectionDAG/ScheduleDAGSimple.cpp @@ -14,8 +14,8 @@ //===----------------------------------------------------------------------===// #define DEBUG_TYPE "sched" -#include "llvm/CodeGen/MachinePassRegistry.h" #include "llvm/CodeGen/ScheduleDAG.h" +#include "llvm/CodeGen/SchedulerRegistry.h" #include "llvm/CodeGen/SelectionDAG.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetMachine.h" diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 3a1af95e81..c68251c230 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -29,7 +29,7 @@ #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineJumpTableInfo.h" #include "llvm/CodeGen/MachineInstrBuilder.h" -#include "llvm/CodeGen/MachinePassRegistry.h" +#include "llvm/CodeGen/SchedulerRegistry.h" #include "llvm/CodeGen/SelectionDAG.h" #include "llvm/CodeGen/SSARegMap.h" #include "llvm/Target/MRegisterInfo.h" @@ -40,7 +40,6 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" -#include "llvm/Support/CommandLine.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Visibility.h" @@ -61,10 +60,24 @@ ViewSchedDAGs("view-sched-dags", cl::Hidden, static const bool ViewISelDAGs = 0, ViewSchedDAGs = 0; #endif + +//===---------------------------------------------------------------------===// +/// +/// RegisterScheduler class - Track the registration of instruction schedulers. +/// +//===---------------------------------------------------------------------===// +MachinePassRegistry RegisterScheduler::Registry; + +//===---------------------------------------------------------------------===// +/// +/// ISHeuristic command line option for instruction schedulers. +/// +//===---------------------------------------------------------------------===// namespace { - cl::opt<const char *, false, RegisterPassParser<RegisterScheduler> > + cl::opt<RegisterScheduler::FunctionPassCtor, false, + RegisterPassParser<RegisterScheduler> > ISHeuristic("sched", - cl::init("default"), + cl::init(createDefaultScheduler), cl::desc("Instruction schedulers available:")); static RegisterScheduler @@ -3629,15 +3642,13 @@ void SelectionDAGISel::SelectBasicBlock(BasicBlock *LLVMBB, MachineFunction &MF, void SelectionDAGISel::ScheduleAndEmitDAG(SelectionDAG &DAG) { if (ViewSchedDAGs) DAG.viewGraph(); - static RegisterScheduler::FunctionPassCtor Ctor = - RegisterScheduler::getDefault(); + RegisterScheduler::FunctionPassCtor Ctor = RegisterScheduler::getDefault(); if (!Ctor) { - Ctor = RegisterScheduler::FindCtor(ISHeuristic); + Ctor = ISHeuristic; RegisterScheduler::setDefault(Ctor); } - assert(Ctor && "No instruction scheduler found"); ScheduleDAG *SL = Ctor(this, &DAG, BB); BB = SL->Run(); delete SL; |