summaryrefslogtreecommitdiff
path: root/lib/Target/PIC16/PIC16Passes/PIC16Overlay.h
blob: 5a2551fabcda94acf88059dd6ca0d30d039dcd68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//===-- PIC16Overlay.h - Interface for PIC16 Frame Overlay -*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source 
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains the PIC16 Overlay infrastructure.
//
//===----------------------------------------------------------------------===//

#ifndef PIC16FRAMEOVERLAY_H
#define PIC16FRAMEOVERLAY_H
 

using std::string;
using namespace llvm;

namespace  llvm {
  // Forward declarations.
  class Function;
  class Module;
  class ModulePass;
  class AnalysisUsage;
  class CallGraphNode;
  class CallGraph;

  namespace PIC16OVERLAY {
    enum OverlayConsts {
      StartInterruptColor = 200,
      StartIndirectCallColor = 300
    }; 
  }
  class PIC16Overlay : public ModulePass {
    std::string OverlayStr;
    unsigned InterruptDepth;
    unsigned IndirectCallColor;
  public:
    static char ID; // Class identification 
    PIC16Overlay() : ModulePass(&ID) {
      OverlayStr = "Overlay=";
      InterruptDepth = PIC16OVERLAY::StartInterruptColor;
      IndirectCallColor = PIC16OVERLAY::StartIndirectCallColor;
    }

    virtual void getAnalysisUsage(AnalysisUsage &AU) const; 
    virtual bool runOnModule(Module &M);

  private: 
    unsigned getColor(Function *Fn);
    void setColor(Function *Fn, unsigned Color);
    unsigned ModifyDepthForInterrupt(CallGraphNode *CGN, unsigned Depth);
    void MarkIndirectlyCalledFunctions(Module &M);
    void DFSTraverse(CallGraphNode *CGN, unsigned Depth);
  };
}  // End of  namespace

#endif