Re: [PATCH v2] rs6000: Add 2 built-ins to read the Time Base Register on PowerPC

2012-09-15 Thread Segher Boessenkool
There is no problem. Segher is concerned that -mcpu=powerpc64, which is suppose to generate "generic" PPC64 code produces mftb instead of mfspr. And the MFTB instruction is phased out of the architecture. I was under the impression that now or in the near future there would be implementations

Re: [PATCH v2] rs6000: Add 2 built-ins to read the Time Base Register on PowerPC

2012-09-14 Thread David Edelsohn
On Fri, Sep 14, 2012 at 8:34 PM, Tulio Magno Quites Machado Filho wrote: > Segher Boessenkool writes: > I don't understand the problem. There is no problem. Segher is concerned that -mcpu=powerpc64, which is suppose to generate "generic" PPC64 code produces mftb instead of mfspr. However, the

Re: [PATCH v2] rs6000: Add 2 built-ins to read the Time Base Register on PowerPC

2012-09-14 Thread Tulio Magno Quites Machado Filho
Segher Boessenkool writes: I don't think TARGET_MFCRF is correct. For example, if you use -mcpu=powerpc64 (which doesn't set this flag) you will get code that does not run on the newer machines. Sorry, but it seems to be working here... I explain how I tested this in the end of the email.

Re: [PATCH v2] rs6000: Add 2 built-ins to read the Time Base Register on PowerPC

2012-09-14 Thread David Edelsohn
On Fri, Sep 14, 2012 at 4:52 PM, Segher Boessenkool wrote: >>> I don't think TARGET_MFCRF is correct. For example, if you use >>> -mcpu=powerpc64 (which doesn't set this flag) you will get code >>> that does not run on the newer machines. >> >> Sorry, but it seems to be working here... >> I expla

Re: [PATCH v2] rs6000: Add 2 built-ins to read the Time Base Register on PowerPC

2012-09-14 Thread Segher Boessenkool
I don't think TARGET_MFCRF is correct. For example, if you use -mcpu=powerpc64 (which doesn't set this flag) you will get code that does not run on the newer machines. Sorry, but it seems to be working here... I explain how I tested this in the end of the email. David tells me all current CPU

Re: [PATCH v2] rs6000: Add 2 built-ins to read the Time Base Register on PowerPC

2012-09-14 Thread Tulio Magno Quites Machado Filho
Segher Boessenkool writes: Hi Tulio, Hi Segher, +(define_expand "rs6000_get_timebase" + [(use (match_operand:DI 0 "gpc_reg_operand" ""))] + "" + " +{ + if (TARGET_POWERPC64) +emit_insn (gen_rs6000_get_timebase_ppc64 (operands[0])); + else +emit_insn (gen_rs6000_get_timebase_ppc

Re: [PATCH v2] rs6000: Add 2 built-ins to read the Time Base Register on PowerPC

2012-09-14 Thread Segher Boessenkool
Hi Tulio, @@ -14103,6 +14105,84 @@ "" "") +(define_expand "rs6000_get_timebase" + [(use (match_operand:DI 0 "gpc_reg_operand" ""))] + "" + " +{ + if (TARGET_POWERPC64) +emit_insn (gen_rs6000_get_timebase_ppc64 (operands[0])); + else +emit_insn (gen_rs6000_get_timebase_ppc32 (

[PATCH v2] rs6000: Add 2 built-ins to read the Time Base Register on PowerPC

2012-09-14 Thread Tulio Magno Quites Machado Filho
Add __builtin_ppc_get_timebase and __builtin_ppc_mftb to read the Time Base Register on PowerPC. They are required by applications that measure time at high frequencies with high precision that can't afford a syscall. __builtin_ppc_get_timebase returns the 64 bits of the Time Base Register while __