LLVM API Documentation

Passes.cpp

Go to the documentation of this file.
00001 //===-- Passes.cpp - Target independent code generation passes ------------===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file was developed by the LLVM research group and is distributed under
00006 // the University of Illinois Open Source License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file defines interfaces to access the target independent code
00011 // generation passes provided by the LLVM backend.
00012 //
00013 //===---------------------------------------------------------------------===//
00014 
00015 #include "llvm/CodeGen/Passes.h"
00016 #include "llvm/Support/CommandLine.h"
00017 #include <iostream>
00018 using namespace llvm;
00019 
00020 namespace {
00021   enum RegAllocName { simple, local, linearscan };
00022 
00023   cl::opt<RegAllocName>
00024   RegAlloc(
00025     "regalloc",
00026     cl::desc("Register allocator to use: (default = linearscan)"),
00027     cl::Prefix,
00028     cl::values(
00029        clEnumVal(simple,        "  simple register allocator"),
00030        clEnumVal(local,         "  local register allocator"),
00031        clEnumVal(linearscan,    "  linear scan register allocator"),
00032        clEnumValEnd),
00033     cl::init(linearscan));
00034 }
00035 
00036 FunctionPass *llvm::createRegisterAllocator() {
00037   switch (RegAlloc) {
00038   default:
00039     std::cerr << "no register allocator selected";
00040     abort();
00041   case simple:
00042     return createSimpleRegisterAllocator();
00043   case local:
00044     return createLocalRegisterAllocator();
00045   case linearscan:
00046     return createLinearScanRegisterAllocator();
00047   }
00048 }
00049