No functionality change. Fix up some whitespace and switch out "" for '' when
[llvm/stm8.git] / lib / CodeGen / Passes.cpp
blob3489db2e9f4f966a401ff9c7ac1ccbf1e58b2f62
1 //===-- Passes.cpp - Target independent code generation passes ------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // 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.
13 //===---------------------------------------------------------------------===//
15 #include "llvm/CodeGen/RegAllocRegistry.h"
16 #include "llvm/CodeGen/Passes.h"
18 using namespace llvm;
20 //===---------------------------------------------------------------------===//
21 ///
22 /// RegisterRegAlloc class - Track the registration of register allocators.
23 ///
24 //===---------------------------------------------------------------------===//
25 MachinePassRegistry RegisterRegAlloc::Registry;
27 static FunctionPass *createDefaultRegisterAllocator() { return 0; }
28 static RegisterRegAlloc
29 defaultRegAlloc("default",
30 "pick register allocator based on -O option",
31 createDefaultRegisterAllocator);
33 //===---------------------------------------------------------------------===//
34 ///
35 /// RegAlloc command line options.
36 ///
37 //===---------------------------------------------------------------------===//
38 static cl::opt<RegisterRegAlloc::FunctionPassCtor, false,
39 RegisterPassParser<RegisterRegAlloc> >
40 RegAlloc("regalloc",
41 cl::init(&createDefaultRegisterAllocator),
42 cl::desc("Register allocator to use"));
45 //===---------------------------------------------------------------------===//
46 ///
47 /// createRegisterAllocator - choose the appropriate register allocator.
48 ///
49 //===---------------------------------------------------------------------===//
50 FunctionPass *llvm::createRegisterAllocator(CodeGenOpt::Level OptLevel) {
51 RegisterRegAlloc::FunctionPassCtor Ctor = RegisterRegAlloc::getDefault();
53 if (!Ctor) {
54 Ctor = RegAlloc;
55 RegisterRegAlloc::setDefault(RegAlloc);
58 if (Ctor != createDefaultRegisterAllocator)
59 return Ctor();
61 // When the 'default' allocator is requested, pick one based on OptLevel.
62 switch (OptLevel) {
63 case CodeGenOpt::None:
64 return createFastRegisterAllocator();
65 default:
66 return createLinearScanRegisterAllocator();