Re: [PATCH 1/6] powerpc/time: Rename mftbl() to mftb()

From: Segher Boessenkool
Date: Thu Oct 01 2020 - 16:49:52 EST


On Thu, Oct 01, 2020 at 12:42:39PM +0000, Christophe Leroy wrote:
> On PPC64, we have mftb().
> On PPC32, we have mftbl() and an #define mftb() mftbl().
>
> mftb() and mftbl() are equivalent, their purpose is to read the
> content of SPRN_TRBL, as returned by 'mftb' simplified instruction.
>
> binutils seems to define 'mftbl' instruction as an equivalent
> of 'mftb'.
>
> However in both 32 bits and 64 bits documentation, only 'mftb' is
> defined, and when performing a disassembly with objdump, the displayed
> instruction is 'mftb'
>
> No need to have two ways to do the same thing with different
> names, rename mftbl() to have only mftb().

There are mttbl and mttbu insns (and no mttb insn); they write a 32-bit
half for the time base. There is an mftb, and an mftbu. mftbu reads
the upper half, while mftb reads the *whole* register. SPR 269 is the
TBU register, while SPR 268 is called both TB and TBL. Yes, it is
confusing :-)

The "mftb" name is much clearer than "mftbl" (on 64-bit), because it
reads the whole 64-bit register. On 32-bit mftbl is clearer (but not
defined in the architecture, not officially an insn or even an extended
mnemonic).


Segher