RISC-V: Make stack_save_restore tests more robust
[official-gcc.git] / gcc / config / vax / predicates.md
blob286c21516b46a1ec6a4cf270d7d6bd4fcc06fa97
1 ;; Predicate definitions for DEC VAX.
2 ;; Copyright (C) 2007-2023 Free Software Foundation, Inc.
3 ;;
4 ;; This file is part of GCC.
5 ;;
6 ;; GCC is free software; you can redistribute it and/or modify it under
7 ;; the terms of the GNU General Public License as published by the Free
8 ;; Software Foundation; either version 3, or (at your option) any later
9 ;; version.
11 ;; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 ;; WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 ;; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 ;; for more details.
16 ;; You should have received a copy of the GNU General Public License
17 ;; along with GCC; see the file COPYING3.  If not see
18 ;; <http://www.gnu.org/licenses/>.
20 ;; Return true if OP is a constant zero operand.
21 (define_predicate "const_zero_operand"
22   (match_test "op == CONST0_RTX (mode)"))
24 ;; Special case of a symbolic operand that's used as a
25 ;; operand.
27 (define_predicate "symbolic_operand"
28   (match_code "const,symbol_ref,label_ref"))
30 (define_predicate "pic_symbolic_operand"
31   (and (match_code "const,symbol_ref,label_ref")
32        (match_test "!flag_pic
33                     || vax_acceptable_pic_operand_p (op, false, true)")))
35 (define_predicate "nonsymbolic_operand"
36   (and (ior (match_test "!flag_pic")
37             (not (match_operand 0 "symbolic_operand")))
38        (match_operand 0 "general_operand" "")))
40 (define_predicate "non_pic_external_memory_operand"
41    (match_code "mem")
43   rtx addr = XEXP (op, 0);
44   if (MEM_P (addr))
45     addr = XEXP (addr, 0);
46   if (GET_CODE (addr) == PLUS)
47     addr = XEXP (addr, 1);
48   if (MEM_P (addr))
49     addr = XEXP (addr, 0);
50   if (GET_CODE (addr) == PLUS)
51     addr = XEXP (addr, 1);
52   return (symbolic_operand (addr, SImode)
53           && !vax_acceptable_pic_operand_p (addr, true, true));
56 (define_predicate "indirect_memory_operand"
57    (match_code "mem")
59   op = XEXP (op, 0);
60   if (MEM_P (op))
61     return 1;
62   if (GET_CODE (op) == PLUS)
63     op = XEXP (op, 1);
64   return MEM_P (op);
67 (define_predicate "indexed_memory_operand"
68    (match_code "mem")
70   rtx addr = XEXP (op, 0);
71   return GET_CODE (addr) != PRE_DEC && GET_CODE (addr) != POST_INC
72          && mode_dependent_address_p (addr, MEM_ADDR_SPACE (op));
75 (define_predicate "illegal_blk_memory_operand"
76    (and (match_code "mem")
77         (ior (and (match_test "flag_pic")
78                   (match_operand 0 "non_pic_external_memory_operand" ""))
79              (ior (match_operand 0 "indexed_memory_operand" "")
80                   (ior (match_operand 0 "indirect_memory_operand" "")
81                        (match_test "GET_CODE (XEXP (op, 0)) == PRE_DEC"))))))
83 (define_predicate "illegal_addsub_di_memory_operand"
84    (and (match_code "mem")
85         (ior (and (match_test "flag_pic")
86                   (match_operand 0 "non_pic_external_memory_operand" ""))
87              (ior (match_operand 0 "indexed_memory_operand" "")
88                   (ior (match_operand 0 "indirect_memory_operand" "")
89                        (match_test "GET_CODE (XEXP (op, 0)) == PRE_DEC"))))))
91 (define_predicate "nonimmediate_addsub_di_operand"
92    (and (match_code "subreg,reg,mem")
93         (and (match_operand:DI 0 "nonimmediate_operand" "")
94              (not (match_operand:DI 0 "illegal_addsub_di_memory_operand")))))
96 (define_predicate "general_addsub_di_operand"
97    (and (match_code "const_int,const_double,subreg,reg,mem")
98         (and (match_operand:DI 0 "general_operand" "")
99              (not (match_operand:DI 0 "illegal_addsub_di_memory_operand")))))
101 ;; Return 1 if the operand is in volatile memory.  Note that during the
102 ;; RTL generation phase, `memory_operand' does not return TRUE for
103 ;; volatile memory references.  So this function allows us to recognize
104 ;; volatile references where it's safe.
105 (define_predicate "volatile_mem_operand"
106   (and (match_code "mem")
107        (match_test "MEM_VOLATILE_P (op)")
108        (if_then_else (match_test "reload_completed")
109          (match_operand 0 "memory_operand")
110          (match_test "memory_address_p (mode, XEXP (op, 0))"))))
112 ;; Return 1 if the operand is a volatile or non-volatile memory operand.
113 (define_predicate "any_memory_operand"
114   (ior (match_operand 0 "memory_operand")
115        (match_operand 0 "volatile_mem_operand")))
117 ;; Return true if OP is a comparison operator that requires at least CCmode.
118 (define_predicate "vax_cc_comparison_operator"
119   (match_code "geu,gtu,leu,ltu"))
121 ;; Return true if OP is a comparison operator that requires at least CCNmode.
122 (define_predicate "vax_ccn_comparison_operator"
123   (match_code "ge,lt"))
125 ;; Return true if OP is a comparison operator that requires at least CCNZmode.
126 (define_predicate "vax_ccnz_comparison_operator"
127   (match_code "gt,le"))
129 ;; Return true if OP is a comparison operator that requires at least CCZmode.
130 (define_predicate "vax_ccz_comparison_operator"
131   (match_code "ne,eq"))