Skip to content

Commit

Permalink
AMDGPU/SI: Emit fixups for long branches
Browse files Browse the repository at this point in the history
Reviewers: arsenm

Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, llvm-commits, tony-tye

Differential Revision: https://reviews.llvm.org/D25366

llvm-svn: 283570
  • Loading branch information
tstellarAMD committed Oct 7, 2016
1 parent f9648b7 commit ef33c4b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
Expand Up @@ -107,6 +107,24 @@ void AMDGPUAsmBackend::processFixupValue(const MCAssembler &Asm,
const MCFixup &Fixup, const MCFragment *DF,
const MCValue &Target, uint64_t &Value,
bool &IsResolved) {
MCValue Res;

// When we have complex expressions like: BB0_1 + (BB0_2 - 4), which are
// used for long branches, this function will be called with
// IsResolved = false and Value set to some pre-computed value. In
// the example above, the value would be:
// (BB0_1 + (BB0_2 - 4)) - CurrentOffsetFromStartOfFunction.
// This is not what we want. We just want the expression computation
// only. The reason the MC layer subtracts the current offset from the
// expression is because the fixup is of kind FK_PCRel_4.
// For these scenarios, evaluateAsValue gives us the computation that we
// want.
if (!IsResolved && Fixup.getValue()->evaluateAsValue(Res, Layout) &&
Res.isAbsolute()) {
Value = Res.getConstant();
IsResolved = true;

}
if (IsResolved)
Value = adjustFixupValue(Fixup, Value, &Asm.getContext());
}
Expand Down

0 comments on commit ef33c4b

Please sign in to comment.