This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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: Using intrinsic functions to extend the isa


Feng LI <nemokingdom@gmail.com> writes:

> I'm currently try to add intrinsic functions to extend the x86 instruction
> set. Encountered a problem when the intrinsic function's return value
> is void, where the asm will not generate in this case.
>
> the intrinsic function looks like:
>
> extern void
> __attribute__((__gnu_inline__, __always_inline__, __artificial__))
> __TTest (unsigned int __C, unsigned int __V, unsigned int offset)
> {
>   __builtin_ia32_ttest (__C, __V, offset);
> }
>
> and the corresponding md part is:
>
> (define_expand "dta_ttest"
>   [(set (match_operand:SI 1 "register_operand" "")
> 	(unspec:SI
> 	  [(match_operand:SI 2 "register_operand" "")
> 	   (match_operand:SI 3 "register_operand" "")]
> 	  UNSPEC_TSTORE))]
>   "TARGET_DTA"
>   "(void) operand0;")
>
> (define_insn "*dta_ttest"
>   [(set (match_operand:SI 0 "register_operand" "=r")
> 	(unspec:SI
> 	  [(match_operand:SI 1 "register_operand" "0")
> 	   (match_operand:SI 2 "register_operand" "")]
> 	  UNSPEC_TSTORE))]
>   "TARGET_DTA"
>   "ttest\t%0 %1 %2"
>   [(set_attr "length" "3")
>    (set_attr "mode" "SI")])
>
>
> The asm will not generate "ttest\t %0 %1 %2" in this case, but if I
> change the return value from void to uint, it will generate the correct
> code.
>
> I'm wondering how could I generate asm code for the intrinsic functions
> with return value of void.

If the intrinsic has no return value, then you need to use
unspec_volatile.  Otherwise the compiler will see that you have an
instruction which doesn't do anything, and will remove it.

But if the instrinsic returns void, I don't understand why you are
setting an operand in the insn.  What does it get set to?

Ian


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