xref: /openbsd/gnu/gcc/gcc/config/avr/predicates.md (revision 09467b48)
1;; Predicate definitions for ATMEL AVR micro controllers.
2;; Copyright (C) 2006, 2007 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
7;; it under the terms of the GNU General Public License as published by
8;; the Free Software Foundation; either version 2, or (at your option)
9;; any later version.
10;;
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.
15;;
16;; You should have received a copy of the GNU General Public License
17;; along with GCC; see the file COPYING.  If not, write to
18;; the Free Software Foundation, 51 Franklin Street, Fifth Floor,
19;; Boston, MA 02110-1301, USA.
20
21;; Registers from r0 to r15.
22(define_predicate "l_register_operand"
23  (and (match_code "reg")
24       (match_test "REGNO (op) <= 15")))
25
26;; Registers from r16 to r31.
27(define_predicate "d_register_operand"
28  (and (match_code "reg")
29       (match_test "REGNO (op) >= 16 && REGNO (op) <= 31")))
30
31;; SP register.
32(define_predicate "stack_register_operand"
33  (and (match_code "reg")
34       (match_test "REGNO (op) == REG_SP")))
35
36;; Return true if OP is a valid address for lower half of I/O space.
37(define_predicate "low_io_address_operand"
38  (and (match_code "const_int")
39       (match_test "IN_RANGE((INTVAL (op)), 0x20, 0x3F)")))
40
41;; Return true if OP is a valid address for high half of I/O space.
42(define_predicate "high_io_address_operand"
43  (and (match_code "const_int")
44       (match_test "IN_RANGE((INTVAL (op)), 0x40, 0x5F)")))
45
46;; Returns 1 if OP is a SYMBOL_REF.
47(define_predicate "symbol_ref_operand"
48  (match_code "symbol_ref"))
49
50;; Return true if OP is a constant that contains only one 1 in its
51;; binary representation.
52(define_predicate "single_one_operand"
53  (and (match_code "const_int")
54       (match_test "exact_log2(INTVAL (op) & GET_MODE_MASK (mode)) >= 0")))
55
56;; Return true if OP is a constant that contains only one 0 in its
57;; binary representation.
58(define_predicate "single_zero_operand"
59  (and (match_code "const_int")
60       (match_test "exact_log2(~INTVAL (op) & GET_MODE_MASK (mode)) >= 0")))
61
62;; True for EQ & NE
63(define_predicate "eqne_operator"
64  (match_code "eq,ne"))
65
66;; True for GE & LT
67(define_predicate "gelt_operator"
68  (match_code "ge,lt"))
69
70;; True for GT, GTU, LE & LEU
71(define_predicate "difficult_comparison_operator"
72  (match_code "gt,gtu,le,leu"))
73
74;; False for GT, GTU, LE & LEU
75(define_predicate "simple_comparison_operator"
76  (and (match_operand 0 "comparison_operator")
77       (not (match_code "gt,gtu,le,leu"))))
78