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