xref: /netbsd-src/external/gpl3/gcc.old/dist/gcc/config/vax/predicates.md (revision 8feb0f0b7eaff0608f8350bbfa3098827b4bb91b)
1;; Predicate definitions for DEC VAX.
2;; Copyright (C) 2007-2020 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.
10;;
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.
15;;
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/>.
19
20;; Special case of a symbolic operand that's used as a
21;; operand.
22
23(define_predicate "symbolic_operand"
24  (match_code "const,symbol_ref,label_ref"))
25
26(define_predicate "local_symbolic_operand"
27  (match_code "const,symbol_ref,label_ref")
28{
29  if (GET_CODE (op) == LABEL_REF)
30    return 1;
31  if (GET_CODE (op) == SYMBOL_REF)
32    return !flag_pic || SYMBOL_REF_LOCAL_P (op);
33  if (GET_CODE (XEXP (XEXP (op, 0), 0)) == LABEL_REF)
34    return 1;
35  return !flag_pic || SYMBOL_REF_LOCAL_P (XEXP (XEXP (op, 0), 0));
36})
37
38(define_predicate "external_symbolic_operand"
39  (and (match_code "symbol_ref")
40       (not (match_operand 0 "local_symbolic_operand" ""))))
41
42(define_predicate "external_const_operand"
43  (and (match_code "const")
44       (match_test "GET_CODE (XEXP (XEXP (op, 0), 0)) == SYMBOL_REF
45		    && !SYMBOL_REF_LOCAL_P (XEXP (XEXP (op, 0), 0))")))
46
47(define_predicate "nonsymbolic_operand"
48  (and (ior (match_test "!flag_pic")
49	    (not (match_operand 0 "symbolic_operand")))
50       (match_operand 0 "general_operand" "")))
51
52(define_predicate "external_memory_operand"
53   (match_code "mem")
54{
55  rtx addr = XEXP (op, 0);
56  if (MEM_P (addr))
57    addr = XEXP (addr, 0);
58  if (GET_CODE (addr) == PLUS)
59    addr = XEXP (addr, 1);
60  if (MEM_P (addr))
61    addr = XEXP (addr, 0);
62  if (GET_CODE (addr) == PLUS)
63    addr = XEXP (addr, 1);
64  return external_symbolic_operand (addr, SImode)
65	 || external_const_operand (addr, SImode);
66})
67
68(define_predicate "indirect_memory_operand"
69   (match_code "mem")
70{
71  op = XEXP (op, 0);
72  if (MEM_P (op))
73    return 1;
74  if (GET_CODE (op) == PLUS)
75    op = XEXP (op, 1);
76  return MEM_P (op);
77})
78
79(define_predicate "indexed_memory_operand"
80   (match_code "mem")
81{
82  rtx addr = XEXP (op, 0);
83  return GET_CODE (addr) != PRE_DEC && GET_CODE (addr) != POST_INC
84	 && mode_dependent_address_p (addr, MEM_ADDR_SPACE (op));
85})
86
87(define_predicate "illegal_blk_memory_operand"
88   (and (match_code "mem")
89	(ior (and (match_test "flag_pic")
90		  (match_operand 0 "external_memory_operand" ""))
91	     (ior (match_operand 0 "indexed_memory_operand" "")
92		  (ior (match_operand 0 "indirect_memory_operand" "")
93		       (match_test "GET_CODE (XEXP (op, 0)) == PRE_DEC"))))))
94
95(define_predicate "illegal_addsub_di_memory_operand"
96   (and (match_code "mem")
97	(ior (and (match_test "flag_pic")
98		  (match_operand 0 "external_memory_operand" ""))
99	     (ior (match_operand 0 "indexed_memory_operand" "")
100		  (ior (match_operand 0 "indirect_memory_operand" "")
101		       (match_test "GET_CODE (XEXP (op, 0)) == PRE_DEC"))))))
102
103(define_predicate "nonimmediate_addsub_di_operand"
104   (and (match_code "subreg,reg,mem")
105	(and (match_operand:DI 0 "nonimmediate_operand" "")
106	     (not (match_operand:DI 0 "illegal_addsub_di_memory_operand")))))
107
108(define_predicate "general_addsub_di_operand"
109   (and (match_code "const_int,const_double,subreg,reg,mem")
110	(and (match_operand:DI 0 "general_operand" "")
111	     (not (match_operand:DI 0 "illegal_addsub_di_memory_operand")))))
112
113;; Return 1 if the operand is in volatile memory.  Note that during the
114;; RTL generation phase, memory_operand does not return TRUE for volatile
115;; memory references.  So this function allows us to recognize volatile
116;; references where it's safe.
117(define_predicate "volatile_mem_operand"
118  (and (and (match_code "mem")
119	    (match_test "MEM_VOLATILE_P (op)"))
120       (if_then_else (match_test "reload_completed")
121         (match_operand 0 "memory_operand")
122         (if_then_else (match_test "reload_in_progress")
123	   (match_test "strict_memory_address_p (mode, XEXP (op, 0))")
124	   (match_test "memory_address_p (mode, XEXP (op, 0))")))))
125