]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
i386: Use SYMBOL_REF_P predicate instead of open coding it
authorUros Bizjak <ubizjak@gmail.com>
Wed, 16 Jul 2025 17:59:07 +0000 (19:59 +0200)
committerUros Bizjak <ubizjak@gmail.com>
Wed, 16 Jul 2025 18:19:09 +0000 (20:19 +0200)
No functional changes.

gcc/ChangeLog:

* config/i386/i386-expand.cc (ix86_expand_move):
Use SYMBOL_REF_P predicate instead of open coding it.
(ix86_split_long_move): Ditto.
(construct_plt_address): Ditto.
(ix86_expand_call): Ditto.
(ix86_notrack_prefixed_insn_p): Ditto.
* config/i386/i386-features.cc
(rest_of_insert_endbr_and_patchable_area): Ditto.
* config/i386/i386.cc (symbolic_reference_mentioned_p): Ditto.
(ix86_force_load_from_GOT_p): Ditto.
(ix86_legitimate_constant_p): Ditto.
(legitimate_pic_operand_p): Ditto.
(legitimate_pic_address_disp_p): Ditto.
(ix86_legitimate_address_p): Ditto.
(legitimize_pic_address): Ditto.
(ix86_legitimize_address): Ditto.
(ix86_delegitimize_tls_address): Ditto.
(ix86_print_operand): Ditto.
(ix86_print_operand_address_as): Ditto.
(ix86_rip_relative_addr_p): Ditto.
(symbolic_base_address_p): Ditto.
* config/i386/i386.h (SYMBOLIC_CONST): Ditto.
* config/i386/i386.md (*anddi_1 to *andsi_1_zext splitter): Ditto.
* config/i386/predicates.md (symbolic_operand): Ditto.
(local_symbolic_operand): Ditto.
(local_func_symbolic_operand): Ditto.

gcc/config/i386/i386-expand.cc
gcc/config/i386/i386-features.cc
gcc/config/i386/i386.cc
gcc/config/i386/i386.h
gcc/config/i386/i386.md
gcc/config/i386/predicates.md

index 7775a96fac7781f03c842ab680903e79f48b92a3..8bacd296fa4d37ebacadf62d26f3492c9b43cea0 100644 (file)
@@ -387,7 +387,7 @@ ix86_expand_move (machine_mode mode, rtx operands[])
       tmp = XEXP (op1, 0);
 
       if (GET_CODE (tmp) != PLUS
-         || GET_CODE (XEXP (tmp, 0)) != SYMBOL_REF)
+         || !SYMBOL_REF_P (XEXP (tmp, 0)))
        break;
 
       op1 = XEXP (tmp, 0);
@@ -6378,7 +6378,7 @@ ix86_split_long_move (rtx operands[])
         fp moves, that force all constants to memory to allow combining.  */
 
       if (MEM_P (operands[1])
-         && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
+         && SYMBOL_REF_P (XEXP (operands[1], 0))
          && CONSTANT_POOL_ADDRESS_P (XEXP (operands[1], 0)))
        operands[1] = get_pool_constant (XEXP (operands[1], 0));
       if (push_operand (operands[0], VOIDmode))
@@ -10245,7 +10245,7 @@ construct_plt_address (rtx symbol)
 {
   rtx tmp, unspec;
 
-  gcc_assert (GET_CODE (symbol) == SYMBOL_REF);
+  gcc_assert (SYMBOL_REF_P (symbol));
   gcc_assert (ix86_cmodel == CM_LARGE_PIC && !TARGET_PECOFF);
   gcc_assert (Pmode == DImode);
 
@@ -10279,7 +10279,7 @@ ix86_expand_call (rtx retval, rtx fnaddr, rtx callarg1,
   tree fndecl;
   bool call_no_callee_saved_registers = false;
 
-  if (GET_CODE (XEXP (fnaddr, 0)) == SYMBOL_REF)
+  if (SYMBOL_REF_P (XEXP (fnaddr, 0)))
     {
       fndecl = SYMBOL_REF_DECL (XEXP (fnaddr, 0));
       if (fndecl)
@@ -10316,7 +10316,7 @@ ix86_expand_call (rtx retval, rtx fnaddr, rtx callarg1,
   if (TARGET_MACHO && !TARGET_64BIT)
     {
 #if TARGET_MACHO
-      if (flag_pic && GET_CODE (XEXP (fnaddr, 0)) == SYMBOL_REF)
+      if (flag_pic && SYMBOL_REF_P (XEXP (fnaddr, 0)))
        fnaddr = machopic_indirect_call_target (fnaddr);
 #endif
     }
@@ -10326,7 +10326,7 @@ ix86_expand_call (rtx retval, rtx fnaddr, rtx callarg1,
         check if PLT was explicitly avoided via no-plt or "noplt" attribute, making
         it an indirect call.  */
       if (flag_pic
-         && GET_CODE (addr) == SYMBOL_REF
+         && SYMBOL_REF_P (addr)
          && ix86_call_use_plt_p (addr))
        {
          if (flag_plt
@@ -10400,7 +10400,7 @@ ix86_expand_call (rtx retval, rtx fnaddr, rtx callarg1,
   if (ix86_cmodel == CM_LARGE_PIC
       && !TARGET_PECOFF
       && MEM_P (fnaddr)
-      && GET_CODE (XEXP (fnaddr, 0)) == SYMBOL_REF
+      && SYMBOL_REF_P (XEXP (fnaddr, 0))
       && !local_symbolic_operand (XEXP (fnaddr, 0), VOIDmode))
     fnaddr = gen_rtx_MEM (QImode, construct_plt_address (XEXP (fnaddr, 0)));
   /* Since x32 GOT slot is 64 bit with zero upper 32 bits, indirect
@@ -10503,7 +10503,7 @@ ix86_expand_call (rtx retval, rtx fnaddr, rtx callarg1,
     }
 
   if (TARGET_MACHO && TARGET_64BIT && !sibcall
-      && ((GET_CODE (addr) == SYMBOL_REF && !SYMBOL_REF_LOCAL_P (addr))
+      && ((SYMBOL_REF_P (addr) && !SYMBOL_REF_LOCAL_P (addr))
          || !fndecl || TREE_PUBLIC (fndecl)))
     {
       /* We allow public functions defined in a TU to bind locally for PIC
@@ -25670,7 +25670,7 @@ ix86_notrack_prefixed_insn_p (rtx_insn *insn)
 
       /* Do not emit 'notrack' if it's not an indirect call.  */
       if (MEM_P (addr)
-         && GET_CODE (XEXP (addr, 0)) == SYMBOL_REF)
+         && SYMBOL_REF_P (XEXP (addr, 0)))
        return false;
       else
        return find_reg_note (insn, REG_CALL_NOCF_CHECK, 0);
index 734ab70c108479c288bdb0761f8b0b63554b6cdb..bab191b196fab740b682097808a5421bf26efd64 100644 (file)
@@ -2953,7 +2953,7 @@ rest_of_insert_endbr_and_patchable_area (bool need_endbr,
 
                  /* Also generate ENDBRANCH for non-tail call which
                     may return via indirect branch.  */
-                 if (GET_CODE (XEXP (fnaddr, 0)) == SYMBOL_REF)
+                 if (SYMBOL_REF_P (XEXP (fnaddr, 0)))
                    fndecl = SYMBOL_REF_DECL (XEXP (fnaddr, 0));
                  if (fndecl == NULL_TREE)
                    fndecl = MEM_EXPR (fnaddr);
index eef4be4a5656b8cf9ad24e9db21787a9d505a611..92673e48d3f9a62da888414a91f2a406cb81fae7 100644 (file)
@@ -5979,7 +5979,7 @@ symbolic_reference_mentioned_p (rtx op)
   const char *fmt;
   int i;
 
-  if (GET_CODE (op) == SYMBOL_REF || GET_CODE (op) == LABEL_REF)
+  if (SYMBOL_REF_P (op) || GET_CODE (op) == LABEL_REF)
     return true;
 
   fmt = GET_RTX_FORMAT (GET_CODE (op));
@@ -10724,8 +10724,7 @@ split_stack_prologue_scratch_regno (void)
 
 static GTY(()) rtx split_stack_fn;
 
-/* A SYMBOL_REF for the more stack function when using the large
-   model.  */
+/* A SYMBOL_REF for the more stack function when using the large model.  */
 
 static GTY(()) rtx split_stack_fn_large;
 
@@ -11413,7 +11412,7 @@ ix86_force_load_from_GOT_p (rtx x, bool call_p)
          && (!flag_pic || this_is_asm_operands)
          && ix86_cmodel != CM_LARGE
          && ix86_cmodel != CM_LARGE_PIC
-         && GET_CODE (x) == SYMBOL_REF
+         && SYMBOL_REF_P (x)
          && ((!call_p
               && (!ix86_direct_extern_access
                   || (SYMBOL_REF_DECL (x)
@@ -11459,15 +11458,15 @@ ix86_legitimate_constant_p (machine_mode mode, rtx x)
          case UNSPEC_TPOFF:
          case UNSPEC_NTPOFF:
            x = XVECEXP (x, 0, 0);
-           return (GET_CODE (x) == SYMBOL_REF
+           return (SYMBOL_REF_P (x)
                    && SYMBOL_REF_TLS_MODEL (x) == TLS_MODEL_LOCAL_EXEC);
          case UNSPEC_DTPOFF:
            x = XVECEXP (x, 0, 0);
-           return (GET_CODE (x) == SYMBOL_REF
+           return (SYMBOL_REF_P (x)
                    && SYMBOL_REF_TLS_MODEL (x) == TLS_MODEL_LOCAL_DYNAMIC);
          case UNSPEC_SECREL32:
            x = XVECEXP (x, 0, 0);
-           return GET_CODE (x) == SYMBOL_REF;
+           return SYMBOL_REF_P (x);
          default:
            return false;
          }
@@ -11475,7 +11474,7 @@ ix86_legitimate_constant_p (machine_mode mode, rtx x)
       /* We must have drilled down to a symbol.  */
       if (GET_CODE (x) == LABEL_REF)
        return true;
-      if (GET_CODE (x) != SYMBOL_REF)
+      if (!SYMBOL_REF_P (x))
        return false;
       /* FALLTHRU */
 
@@ -11602,11 +11601,11 @@ legitimate_pic_operand_p (rtx x)
            return TARGET_64BIT;
          case UNSPEC_TPOFF:
            x = XVECEXP (inner, 0, 0);
-           return (GET_CODE (x) == SYMBOL_REF
+           return (SYMBOL_REF_P (x)
                    && SYMBOL_REF_TLS_MODEL (x) == TLS_MODEL_LOCAL_EXEC);
          case UNSPEC_SECREL32:
            x = XVECEXP (inner, 0, 0);
-           return GET_CODE (x) == SYMBOL_REF;
+           return SYMBOL_REF_P (x);
          case UNSPEC_MACHOPIC_OFFSET:
            return legitimate_pic_address_disp_p (x);
          default:
@@ -11666,7 +11665,7 @@ legitimate_pic_address_disp_p (rtx disp)
          if (GET_CODE (op0) == UNSPEC
              && XINT (op0, 1) == UNSPEC_PCREL)
            return true;
-         if (GET_CODE (op0) != SYMBOL_REF)
+         if (!SYMBOL_REF_P (op0))
            break;
          /* FALLTHRU */
 
@@ -11731,7 +11730,7 @@ legitimate_pic_address_disp_p (rtx disp)
              && XINT (disp, 1) != UNSPEC_PLTOFF))
        return false;
 
-      if (GET_CODE (XVECEXP (disp, 0, 0)) != SYMBOL_REF
+      if (!SYMBOL_REF_P (XVECEXP (disp, 0, 0))
          && GET_CODE (XVECEXP (disp, 0, 0)) != LABEL_REF)
        return false;
       return true;
@@ -11760,13 +11759,13 @@ legitimate_pic_address_disp_p (rtx disp)
       /* We need to check for both symbols and labels because VxWorks loads
         text labels with @GOT rather than @GOTOFF.  See gotoff_operand for
         details.  */
-      return (GET_CODE (XVECEXP (disp, 0, 0)) == SYMBOL_REF
+      return (SYMBOL_REF_P (XVECEXP (disp, 0, 0))
              || GET_CODE (XVECEXP (disp, 0, 0)) == LABEL_REF);
     case UNSPEC_GOTOFF:
       /* Refuse GOTOFF in 64bit mode since it is always 64bit when used.
         While ABI specify also 32bit relocation but we don't produce it in
         small PIC model at all.  */
-      if ((GET_CODE (XVECEXP (disp, 0, 0)) == SYMBOL_REF
+      if ((SYMBOL_REF_P (XVECEXP (disp, 0, 0))
           || GET_CODE (XVECEXP (disp, 0, 0)) == LABEL_REF)
          && !TARGET_64BIT)
         return !TARGET_PECOFF && gotoff_operand (XVECEXP (disp, 0, 0), Pmode);
@@ -11777,19 +11776,19 @@ legitimate_pic_address_disp_p (rtx disp)
       if (saw_plus)
        return false;
       disp = XVECEXP (disp, 0, 0);
-      return (GET_CODE (disp) == SYMBOL_REF
+      return (SYMBOL_REF_P (disp)
              && SYMBOL_REF_TLS_MODEL (disp) == TLS_MODEL_INITIAL_EXEC);
     case UNSPEC_NTPOFF:
       disp = XVECEXP (disp, 0, 0);
-      return (GET_CODE (disp) == SYMBOL_REF
+      return (SYMBOL_REF_P (disp)
              && SYMBOL_REF_TLS_MODEL (disp) == TLS_MODEL_LOCAL_EXEC);
     case UNSPEC_DTPOFF:
       disp = XVECEXP (disp, 0, 0);
-      return (GET_CODE (disp) == SYMBOL_REF
+      return (SYMBOL_REF_P (disp)
              && SYMBOL_REF_TLS_MODEL (disp) == TLS_MODEL_LOCAL_DYNAMIC);
     case UNSPEC_SECREL32:
       disp = XVECEXP (disp, 0, 0);
-      return GET_CODE (disp) == SYMBOL_REF;
+      return SYMBOL_REF_P (disp);
     }
 
   return false;
@@ -12135,7 +12134,7 @@ ix86_legitimate_address_p (machine_mode, rtx addr, bool strict,
               && !CONST_INT_P (disp)
               && (GET_CODE (disp) != CONST
                   || !ix86_legitimate_constant_p (Pmode, disp))
-              && (GET_CODE (disp) != SYMBOL_REF
+              && (!SYMBOL_REF_P (disp)
                   || !ix86_legitimate_constant_p (Pmode, disp)))
        /* Displacement is not constant.  */
        return false;
@@ -12242,7 +12241,7 @@ legitimize_pic_address (rtx orig, rtx reg)
       else
        new_rtx = gen_rtx_PLUS (Pmode, pic_offset_table_rtx, new_rtx);
     }
-  else if ((GET_CODE (addr) == SYMBOL_REF && SYMBOL_REF_TLS_MODEL (addr) == 0)
+  else if ((SYMBOL_REF_P (addr) && SYMBOL_REF_TLS_MODEL (addr) == 0)
           /* We can't always use @GOTOFF for text labels
              on VxWorks, see gotoff_operand.  */
           || (TARGET_VXWORKS_VAROFF && GET_CODE (addr) == LABEL_REF))
@@ -12380,7 +12379,7 @@ legitimize_pic_address (rtx orig, rtx reg)
                  /* For %rip addressing, we have to use
                     just disp32, not base nor index.  */
                  if (TARGET_64BIT
-                     && (GET_CODE (base) == SYMBOL_REF
+                     && (SYMBOL_REF_P (base)
                          || GET_CODE (base) == LABEL_REF))
                    base = force_reg (mode, base);
                  if (GET_CODE (new_rtx) == PLUS
@@ -12883,12 +12882,12 @@ ix86_legitimize_address (rtx x, rtx, machine_mode mode)
   bool changed = false;
   unsigned log;
 
-  log = GET_CODE (x) == SYMBOL_REF ? SYMBOL_REF_TLS_MODEL (x) : 0;
+  log = SYMBOL_REF_P (x) ? SYMBOL_REF_TLS_MODEL (x) : 0;
   if (log)
     return legitimize_tls_address (x, (enum tls_model) log, false);
   if (GET_CODE (x) == CONST
       && GET_CODE (XEXP (x, 0)) == PLUS
-      && GET_CODE (XEXP (XEXP (x, 0), 0)) == SYMBOL_REF
+      && SYMBOL_REF_P (XEXP (XEXP (x, 0), 0))
       && (log = SYMBOL_REF_TLS_MODEL (XEXP (XEXP (x, 0), 0))))
     {
       rtx t = legitimize_tls_address (XEXP (XEXP (x, 0), 0),
@@ -13305,7 +13304,7 @@ ix86_delegitimize_tls_address (rtx orig_x)
   if (GET_CODE (unspec) != UNSPEC || XINT (unspec, 1) != UNSPEC_NTPOFF)
     return orig_x;
   x = XVECEXP (unspec, 0, 0);
-  gcc_assert (GET_CODE (x) == SYMBOL_REF);
+  gcc_assert (SYMBOL_REF_P (x));
   if (unspec != XEXP (addr.disp, 0))
     x = gen_rtx_PLUS (Pmode, x, XEXP (XEXP (addr.disp, 0), 1));
   if (addr.index)
@@ -14699,7 +14698,7 @@ ix86_print_operand (FILE *file, rtx x, int code)
              if (ASSEMBLER_DIALECT == ASM_ATT)
                putc ('$', file);
            }
-         else if (GET_CODE (x) == CONST || GET_CODE (x) == SYMBOL_REF
+         else if (GET_CODE (x) == CONST || SYMBOL_REF_P (x)
                   || GET_CODE (x) == LABEL_REF)
            {
              if (ASSEMBLER_DIALECT == ASM_ATT)
@@ -14796,7 +14795,7 @@ ix86_print_operand_address_as (FILE *file, rtx addr,
        symbol = XEXP (XEXP (disp, 0), 0);
 
       if (GET_CODE (symbol) == LABEL_REF
-         || (GET_CODE (symbol) == SYMBOL_REF
+         || (SYMBOL_REF_P (symbol)
              && SYMBOL_REF_TLS_MODEL (symbol) == 0))
        base = pc_rtx;
     }
@@ -17680,7 +17679,7 @@ ix86_rip_relative_addr_p (struct ix86_address *parts)
            symbol = XEXP (symbol, 0);
 
          if (GET_CODE (symbol) == LABEL_REF
-             || (GET_CODE (symbol) == SYMBOL_REF
+             || (SYMBOL_REF_P (symbol)
                  && SYMBOL_REF_TLS_MODEL (symbol) == 0)
              || (GET_CODE (symbol) == UNSPEC
                  && (XINT (symbol, 1) == UNSPEC_GOTPCREL
@@ -26798,7 +26797,7 @@ ix86_reloc_rw_mask (void)
 static bool
 symbolic_base_address_p (rtx addr)
 {
-  if (GET_CODE (addr) == SYMBOL_REF)
+  if (SYMBOL_REF_P (addr))
     return true;
 
   if (GET_CODE (addr) == UNSPEC && XINT (addr, 1) == UNSPEC_GOTOFF)
index bfc6c6f3507fa4cb11f3395e28a7d580c6420888..3b11d838b25ba78d810e114e27408a1ca7ded9d2 100644 (file)
@@ -1842,7 +1842,7 @@ typedef struct ix86_args {
 #define STRIP_UNARY(X) (UNARY_P (X) ? XEXP (X, 0) : X)
 
 #define SYMBOLIC_CONST(X)      \
-  (GET_CODE (X) == SYMBOL_REF                                          \
+  (SYMBOL_REF_P (X)                                                    \
    || GET_CODE (X) == LABEL_REF                                                \
    || (GET_CODE (X) == CONST && symbolic_reference_mentioned_p (X)))
 \f
index 83c438b129c9cdd75db8dd7b5a2d90e5bab2a0c0..9c4687e9a2ba392064b66ef4f5813961672ce951 100644 (file)
                   (zero_extend:DI (and:SI (match_dup 1) (match_dup 2))))
              (clobber (reg:CC FLAGS_REG))])]
 {
-  if (GET_CODE (operands[2]) == SYMBOL_REF
+  if (SYMBOL_REF_P (operands[2])
       || GET_CODE (operands[2]) == LABEL_REF)
     {
       operands[2] = shallow_copy_rtx (operands[2]);
index afea80d24ae70291b8f290e1ecb604465e2c4dc5..cdde240f20be85f7c7cc77d5b3415de6c2ec7fac 100644 (file)
 
     case CONST:
       op = XEXP (op, 0);
-      if (GET_CODE (op) == SYMBOL_REF
+      if (SYMBOL_REF_P (op)
          || GET_CODE (op) == LABEL_REF
          || (GET_CODE (op) == UNSPEC
              && (XINT (op, 1) == UNSPEC_GOT
        return false;
 
       op = XEXP (op, 0);
-      if (GET_CODE (op) == SYMBOL_REF
+      if (SYMBOL_REF_P (op)
          || GET_CODE (op) == LABEL_REF)
        return true;
       /* Only @GOTOFF gets offsets.  */
        return false;
 
       op = XVECEXP (op, 0, 0);
-      if (GET_CODE (op) == SYMBOL_REF
+      if (SYMBOL_REF_P (op)
          || GET_CODE (op) == LABEL_REF)
        return true;
       return false;
   if (GET_CODE (op) == LABEL_REF)
     return true;
 
-  if (GET_CODE (op) != SYMBOL_REF)
+  if (!SYMBOL_REF_P (op))
     return false;
 
   if (SYMBOL_REF_TLS_MODEL (op))
       && CONST_INT_P (XEXP (XEXP (op, 0), 1)))
     op = XEXP (XEXP (op, 0), 0);
 
-  if (GET_CODE (op) == SYMBOL_REF
+  if (SYMBOL_REF_P (op)
       && !SYMBOL_REF_FUNCTION_P (op))
     return false;
 
        }
       if (TARGET_64BIT
          && flag_pic
-         && (GET_CODE (disp) == SYMBOL_REF
+         && (SYMBOL_REF_P (disp)
              || GET_CODE (disp) == LABEL_REF))
        return false;
     }