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: inline assembly vs. intrinsic functions


2011/3/22 Ian Lance Taylor <iant@google.com>:
> roy rosen <roy.1rosen@gmail.com> writes:
>
>> 2010/10/26 Ian Lance Taylor <iant@google.com>:
>>> roy rosen <roy.1rosen@gmail.com> writes:
>>>
>>>> I am trying to demonstrate my port capabilities.
>>>> I am writing an application which needs to use instructions like max
>>>> a,b,c,d,e,f where a,b,c are inputs and d,e,f are outputs.
>>>> Is that possible to write an intrinsic function for that?
>>>> I think not because that means that I need to pass d,e,f by reference
>>>> which means that they would be in memory and not in a register as
>>>> meant by the instruction.
>>>
>>> That is correct. ?An intrinsic function is a normal function. ?If you
>>> want it to have multiple outputs, you need to pass in addresses, or you
>>> need to have it return a struct.
>>>
>>> I'm a bit curious as to why a function named max would have multiple
>>> outputs.
>>>
>>>> Is there any port with such an example?
>>>
>>> Not to my knowledge. ?I wrote a private port in which some intrinsics
>>> returned a struct, and to keep everything out of memory I added
>>> additional intrinsics to retrieve elements of the struct. ?It's awkward
>>> to use but the resulting code is fine.
>>>
>> Can you please explain how this solution should work?
>> First a code with memory accesses would be generated and then
>> optimizations would optimize it to use registers directly?
>
> You build a RECORD_TYPE holding the fields you want to return. ?You
> define the appropriate builtin functions to return that record type.

How is that done? using define_insn? How do I tell it to return a struct?
Is there an example I can look at?

Roy.

> You define another builtin function for each field, which takes the
> RECORD_TYPE as its argument and returns the type of the field. ?In
> TARGET_FOLD_BUILTIN you convert the per-field functions into
> COMPONENT_REFs.
>
> Ian
>


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