Fix think-o: emit all 8 bytes of the EOF marker. Also reflow a line in a
[llvm/stm8.git] / lib / CodeGen / Passes.cpp
blobc62227535fc99c0cd039cf7be2cac6a254eca879
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 // This forces linking of the greedy register allocator, so -regalloc=greedy
59 // works in clang.
60 if (Ctor == createGreedyRegisterAllocator)
61 return createGreedyRegisterAllocator();
63 if (Ctor != createDefaultRegisterAllocator)
64 return Ctor();
66 // When the 'default' allocator is requested, pick one based on OptLevel.
67 switch (OptLevel) {
68 case CodeGenOpt::None:
69 return createFastRegisterAllocator();
70 default:
71 return createLinearScanRegisterAllocator();