This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [GOLD] PowerPC64 toc code optimization


On Thu, Dec 6, 2012 at 5:20 AM, Alan Modra <amodra@gmail.com> wrote:

> +static bool
> +ok_lo_toc_insn(uint32_t insn)
> +{
> +  return ((insn & (0x3f << 26)) == 14u << 26 /* addi */
> +         || (insn & (0x3f << 26)) == 32u << 26 /* lwz */
> +         || (insn & (0x3f << 26)) == 34u << 26 /* lbz */
> +         || (insn & (0x3f << 26)) == 36u << 26 /* stw */
> +         || (insn & (0x3f << 26)) == 38u << 26 /* stb */
> +         || (insn & (0x3f << 26)) == 40u << 26 /* lhz */
> +         || (insn & (0x3f << 26)) == 42u << 26 /* lha */
> +         || (insn & (0x3f << 26)) == 44u << 26 /* sth */
> +         || (insn & (0x3f << 26)) == 46u << 26 /* lmw */
> +         || (insn & (0x3f << 26)) == 47u << 26 /* stmw */
> +         || (insn & (0x3f << 26)) == 48u << 26 /* lfs */
> +         || (insn & (0x3f << 26)) == 50u << 26 /* lfd */
> +         || (insn & (0x3f << 26)) == 52u << 26 /* stfs */
> +         || (insn & (0x3f << 26)) == 54u << 26 /* stfd */
> +         || ((insn & (0x3f << 26)) == 58u << 26 /* lwa,ld,lmd */
> +             && (insn & 3) != 1)
> +         || ((insn & (0x3f << 26)) == 62u << 26 /* std, stmd */
> +             && ((insn & 3) == 0 || (insn & 3) == 3))
> +         || (insn & (0x3f << 26)) == 12u << 26 /* addic */);
> +}
> +
>  // Return the value to use for a branch relocation.
>

The pattern "(insn & (0x3f << 26)) == XXX << 26" repeats so many
times.  Why not define a predicate? It would be difficult to spot a
typo if there was one.

-Doug


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]