[llvm-commits] CVS: llvm/lib/Reoptimizer/TraceCache/InstrUtils.cpp
Anand Shukla
ashukla at cs.uiuc.edu
Fri Sep 20 12:12:00 PDT 2002
Changes in directory llvm/lib/Reoptimizer/TraceCache:
InstrUtils.cpp updated: 1.2 -> 1.3
---
Log message:
Minor changes: such as removing debug info
---
Diffs of the changes:
Index: llvm/lib/Reoptimizer/TraceCache/InstrUtils.cpp
diff -u llvm/lib/Reoptimizer/TraceCache/InstrUtils.cpp:1.2 llvm/lib/Reoptimizer/TraceCache/InstrUtils.cpp:1.3
--- llvm/lib/Reoptimizer/TraceCache/InstrUtils.cpp:1.2 Sun Sep 15 17:33:48 2002
+++ llvm/lib/Reoptimizer/TraceCache/InstrUtils.cpp Fri Sep 20 12:10:57 2002
@@ -4,6 +4,11 @@
//
//===----------------------------------------------------------------------===//
+//This file uses gcc 3.1 specific syntax
+//So to compile it with gcc 3.1
+//Remove #if 0 and corresponding #endif if gcc version is 3.1
+//#if 0
+
#include "llvm/Reoptimizer/InstrUtils.h"
#include <assert.h>
#include <iostream>
@@ -17,52 +22,66 @@
}
uint64_t getNonDepJmpTarget(unsigned int y, uint64_t oldAdd){
- return (oldAdd+4ull*(((y&262144ull)==262144ull) ? ((y&0x0007ffffull)|0xfffffffffff80000ull) : (y&0x0007ffffull)));
+ return (oldAdd+4*(((y&262144)==262144) ? ((y&0x0007ffff)|0xfffffffffff80000) : (y&0x0007ffff)));
}
uint64_t getDepJmpTarget(unsigned int y, uint64_t oldAdd){
- return (oldAdd+4ull*(((y&2097152ull)==2097152ull) ? ((y&0x003fffffull)|0xffffffffffc00000ull) : (y&0x003fffffull)));
+ return (oldAdd+4*(((y&2097152)==2097152) ? ((y&0x003fffff)|0xffffffffffc00000) : (y&0x003fffff)));
}
-/*
+
unsigned int getUndepJumpInstr(unsigned int a, uint64_t to, uint64_t pc){
- assert((((to-pc)/4)&(2^18-1) < 2^18) && "Can't fit target!");
+ 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);
+ }
+
+ //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)
- sgn = 2^18;
+ sgn = 262144;
return ((a&0xfff80000)|diff|sgn);
}
-*/
-/*
+
+
unsigned int getDepJumpInstr(unsigned int a, uint64_t to, uint64_t pc){
- assert((((to-pc)/4)&(2^21-1) < 2^21) && "Can't fit target!");
+ //assert((((to-pc)/4)&(2097151) < 2097152) && "Can't fit target!");
+ if(to>pc)
+ assert((to-pc)/4<2097152 && "Can't fit target!");
+ else
+ assert((pc-to)/4<2097152 && "Can't fit target!");
+
unsigned int diff = (((to-pc)/4)&0x1fffff);
unsigned int sgn=0;
if(to<pc)
- sgn = 2^21;
+ sgn = 2097152;
return ((a&0xffc00000)|diff|sgn);
}
-*/
+
//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){
- return ((a&0xffc00000)|(((to-pc)/4)&0x003fffff));
-}
-
-unsigned int getUndepJumpInstr(unsigned int a, uint64_t to, uint64_t pc){
- return ((a&0xfff80000)|(((to-pc)/4)&0x0007ffff));
-}
+//unsigned int getDepJumpInstr(unsigned int a, uint64_t to, uint64_t pc){
+//return ((a&0xffc00000)|(((to-pc)/4)&0x003fffff));
+//}
+
+//unsigned int getUndepJumpInstr(unsigned int a, uint64_t to, uint64_t pc){
+//return ((a&0xfff80000)|(((to-pc)/4)&0x0007ffff));
+//}
bool isCallInstr(unsigned int a){
return ((a & 0xc0000000) == 0x40000000);
}
uint64_t getCallTarget(unsigned int y, uint64_t oldAdd){
- uint64_t toRet = (oldAdd + 4ull*(((y&536870912ull)==536870912ull)?(0xffffffffc0000000ull|(y&0x3fffffffull)):(y&0x3fffffffull)));
- std::cerr<<"\t\t\tCall Target:"<<(void *)toRet<<"\n";
+ uint64_t toRet = (oldAdd + 4*(((y&536870912)==536870912)?(0xffffffffc0000000|(y&0x3fffffff)):(y&0x3fffffff)));
+ //std::cerr<<"\t\t\tCall Target:"<<(void *)toRet<<"\n";
return toRet;
}
@@ -74,8 +93,8 @@
if(to<pc)
sgn = 2^29;
unsigned int inst = (0x40000000|diff|sgn);
- std::cerr<<"to: "<<(void *)to<<"\t frm: "<<(void *)pc
- <<"\t inst"<<(void *)inst<<"\n";
+ //std::cerr<<"to: "<<(void *)to<<"\t frm: "<<(void *)pc
+ // <<"\t inst"<<(void *)inst<<"\n";
return inst;
}
@@ -94,9 +113,19 @@
}
uint64_t getBPRTarget(unsigned int b, uint64_t oldAdd){
- return (oldAdd+4ull*(((b&2097152ull)==2097152ull)?(0xffffffffffff0000ull|((b&3145728ull)>>6)|(b&16383ull)):(((b&3145728ull)>>6)|(b&16383ull))));
+ 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){
@@ -111,10 +140,10 @@
frm+=4;
uint64_t target = (to-frm)/4;
//target < 2^21
- assert((target&(0x7fffffffffffffffull))<2097152 && "Target out of range!");
+ assert((target&(0x7fffffffffffffff))<2097152 && "Target out of range!");
unsigned int inst =
- ((target & (2097151))|((target&(0x8000000000000000ull))>>42));
+ ((target & (2097151))|((target&(0x8000000000000000))>>42));
inst = inst|(0x00800000);//skeleton filled in
@@ -139,8 +168,9 @@
}
void doFlush(uint64_t st_addr, uint64_t end_addr){
- return;
- //for(uint64_t i = st_addr; i<=end_addr; i+=8){
- //asm("flush %0"::"r" (i));
- //}
+ for(uint64_t i = st_addr; i<=end_addr; i+=8){
+ asm("flush %0"::"r" (i));
+ }
}
+
+//#endif
More information about the llvm-commits
mailing list