This is the mail archive of the gcc-patches@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: [PATCH][RFC] Introduce BIT_FIELD_INSERT


On Thu, 19 May 2016, Eric Botcazou wrote:

> > Index: trunk/gcc/tree.def
> > ===================================================================
> > *** trunk.orig/gcc/tree.def	2016-05-17 17:19:41.783958489 +0200
> > --- trunk/gcc/tree.def	2016-05-19 10:23:35.779141973 +0200
> > *************** DEFTREECODE (ADDR_EXPR, "addr_expr", tcc
> > *** 852,857 ****
> > --- 852,871 ----
> >      descriptor of type ptr_mode.  */
> >   DEFTREECODE (FDESC_EXPR, "fdesc_expr", tcc_expression, 2)
> > 
> > + /* Given a word, a value and a bit position within the word,
> > +    produce the value that results if replacing the parts of word
> > +    starting at the bit position with value.
> > +    Operand 0 is a tree for the word of integral or vector type;
> > +    Operand 1 is a tree for the value of integral or vector element type;
> > +    Operand 2 is a tree giving the constant position of the first
> > referenced bit; +    The number of bits replaced is given by the precision
> > of the value +    type if that is integral or by its size if it is
> > non-integral. +    ???  The reason to make the size of the replacement
> > implicit is to not +    have a quaternary operation.
> > +    The replaced bits shall be fully inside the word.  If the word is of
> > +    vector type the replaced bits shall be aligned with its elements.  */
> > + DEFTREECODE (BIT_INSERT_EXPR, "bit_field_insert", tcc_expression, 3)
> > +
> 
> "word" is ambiguous (what is a word of vector type?).  What's allowed as 
> operand #0 exactly?  If that's anything, I'd call it a value too, possibly 
> with a qualifier, for example:
> 
>  /* Given a container value, a replacement value and a bit position within
>     the container, produce the value that results from replacing the part of
>     the container starting at the bit position with the replacement value.
>     Operand 0 is a tree for the container value of integral or vector type;
>     Operand 1 is a tree for the replacement value of another integral or
>     vector element type;
>     Operand 2 is a tree giving the constant bit position;
>     The number of bits replaced is given by the precision of the type of the
>     replacement value if it is integral or by its size if it is non-integral.
>     ???  The reason to make the size of the replacement implicit is to avoid
>     introducing a quaternary operation.
>     The replaced bits shall be fully inside the container.  If the container
>     is of vector type, then these bits shall be aligned with its elements.  */
> DEFTREECODE (BIT_INSERT_EXPR, "bit_field_insert", tcc_expression, 3)

Sounds good.  I will commit later with your wording.

Richard.


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