For things that do mftb with high frequency, maybe you should also add a builtin that does just an mftb, i.e. returns a 32-bit result on 32- bit
implementations.

Are you thinking in a function that returns only the TBL?

On 32-bit, just TBL; on 64-bit, the whole TB (there is no machine
instruction to read just TBL on 64-bit, so it doesn't make much
sense to have it return a 32-bit number).

+(define_insn "get_timebase_ppc32"
+  [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
+        (unspec_volatile:DI [(const_int 0)] UNSPECV_GETTB))
+   (clobber (match_scratch:SI 1 "=r"))]
+  "TARGET_POWERPC && !TARGET_POWERPC64"
+{
+    return "mftbu %0\;"
+          "mftb %L0\;"
+          "mftbu %1\;"
+          "cmpw %0,%1\;"
+          "bne- $-16";
+})

This only works for WORDS_BIG_ENDIAN.

Yes.

Do you mean you are fixing it?  :-)

Does mftb work on all supported assemblers?  The machine instruction
is phased out, but some assemblers translate it to mfspr.

According to the Power ISA 2.06 they should translate it to mfspr.

Yes, I realised that later.

But then a binary compiled with an assembler that emits mfspr for mftb
will not run on POWER3 or 601.  I don't know what to do about that;
maybe just document it.


Segher

Reply via email to