mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-13 22:24:07 +00:00
Add a -regalloc=default option that chooses a register allocator based on the -O
optimization level. This only really affects llc for now because both the llvm-gcc and clang front ends override the default register allocator. I intend to remove that code later. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104904 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -24,6 +24,11 @@ using namespace llvm;
|
||||
//===---------------------------------------------------------------------===//
|
||||
MachinePassRegistry RegisterRegAlloc::Registry;
|
||||
|
||||
static FunctionPass *createDefaultRegisterAllocator() { return 0; }
|
||||
static RegisterRegAlloc
|
||||
defaultRegAlloc("default",
|
||||
"pick register allocator based on -O option",
|
||||
createDefaultRegisterAllocator);
|
||||
|
||||
//===---------------------------------------------------------------------===//
|
||||
///
|
||||
@ -33,8 +38,8 @@ MachinePassRegistry RegisterRegAlloc::Registry;
|
||||
static cl::opt<RegisterRegAlloc::FunctionPassCtor, false,
|
||||
RegisterPassParser<RegisterRegAlloc> >
|
||||
RegAlloc("regalloc",
|
||||
cl::init(&createLinearScanRegisterAllocator),
|
||||
cl::desc("Register allocator to use (default=linearscan)"));
|
||||
cl::init(&createDefaultRegisterAllocator),
|
||||
cl::desc("Register allocator to use"));
|
||||
|
||||
|
||||
//===---------------------------------------------------------------------===//
|
||||
@ -42,13 +47,22 @@ RegAlloc("regalloc",
|
||||
/// createRegisterAllocator - choose the appropriate register allocator.
|
||||
///
|
||||
//===---------------------------------------------------------------------===//
|
||||
FunctionPass *llvm::createRegisterAllocator() {
|
||||
FunctionPass *llvm::createRegisterAllocator(CodeGenOpt::Level OptLevel) {
|
||||
RegisterRegAlloc::FunctionPassCtor Ctor = RegisterRegAlloc::getDefault();
|
||||
|
||||
|
||||
if (!Ctor) {
|
||||
Ctor = RegAlloc;
|
||||
RegisterRegAlloc::setDefault(RegAlloc);
|
||||
}
|
||||
|
||||
return Ctor();
|
||||
|
||||
if (Ctor != createDefaultRegisterAllocator)
|
||||
return Ctor();
|
||||
|
||||
// When the 'default' allocator is requested, pick one based on OptLevel.
|
||||
switch (OptLevel) {
|
||||
case CodeGenOpt::None:
|
||||
return createLocalRegisterAllocator();
|
||||
default:
|
||||
return createLinearScanRegisterAllocator();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user