[llvm] r283570 - AMDGPU/SI: Emit fixups for long branches

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 23 15:32:55 PDT 2017


Do you have a testcase for this?

Cheers,
Rafael

Tom Stellard via llvm-commits <llvm-commits at lists.llvm.org> writes:

> Author: tstellar
> Date: Fri Oct  7 11:01:18 2016
> New Revision: 283570
>
> URL: http://llvm.org/viewvc/llvm-project?rev=283570&view=rev
> Log:
> 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
>
> Modified:
>     llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
>
> Modified: llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp?rev=283570&r1=283569&r2=283570&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp (original)
> +++ llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp Fri Oct  7 11:01:18 2016
> @@ -107,6 +107,24 @@ void AMDGPUAsmBackend::processFixupValue
>                                           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());
>  }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list