3fd107b13335fee1718e7763310b6d6ac4916bb8
[oota-llvm.git] / lib / CodeGen / Passes.cpp
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/Passes.h"
16 #include "Support/CommandLine.h"
17 #include <iostream>
18 using namespace llvm;
19
20 namespace {
21   enum RegAllocName { simple, local, linearscan, iterativescan };
22
23   cl::opt<RegAllocName>
24   RegAlloc("regalloc",
25            cl::desc("Register allocator to use: (default = simple)"),
26            cl::Prefix,
27            cl::values(clEnumVal(simple,       "  simple register allocator"),
28                       clEnumVal(local,        "  local register allocator"),
29                       clEnumVal(linearscan,   "  linear scan register allocator"),
30                       clEnumVal(iterativescan,"  iterative scan register allocator"),
31                       clEnumValEnd),
32            cl::init(local));
33 }
34
35 FunctionPass *llvm::createRegisterAllocator() {
36   switch (RegAlloc) {
37   default:
38     std::cerr << "no register allocator selected";
39     abort();
40   case simple:
41     return createSimpleRegisterAllocator();
42   case local:
43     return createLocalRegisterAllocator();
44   case linearscan:
45     return createLinearScanRegisterAllocator();
46   case iterativescan:
47     return createIterativeScanRegisterAllocator();
48   }
49 }
50