1 ;; Predicate definitions for ATMEL AVR micro controllers.
2 ;; Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
4 ;; This file is part of GCC.
6 ;; GCC is free software; you can redistribute it and/or modify
7 ;; it under the terms of the GNU General Public License as published by
8 ;; the Free Software Foundation; either version 3, or (at your option)
11 ;; GCC is distributed in the hope that it will be useful,
12 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;; GNU General Public License 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 ;; Registers from r0 to r15.
21 (define_predicate "l_register_operand"
22 (and (match_code "reg")
23 (match_test "REGNO (op) <= 15")))
25 ;; Registers from r16 to r31.
26 (define_predicate "d_register_operand"
27 (and (match_code "reg")
28 (match_test "REGNO (op) >= 16 && REGNO (op) <= 31")))
30 (define_predicate "even_register_operand"
31 (and (match_code "reg")
32 (and (match_test "REGNO (op) <= 31")
33 (match_test "(REGNO (op) & 1) == 0"))))
35 (define_predicate "odd_register_operand"
36 (and (match_code "reg")
37 (and (match_test "REGNO (op) <= 31")
38 (match_test "(REGNO (op) & 1) != 0"))))
41 (define_predicate "stack_register_operand"
42 (and (match_code "reg")
43 (match_test "REGNO (op) == REG_SP")))
45 ;; Return true if OP is a valid address for lower half of I/O space.
46 (define_predicate "low_io_address_operand"
47 (and (match_code "const_int")
48 (match_test "IN_RANGE((INTVAL (op)), 0x20, 0x3F)")))
50 ;; Return true if OP is a valid address for high half of I/O space.
51 (define_predicate "high_io_address_operand"
52 (and (match_code "const_int")
53 (match_test "IN_RANGE((INTVAL (op)), 0x40, 0x5F)")))
55 ;; Return true if OP is a valid address of I/O space.
56 (define_predicate "io_address_operand"
57 (and (match_code "const_int")
58 (match_test "IN_RANGE((INTVAL (op)), 0x20, (0x60 - GET_MODE_SIZE(mode)))")))
60 ;; Return 1 if OP is the zero constant for MODE.
61 (define_predicate "const0_operand"
62 (and (match_code "const_int,const_double")
63 (match_test "op == CONST0_RTX (mode)")))
65 ;; Return 1 if OP is the one constant integer for MODE.
66 (define_predicate "const1_operand"
67 (and (match_code "const_int")
68 (match_test "op == CONST1_RTX (mode)")))
71 ;; Return 1 if OP is constant integer 0..7 for MODE.
72 (define_predicate "const_0_to_7_operand"
73 (and (match_code "const_int")
74 (match_test "IN_RANGE (INTVAL (op), 0, 7)")))
76 ;; Return 1 if OP is constant integer 2..7 for MODE.
77 (define_predicate "const_2_to_7_operand"
78 (and (match_code "const_int")
79 (match_test "IN_RANGE (INTVAL (op), 2, 7)")))
81 ;; Return 1 if OP is constant integer 2..6 for MODE.
82 (define_predicate "const_2_to_6_operand"
83 (and (match_code "const_int")
84 (match_test "IN_RANGE (INTVAL (op), 2, 6)")))
86 ;; Returns true if OP is either the constant zero or a register.
87 (define_predicate "reg_or_0_operand"
88 (ior (match_operand 0 "register_operand")
89 (match_operand 0 "const0_operand")))
91 ;; Returns 1 if OP is a SYMBOL_REF.
92 (define_predicate "symbol_ref_operand"
93 (match_code "symbol_ref"))
95 ;; Return true if OP is a text segment reference.
96 ;; This is needed for program memory address expressions.
97 (define_predicate "text_segment_operand"
98 (match_code "code_label,label_ref,symbol_ref,plus,const")
100 switch (GET_CODE (op))
107 return SYMBOL_REF_FUNCTION_P (op);
109 /* Assume canonical format of symbol + constant.
112 return text_segment_operand (XEXP (op, 0), VOIDmode);
118 ;; Return true if OP is a constant that contains only one 1 in its
119 ;; binary representation.
120 (define_predicate "single_one_operand"
121 (and (match_code "const_int")
122 (match_test "exact_log2(INTVAL (op) & GET_MODE_MASK (mode)) >= 0")))
124 ;; Return true if OP is a constant that contains only one 0 in its
125 ;; binary representation.
126 (define_predicate "single_zero_operand"
127 (and (match_code "const_int")
128 (match_test "exact_log2(~INTVAL (op) & GET_MODE_MASK (mode)) >= 0")))
131 (define_predicate "avr_sp_immediate_operand"
132 (and (match_code "const_int")
133 (match_test "INTVAL (op) >= -6 && INTVAL (op) <= 5")))
136 (define_predicate "eqne_operator"
137 (match_code "eq,ne"))
140 (define_predicate "gelt_operator"
141 (match_code "ge,lt"))
143 ;; True for GT, GTU, LE & LEU
144 (define_predicate "difficult_comparison_operator"
145 (match_code "gt,gtu,le,leu"))
147 ;; False for GT, GTU, LE & LEU
148 (define_predicate "simple_comparison_operator"
149 (and (match_operand 0 "comparison_operator")
150 (not (match_code "gt,gtu,le,leu"))))
152 ;; Return true if OP is a valid call operand.
153 (define_predicate "call_insn_operand"
154 (and (match_code "mem")
155 (ior (match_test "register_operand (XEXP (op, 0), mode)")
156 (match_test "CONSTANT_ADDRESS_P (XEXP (op, 0))"))))
158 ;; True for register that is pseudo register.
159 (define_predicate "pseudo_register_operand"
160 (and (match_code "reg")
161 (match_test "!HARD_REGISTER_P (op)")))
163 ;; Return true if OP is a constant integer that is either
165 (define_predicate "const_8_16_24_operand"
166 (and (match_code "const_int")
167 (match_test "8 == INTVAL(op) || 16 == INTVAL(op) || 24 == INTVAL(op)")))
169 ;; Unsigned CONST_INT that fits in 8 bits, i.e. 0..255.
170 (define_predicate "u8_operand"
171 (and (match_code "const_int")
172 (match_test "IN_RANGE (INTVAL (op), 0, 255)")))
174 ;; Signed CONST_INT that fits in 8 bits, i.e. -128..127.
175 (define_predicate "s8_operand"
176 (and (match_code "const_int")
177 (match_test "IN_RANGE (INTVAL (op), -128, 127)")))
179 ;; One-extended CONST_INT that fits in 8 bits, i.e. -256..-1.
180 (define_predicate "o8_operand"
181 (and (match_code "const_int")
182 (match_test "IN_RANGE (INTVAL (op), -256, -1)")))
184 ;; Signed CONST_INT that fits in 9 bits, i.e. -256..255.
185 (define_predicate "s9_operand"
186 (and (match_code "const_int")
187 (match_test "IN_RANGE (INTVAL (op), -256, 255)")))
189 (define_predicate "register_or_s9_operand"
190 (ior (match_operand 0 "register_operand")
191 (match_operand 0 "s9_operand")))