This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: How to implement "unsigned long long __rdtsc ()" for x86?
On Fri, Jan 16, 2009 at 1:28 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Fri, Jan 16, 2009 at 12:47 PM, Andrew Pinski <pinskia@gmail.com> wrote:
>> On Fri, Jan 16, 2009 at 11:35 AM, Jack Lloyd <lloyd@randombit.net> wrote:
>>> According to the info docs, the Alpha has __builtin_alpha_rpcc which
>>> doesn't take any inputs either, and should just call rpcc much as an
>>> rdtsc intrinsic would, so it may provide a more direct model.
>>
>> (define_insn "builtin_rpcc"
>> [(set (match_operand:DI 0 "register_operand" "=r")
>> (unspec_volatile:DI [(const_int 0)] UNSPECV_RPCC))]
>> ""
>> "rpcc %0"
>> [(set_attr "type" "ilog")])
>>
>> So yes this is exactly what I was mentioning to do ...
>>
>
> The problem is 64bit. I have
>
> (define_insn "*rdtsc_rex64"
> [(parallel [(set (match_operand:DI 0 "register_operand" "=a")
> (unspec_volatile:DI [(const_int 0)] UNSPECV_RDTSC_EAX))
> (set (match_operand:DI 1 "register_operand" "=d")
> (unspec_volatile:DI [(const_int 0)] UNSPECV_RDTSC_EDX))])]
> "TARGET_64BIT"
> "rdtsc"
> [(set_attr "type" "other")
> (set_attr "length" "2")])
>
> But I got
>
> y.c: In function 'foo2':
> y.c:7: error: unrecognizable insn:
> (insn 5 4 6 3 y.c:6 (parallel [
> (set (reg:DI 62)
> (unspec_volatile [
> (const_int 0 [0x0])
> ] 19))
> (set (reg:DI 61)
> (unspec_volatile [
> (const_int 0 [0x0])
> ] 20))
> ]) -1 (nil))
> y.c:7: internal compiler error: in extract_insn, at recog.c:2027
> Please submit a full bug report,
>
> It looks like I can't use 2 unspec_volatile SETs in one RTL.
>
Never mind. It was a typo.
--
H.J.