blob: 5a2551fabcda94acf88059dd6ca0d30d039dcd68 [file] [log] [blame]
Sanjiv Guptae19000c2010-02-17 06:46:23 +00001//===-- PIC16Overlay.h - Interface for PIC16 Frame Overlay -*- C++ -*-===//
Sanjiv Gupta00e8f5a2009-10-21 10:42:44 +00002//
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
Sanjiv Gupta00e8f5a2009-10-21 10:42:44 +000017
18using std::string;
19using namespace llvm;
20
21namespace llvm {
Sanjiv Guptae19000c2010-02-17 06:46:23 +000022 // Forward declarations.
23 class Function;
24 class Module;
25 class ModulePass;
26 class AnalysisUsage;
27 class CallGraphNode;
28 class CallGraph;
29
30 namespace PIC16OVERLAY {
Sanjiv Gupta00e8f5a2009-10-21 10:42:44 +000031 enum OverlayConsts {
32 StartInterruptColor = 200,
33 StartIndirectCallColor = 300
34 };
35 }
Sanjiv Guptae19000c2010-02-17 06:46:23 +000036 class PIC16Overlay : public ModulePass {
Sanjiv Gupta00e8f5a2009-10-21 10:42:44 +000037 std::string OverlayStr;
38 unsigned InterruptDepth;
39 unsigned IndirectCallColor;
40 public:
41 static char ID; // Class identification
Sanjiv Guptae19000c2010-02-17 06:46:23 +000042 PIC16Overlay() : ModulePass(&ID) {
Sanjiv Gupta00e8f5a2009-10-21 10:42:44 +000043 OverlayStr = "Overlay=";
Sanjiv Guptae19000c2010-02-17 06:46:23 +000044 InterruptDepth = PIC16OVERLAY::StartInterruptColor;
45 IndirectCallColor = PIC16OVERLAY::StartIndirectCallColor;
Sanjiv Gupta00e8f5a2009-10-21 10:42:44 +000046 }
47
48 virtual void getAnalysisUsage(AnalysisUsage &AU) const;
49 virtual bool runOnModule(Module &M);
50
51 private:
52 unsigned getColor(Function *Fn);
53 void setColor(Function *Fn, unsigned Color);
54 unsigned ModifyDepthForInterrupt(CallGraphNode *CGN, unsigned Depth);
55 void MarkIndirectlyCalledFunctions(Module &M);
56 void DFSTraverse(CallGraphNode *CGN, unsigned Depth);
57 };
58} // End of namespace
59
60#endif