This is the mail archive of the 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: [PATCH 4/9] Add ELFv2 .localentry support.

On 10/29/2013 07:25 PM, Alan Modra wrote:
> +/* The ELFv2 ABI uses three bits in the symbol st_other field of a
> +   function definition to specify the number of instructions between a
> +   function's global entry point and local entry point.
> +   The global entry point is used when it is necessary to set up the
> +   toc pointer (r2) for the function.  Callers must enter the global
> +   entry point with r12 set to the global entry point address.  On
> +   return from the function, r2 may have a different value to that
> +   which it had on entry.
> +   The local entry point is used when r2 is known to already be valid
> +   for the function.  There is no requirement on r12 when using the
> +   local entry point, and on return r2 will contain the same value as
> +   at entry.
> +   A value of zero in these bits means that the function has a single
> +   entry point with no requirement on r12 or r2, and that on return r2
> +   will contain the same value as at entry.
> +   Values of one and seven are reserved.  */
> +#define STO_PPC64_LOCAL_BIT		5
> +#define STO_PPC64_LOCAL_MASK		(7 << STO_PPC64_LOCAL_BIT)
> +
> +// 3 bit other field to bytes.
> +static inline unsigned int
> +ppc64_decode_local_entry(unsigned int other)
> +{
> +  return ((1 << other) >> 2) << 2;
> +}

Is this really the best definition?  How might one record that one that there
is no local entry point, i.e. one must always enter with r12 set to the global
entry address?

Why have you chosen an encoding that records powers of 2?  Are you really ever
going to have 32 insns in the global entry point before the local entry point?

I would have thought that one would pretty much always have exactly two insns
in the global entry point before the local entry point (addis+addi).  Reserving
3 bits would allow 0-7 insns to be skipped, which still seems way more than enough.

Compare your scheme with the one used on Alpha, where we have two bits in
s_other to optimize this.  If STO_ALPHA_NOPV is set, then local_entry ==
global_entry, equivalent to your st_other == 0 above.  If STO_ALPHA_STD_GPLOAD
is set, then local_entry == global_entry + 8.  If neither bit is set, then
there is no local_entry and the global_entry must be used.

For dealing with hand-written assembly, this requirement that the user actually
set the .localentry before local entry optimization occurs seems the safest route.


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