1 ;; Predicate definitions for XSTORMY16.
2 ;; Copyright (C) 2005-2017 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 ;; Return 1 if OP is a shift operator.
22 (define_predicate "shift_operator"
23 (match_code "ashift,ashiftrt,lshiftrt")
25 enum rtx_code code = GET_CODE (op);
27 return (code == ASHIFT
32 ;; Return 1 if this is an EQ or NE operator.
34 (define_predicate "equality_operator"
37 return ((mode == VOIDmode || GET_MODE (op) == mode)
38 && (GET_CODE (op) == EQ || GET_CODE (op) == NE));
41 ;; Return 1 if this is a comparison operator but not an EQ or NE
44 (define_predicate "inequality_operator"
45 (match_code "ge,gt,le,lt,geu,gtu,leu,ltu")
47 return comparison_operator (op, mode) && ! equality_operator (op, mode);
50 ;; Return 1 if this is a LT, GE, LTU, or GEU operator.
52 (define_predicate "xstormy16_ineqsi_operator"
53 (match_code "lt,ge,ltu,geu")
55 enum rtx_code code = GET_CODE (op);
57 return ((mode == VOIDmode || GET_MODE (op) == mode)
58 && (code == LT || code == GE || code == LTU || code == GEU));
61 ;; Predicate for MEMs that can use special 8-bit addressing.
63 (define_predicate "xstormy16_below100_operand"
66 if (GET_MODE (op) != mode)
68 if (GET_CODE (op) == MEM)
70 else if (GET_CODE (op) == SUBREG
71 && GET_CODE (XEXP (op, 0)) == MEM
72 && !MEM_VOLATILE_P (XEXP (op, 0)))
73 op = XEXP (XEXP (op, 0), 0);
76 if (GET_CODE (op) == CONST_INT)
78 HOST_WIDE_INT i = INTVAL (op);
79 return (i >= 0x7f00 && i < 0x7fff);
81 return xstormy16_below100_symbol (op, HImode);
84 ;; TODO: Add a comment here.
86 (define_predicate "xstormy16_below100_or_register"
87 (match_code "mem,reg,subreg")
89 return (xstormy16_below100_operand (op, mode)
90 || register_operand (op, mode));
93 ;; TODO: Add a comment here.
95 (define_predicate "xstormy16_splittable_below100_or_register"
96 (match_code "mem,reg,subreg")
98 if (GET_CODE (op) == MEM && MEM_VOLATILE_P (op))
100 return (xstormy16_below100_operand (op, mode)
101 || register_operand (op, mode));
104 ;; Predicate for constants with exactly one bit not set.
106 (define_predicate "xstormy16_onebit_clr_operand"
107 (match_code "const_int")
110 if (GET_CODE (op) != CONST_INT)
117 return exact_log2 (i) != -1;
120 ;; Predicate for constants with exactly one bit set.
122 (define_predicate "xstormy16_onebit_set_operand"
123 (match_code "const_int")
126 if (GET_CODE (op) != CONST_INT)
133 return exact_log2 (i) != -1;
136 ;; TODO: Add a comment here.
138 (define_predicate "nonimmediate_nonstack_operand"
139 (match_code "reg,mem,subreg")
141 /* 'Q' is for pushes, 'R' for pops. */
142 return (nonimmediate_operand (op, mode)
143 && ! satisfies_constraint_Q (op)
144 && ! satisfies_constraint_R (op));
147 (define_predicate "xstormy16_carry_plus_operand"
150 return (GET_CODE (XEXP (op, 1)) == CONST_INT
151 && (INTVAL (XEXP (op, 1)) < -4 || INTVAL (XEXP (op, 1)) > 4));
154 (define_predicate "xs_hi_nonmemory_operand"
155 (match_code "const_int,reg,subreg,const")
157 return nonmemory_operand (op, mode);