]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/rl78/predicates.md
rl78-real.md (addqi3_real): Allow volatiles.
[thirdparty/gcc.git] / gcc / config / rl78 / predicates.md
1 ;; Machine Description for Renesas RL78 processors
2 ;; Copyright (C) 2011-2015 Free Software Foundation, Inc.
3 ;; Contributed by Red Hat.
4
5 ;; This file is part of GCC.
6
7 ;; GCC is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 3, or (at your option)
10 ;; any later version.
11
12 ;; GCC is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
16
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GCC; see the file COPYING3. If not see
19 ;; <http://www.gnu.org/licenses/>.
20 \f
21
22 (define_predicate "rl78_volatile_memory_operand"
23 (and (match_code "mem")
24 (match_test ("memory_address_addr_space_p (GET_MODE (op), XEXP (op, 0), MEM_ADDR_SPACE (op))")))
25 )
26
27 ; TRUE for any valid general operand. We do this because
28 ; general_operand refuses to match volatile memory refs.
29
30 (define_predicate "rl78_general_operand"
31 (ior (match_operand 0 "general_operand")
32 (match_operand 0 "rl78_volatile_memory_operand"))
33 )
34
35 ; Likewise for nonimmediate_operand.
36
37 (define_predicate "rl78_nonimmediate_operand"
38 (ior (match_operand 0 "nonimmediate_operand")
39 (match_operand 0 "rl78_volatile_memory_operand"))
40 )
41
42 (define_predicate "rl78_nonfar_operand"
43 (and (match_operand 0 "rl78_general_operand")
44 (not (match_test "rl78_far_p (op)")))
45 )
46
47 (define_predicate "rl78_nonfar_nonimm_operand"
48 (and (match_operand 0 "rl78_nonimmediate_operand")
49 (not (match_test "rl78_far_p (op)")))
50 )
51
52 (define_predicate "rl78_near_mem_operand"
53 (and (match_code "mem")
54 (match_test "!rl78_far_p (op) && rl78_as_legitimate_address (VOIDmode, XEXP (op, 0), true, ADDR_SPACE_GENERIC)"))
55 )
56
57 (define_predicate "ubyte_operand"
58 (and (match_code "const_int")
59 (match_test "IN_RANGE (INTVAL (op), 0, 255)")))
60
61 (define_predicate "rl78_24_operand"
62 (and (match_code "const_int")
63 (match_test "INTVAL (op) == 2 || INTVAL (op) == 4")))
64
65 (define_predicate "uword_operand"
66 (ior (ior (ior (match_code "const")
67 (and (match_code "const_int")
68 (match_test "IN_RANGE (INTVAL (op), 0, 65536)")))
69 (and (match_code "subreg")
70 (ior (match_code "symbol_ref" "0")
71 (match_code "const" "0"))))
72 (match_code "symbol_ref")
73 ))
74
75 (define_predicate "rl78_cmp_operator_signed"
76 (match_code "gt,ge,lt,le"))
77 (define_predicate "rl78_cmp_operator_real"
78 (match_code "eq,ne,gtu,ltu,geu,leu"))
79 (define_predicate "rl78_cmp_operator"
80 (match_code "eq,ne,gtu,ltu,geu,leu,gt,lt,ge,le"))
81
82 (define_predicate "rl78_ax_operand"
83 (and (match_code "reg")
84 (match_test "REGNO (op) == AX_REG || REGNO (op) >= FIRST_PSEUDO_REGISTER")))
85
86 (define_predicate "rl78_addw_operand"
87 (and (match_code "reg")
88 (match_test "REGNO (op) == AX_REG || REGNO (op) == SP_REG || REGNO (op) >= FIRST_PSEUDO_REGISTER")))
89
90 (define_predicate "rl78_stack_based_mem"
91 (and (match_code "mem")
92 (ior (and (match_code "reg" "0")
93 (match_test "REGNO (XEXP (op, 0)) == SP_REG"))
94 (and (match_code "plus" "0")
95 (and (match_code "reg" "00")
96 (match_test "REGNO (XEXP (XEXP (op, 0), 0)) == SP_REG")
97 (and (match_code "const_int" "01")
98 (match_test "IN_RANGE (INTVAL (XEXP (XEXP (op, 0), 1)), 0, 256 - GET_MODE_SIZE (GET_MODE (op)))"))
99 )))))