[llvm-commits] CVS: llvm/lib/Reoptimizer/TraceCache/VirtualMem.cpp
Anand Shukla
ashukla at cs.uiuc.edu
Sat Sep 21 00:05:10 PDT 2002
Changes in directory llvm/lib/Reoptimizer/TraceCache:
VirtualMem.cpp updated: 1.3 -> 1.4
---
Log message:
added exit stubs for outgoing branches!
---
Diffs of the changes:
Index: llvm/lib/Reoptimizer/TraceCache/VirtualMem.cpp
diff -u llvm/lib/Reoptimizer/TraceCache/VirtualMem.cpp:1.3 llvm/lib/Reoptimizer/TraceCache/VirtualMem.cpp:1.4
--- llvm/lib/Reoptimizer/TraceCache/VirtualMem.cpp:1.3 Fri Sep 20 12:11:09 2002
+++ llvm/lib/Reoptimizer/TraceCache/VirtualMem.cpp Sat Sep 21 00:04:04 2002
@@ -97,45 +97,23 @@
writeInstToVM(location+4, 0x01000000);
}
-void VirtualMem::setBranches(std::map<int, uint64_t> &branchMap,
+void VirtualMem::setBranches(std::map<int, int> &branchMap,
uint64_t startAddr){
- for(std::map<int, uint64_t>::iterator MI = branchMap.begin(),
+ for(std::map<int, int>::iterator MI = branchMap.begin(),
ME = branchMap.end(); MI != ME; ++MI){
- int index = MI->first;
- uint64_t frm = startAddr+4*index;
+
+ uint64_t frm = startAddr+ 4*MI->first;
+ uint64_t to = startAddr + 4*MI->second;
+
unsigned int instr = readInstrFrmVm(frm);
//check if instr is a branch
assert(isBranchInstr(instr) && "Not a jump instruction");
- if(isNonDepJump(instr)){
- uint64_t branchTarget = getNonDepJmpTarget(instr, MI->second);
- unsigned int newInstr = getUndepJumpInstr(instr, branchTarget, frm);
- writeInstToVM(frm, newInstr);
- //std::cerr<<"New instruction:"<<(void *)newInstr<<"\n";
- }
- else if(isDepJump(instr)){
- uint64_t branchTarget = getDepJmpTarget(instr, MI->second);
- unsigned int newInstr = getDepJumpInstr(instr, branchTarget, frm);
- writeInstToVM(frm, newInstr);
- //std::cerr<<"New instruction:"<<(void *)newInstr<<"\n";
- }
- else if(isBPR(instr)){
- uint64_t branchTarget = getBPRTarget(instr, MI->second);
-
- std::pair<unsigned int, unsigned int> newInstr =
- getBPRInstr(instr, branchTarget, frm);
- //unsigned int newInstr = getBPRInstr(instr, branchTarget, frm);
- writeInstToVM(frm, newInstr.first);
- writeInstToVM(frm+4, newInstr.second);
- //std::cerr<<"New instruction:"<<(void *)newInstr.first<<"\t"<<(void *)newInstr.second<<"\n";
- }
- else{
- //std::cerr<<(void *) instr<<"\n";
- assert(0 && "This jump/branch not yet handled!");
- }
-
+ unsigned int newInstr = getBranchInst(instr, to , frm);
+
+ writeInstToVM(frm, newInstr);
}
}
@@ -159,120 +137,39 @@
}
}
-std::pair<unsigned int, unsigned int> VirtualMem::getInvertedBranch(uint64_t br1, uint64_t br2){
+unsigned int VirtualMem::getInvertedBranch(uint64_t br1){
- assert(isBranchInstr(br1) && isBranchInstr(br2) && "Not a branch!");
-
- unsigned int cmp = 0;
+ assert(isBranchInstr(br1) && "Not a branch!");
unsigned int cond = 0;
- //check if br1 is a predicated branch
+
+ //check if br1 is a predicated branch
if(isBPR(br1)){
- //assign a condition code instruction
- cmp = 0x80a02000; //skeleton
- //fill in register!
- cmp = cmp|(br1&507904);//cmp|(br1&(2^18+2^17+2^16+2^15+2^14))
-
cond = (br1&0x0e000000)>>25;
assert(cond !=4 && cond!=0 && cond<8 &&
"Incorrect cond codes for BPR Instruction!");
- //get cond codes for simple branches (BIcc)!
- if(cond>4)
+ //get inverted cond!
+ if(cond<4)
cond+=4;
+ else
+ cond %= 4;
+
+ cond = cond << 25;
+ //mask with 2^32-1-2^25-2^26-2^27
+ return (br1 & 4060086271) | cond;
}
- else
- cond = (br1&0x1e000000)>>25;
-
- assert( (isDepJump(br2) || isNonDepJump(br2)) &&
- "br2 must be non-predicated jump!");
- //mask with 2^32-1-2^25-2^26-2^27-2^28
- unsigned int inst = (br2 & 3791650815U);
+ cond = (br1&0x1e000000)>>25;
//reverse cond
if(cond<8)
cond+=8;
else
- cond = cond%8;
+ cond %= 8;
- inst = inst|(cond<<25);
- return std::make_pair(cmp, inst);
+ cond = cond << 25;
- // unsigned int cond2 = (br2&0x1e000000)>>25; //br2 has to be normal branch
- // assert((cond2==8 || cond2==0) &&
- // "Can only handle case where second branch is unconditional!");
-
-
- // //mask with 2^32-1-2^25-2^26-2^27-2^28
- // unsigned int inst = (br1&3791650815)|reverse;
-
-
- //if(isNonDepJump(br2)){
- // unsigned int inst = (br2&4294443008);//br2&(2^32-1-2^19+1)
- // inst = inst|((br1&3145728)>>6
- // //hi = (br2&(2^18))<<3 | (br2&(2^14))<<6
- // unsigned int hi = ((br2&262144)<<3)|((br2&16384)<<6);
- // unsigned int lo = br2&16383;//2^14-1
- // inst = hi|lo;
- //}
- //else{
- //mask with 2^20+2^19...+2^15
- //assert( (br2&2064384) == 0 &&
- // "Target can not be fitted into br target!");
-
- //hi = br2&2^21 | (br2&2^14)<<6
- //unsigned int hi = (br2&2097152) | ((br2&16384)<<6);
- //unsigned int lo = br2&16383;//2^14-1
- //inst = hi|lo;
- //}
-
- //newBr = (br1 & (0xffffffff - (2^27+2^26+2^25))) &
- //(0xffffffff - (2^21+2^20+2^14-1)
- //unsigned int newBr = (br1 & 4060086271) & 4291805184;
- //newBr = (newBr|reverse)|inst;
- //return newBr;
- //}
-
-
- // std::cerr<<"Br1: "<<(void *)br1<<"\t\tBr2: "<<(void *)br2<<"\n";
- // //assert((isDepJump(br1) && isDepJump(br2)) ||
- // // (isNonDepJump(br1) && isNonDepJump(br2)) &&
- // // "Branches with different target lengths!");
-
-
- // unsigned int cond = (br1&0x1e000000)>>25;
- // unsigned int cond2 = (br2&0x1e000000)>>25;
- // unsigned int reverse = 0;
-
- // //check that second branch is unconditional!
- // assert( (cond2==8 || cond2==0) &&
- // "Can only handle case where second branch is unconditional!");
-
- // assert(cond<=15 && "branch code has to be in range 0-15");
-
- // if(cond <8)
- // reverse = cond+8;
- // else
- // reverse = cond%8;
-
- // reverse = reverse<<25;
- // unsigned int inst = 0;
-
- // if(isDepJump(br1) && isDepJump(br2)){
- // // br2&(oxffffffff - (2^25+2^26+2^27+2^28) - (2^22-1)) | (br1&(2^22-1)
- // inst = ((br2&3787456512)|reverse)|(br1&4194303);
- // }
- // else if(isNonDepJump(br1) && isNonDepJump(br2)) {
- // // br2&(oxffffffff - (2^25+2^26+2^27+2^28) - (2^19-1)) | (br1&(2^19-1)
- // inst = ((br2&3791126528)|reverse)|(br1&524287);
- // }
- // else if(isDepJump(br1) && isNonDepJump(br2)){
- // assert((br1&1835008)==0 && "Target can't fit in undeprecated branch!");
- // inst = ((br2&3791126528)|reverse)|(br1&4194303);
- // }
- // else if(isNonDepJump(br1) && isDepJump(br2)){
- // inst = ((br2&3787456512)|reverse)|(br1&524287);
- // }
- // return inst;
+ //mask with 2^32-1-2^25-2^26-2^27-2^28
+ return (br1 & 3791650815U)|(cond);
}
More information about the llvm-commits
mailing list