[llvm-commits] CVS: llvm/lib/Target/SparcV9/SparcV9CodeEmitter.cpp
Brian Gaeke
gaeke at cs.uiuc.edu
Thu May 20 02:44:01 PDT 2004
Changes in directory llvm/lib/Target/SparcV9:
SparcV9CodeEmitter.cpp updated: 1.61 -> 1.62
---
Log message:
Fix a bug in outputting branches to constant PCs. Since the PC is supplied as
a full 64-bit address, it must be adjusted to fit in the branch instruction's
immediate field. (This is only used in the reoptimizer, for now.)
---
Diffs of the changes: (+3 -2)
Index: llvm/lib/Target/SparcV9/SparcV9CodeEmitter.cpp
diff -u llvm/lib/Target/SparcV9/SparcV9CodeEmitter.cpp:1.61 llvm/lib/Target/SparcV9/SparcV9CodeEmitter.cpp:1.62
--- llvm/lib/Target/SparcV9/SparcV9CodeEmitter.cpp:1.61 Wed May 19 16:30:01 2004
+++ llvm/lib/Target/SparcV9/SparcV9CodeEmitter.cpp Thu May 20 02:43:40 2004
@@ -597,8 +597,9 @@
unsigned* CurrPC = (unsigned*)(intptr_t)MCE.getCurrentPCValue();
BBRefs.push_back(std::make_pair(BB, std::make_pair(CurrPC, &MI)));
} else if (const ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
- // Make constant PC-relative by subtracting the PC from it.
- rv = CI->getRawValue() - MCE.getCurrentPCValue();
+ // The real target of the branch is CI = PC + (rv * 4)
+ // So undo that: give the instruction (CI - PC) / 4
+ rv = (CI->getRawValue() - MCE.getCurrentPCValue()) / 4;
} else if (GlobalValue *GV = dyn_cast<GlobalValue>(V)) {
// same as MO.isGlobalAddress()
DEBUG(std::cerr << "GlobalValue: ");
More information about the llvm-commits
mailing list