blob: 7b4ec8efbcf364d9edc036ad68d7e0f37aee042a [file] [log] [blame]
Evan Cheng09e8ca82008-10-20 21:44:59 +00001//===-- PreAllocSplitting.cpp - Pre-allocation Interval Spltting Pass. ----===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the machine instruction level pre-register allocation
11// live interval splitting pass. It finds live interval barriers, i.e.
12// instructions which will kill all physical registers in certain register
13// classes, and split all live intervals which cross the barrier.
14//
15//===----------------------------------------------------------------------===//
16
17#define DEBUG_TYPE "pre-alloc-split"
18#include "llvm/CodeGen/LiveIntervalAnalysis.h"
19#include "llvm/CodeGen/MachineFunctionPass.h"
20#include "llvm/CodeGen/MachineLoopInfo.h"
21#include "llvm/CodeGen/MachineRegisterInfo.h"
22#include "llvm/CodeGen/Passes.h"
23#include "llvm/CodeGen/RegisterCoalescer.h"
24#include "llvm/Target/TargetMachine.h"
25#include "llvm/Target/TargetOptions.h"
26#include "llvm/Target/TargetRegisterInfo.h"
27#include "llvm/Support/CommandLine.h"
28#include "llvm/Support/Debug.h"
29#include "llvm/ADT/PostOrderIterator.h"
30#include "llvm/ADT/SmallPtrSet.h"
31using namespace llvm;
32
33namespace {
34 class VISIBILITY_HIDDEN PreAllocSplitting : public MachineFunctionPass {
35 // ProcessedBarriers - Register live interval barriers that have already
36 // been processed.
37 SmallPtrSet<MachineInstr*, 16> ProcessedBarriers;
38
39 // ActiveBarriers - Register live interval barriers that are currently
40 // being processed.
41 SmallSet<unsigned, 16> ActiveBarriers;
42 public:
43 static char ID;
44 PreAllocSplitting() : MachineFunctionPass(&ID) {}
45
46 virtual bool runOnMachineFunction(MachineFunction &MF);
47
48 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
49 AU.addRequired<LiveIntervals>();
50 AU.addPreserved<LiveIntervals>();
51 AU.addPreserved<MachineLoopInfo>();
52 AU.addPreserved<RegisterCoalescer>();
53 if (StrongPHIElim)
54 AU.addPreservedID(StrongPHIEliminationID);
55 else
56 AU.addPreservedID(PHIEliminationID);
57 AU.addPreservedID(TwoAddressInstructionPassID);
58 MachineFunctionPass::getAnalysisUsage(AU);
59 }
60
61 virtual void releaseMemory() {
62 ProcessedBarriers.clear();
63 ActiveBarriers.clear();
64 }
65
66 virtual const char *getPassName() const {
67 return "Pre-Register Allocaton Live Interval Splitting";
68 }
69 };
70} // end anonymous namespace
71
72char PreAllocSplitting::ID = 0;
73
74static RegisterPass<PreAllocSplitting>
75X("pre-alloc-splitting", "Pre-Register Allocation Live Interval Splitting");
76
77const PassInfo *const llvm::PreAllocSplittingID = &X;
78
79bool PreAllocSplitting::runOnMachineFunction(MachineFunction &MF) {
80 return false;
81}