public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-80] Introduce VIRTUAL_REGISTER_P and VIRTUAL_REGISTER_NUM_P predicates
@ 2023-04-19 13:40 Uros Bizjak
  0 siblings, 0 replies; only message in thread
From: Uros Bizjak @ 2023-04-19 13:40 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:258aecd7021b15c23a067323c00f1450dca0a506

commit r14-80-g258aecd7021b15c23a067323c00f1450dca0a506
Author: Uros Bizjak <ubizjak@gmail.com>
Date:   Wed Apr 19 15:38:31 2023 +0200

    Introduce VIRTUAL_REGISTER_P and VIRTUAL_REGISTER_NUM_P predicates
    
    These two predicates are similar to existing HARD_REGISTER_P and
    HARD_REGISTER_NUM_P predicates and return 1 if the given register
    corresponds to a virtual register.
    
    gcc/ChangeLog:
    
            * rtl.h (VIRTUAL_REGISTER_P): New predicate.
            (VIRTUAL_REGISTER_NUM_P): Ditto.
            (REGNO_PTR_FRAME_P): Use VIRTUAL_REGISTER_NUM_P predicate.
            * expr.cc (force_operand): Use VIRTUAL_REGISTER_P predicate.
            * function.cc (instantiate_decl_rtl): Ditto.
            * rtlanal.cc (rtx_addr_can_trap_p_1): Ditto.
            (nonzero_address_p): Ditto.
            (refers_to_regno_p): Use VIRTUAL_REGISTER_NUM_P predicate.

Diff:
---
 gcc/expr.cc     |  3 +--
 gcc/function.cc |  3 +--
 gcc/rtl.h       | 12 +++++++++---
 gcc/rtlanal.cc  |  8 +++-----
 4 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/gcc/expr.cc b/gcc/expr.cc
index f8f5cc5a6ca..758dda9ec68 100644
--- a/gcc/expr.cc
+++ b/gcc/expr.cc
@@ -8178,8 +8178,7 @@ force_operand (rtx value, rtx target)
       if (code == PLUS && CONST_INT_P (op2)
 	  && GET_CODE (XEXP (value, 0)) == PLUS
 	  && REG_P (XEXP (XEXP (value, 0), 0))
-	  && REGNO (XEXP (XEXP (value, 0), 0)) >= FIRST_VIRTUAL_REGISTER
-	  && REGNO (XEXP (XEXP (value, 0), 0)) <= LAST_VIRTUAL_REGISTER)
+	  && VIRTUAL_REGISTER_P (XEXP (XEXP (value, 0), 0)))
 	{
 	  rtx temp = expand_simple_binop (GET_MODE (value), code,
 					  XEXP (XEXP (value, 0), 0), op2,
diff --git a/gcc/function.cc b/gcc/function.cc
index edf0b2ec6cf..f0ae641512d 100644
--- a/gcc/function.cc
+++ b/gcc/function.cc
@@ -1838,8 +1838,7 @@ instantiate_decl_rtl (rtx x)
   addr = XEXP (x, 0);
   if (CONSTANT_P (addr)
       || (REG_P (addr)
-	  && (REGNO (addr) < FIRST_VIRTUAL_REGISTER
-	      || REGNO (addr) > LAST_VIRTUAL_REGISTER)))
+	  && !VIRTUAL_REGISTER_P (addr)))
     return;
 
   instantiate_virtual_regs_in_rtx (&XEXP (x, 0));
diff --git a/gcc/rtl.h b/gcc/rtl.h
index 60852aeecd8..f634cab730b 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -1967,11 +1967,18 @@ set_regno_raw (rtx x, unsigned int regno, unsigned int nregs)
   (RTL_FLAG_CHECK1 ("MEM_POINTER", (RTX), MEM)->frame_related)
 
 /* 1 if the given register REG corresponds to a hard register.  */
-#define HARD_REGISTER_P(REG) (HARD_REGISTER_NUM_P (REGNO (REG)))
+#define HARD_REGISTER_P(REG) HARD_REGISTER_NUM_P (REGNO (REG))
 
 /* 1 if the given register number REG_NO corresponds to a hard register.  */
 #define HARD_REGISTER_NUM_P(REG_NO) ((REG_NO) < FIRST_PSEUDO_REGISTER)
 
+/* 1 if the given register REG corresponds to a virtual register.  */
+#define VIRTUAL_REGISTER_P(REG) VIRTUAL_REGISTER_NUM_P (REGNO (REG))
+
+/* 1 if the given register number REG_NO corresponds to a virtual register.  */
+#define VIRTUAL_REGISTER_NUM_P(REG_NO)					\
+  IN_RANGE (REG_NO, FIRST_VIRTUAL_REGISTER, LAST_VIRTUAL_REGISTER)
+
 /* For a CONST_INT rtx, INTVAL extracts the integer.  */
 #define INTVAL(RTX) XCWINT (RTX, 0, CONST_INT)
 #define UINTVAL(RTX) ((unsigned HOST_WIDE_INT) INTVAL (RTX))
@@ -4078,8 +4085,7 @@ PUT_MODE (rtx x, machine_mode mode)
    || (REGNUM) == FRAME_POINTER_REGNUM		\
    || (REGNUM) == HARD_FRAME_POINTER_REGNUM	\
    || (REGNUM) == ARG_POINTER_REGNUM		\
-   || ((REGNUM) >= FIRST_VIRTUAL_REGISTER	\
-       && (REGNUM) <= LAST_VIRTUAL_POINTER_REGISTER))
+   || VIRTUAL_REGISTER_NUM_P (REGNUM))
 
 /* REGNUM never really appearing in the INSN stream.  */
 #define INVALID_REGNUM			(~(unsigned int) 0)
diff --git a/gcc/rtlanal.cc b/gcc/rtlanal.cc
index e69d2e8a9f5..c96a88cebf1 100644
--- a/gcc/rtlanal.cc
+++ b/gcc/rtlanal.cc
@@ -643,8 +643,7 @@ rtx_addr_can_trap_p_1 (const_rtx x, poly_int64 offset, poly_int64 size,
 	  return 1;
 	}
       /* All of the virtual frame registers are stack references.  */
-      if (REGNO (x) >= FIRST_VIRTUAL_REGISTER
-	  && REGNO (x) <= LAST_VIRTUAL_REGISTER)
+      if (VIRTUAL_REGISTER_P (x))
 	return 0;
       return 1;
 
@@ -733,8 +732,7 @@ nonzero_address_p (const_rtx x)
 	  || (x == arg_pointer_rtx && fixed_regs[ARG_POINTER_REGNUM]))
 	return true;
       /* All of the virtual frame registers are stack references.  */
-      if (REGNO (x) >= FIRST_VIRTUAL_REGISTER
-	  && REGNO (x) <= LAST_VIRTUAL_REGISTER)
+      if (VIRTUAL_REGISTER_P (x))
 	return true;
       return false;
 
@@ -1769,7 +1767,7 @@ refers_to_regno_p (unsigned int regno, unsigned int endregno, const_rtx x,
 	   || (FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
 	       && x_regno == ARG_POINTER_REGNUM)
 	   || x_regno == FRAME_POINTER_REGNUM)
-	  && regno >= FIRST_VIRTUAL_REGISTER && regno <= LAST_VIRTUAL_REGISTER)
+	  && VIRTUAL_REGISTER_NUM_P (regno))
 	return true;
 
       return endregno > x_regno && regno < END_REGNO (x);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-04-19 13:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-19 13:40 [gcc r14-80] Introduce VIRTUAL_REGISTER_P and VIRTUAL_REGISTER_NUM_P predicates Uros Bizjak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).