blob: bcd67c5037f5a84ed032d4c34e5afe3adf466ecf [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//===---------------------------------------------------------------------===//
33namespace {
Dan Gohman2c37da52008-05-06 01:53:16 +000034 static
Dan Gohmanf17a25c2007-07-18 16:29:46 +000035 cl::opt<RegisterRegAlloc::FunctionPassCtor, false,
36 RegisterPassParser<RegisterRegAlloc> >
37 RegAlloc("regalloc",
38 cl::init(&createLinearScanRegisterAllocator),
39 cl::desc("Register allocator to use: (default = linearscan)"));
40}
41
42
43//===---------------------------------------------------------------------===//
44///
45/// createRegisterAllocator - choose the appropriate register allocator.
46///
47//===---------------------------------------------------------------------===//
48FunctionPass *llvm::createRegisterAllocator() {
49 RegisterRegAlloc::FunctionPassCtor Ctor = RegisterRegAlloc::getDefault();
50
51 if (!Ctor) {
52 Ctor = RegAlloc;
53 RegisterRegAlloc::setDefault(RegAlloc);
54 }
55
56 return Ctor();
57}