blob: d70c4e7d529be40b2ca5476d507496c12f9d3cfe [file] [log] [blame]
Sanjiv Gupta00e8f5a2009-10-21 10:42:44 +00001//===-- PIC16FrameOverlay.h - Interface for PIC16 Frame Overlay -*- C++ -*-===//
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 contains the PIC16 Overlay infrastructure.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef PIC16FRAMEOVERLAY_H
15#define PIC16FRAMEOVERLAY_H
16
17#include "llvm/Analysis/CallGraph.h"
18#include "llvm/Pass.h"
19#include "llvm/CallGraphSCCPass.h"
20
21using std::string;
22using namespace llvm;
23
24namespace llvm {
25 namespace PIC16Overlay {
26 enum OverlayConsts {
27 StartInterruptColor = 200,
28 StartIndirectCallColor = 300
29 };
30 }
31 class PIC16FrameOverlay : public ModulePass {
32 std::string OverlayStr;
33 unsigned InterruptDepth;
34 unsigned IndirectCallColor;
35 public:
36 static char ID; // Class identification
37 PIC16FrameOverlay() : ModulePass(&ID) {
38 OverlayStr = "Overlay=";
39 InterruptDepth = PIC16Overlay::StartInterruptColor;
40 IndirectCallColor = PIC16Overlay::StartIndirectCallColor;
41 }
42
43 virtual void getAnalysisUsage(AnalysisUsage &AU) const;
44 virtual bool runOnModule(Module &M);
45
46 private:
47 unsigned getColor(Function *Fn);
48 void setColor(Function *Fn, unsigned Color);
49 unsigned ModifyDepthForInterrupt(CallGraphNode *CGN, unsigned Depth);
50 void MarkIndirectlyCalledFunctions(Module &M);
51 void DFSTraverse(CallGraphNode *CGN, unsigned Depth);
52 };
53} // End of namespace
54
55#endif