1 //===-- PIC16Cloner.h - PIC16 LLVM Cloner for shared functions --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains declaration of a cloner class clone all functions that
11 // are shared between the main line code (ML) and interrupt line code (IL).
13 //===----------------------------------------------------------------------===//
18 #include "llvm/ADT/ValueMap.h"
35 class PIC16Cloner : public ModulePass {
37 static char ID; // Class identification
38 PIC16Cloner() : ModulePass(ID) {}
40 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
41 AU.addRequired<CallGraph>();
43 virtual bool runOnModule(Module &M);
46 // Mark reachable functions for the MainLine or InterruptLine.
47 void markCallGraph(CallGraphNode *CGN, string StringMark);
49 // Clone auto variables of function specified.
50 void CloneAutos(Function *F);
52 // Clone the body of a function.
53 Function *cloneFunction(Function *F);
55 // Clone all shared functions.
56 void cloneSharedFunctions(CallGraphNode *isrCGN);
58 // Remap all call sites to the shared function.
59 void remapAllSites(Function *Caller, Function *OrgF, Function *Clone);
61 // Error reporting for PIC16Pass
62 void reportError(string ErrorString, vector<string> &Values);
63 void reportError(string ErrorString);
66 // Records if the interrupt function has already been found.
67 // If more than one interrupt function is found then an error
71 // This ValueMap maps the auto variables of the original functions with
72 // the corresponding cloned auto variable of the cloned function.
73 // This value map is passed during the function cloning so that all the
74 // uses of auto variables be updated properly.
75 ValueMap<const Value*, Value*> VMap;
77 // Map of a already cloned functions.
78 map<Function *, Function *> ClonedFunctionMap;
79 typedef map<Function *, Function *>::iterator cloned_map_iterator;
81 } // End of anonymous namespace