diff options
| author | Brian Gaeke <gaeke@uiuc.edu> | 2004-05-20 07:43:40 +0000 |
|---|---|---|
| committer | Brian Gaeke <gaeke@uiuc.edu> | 2004-05-20 07:43:40 +0000 |
| commit | 7b7a14d718c192581d0f0085989f1b20f5d457d1 (patch) | |
| tree | f28559661459a73f5ef18eb9f683d6c2342fec77 /llvm/lib | |
| parent | e8949b3083db08225395ac9443e9752aa337eaa1 (diff) | |
| download | bcm5719-llvm-7b7a14d718c192581d0f0085989f1b20f5d457d1.tar.gz bcm5719-llvm-7b7a14d718c192581d0f0085989f1b20f5d457d1.zip | |
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.)
llvm-svn: 13608
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/SparcV9/SparcV9CodeEmitter.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Target/SparcV9/SparcV9CodeEmitter.cpp b/llvm/lib/Target/SparcV9/SparcV9CodeEmitter.cpp index 6606d8d6460..4fc221325a8 100644 --- a/llvm/lib/Target/SparcV9/SparcV9CodeEmitter.cpp +++ b/llvm/lib/Target/SparcV9/SparcV9CodeEmitter.cpp @@ -597,8 +597,9 @@ int64_t SparcV9CodeEmitter::getMachineOpValue(MachineInstr &MI, 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: "); |

