2018-02-09 Sebastian Perta <sebastian.perta@renesas.com>
[official-gcc.git] / gcc / config / vax / predicates.md
blob26c50eff2f3f19d53b7ddd40ca804d180089cc00
1 ;; Predicate definitions for DEC VAX.
2 ;; Copyright (C) 2007-2018 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 ;; Special case of a symbolic operand that's used as a
21 ;; operand.
23 (define_predicate "symbolic_operand"
24   (match_code "const,symbol_ref,label_ref"))
26 (define_predicate "local_symbolic_operand"
27   (match_code "const,symbol_ref,label_ref")
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));
38 (define_predicate "external_symbolic_operand"
39   (and (match_code "symbol_ref")
40        (not (match_operand 0 "local_symbolic_operand" ""))))
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))")))
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" "")))
52 (define_predicate "external_memory_operand"
53    (match_code "mem")
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);
68 (define_predicate "indirect_memory_operand"
69    (match_code "mem")
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);
79 (define_predicate "indexed_memory_operand"
80    (match_code "mem")
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));
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"))))))
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"))))))
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")))))
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")))))