[llvm-commits] CVS: llvm/lib/Reoptimizer/TraceCache/VirtualMem.cpp
Anand Shukla
ashukla at cs.uiuc.edu
Fri Feb 14 14:46:04 PST 2003
Changes in directory llvm/lib/Reoptimizer/TraceCache:
VirtualMem.cpp updated: 1.8 -> 1.9
---
Log message:
Changes to runtime framework
---
Diffs of the changes:
Index: llvm/lib/Reoptimizer/TraceCache/VirtualMem.cpp
diff -u llvm/lib/Reoptimizer/TraceCache/VirtualMem.cpp:1.8 llvm/lib/Reoptimizer/TraceCache/VirtualMem.cpp:1.9
--- llvm/lib/Reoptimizer/TraceCache/VirtualMem.cpp:1.8 Mon Jan 27 17:41:43 2003
+++ llvm/lib/Reoptimizer/TraceCache/VirtualMem.cpp Fri Feb 14 14:45:42 2003
@@ -6,6 +6,9 @@
#include "llvm/Reoptimizer/VirtualMem.h"
#include "llvm/Reoptimizer/InstrUtils.h"
+#include "llvm/Reoptimizer/TraceCache.h"
+#include "llvm/Reoptimizer/TraceCache2.h"
+#include "llvm/Reoptimizer/GetTraceTime.h"
VirtualMem::VirtualMem(){
//open file pointer
@@ -35,6 +38,52 @@
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, TraceCache2 *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, TraceCache2 *tr2){
+ unsigned int instr=0;
+
+ instr = tr->getAddr(frm);
+ if(instr)
+ return instr;
+
+ instr = tr2->getAddr(frm);
+ if(instr)
+ return instr;
+
+ lseek(fp, frm, SEEK_SET);
+
+ read(fp, &instr, 4);
+ return instr;
+}
+
void VirtualMem::writeInstToVM(uint64_t dest, unsigned int newInstr){
lseek(fp, dest, SEEK_SET);
write(fp, &newInstr, 4);
@@ -128,6 +177,26 @@
}
}
+void VirtualMem::setBranches(std::map<int, uint64_t> &branchMap,
+ uint64_t startAddr){
+
+ for(std::map<int, uint64_t>::iterator MI = branchMap.begin(),
+ ME = branchMap.end(); MI != ME; ++MI){
+
+ uint64_t frm = startAddr+ 4*MI->first;
+ uint64_t to = MI->second;
+
+ unsigned int instr = readInstrFrmVm(frm);
+
+ //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){
@@ -141,8 +210,9 @@
//check if instr is a branch
assert(isCallInstr(instr) && "Not a jump instruction");
- uint64_t callTarget = getCallTarget(instr, MI->second);
- unsigned int newInstr = getCallInstr(callTarget, frm);
+ //uint64_t callTarget = getCallTarget(instr, MI->second);
+ // unsigned int newInstr = getCallInstr(callTarget, frm);
+ unsigned int newInstr = getCallInstr(MI->second, frm);
writeInstToVM(frm, newInstr);
//std::cerr<<"New instruction:"<<(void *)newInstr<<"\n";
}
More information about the llvm-commits
mailing list