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: Must TYPE_MODE of a UNION_TYPE be of MODE_INT class?


> See stor-layout.c (compute_record_mode), particularly this section:
> 
>    /* If we only have one real field; use its mode if that mode's size
>       matches the type's size.  This only applies to RECORD_TYPE.  This
>       does not apply to unions.  */
>    if (TREE_CODE (type) == RECORD_TYPE && mode != VOIDmode
>        && tree_fits_uhwi_p (TYPE_SIZE (type))
>        && known_eq (GET_MODE_BITSIZE (mode), tree_to_uhwi (TYPE_SIZE
>            (type))))
>    ;
>    else
>      mode = mode_for_size_tree (TYPE_SIZE (type), MODE_INT, 1).else_blk ();
> 
> Is there a reason the type of the union must be of MODE_INT class but a
> RECORD_TYPE with one field can have the class of it's single field?

Yes, ABIs that pass structures or unions in registers traditionally pass the 
unions always in integer registers, whereas for structures it's dependent on 
the types of the fields.

> Could anyone provide some insight on whether the TYPE_MODE of a union should
> stay as a MODE_INT class or if it would be acceptable for the TYPE_MODE to
> be other classes e.g. MODE_FLOAT?

No, I don't think we want to change that.

-- 
Eric Botcazou


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