llvm-6502/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h
Sanjiv Gupta e74c3bae3a Initial implementation of PIC16 Cloner pass.
This pass is supposed to be run on the linked .bc module.
It traveses the module call graph twice. Once starting from the main function
and marking each reached function as "ML". Again, starting from the ISR
and cloning any reachable function that was marked as "ML". After cloning
the function, it remaps all the call sites in IL functions to call the
cloned functions. 

Currently only marking is being done.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96435 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-17 01:11:53 +00:00

71 lines
2.1 KiB
C++

//===-- PIC16Cloner.h - PIC16 LLVM Cloner for shared functions --*- 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 declaration of a cloner class clone all functions that
// are shared between the main line code (ML) and interrupt line code (IL).
//
//===----------------------------------------------------------------------===//
#ifndef PIC16CLONER_H
#define PIC16CLONER_H
#include "llvm/ADT/DenseMap.h"
using namespace llvm;
using std::vector;
using std::string;
using std::map;
namespace llvm {
// forward classes.
class Value;
class Function;
class Module;
class ModulePass;
class CallGraph;
class CallGraphNode;
class AnalysisUsage;
class PIC16Cloner : public ModulePass {
public:
static char ID; // Class identification
PIC16Cloner() : ModulePass(&ID) {}
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<CallGraph>();
}
virtual bool runOnModule(Module &M);
private: // Functions
// Mark reachable functions for the MainLine or InterruptLine.
void markCallGraph(CallGraphNode *CGN, string StringMark);
// Clone auto variables of function specified.
void CloneAutos(Function *F);
// Error reporting for PIC16Pass
void reportError(string ErrorString, vector<string> &Values);
void reportError(string ErrorString);
private: //data
// Records if the interrupt function has already been found.
// If more than one interrupt function is found then an error
// should be thrown.
bool foundISR;
// This ValueMap maps the auto variables of the original functions with
// the corresponding cloned auto variable of the cloned function.
// This value map is passed during the function cloning so that all the
// uses of auto variables be updated properly.
DenseMap<const Value*, Value*> ValueMap;
};
} // End of anonymous namespace
#endif