summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2016-10-07 16:01:18 +0000
committerTom Stellard <thomas.stellard@amd.com>2016-10-07 16:01:18 +0000
commitef33c4b3f21b470761a79a8f5d0920d15609a93a (patch)
tree8aff6927f3204c29c280b9c8a665ef26a20058d4 /llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
parentf9648b72df0074a57586111f0525c7bd59eecc48 (diff)
downloadbcm5719-llvm-ef33c4b3f21b470761a79a8f5d0920d15609a93a.tar.gz
bcm5719-llvm-ef33c4b3f21b470761a79a8f5d0920d15609a93a.zip
AMDGPU/SI: Emit fixups for long branches
Reviewers: arsenm Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, llvm-commits, tony-tye Differential Revision: https://reviews.llvm.org/D25366 llvm-svn: 283570
Diffstat (limited to 'llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp')
-rw-r--r--llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
index 5e69739ad7f..021f3fe48ca 100644
--- a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
+++ b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
@@ -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());
}
OpenPOWER on IntegriCloud