Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1 | //===-- Passes.cpp - Target independent code generation passes ------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by the LLVM research group and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines interfaces to access the target independent code |
| 11 | // generation passes provided by the LLVM backend. |
| 12 | // |
| 13 | //===---------------------------------------------------------------------===// |
| 14 | |
| 15 | #include "llvm/CodeGen/RegAllocRegistry.h" |
| 16 | #include "llvm/CodeGen/Passes.h" |
| 17 | |
| 18 | using namespace llvm; |
| 19 | |
| 20 | //===---------------------------------------------------------------------===// |
| 21 | /// |
| 22 | /// RegisterRegAlloc class - Track the registration of register allocators. |
| 23 | /// |
| 24 | //===---------------------------------------------------------------------===// |
| 25 | MachinePassRegistry RegisterRegAlloc::Registry; |
| 26 | |
| 27 | |
| 28 | //===---------------------------------------------------------------------===// |
| 29 | /// |
| 30 | /// RegAlloc command line options. |
| 31 | /// |
| 32 | //===---------------------------------------------------------------------===// |
| 33 | namespace { |
| 34 | cl::opt<RegisterRegAlloc::FunctionPassCtor, false, |
| 35 | RegisterPassParser<RegisterRegAlloc> > |
| 36 | RegAlloc("regalloc", |
| 37 | cl::init(&createLinearScanRegisterAllocator), |
| 38 | cl::desc("Register allocator to use: (default = linearscan)")); |
| 39 | } |
| 40 | |
| 41 | |
| 42 | //===---------------------------------------------------------------------===// |
| 43 | /// |
| 44 | /// createRegisterAllocator - choose the appropriate register allocator. |
| 45 | /// |
| 46 | //===---------------------------------------------------------------------===// |
| 47 | FunctionPass *llvm::createRegisterAllocator() { |
| 48 | RegisterRegAlloc::FunctionPassCtor Ctor = RegisterRegAlloc::getDefault(); |
| 49 | |
| 50 | if (!Ctor) { |
| 51 | Ctor = RegAlloc; |
| 52 | RegisterRegAlloc::setDefault(RegAlloc); |
| 53 | } |
| 54 | |
| 55 | return Ctor(); |
| 56 | } |