This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [GOLD] PowerPC64 toc code optimization
- From: Doug Kwan (éæå) <dougkwan at google dot com>
- To: binutils <binutils at sourceware dot org>
- Date: Thu, 6 Dec 2012 10:35:15 -0800
- Subject: Re: [GOLD] PowerPC64 toc code optimization
- References: <20121206132051.GA32689@bubble.grove.modra.org>
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