[llvm-commits] CVS: reopt/lib/TraceCache/InstrUtils.cpp
Brian Gaeke
gaeke at cs.uiuc.edu
Fri Apr 23 15:11:03 PDT 2004
Changes in directory reopt/lib/TraceCache:
InstrUtils.cpp updated: 1.15 -> 1.16
---
Log message:
Make doFlush() round down addresses to the next doubleword boundary correctly.
Document getDepJumpInstr().
---
Diffs of the changes: (+19 -9)
Index: reopt/lib/TraceCache/InstrUtils.cpp
diff -u reopt/lib/TraceCache/InstrUtils.cpp:1.15 reopt/lib/TraceCache/InstrUtils.cpp:1.16
--- reopt/lib/TraceCache/InstrUtils.cpp:1.15 Wed Nov 19 16:51:51 2003
+++ reopt/lib/TraceCache/InstrUtils.cpp Fri Apr 23 15:10:35 2004
@@ -70,15 +70,25 @@
return ((a&0xfff80000U)|diff|sgn);
}
-unsigned int getDepJumpInstr(unsigned int a, uint64_t to, uint64_t pc){
- if(to>pc)
- assert((to-pc)/4<2097152 && "Can't fit target!");
+/// getDepJumpInstr - Returns a PC-relative branch instruction from
+/// address FROM to address TO of the same conditionality (BA, BN, BNE, BE,
+/// BG...) as INSTR. INSTR must be a Bicc instruction (branch on integer
+/// condition codes with no prediction), and FROM must be its address in
+/// memory.
+///
+unsigned int getDepJumpInstr(unsigned int instr, uint64_t to, uint64_t from) {
+ if(to>from)
+ assert((to-from)/4<2097152 && "Can't fit target!");
else
- assert((pc-to)/4<2097152 && "Can't fit target!");
+ assert((from-to)/4<2097152 && "Can't fit target!");
- unsigned int diff = (((to-pc)/4)&0x1fffff);
- unsigned int sgn = ((to < pc) ? (1 << 21) : 0);
- return ((a&0xffc00000)|diff|sgn);
+ // Compute new 22-bit PC-relative branch target.
+ unsigned int diff = ((to - from) / 4) & 0x1fffff;
+ unsigned int sgn = ((to < from) ? (1 << 21) : 0);
+
+ // Mask out the instruction's old branch target, OR in the new one,
+ // and return it.
+ return ((instr&0xffc00000)|diff|sgn);
}
uint64_t getBPRTarget(unsigned int b, uint64_t oldAdd){
@@ -149,8 +159,8 @@
void doFlush(uint64_t st_addr, uint64_t end_addr){
#ifdef __sparc__
- if(st_addr%8 != 0)
- st_addr -=4;
+ if(st_addr % 8 != 0)
+ st_addr &= ~7; // Round down to the next lower doubleword boundary
for(uint64_t i = st_addr; i<=end_addr; i+=8){
asm("flush %0"::"r" (i));
}
More information about the llvm-commits
mailing list