[llvm-commits] CVS: llvm/include/llvm/Reoptimizer/TraceCache.h
Anand Shukla
ashukla at cs.uiuc.edu
Sun Sep 15 15:41:08 PDT 2002
Changes in directory llvm/include/llvm/Reoptimizer:
TraceCache.h updated: 1.1 -> 1.2
---
Log message:
Modified addTrace, and other interface functions
---
Diffs of the changes:
Index: llvm/include/llvm/Reoptimizer/TraceCache.h
diff -u llvm/include/llvm/Reoptimizer/TraceCache.h:1.1 llvm/include/llvm/Reoptimizer/TraceCache.h:1.2
--- llvm/include/llvm/Reoptimizer/TraceCache.h:1.1 Thu Aug 1 02:18:26 2002
+++ llvm/include/llvm/Reoptimizer/TraceCache.h Sun Sep 15 15:40:41 2002
@@ -6,40 +6,13 @@
#ifndef LLVM_TRACECACHE_H
#define LLVM_TRACECACHE_H
-
#include <map>
#include <vector>
#include <list>
#include <utility>
-//two kinds of branches being handled for now
-//BIcc, and BPcc instructions
-//(sparcV9 manual, pg 146-150)
-
-inline bool isBranchInstr(unsigned y) {
- if (y & 0xc0000000) return false;
-
- switch ((y >> 22) & 0x7) {
- case 1:
- case 2:
- case 3:
- case 5:
- case 6:
- return true;
- default:
- return false;
- }
-}
-
-#define isNonDepJump(y) ((y & 0x01c00000) == 4194304)
-#define isDepJump(y) ((y & 0x01c00000) == 8388608)
-
-#define getNonDepJmpTarget(y, oldAdd) (oldAdd+4*(((y&262144)==262144) ? ((y&0x0007ffff)|0xfffffffffff80000) : (y&0x0007ffff)))
-#define getDepJmpTarget(y, oldAdd) (oldAdd+4*(((y&2097152)==2097152) ? ((y&0x003fffff)|0xffffffffffc00000) : (y&0x003fffff)))
-#define getDepJumpInstr(a, to, pc) ((a&0xffc00000)|(((to-pc)/4)&0x003fffff))
-#define getUndepJumpInstr(a, to, pc) ((a&0xfff80000)|(((to-pc)/4)&0x0007ffff))
-
-const int globalMemSize = 10000;
+class VirtualMem;
+class MemoryManager;
class TraceCache{
private:
@@ -48,99 +21,71 @@
std::map<int, uint64_t> traceId;
std::map<uint64_t, int> reverseTraceId;
+ std::map<uint64_t, std::pair<unsigned int, unsigned int> >
+ tracesFirstInstruction;
+
std::map<uint64_t, uint64_t> reverseMap; //map frm trace addr to original addr
//for a given outgoing address (outside trace cache),
//the addresses IN THE trace cache
//that point to that address
- std::map<uint64_t, std::vector<uint64_t> > outMaps;
+ //std::map<uint64_t, std::vector<uint64_t> > outMaps;
//same for incoming addresses
- std::map<uint64_t, std::vector<uint64_t> > inMaps;
+ //std::map<uint64_t, std::vector<uint64_t> > inMaps;
std::list<uint64_t> allocationOrder;
bool isLimitSet; //this must be set during initialization!!!
- int limit, currSize, fp; //fp is file pointer
-
- uint64_t memStart, memEnd;
+ int limit, currSize; //fp is file pointer
//gets addr of target in branch
- //uint64_t getBranchAddr(const std::pair<uint64_t, uint64_t> &n);
+ uint64_t getBranchAddr(const std::pair<uint64_t, uint64_t> &n);
//change every address in F pointing to frm to "to"
void changeAddr(uint64_t frm, uint64_t to);
- //Memory management: right now very trivial
- //list of free memory ranges: sorted order
- std::list<std::pair<uint64_t, uint64_t> > freeMemList;
- void memoryInitialize(); //initialize
- uint64_t getMemory(int sz); //return a pointer to memory of size sz
- void freeTraceMemory(uint64_t toRemove, int size);//size is no if instructions
-
//reading/modifying process space VM
- void intializeVM();
- void copyToVM(unsigned int trace[],
- uint64_t traceStartAddr, int sz);
- unsigned int readInstrFrmVm(uint64_t frm);
- void writeInstToVM(uint64_t dest, unsigned int newInstr);
+ //void intializeVM();
+ //void copyToVM(unsigned int trace[],
+ // uint64_t traceStartAddr, int sz);
+ //unsigned int readInstrFrmVm(uint64_t frm);
+ //void writeInstToVM(uint64_t dest, unsigned int newInstr);
public:
+ void setLimit(int n);
+ int getLimit() { return limit;}
+
+ bool hasMaxSize(){ return isLimitSet;}
+ bool hasTraceAddr(uint64_t n){ return (traces.find(n)!=traces.end()); }
+ bool hasTraceId(int n) { return (traceId.find(n)!=traceId.end()); }
+
//constructors
- //if trace is to have smaller size than the default size
TraceCache(int limitSize);
- //if trace is to have default size (of 10K instructions)
TraceCache();
//add trace of a given size
- //return false if cannot allocate
-
- //Arguments:
- // instAddr: the address of start of trace in the ORIGINAL machine code
- // trace[]: an array of "instructions"
- // sz: size of trace[]
- // inBranches: the Addressess of instructions in the ORIGINAL code which
- // have branch targets as instAddr
- // outBranches: the Address of instructions inserted in the trace
- // (e.g. &trace[3], &trace[7] etc) which have branches/jumps
- // traceUnisId: some unique number for identifying the trace: ordinarily,
- // instAddr will be used to identify the trace, but sometimes
- // another identification can be used for the trace, such as
- // "path no". In this case, traceUnisId must be path_no.
-
- // Note that only one trace can exist in the trace cachestarting with a given
- // instAddr. To add another trace with same instAddr, the earlier trace MUST
- // be removed first!
- bool addTrace(uint64_t instAddr, unsigned int trace[], int sz,
- std::vector<uint64_t> &inBranches,
- std::vector<std::pair<uint64_t, uint64_t> > &outBranches,
- int traceUniqId);
+ //return null if cannot allocate
+ //return an address where trace can be allocated otherwise
+ //the trace allocation is done by the calling program:starting
+ //at the address returned. The trace cache stiches the program
+ //addresses to jump to the new location for addresses that use the
+ //basic block bb as target
+
+ bool addTrace(uint64_t instAddr,
+ std::vector<unsigned int> &trace,
+ int traceUniqId,
+ std::map<int, uint64_t> &callMap,
+ std::map<int, uint64_t> &branchMap);
+
+ //bool addTrace(uint64_t instAddr, unsigned int trace[], int sz,
+ // std::vector<uint64_t> &inBranches,
+ // std::vector<std::pair<uint64_t, uint64_t> > &outBranches, int traceUniqId);
- //remove trace starting with address n (this wil lbe instAddr of the trace
- //added earlier.
+ //remove trace starting with address n
void removeTrace(uint64_t n);
- //reset limit of a trace whose limit was set earlier. This
- //new limit MUST NOT be smaller than "current" size of trace (sum of traces
- // currently in trace)
- void setLimit(int n);
-
- //get the size of trace
- int getLimit() { return limit;}
-
- //if trace has a max size
- bool hasMaxSize(){ return isLimitSet;}
-
- //Does the traceCache contain a trace starting with a given instAddr
- //instAddr is the address in the original machine code
- bool hasTraceAddr(uint64_t instAddr){
- return (traces.find(instAddr)!=traces.end());
- }
-
- //Does the traceCache have a trace with given uniqueID
- bool hasTraceId(int n) { return (traceId.find(n)!=traceId.end()); }
-
- uint64_t getBranchAddr(const std::pair<uint64_t, uint64_t> &n);
-
+ VirtualMem *vm;
+ MemoryManager *mm;
};
#endif
More information about the llvm-commits
mailing list