blob: a7bea1fd4f986af9f63896056db99f223648c7f1 [file] [log] [blame]
Evan Cheng3f32d652008-06-04 09:18:41 +00001//===-- LiveStackAnalysis.cpp - Live Stack Slot Analysis ------------------===//
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 live stack slot analysis pass. It is analogous to
11// live interval analysis except it's analyzing liveness of stack slots rather
12// than registers.
13//
14//===----------------------------------------------------------------------===//
15
16#define DEBUG_TYPE "livestacks"
17#include "llvm/CodeGen/LiveStackAnalysis.h"
Lang Hamesf41538d2009-06-02 16:53:25 +000018#include "llvm/CodeGen/LiveIntervalAnalysis.h"
Evan Cheng3f32d652008-06-04 09:18:41 +000019#include "llvm/CodeGen/Passes.h"
20#include "llvm/Target/TargetRegisterInfo.h"
21#include "llvm/Support/Debug.h"
Chris Lattnerc02497f2009-08-23 03:47:42 +000022#include "llvm/Support/raw_ostream.h"
Evan Cheng3f32d652008-06-04 09:18:41 +000023#include "llvm/ADT/Statistic.h"
Lang Hamesf41538d2009-06-02 16:53:25 +000024#include <limits>
Evan Cheng3f32d652008-06-04 09:18:41 +000025using namespace llvm;
26
27char LiveStacks::ID = 0;
28static RegisterPass<LiveStacks> X("livestacks", "Live Stack Slot Analysis");
29
Lang Hamesf41538d2009-06-02 16:53:25 +000030void LiveStacks::scaleNumbering(int factor) {
31 // Scale the intervals.
32 for (iterator LI = begin(), LE = end(); LI != LE; ++LI) {
33 LI->second.scaleNumbering(factor);
34 }
35}
36
Evan Cheng3f32d652008-06-04 09:18:41 +000037void LiveStacks::getAnalysisUsage(AnalysisUsage &AU) const {
Evan Chengef901c52008-09-22 22:26:15 +000038 AU.setPreservesAll();
Evan Chengbbeeb2a2008-09-22 20:58:04 +000039 MachineFunctionPass::getAnalysisUsage(AU);
Evan Cheng3f32d652008-06-04 09:18:41 +000040}
41
42void LiveStacks::releaseMemory() {
43 // Release VNInfo memroy regions after all VNInfo objects are dtor'd.
44 VNInfoAllocator.Reset();
Evan Chengc781a242009-05-03 18:32:42 +000045 S2IMap.clear();
46 S2RCMap.clear();
Evan Cheng3f32d652008-06-04 09:18:41 +000047}
48
49bool LiveStacks::runOnMachineFunction(MachineFunction &) {
50 // FIXME: No analysis is being done right now. We are relying on the
51 // register allocators to provide the information.
52 return false;
53}
54
55/// print - Implement the dump method.
Chris Lattner45cfe542009-08-23 06:03:38 +000056void LiveStacks::print(raw_ostream &OS, const Module*) const {
Chris Lattnerc02497f2009-08-23 03:47:42 +000057
58 OS << "********** INTERVALS **********\n";
Evan Cheng3f32d652008-06-04 09:18:41 +000059 for (const_iterator I = begin(), E = end(); I != E; ++I) {
Chris Lattnerc02497f2009-08-23 03:47:42 +000060 I->second.print(OS);
Evan Chengc781a242009-05-03 18:32:42 +000061 int Slot = I->first;
62 const TargetRegisterClass *RC = getIntervalRegClass(Slot);
63 if (RC)
Chris Lattnerc02497f2009-08-23 03:47:42 +000064 OS << " [" << RC->getName() << "]\n";
Evan Chengc781a242009-05-03 18:32:42 +000065 else
Chris Lattnerc02497f2009-08-23 03:47:42 +000066 OS << " [Unknown]\n";
Evan Cheng3f32d652008-06-04 09:18:41 +000067 }
68}