1 ;; Operand and operator predicates for the GCC MMIX port.
2 ;; Copyright (C) 2005, 2007 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 ;; True if this is a foldable comparison operator
21 ;; - one where a the result of (compare:CC (reg) (const_int 0)) can be
22 ;; replaced by (reg). */
24 (define_predicate "mmix_foldable_comparison_operator"
25 (match_code "ne, eq, ge, gt, le, lt, gtu, leu")
27 RTX_CODE code = GET_CODE (op);
32 /* This little bit is why the body of this predicate is kept as C. */
34 mode = GET_MODE (XEXP (op, 0));
36 return ((mode == CCmode || mode == DImode)
37 && (code == NE || code == EQ || code == GE || code == GT
38 || code == LE || code == LT))
39 /* FIXME: This may be a stupid trick. What happens when GCC wants to
40 reverse the condition? Can it do that by itself? Maybe it can
41 even reverse the condition to fit a foldable one in the first
43 || (mode == CC_UNSmode && (code == GTU || code == LEU));
46 ;; Like comparison_operator, but only true if this comparison operator is
47 ;; applied to a valid mode. Needed to avoid jump.c generating invalid
48 ;; code with -ffast-math (gcc.dg/20001228-1.c).
50 (define_predicate "mmix_comparison_operator"
51 (match_operand 0 "comparison_operator")
53 RTX_CODE code = GET_CODE (op);
55 /* Comparison operators usually don't have a mode, but let's try and get
56 one anyway for the day that changes. */
60 /* Get the mode from the first operand if we don't have one.
61 Also the reason why we do this in C. */
63 mode = GET_MODE (XEXP (op, 0));
65 /* FIXME: This needs to be kept in sync with the tables in
66 mmix_output_condition. */
69 || (mode == CC_FUNmode
70 && (code == ORDERED || code == UNORDERED))
72 && (code == GT || code == LT))
73 || (mode == CC_FPEQmode
74 && (code == NE || code == EQ))
75 || (mode == CC_UNSmode
76 && (code == GEU || code == GTU || code == LEU || code == LTU))
78 && (code == NE || code == EQ || code == GE || code == GT
79 || code == LE || code == LT))
81 && (code == NE || code == EQ || code == GE || code == GT
82 || code == LE || code == LT || code == LEU || code == GTU));
85 ;; True if this is a register with a condition-code mode.
87 (define_predicate "mmix_reg_cc_operand"
88 (and (match_operand 0 "register_operand")
89 (ior (match_test "GET_MODE (op) == CCmode")
90 (ior (match_test "GET_MODE (op) == CC_UNSmode")
91 (ior (match_test "GET_MODE (op) == CC_FPmode")
92 (ior (match_test "GET_MODE (op) == CC_FPEQmode")
93 (match_test "GET_MODE (op) == CC_FUNmode")))))))
95 ;; True if this is an address_operand or a symbolic operand.
97 (define_predicate "mmix_symbolic_or_address_operand"
98 (match_code "symbol_ref, label_ref, const, subreg, reg, plus")
100 switch (GET_CODE (op))
106 /* The reason why this body still is C. */
108 if ((GET_CODE (XEXP (op, 0)) == SYMBOL_REF
109 || GET_CODE (XEXP (op, 0)) == LABEL_REF)
110 && (GET_CODE (XEXP (op, 1)) == CONST_INT
111 || (GET_CODE (XEXP (op, 1)) == CONST_DOUBLE
112 && GET_MODE (XEXP (op, 1)) == VOIDmode)))
116 return address_operand (op, mode);
120 ;; True if this is a register or CONST_INT (or CONST_DOUBLE for DImode).
121 ;; We could narrow the value down with a couple of predicates, but that
122 ;; doesn't seem to be worth it at the moment.
124 (define_predicate "mmix_reg_or_constant_operand"
125 (ior (match_operand 0 "register_operand")
126 (ior (match_code "const_int")
127 (and (match_code "const_double")
128 (match_test "GET_MODE (op) == VOIDmode")))))
130 ;; True if this is a register or 0 (int or float).
132 (define_predicate "mmix_reg_or_0_operand"
134 (match_operand 0 "register_operand")
136 (and (match_code "const_int")
137 (match_test "op == const0_rtx"))
139 (match_code "const_double")
140 ;; FIXME: Is mode calculation necessary and correct?
142 "op == CONST0_RTX (mode == VOIDmode ? GET_MODE (op) : mode)")))))
144 ;; True if this is a register or an int 0..255.
146 (define_predicate "mmix_reg_or_8bit_operand"
148 (match_operand 0 "register_operand")
149 (and (match_code "const_int")
150 (match_test "CONST_OK_FOR_LETTER_P (INTVAL (op), 'I')"))))