LLVM API Documentation
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, iterativescan }; 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 clEnumVal(iterativescan, " iterative scan register allocator"), 00033 clEnumValEnd), 00034 cl::init(linearscan)); 00035 } 00036 00037 FunctionPass *llvm::createRegisterAllocator() { 00038 switch (RegAlloc) { 00039 default: 00040 std::cerr << "no register allocator selected"; 00041 abort(); 00042 case simple: 00043 return createSimpleRegisterAllocator(); 00044 case local: 00045 return createLocalRegisterAllocator(); 00046 case linearscan: 00047 return createLinearScanRegisterAllocator(); 00048 case iterativescan: 00049 return createIterativeScanRegisterAllocator(); 00050 } 00051 } 00052