2003-12-28 15:59:53 +08:00
|
|
|
//===-- Passes.cpp - Target independent code generation passes ------------===//
|
2005-04-22 06:36:52 +08:00
|
|
|
//
|
2003-10-21 03:43:21 +08:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
2005-04-22 06:36:52 +08:00
|
|
|
//
|
2003-10-21 03:43:21 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2003-10-03 00:57:49 +08:00
|
|
|
//
|
|
|
|
// This file defines interfaces to access the target independent code
|
|
|
|
// generation passes provided by the LLVM backend.
|
|
|
|
//
|
|
|
|
//===---------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/CodeGen/Passes.h"
|
2004-09-02 06:55:40 +08:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2003-12-28 15:59:53 +08:00
|
|
|
#include <iostream>
|
|
|
|
using namespace llvm;
|
2003-11-12 06:41:34 +08:00
|
|
|
|
2003-10-03 00:57:49 +08:00
|
|
|
namespace {
|
2005-10-24 12:14:30 +08:00
|
|
|
enum RegAllocName { simple, local, linearscan };
|
2003-10-03 00:57:49 +08:00
|
|
|
|
2006-07-21 01:28:38 +08:00
|
|
|
static cl::opt<RegAllocName>
|
2004-07-22 23:30:33 +08:00
|
|
|
RegAlloc(
|
2004-07-22 22:29:31 +08:00
|
|
|
"regalloc",
|
2004-07-23 05:46:02 +08:00
|
|
|
cl::desc("Register allocator to use: (default = linearscan)"),
|
2004-07-22 22:29:31 +08:00
|
|
|
cl::Prefix,
|
|
|
|
cl::values(
|
|
|
|
clEnumVal(simple, " simple register allocator"),
|
|
|
|
clEnumVal(local, " local register allocator"),
|
|
|
|
clEnumVal(linearscan, " linear scan register allocator"),
|
|
|
|
clEnumValEnd),
|
2004-07-23 02:42:00 +08:00
|
|
|
cl::init(linearscan));
|
2003-10-03 00:57:49 +08:00
|
|
|
}
|
|
|
|
|
2003-12-28 15:59:53 +08:00
|
|
|
FunctionPass *llvm::createRegisterAllocator() {
|
2003-10-03 00:57:49 +08:00
|
|
|
switch (RegAlloc) {
|
2003-12-28 15:59:53 +08:00
|
|
|
default:
|
|
|
|
std::cerr << "no register allocator selected";
|
|
|
|
abort();
|
2003-10-03 00:57:49 +08:00
|
|
|
case simple:
|
|
|
|
return createSimpleRegisterAllocator();
|
|
|
|
case local:
|
|
|
|
return createLocalRegisterAllocator();
|
2003-11-20 11:32:25 +08:00
|
|
|
case linearscan:
|
|
|
|
return createLinearScanRegisterAllocator();
|
2003-10-03 00:57:49 +08:00
|
|
|
}
|
|
|
|
}
|
2003-11-12 06:41:34 +08:00
|
|
|
|