[PATCH] PowerPC: Resolve constant at l/h/ha without fixups

Ulrich Weigand Ulrich.Weigand at de.ibm.com
Tue Mar 11 12:43:35 PDT 2014


as noticed in a recent discussion with Roman, while we support constructs
like "1234 at l" now, this still generates a fixup, where it would be
preferable to resolve the expression directly without fixup or relocations.

The reason why this doesn't work is the !Layout test in

  if (!Layout || !getSubExpr()->EvaluateAsRelocatable(Value, *Layout))
    return false;

EvaluteAsRelocatableImpl may be called from various original MCExpr
routines, including EvaluateAsAbsolute.  In some of these cases, Layout is
NULL.  However, we still can (and should) simplify the target expression if
the subexpression is in fact a constant.

The generic EvaluteAsRelocatableImpl recurses on subexpressions using a
generic implementation that does not require a non-NULL Layout:

bool MCExpr::EvaluateAsRelocatableImpl(MCValue &Res,
                                       const MCAssembler *Asm,
                                       const MCAsmLayout *Layout,
                                       const SectionAddrMap *Addrs,
                                       bool InSet) const

Unfortunately, this is "protected", and therefore cannot be used from the
PPCMCExpr code (and we don't have all the required arguments either, since
they're not passed to the MCTargetExpr implementation).  I've tried
unsuccessfully to change common code along these lines while still keeping
the routine protected ...  any suggestions how to do that?

In any case, here is a PowerPC-only patch that still fixes the problem for
us; this is basically along the lines of the hack Roman originally
suggested.  I guess we can still put this in for now until a cleaner common
code solution is implemented ...   Thoughts?

(See attached file: diff-llvm-ppc64-constantfixup)

Mit freundlichen Gruessen / Best Regards

Ulrich Weigand

  Dr. Ulrich Weigand | Phone: +49-7031/16-3727
  STSM, GNU/Linux compilers and toolchain
  IBM Deutschland Research & Development GmbH
  Vorsitzende des Aufsichtsrats: Martina Koederitz | Geschäftsführung: Dirk
  Sitz der Gesellschaft: Böblingen | Registergericht: Amtsgericht
Stuttgart, HRB 243294
-------------- next part --------------
A non-text attachment was scrubbed...
Name: diff-llvm-ppc64-constantfixup
Type: application/octet-stream
Size: 2406 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140311/3616c23a/attachment.obj>

More information about the llvm-commits mailing list