diff mbox

[2/5] Tweak subreg_get_info documentation

Message ID 87ha05nsrd.fsf@e105548-lin.cambridge.arm.com
State New
Headers show

Commit Message

Richard Sandiford Sept. 18, 2014, 10:10 a.m. UTC
Try to clarify what subreg_get_info does and doesn't check.


gcc/
	* rtl.h (subreg_info): Expand commentary
	* rtlanal.c (subreg_get_info): Likewise.

Comments

Jeff Law Sept. 19, 2014, 6:16 a.m. UTC | #1
On 09/18/14 04:10, Richard Sandiford wrote:
> Try to clarify what subreg_get_info does and doesn't check.
>
>
> gcc/
> 	* rtl.h (subreg_info): Expand commentary
> 	* rtlanal.c (subreg_get_info): Likewise.
OK independently of the other patches as well.

jeff
diff mbox

Patch

Index: gcc/rtl.h
===================================================================
--- gcc/rtl.h	2014-09-15 10:00:14.693366097 +0100
+++ gcc/rtl.h	2014-09-15 10:00:14.689366147 +0100
@@ -2866,10 +2866,13 @@  struct subreg_info
 {
   /* Offset of first hard register involved in the subreg.  */
   int offset;
-  /* Number of hard registers involved in the subreg.  */
+  /* Number of hard registers involved in the subreg.  In the case of
+     a paradoxical subreg, this is the number of registers that would
+     be modified by writing to the subreg; some of them may be don't-care
+     when reading from the subreg.  */
   int nregs;
   /* Whether this subreg can be represented as a hard reg with the new
-     mode.  */
+     mode (by adding OFFSET to the original hard register).  */
   bool representable_p;
 };
 
Index: gcc/rtlanal.c
===================================================================
--- gcc/rtlanal.c	2014-09-15 10:00:14.693366097 +0100
+++ gcc/rtlanal.c	2014-09-15 10:00:14.689366147 +0100
@@ -3411,7 +3411,20 @@  subreg_lsb (const_rtx x)
    xmode  - The mode of xregno.
    offset - The byte offset.
    ymode  - The mode of a top level SUBREG (or what may become one).
-   info   - Pointer to structure to fill in.  */
+   info   - Pointer to structure to fill in.
+
+   Rather than considering one particular inner register (and thus one
+   particular "outer" register) in isolation, this function really uses
+   XREGNO as a model for a sequence of isomorphic hard registers.  Thus the
+   function does not check whether adding INFO->offset to XREGNO gives
+   a valid hard register; even if INFO->offset + XREGNO is out of range,
+   there might be another register of the same type that is in range.
+   Likewise it doesn't check whether HARD_REGNO_MODE_OK accepts the new
+   register, since that can depend on things like whether the final
+   register number is even or odd.  Callers that want to check whether
+   this particular subreg can be replaced by a simple (reg ...) should
+   use simplify_subreg_regno.  */
+
 void
 subreg_get_info (unsigned int xregno, enum machine_mode xmode,
 		 unsigned int offset, enum machine_mode ymode,