Sanjiv Gupta | e19000c | 2010-02-17 06:46:23 +0000 | [diff] [blame] | 1 | //===-- PIC16Overlay.h - Interface for PIC16 Frame Overlay -*- C++ -*-===// |
Sanjiv Gupta | 00e8f5a | 2009-10-21 10:42:44 +0000 | [diff] [blame] | 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 | |
Sanjiv Gupta | 00e8f5a | 2009-10-21 10:42:44 +0000 | [diff] [blame] | 17 | |
| 18 | using std::string; |
| 19 | using namespace llvm; |
| 20 | |
| 21 | namespace llvm { |
Sanjiv Gupta | e19000c | 2010-02-17 06:46:23 +0000 | [diff] [blame] | 22 | // 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 Gupta | 00e8f5a | 2009-10-21 10:42:44 +0000 | [diff] [blame] | 31 | enum OverlayConsts { |
| 32 | StartInterruptColor = 200, |
| 33 | StartIndirectCallColor = 300 |
| 34 | }; |
| 35 | } |
Sanjiv Gupta | e19000c | 2010-02-17 06:46:23 +0000 | [diff] [blame] | 36 | class PIC16Overlay : public ModulePass { |
Sanjiv Gupta | 00e8f5a | 2009-10-21 10:42:44 +0000 | [diff] [blame] | 37 | std::string OverlayStr; |
| 38 | unsigned InterruptDepth; |
| 39 | unsigned IndirectCallColor; |
| 40 | public: |
| 41 | static char ID; // Class identification |
Sanjiv Gupta | e19000c | 2010-02-17 06:46:23 +0000 | [diff] [blame] | 42 | PIC16Overlay() : ModulePass(&ID) { |
Sanjiv Gupta | 00e8f5a | 2009-10-21 10:42:44 +0000 | [diff] [blame] | 43 | OverlayStr = "Overlay="; |
Sanjiv Gupta | e19000c | 2010-02-17 06:46:23 +0000 | [diff] [blame] | 44 | InterruptDepth = PIC16OVERLAY::StartInterruptColor; |
| 45 | IndirectCallColor = PIC16OVERLAY::StartIndirectCallColor; |
Sanjiv Gupta | 00e8f5a | 2009-10-21 10:42:44 +0000 | [diff] [blame] | 46 | } |
| 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 |