[PATCH] D25366: AMDGPU/SI: Emit fixups for long branches

Tom Stellard via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 7 06:31:37 PDT 2016


tstellarAMD created this revision.
tstellarAMD added a reviewer: arsenm.
tstellarAMD added a subscriber: llvm-commits.
Herald added subscribers: tony-tye, yaxunl, nhaehnle, wdng, kzhuravl.

https://reviews.llvm.org/D25366

Files:
  lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp


Index: lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
===================================================================
--- lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
+++ lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
@@ -107,6 +107,24 @@
                                          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());
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25366.73924.patch
Type: text/x-patch
Size: 1373 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161007/80991e5e/attachment.bin>


More information about the llvm-commits mailing list