[llvm-commits] CVS: reopt/lib/TraceCache/InstrUtils.cpp MemoryManager.cpp TraceCache.cpp VirtualMem.cpp

Brian Gaeke gaeke at cs.uiuc.edu
Wed Nov 19 16:53:11 PST 2003


Changes in directory reopt/lib/TraceCache:

InstrUtils.cpp updated: 1.14 -> 1.15
MemoryManager.cpp updated: 1.12 -> 1.13
TraceCache.cpp updated: 1.18 -> 1.19
VirtualMem.cpp updated: 1.13 -> 1.14

---
Log message:

Put reoptimizer code into 'llvm' namespace.
Other minor cleanups.


---
Diffs of the changes:  (+16 -34)

Index: reopt/lib/TraceCache/InstrUtils.cpp
diff -u reopt/lib/TraceCache/InstrUtils.cpp:1.14 reopt/lib/TraceCache/InstrUtils.cpp:1.15
--- reopt/lib/TraceCache/InstrUtils.cpp:1.14	Mon Oct 20 12:36:55 2003
+++ reopt/lib/TraceCache/InstrUtils.cpp	Wed Nov 19 16:51:51 2003
@@ -9,6 +9,8 @@
 #include <cassert>
 #include <iostream>
 
+namespace llvm {
+
 uint64_t getBranchTarget(unsigned br, uint64_t pc){
   if(isNonDepJump(br))
     return getNonDepJmpTarget(br, pc);
@@ -202,3 +204,5 @@
 	  ((inst & 0xffffffff) == 0x81c7e008) ||
 	  ((inst & 0xffffffff) == 0x81c3e008));
 }
+
+} // end namespace llvm


Index: reopt/lib/TraceCache/MemoryManager.cpp
diff -u reopt/lib/TraceCache/MemoryManager.cpp:1.12 reopt/lib/TraceCache/MemoryManager.cpp:1.13
--- reopt/lib/TraceCache/MemoryManager.cpp:1.12	Mon Oct 27 13:00:29 2003
+++ reopt/lib/TraceCache/MemoryManager.cpp	Wed Nov 19 16:51:51 2003
@@ -28,7 +28,7 @@
 #include <cassert>
 #include <iostream>
 
-using std::cerr;
+using namespace llvm;
 
 MemoryManager::MemoryManager(){
   uint64_t memAlign = (uint64_t)(intptr_t)&FirstTraceFunction;
@@ -45,7 +45,6 @@
   freeMemList.push_back(std::make_pair(memStart, memEnd));
 }
 
-
 MemoryManager::MemoryManager(unsigned int memSize){
   uint64_t memAlign = (uint64_t)(intptr_t)&FirstTraceFunction;
   if(memAlign % 32){
@@ -74,9 +73,9 @@
   freeMemList.push_back(std::make_pair(memStart, memEnd));
 }
 
-
 //allocate the first free memory
 //returns 0 if no memory can be assigned
+//
 uint64_t MemoryManager::getMemory(int sz){
   //find a pair in freeMemList whose range>sz
 


Index: reopt/lib/TraceCache/TraceCache.cpp
diff -u reopt/lib/TraceCache/TraceCache.cpp:1.18 reopt/lib/TraceCache/TraceCache.cpp:1.19
--- reopt/lib/TraceCache/TraceCache.cpp:1.18	Fri Aug 22 12:43:42 2003
+++ reopt/lib/TraceCache/TraceCache.cpp	Wed Nov 19 16:51:52 2003
@@ -19,6 +19,7 @@
 //#define GET_ALL_INFO
 
 using std::cerr;
+using namespace llvm;
 
 TraceCache::TraceCache(int limitSize){
   mm = new MemoryManager();
@@ -32,7 +33,6 @@
   vm = new VirtualMem();
 }
 
-
 TraceCache::TraceCache(){
   mm = new MemoryManager();
 
@@ -63,7 +63,6 @@
   vm = vmem;
 }
 
-
 TraceCache::TraceCache(void (*dfunc)(), unsigned int memSize, 
 		       VirtualMem *vmem){
   mm = new MemoryManager(dfunc, memSize);
@@ -93,7 +92,6 @@
     return 0;
 }
 
-
 unsigned int TraceCache::getAddr(uint64_t addr){
     if(hasTraceInstructions(addr))
        return traceInstructions[addr][0];
@@ -118,10 +116,11 @@
 //has address instrAddr in the original program
 //size of array is sz (number of instructions)
 // returns false if cannot assign space to trace
-
-////USING THIS
+//
+//USING THIS
 //Do the following:
 //1. Insert a jump at location instrAddr with target as new trace
+//
 bool TraceCache::addTrace(uint64_t &instAddr,
 			  uint64_t &endAddr,
 			  std::vector<unsigned int> &trace, 
@@ -360,7 +359,6 @@
   
   return true;
 }
-
   
 //#undef GET_TRACE_TIME
 
@@ -432,6 +430,7 @@
 //USING THIS
 //Do the following:
 //1. Insert a jump at location instrAddr with target as new trace
+//
 bool TraceCache::addTrace(uint64_t instAddr,
 			  uint64_t endAddr,
 			  std::vector<unsigned int> &trace, 


Index: reopt/lib/TraceCache/VirtualMem.cpp
diff -u reopt/lib/TraceCache/VirtualMem.cpp:1.13 reopt/lib/TraceCache/VirtualMem.cpp:1.14
--- reopt/lib/TraceCache/VirtualMem.cpp:1.13	Sat Sep 13 16:12:14 2003
+++ reopt/lib/TraceCache/VirtualMem.cpp	Wed Nov 19 16:51:52 2003
@@ -11,6 +11,8 @@
 #include "reopt/GetTraceTime.h"
 #include <cassert>
 
+using namespace llvm;
+
 VirtualMem::VirtualMem(){
   //open file pointer
   char ctr[25];
@@ -52,21 +54,6 @@
   return instr;
 }
 
-/*
-unsigned int VirtualMem::readInstrFrmVm(uint64_t frm, TraceCache *tr){
-  unsigned int instr=0;
-
-  instr = tr->getAddr(frm);
-  if(instr)
-      return instr;      
-
-  lseek(fp, frm, SEEK_SET);
-
-  read(fp, &instr, 4);
-  return instr;
-}
-*/
-
 unsigned int VirtualMem::readInstrFrmVm(uint64_t frm, TraceCache *tr, 
 					TraceCache *tr2){
   unsigned int instr=0;
@@ -93,7 +80,7 @@
 //two kinds of branches being handled for now
 //BIcc, and BPcc instructions
 //(sparcV9 manual, pg 146-150)
-
+//
 void VirtualMem::changeBranchTarget(uint64_t frm, uint64_t to){ 
   unsigned int instr = readInstrFrmVm(frm);
   //std::cerr<<"Instruction at: "<<(void *)frm<<" Is:"<<(void *)instr<<"\n";
@@ -122,7 +109,6 @@
   }
 }
 
-
 uint64_t VirtualMem::getBranchTarget(const std::pair<uint64_t, uint64_t> &n){
   
   unsigned int instr = readInstrFrmVm(n.second);
@@ -142,6 +128,7 @@
 }
 
 //write branch inst, followed by a null inst in delay slot
+//
 void VirtualMem::writeBranchInstruction(uint64_t location, uint64_t target){
   //uint64_t instToWrite = getDepJumpInstr(0x10800000, target, location);
   //create branch will annul bit set
@@ -152,6 +139,7 @@
 
 #ifdef GET_TRACE_TIME
 //write call instruction to llvm_start_time, followed by nop
+//
 void VirtualMem::writeCallLLVMTime(uint64_t instAddr){
   unsigned int callInst = getCallInstr((uint64_t)(intptr_t)&llvm_time_start, instAddr);
   writeInstToVM(instAddr, callInst);
@@ -161,7 +149,6 @@
 
 void VirtualMem::setBranches(std::map<int, int> &branchMap, 
                              uint64_t startAddr){
-  
   for(std::map<int, int>::iterator MI = branchMap.begin(), 
         ME = branchMap.end(); MI != ME; ++MI){
 
@@ -172,16 +159,13 @@
     
     //check if instr is a branch
     assert(isBranchInstr(instr) && "Not a jump instruction");
-
     unsigned int newInstr = getBranchInst(instr, to , frm);
-    
     writeInstToVM(frm, newInstr);
   }
 }
 
 void VirtualMem::setBranches(std::map<int, uint64_t> &branchMap, 
                              uint64_t startAddr){
-
   //std::cerr<<"In branch map!\n";
   for(std::map<int, uint64_t>::iterator MI = branchMap.begin(), 
         ME = branchMap.end(); MI != ME; ++MI){
@@ -194,16 +178,13 @@
     
     //check if instr is a branch
     assert(isBranchInstr(instr) && "Not a jump instruction");
-
     unsigned int newInstr = getBranchInst(instr, to , frm);
-    
     writeInstToVM(frm, newInstr);
   }
 }
 
 void VirtualMem::setCalls(std::map<int, uint64_t> &callMap, 
                                uint64_t startAddr){
-  
   for(std::map<int, uint64_t>::iterator MI = callMap.begin(), 
         ME = callMap.end(); MI != ME; ++MI){
     
@@ -223,7 +204,6 @@
 }
 
 unsigned int VirtualMem::getInvertedBranch(unsigned int br1){
-
   assert(isBranchInstr(br1) && "Not a branch!");
   unsigned int cond = 0;
  





More information about the llvm-commits mailing list