Changes For Bug 352
[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 "llvm/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(
25     "regalloc",
26     cl::desc("Register allocator to use: (default = linearscan)"),
27     cl::Prefix,
28     cl::values(
29        clEnumVal(simple,        "  simple register allocator"),
30        clEnumVal(local,         "  local register allocator"),
31        clEnumVal(linearscan,    "  linear scan register allocator"),
32        clEnumVal(iterativescan, "  iterative scan register allocator"),
33        clEnumValEnd),
34     cl::init(linearscan));
35 }
36
37 FunctionPass *llvm::createRegisterAllocator() {
38   switch (RegAlloc) {
39   default:
40     std::cerr << "no register allocator selected";
41     abort();
42   case simple:
43     return createSimpleRegisterAllocator();
44   case local:
45     return createLocalRegisterAllocator();
46   case linearscan:
47     return createLinearScanRegisterAllocator();
48   case iterativescan:
49     return createIterativeScanRegisterAllocator();
50   }
51 }
52