OSDN Git Service

* config/dfp-bit.c (DFP_TO_INT): Remove unnecessary cast.
[pf3gnuchains/gcc-fork.git] / gcc / config / mmix / predicates.md
1 ;; Operand and operator predicates for the GCC MMIX port.
2 ;; Copyright (C) 2005, 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 3, 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 COPYING3.  If not see
18 ;; <http://www.gnu.org/licenses/>.
19
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).  */
23
24 (define_predicate "mmix_foldable_comparison_operator"
25   (match_code "ne, eq, ge, gt, le, lt, gtu, leu")
26 {
27   RTX_CODE code = GET_CODE (op);
28
29   if (mode == VOIDmode)
30     mode = GET_MODE (op);
31
32   /* This little bit is why the body of this predicate is kept as C.  */
33   if (mode == VOIDmode)
34     mode = GET_MODE (XEXP (op, 0));
35
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
42        place?  */
43     || (mode == CC_UNSmode && (code == GTU || code == LEU));
44 })
45
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).
49
50 (define_predicate "mmix_comparison_operator"
51   (match_operand 0 "comparison_operator")
52 {
53   RTX_CODE code = GET_CODE (op);
54
55   /* Comparison operators usually don't have a mode, but let's try and get
56      one anyway for the day that changes.  */
57   if (mode == VOIDmode)
58     mode = GET_MODE (op);
59
60   /* Get the mode from the first operand if we don't have one.
61      Also the reason why we do this in C.  */
62   if (mode == VOIDmode)
63     mode = GET_MODE (XEXP (op, 0));
64
65   /* FIXME: This needs to be kept in sync with the tables in
66      mmix_output_condition.  */
67   return
68     mode == VOIDmode
69     || (mode == CC_FUNmode
70         && (code == ORDERED || code == UNORDERED))
71     || (mode == CC_FPmode
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))
77     || (mode == CCmode
78         && (code == NE || code == EQ || code == GE || code == GT
79             || code == LE || code == LT))
80     || (mode == DImode
81         && (code == NE || code == EQ || code == GE || code == GT
82             || code == LE || code == LT || code == LEU || code == GTU));
83 })
84
85 ;; True if this is a register with a condition-code mode.
86
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")))))))
94
95 ;; True if this is an address_operand or a symbolic operand.
96
97 (define_predicate "mmix_symbolic_or_address_operand"
98   (match_code "symbol_ref, label_ref, const, subreg, reg, plus")
99 {
100   switch (GET_CODE (op))
101     {
102     case SYMBOL_REF:
103     case LABEL_REF:
104       return 1;
105     case CONST:
106       /* The reason why this body still is C.  */
107       op = XEXP (op, 0);
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)))
113         return 1;
114       /* Fall through.  */
115     default:
116       return address_operand (op, mode);
117     }
118 })
119
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.
123
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")))))
129
130 ;; True if this is a register or 0 (int or float).
131
132 (define_predicate "mmix_reg_or_0_operand"
133   (ior
134    (match_operand 0 "register_operand")
135    (ior
136     (and (match_code "const_int")
137          (match_test "op == const0_rtx"))
138     (and
139      (match_code "const_double")
140      ;; FIXME: Is mode calculation necessary and correct?
141      (match_test
142       "op == CONST0_RTX (mode == VOIDmode ? GET_MODE (op) : mode)")))))
143
144 ;; True if this is a register or an int 0..255.
145
146 (define_predicate "mmix_reg_or_8bit_operand"
147   (ior
148    (match_operand 0 "register_operand")
149    (and (match_code "const_int")
150         (match_test "CONST_OK_FOR_LETTER_P (INTVAL (op), 'I')"))))