blob: f67eb79be3e1c8828a2f4cc82328062075b49fed [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===-- Passes.cpp - Target independent code generation passes ------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
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/RegAllocRegistry.h"
16#include "llvm/CodeGen/Passes.h"
17
18using namespace llvm;
19
20//===---------------------------------------------------------------------===//
21///
22/// RegisterRegAlloc class - Track the registration of register allocators.
23///
24//===---------------------------------------------------------------------===//
25MachinePassRegistry RegisterRegAlloc::Registry;
26
27
28//===---------------------------------------------------------------------===//
29///
30/// RegAlloc command line options.
31///
32//===---------------------------------------------------------------------===//
Dan Gohman089efff2008-05-13 00:00:25 +000033static cl::opt<RegisterRegAlloc::FunctionPassCtor, false,
34 RegisterPassParser<RegisterRegAlloc> >
35RegAlloc("regalloc",
36 cl::init(&createLinearScanRegisterAllocator),
37 cl::desc("Register allocator to use: (default = linearscan)"));
Dan Gohmanf17a25c2007-07-18 16:29:46 +000038
39
40//===---------------------------------------------------------------------===//
41///
42/// createRegisterAllocator - choose the appropriate register allocator.
43///
44//===---------------------------------------------------------------------===//
45FunctionPass *llvm::createRegisterAllocator() {
46 RegisterRegAlloc::FunctionPassCtor Ctor = RegisterRegAlloc::getDefault();
47
48 if (!Ctor) {
49 Ctor = RegAlloc;
50 RegisterRegAlloc::setDefault(RegAlloc);
51 }
52
53 return Ctor();
54}