[llvm-commits] CVS: reopt/lib/TraceCache/InstrUtils.cpp
Brian Gaeke
gaeke at cs.uiuc.edu
Mon Apr 26 15:04:04 PDT 2004
Changes in directory reopt/lib/TraceCache:
InstrUtils.cpp updated: 1.17 -> 1.18
---
Log message:
Reorganize and document isCallInstr().
Reorganize getCallTarget().
Document getUndepJumpInstr() and rename its operands.
Edit getDepJumpInstr()'s comment.
---
Diffs of the changes: (+31 -18)
Index: reopt/lib/TraceCache/InstrUtils.cpp
diff -u reopt/lib/TraceCache/InstrUtils.cpp:1.17 reopt/lib/TraceCache/InstrUtils.cpp:1.18
--- reopt/lib/TraceCache/InstrUtils.cpp:1.17 Mon Apr 26 14:47:33 2004
+++ reopt/lib/TraceCache/InstrUtils.cpp Mon Apr 26 15:02:59 2004
@@ -49,6 +49,13 @@
return (instr & 0xd1c00000) == 0x00c00000;
}
+/// isCallInstr - Returns true iff instr encodes a CALL instruction.
+/// See SPARCv9 manual, section A.8.
+///
+bool isCallInstr (unsigned int instr) {
+ return (instr & 0xc0000000) == 0x40000000;
+}
+
//===----------------------------------------------------------------------===//
//===----- Instructions for extracting SPARCv9 branch target addresses ----===//
@@ -82,6 +89,12 @@
return (oldAdd+4*(((b&2097152)==2097152)?(0xffffffffffff0000ULL|((b&3145728)>>6)|(b&16383)):(((b&3145728)>>6)|(b&16383))));
}
+uint64_t getCallTarget(unsigned int y, uint64_t oldAdd){
+ return oldAdd + 4 * (((y&0x20000000) == 0x20000000)
+ ? (0xffffffffc0000000ULL | (y & 0x3fffffff))
+ : (y & 0x3fffffff));
+}
+
//===----------------------------------------------------------------------===//
//===----- Instructions for extracting SPARCv9 branch target addresses ----===//
@@ -99,21 +112,31 @@
}
}
-unsigned int getUndepJumpInstr(unsigned int a, uint64_t to, uint64_t pc){
- if(to>pc)
- assert((to-pc)/4<262144 && "Can't fit target!");
+/// getUndepJumpInstr - 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 BPcc or FBPfcc instruction (branch on integer
+/// condition codes with prediction and annul bits), and FROM must be its
+/// address in memory.
+///
+unsigned int getUndepJumpInstr(unsigned int instr, uint64_t to, uint64_t from) {
+ if(to>from)
+ assert((to-from)/4<262144 && "Can't fit target!");
else
- assert((pc-to)/4<262144 && "Can't fit target!");
+ assert((from-to)/4<262144 && "Can't fit target!");
- unsigned int diff = (((to-pc)/4)&0x3ffff);
- unsigned int sgn = ((to < pc) ? (1 << 21) : 0);
- return ((a&0xfff80000U)|diff|sgn);
+ // Compute new 19-bit PC-relative branch target.
+ unsigned int diff = (((to-from)/4)&0x3ffff);
+ unsigned int sgn = ((to < from) ? (1 << 21) : 0);
+
+ // Mask out the old branch target, OR in the new one, and return it.
+ return ((instr&0xfff80000U)|diff|sgn);
}
/// 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 or FBfcc instruction (branch on integer
-/// condition codes with no prediction), and FROM must be its address in memory.
+/// condition codes with no prediction bits), and FROM must be its address in
+/// memory.
///
unsigned int getDepJumpInstr(unsigned int instr, uint64_t to, uint64_t from) {
if(to>from)
@@ -147,16 +170,6 @@
//TODO: put assert to check branch destinations!
//TODO: Take out sign bit in branch instr
-
-bool isCallInstr(unsigned int a){
- return ((a & 0xc0000000) == 0x40000000);
-}
-
-uint64_t getCallTarget(unsigned int y, uint64_t oldAdd){
- return oldAdd + 4 * (((y&0x20000000) == 0x20000000)
- ? (0xffffffffc0000000ULL | (y & 0x3fffffff))
- : (y & 0x3fffffff));
-}
// pc is the "from" address
unsigned int getCallInstr(uint64_t to , uint64_t pc){
More information about the llvm-commits
mailing list