blob: f67eb79be3e1c8828a2f4cc82328062075b49fed [file] [log] [blame]
Chris Lattneraa4c91f2003-12-28 07:59:53 +00001//===-- Passes.cpp - Target independent code generation passes ------------===//
Misha Brukmanedf128a2005-04-21 22:36:52 +00002//
John Criswellb576c942003-10-20 19:43:21 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Misha Brukmanedf128a2005-04-21 22:36:52 +00007//
John Criswellb576c942003-10-20 19:43:21 +00008//===----------------------------------------------------------------------===//
Alkis Evlogimenos7237ece2003-10-02 16:57:49 +00009//
10// This file defines interfaces to access the target independent code
11// generation passes provided by the LLVM backend.
12//
13//===---------------------------------------------------------------------===//
14
Jim Laskeyeb577ba2006-08-02 12:30:23 +000015#include "llvm/CodeGen/RegAllocRegistry.h"
Alkis Evlogimenos7237ece2003-10-02 16:57:49 +000016#include "llvm/CodeGen/Passes.h"
Jim Laskey13ec7022006-08-01 14:21:23 +000017
Chris Lattneraa4c91f2003-12-28 07:59:53 +000018using namespace llvm;
Brian Gaeked0fde302003-11-11 22:41:34 +000019
Jim Laskeyeb577ba2006-08-02 12:30:23 +000020//===---------------------------------------------------------------------===//
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 Gohman844731a2008-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)"));
Alkis Evlogimenos7237ece2003-10-02 16:57:49 +000038
Jim Laskeyeb577ba2006-08-02 12:30:23 +000039
40//===---------------------------------------------------------------------===//
41///
42/// createRegisterAllocator - choose the appropriate register allocator.
43///
44//===---------------------------------------------------------------------===//
Jim Laskey33a0a6d2006-07-27 20:05:00 +000045FunctionPass *llvm::createRegisterAllocator() {
Jim Laskey9ff542f2006-08-01 18:29:48 +000046 RegisterRegAlloc::FunctionPassCtor Ctor = RegisterRegAlloc::getDefault();
Jim Laskey33a0a6d2006-07-27 20:05:00 +000047
Jim Laskey13ec7022006-08-01 14:21:23 +000048 if (!Ctor) {
Jim Laskeyeb577ba2006-08-02 12:30:23 +000049 Ctor = RegAlloc;
50 RegisterRegAlloc::setDefault(RegAlloc);
Jim Laskey13ec7022006-08-01 14:21:23 +000051 }
52
Jim Laskey33a0a6d2006-07-27 20:05:00 +000053 return Ctor();
54}