[llvm-commits] CVS: llvm/lib/Reoptimizer/TraceCache/InstrUtils.cpp
Anand Shukla
ashukla at cs.uiuc.edu
Sat Sep 21 00:04:01 PDT 2002
Changes in directory llvm/lib/Reoptimizer/TraceCache:
InstrUtils.cpp updated: 1.4 -> 1.5
---
Log message:
added exit stubs for outgoing branches!
---
Diffs of the changes:
Index: llvm/lib/Reoptimizer/TraceCache/InstrUtils.cpp
diff -u llvm/lib/Reoptimizer/TraceCache/InstrUtils.cpp:1.4 llvm/lib/Reoptimizer/TraceCache/InstrUtils.cpp:1.5
--- llvm/lib/Reoptimizer/TraceCache/InstrUtils.cpp:1.4 Fri Sep 20 13:52:47 2002
+++ llvm/lib/Reoptimizer/TraceCache/InstrUtils.cpp Sat Sep 21 00:03:55 2002
@@ -12,6 +12,33 @@
#include <assert.h>
#include <iostream>
+uint64_t getBranchTarget(unsigned int br, uint64_t pc){
+ if(isNonDepJump(br))
+ return getNonDepJmpTarget(br, pc);
+ else if(isDepJump(br))
+ return getDepJmpTarget(br, pc);
+ else if(isBPR(br))
+ return getBPRTarget(br, pc);
+ else{
+ std::cerr<<(void *)br<<"\n";
+ assert(false && "This branch not handled!");
+ }
+}
+
+unsigned int getBranchInst(unsigned int br, uint64_t to, uint64_t frm){
+ if(isNonDepJump(br))
+ return getUndepJumpInstr(br, to, frm);
+ else if(isDepJump(br))
+ return getDepJumpInstr(br, to, frm);
+ else if(isBPR(br))
+ return getBPRInstr(br, to, frm);
+ else{
+ std::cerr<<(void *)br<<"\n";
+ assert(false && "This branch not handled!");
+ }
+}
+
+
bool isNonDepJump(unsigned int y){
return ((y & 0x01c00000) == 4194304);
}
@@ -30,16 +57,11 @@
unsigned int getUndepJumpInstr(unsigned int a, uint64_t to, uint64_t pc){
- if(to>pc){
- if((to-pc)/4>262143)
- return getDepJumpInstr((a&0xfe3fffff)|8388608, to, pc);
- }
- else{
- if((pc-to)/4>262143)
- return getDepJumpInstr((a&0xfe3fffff)|8388608, to, pc);
- }
+ if(to>pc)
+ assert((to-pc)/4<262144 && "Can't fit target!");
+ else
+ assert((pc-to)/4<262144 && "Can't fit target!");
- //assert((((to-pc)/4)&(262143) < 262144) && "Can't fit target!"); //2^18
unsigned int diff = (((to-pc)/4)&0x3ffff);
unsigned int sgn=0;
if(to<pc)
@@ -64,6 +86,26 @@
}
+uint64_t getBPRTarget(unsigned int b, uint64_t oldAdd){
+ return (oldAdd+4*(((b&2097152)==2097152)?(0xffffffffffff0000|((b&3145728)>>6)|(b&16383)):(((b&3145728)>>6)|(b&16383))));
+}
+
+unsigned int getBPRInstr(unsigned int b, uint64_t to, uint64_t frm){
+
+ if(to>frm)
+ assert((to-frm)/4 < 32768 && "Target out of range!");
+ else
+ assert((frm-to)/4 < 32768 && "Target out of range!");
+
+ //frame = 2^32-1-(2^21+2^20+2^14-1)
+ unsigned int frame = b&4291805184;
+ uint64_t target = (to-frm)/4;
+
+ unsigned int hi = ((target & (2147483648))>>10)|((target&(16384))<<6);
+ unsigned lo = target&(16383);
+ return (frame|hi|lo);
+}
+
//TODO: put assert to check branch destinations!
//TODO: Take out sign bit in branch instr
//unsigned int getDepJumpInstr(unsigned int a, uint64_t to, uint64_t pc){
@@ -111,20 +153,8 @@
return ( (b&0x01c00000) == 0x00c00000);
}
-uint64_t getBPRTarget(unsigned int b, uint64_t oldAdd){
- return (oldAdd+4*(((b&2097152)==2097152)?(0xffffffffffff0000|((b&3145728)>>6)|(b&16383)):(((b&3145728)>>6)|(b&16383))));
-}
-
-// unsigned int getBPRInstr(unsigned int b, uint64_t to, uint64_t frm){
-// //frame = 2^32-1-(2^21+2^20+2^14-1)
-// unsigned int frame = b&4291805184;
-// uint64_t target = (to-frm)/4;
-// assert((target&(2147483647))<32768 && "Target out of range!");
-// unsigned int hi = ((target & (2147483648))>>10)|((target&(16384))<<6);
-// unsigned lo = target&(16383);
-// return (frame|hi|lo);
-// }
+/*
std::pair<unsigned int, unsigned int> getBPRInstr(unsigned int b, uint64_t to,
uint64_t frm){
@@ -159,8 +189,7 @@
return std::make_pair(cmp, inst);
}
-
-
+*/
bool isBranchInstr(unsigned int y){
return (((y & 0xc0000000) == 0) && (isBPR(y) || isNonDepJump(y) || isDepJump(y)));
More information about the llvm-commits
mailing list