OSDN Git Service

2007-02-21 Trevor Smigiel <trevor_smigiel@playstation.sony.com>
[pf3gnuchains/gcc-fork.git] / gcc / config / spu / constraints.md
1 ;; Constraint definitions for SPU
2 ;; Copyright (C) 2006 Free Software Foundation, Inc.
3 ;;
4 ;; This file is free software; you can redistribute it and/or modify it under
5 ;; the terms of the GNU General Public License as published by the Free
6 ;; Software Foundation; either version 2 of the License, or (at your option) 
7 ;; any later version.
8
9 ;; This file is distributed in the hope that it will be useful, but WITHOUT
10 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 ;; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 ;; for more details.
13
14 ;; You should have received a copy of the GNU General Public License
15 ;; along with this file; see the file COPYING.  If not, write to the Free
16 ;; Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
17 ;; 02110-1301, USA.
18
19 \f
20 ;; GCC standard constraints:  g, i, m, n, o, p, r, s, E-H, I-P, V, X
21 ;; unused for SPU:  E-H, L, Q, d, e, h, q, t-z
22
23 ;; For most immediate constraints we have 3 variations to deal with the
24 ;; fact const_int has no mode.  One variation treats const_int as 32 bit,
25 ;; another treats it as 64 bit, and the third sign extends it to 128 bit.
26
27 (define_constraint "A"
28   "An immediate which can be loaded with the il/ila/ilh/ilhu instructions.  const_int is treated as a 32-bit value."
29   (ior (and (match_code "const_int,const_double,const_vector")
30             (match_test "immediate_load_p (op, SImode)"))
31        (match_code "symbol_ref,label_ref,high,const")))
32
33 (define_constraint "B"
34   "An immediate for arithmetic instructions (e.g., ai, ceqi).  const_int is treated as a 32-bit value."
35   (and (match_code "const_int,const_double,const_vector")
36        (match_test "arith_immediate_p (op, SImode, -0x200, 0x1ff)")))
37
38 (define_constraint "C"
39   "An immediate for and/xor/or instructions.  const_int is treated as a 32-bit value."
40   (and (match_code "const_int,const_double,const_vector")
41        (match_test "logical_immediate_p (op, SImode)")))
42
43 (define_constraint "D"
44   "An immediate for iohl instruction.  const_int is treated as a 32-bit value."
45   (and (match_code "const_int,const_double,const_vector")
46        (match_test "iohl_immediate_p (op, SImode)")))
47
48 (define_constraint "U"
49   "An immediate which can be loaded with the il/ila/ilh/ilhu instructions.  const_int is sign extended to 128 bit."
50   (and (match_code "const_int,const_double,const_vector")
51        (match_test "immediate_load_p (op, TImode)")))
52
53 (define_constraint "W"
54   "An immediate for shift and rotate instructions.  const_int is treated as a 32-bit value."
55   (and (match_code "const_int,const_double,const_vector")
56        (match_test "arith_immediate_p (op, SImode, -0x80000000ll, 0x7fffffffll)")))
57
58 (define_constraint "Y"
59   "An immediate for and/xor/or instructions.  const_int is sign extended as a 128 bit."
60   (and (match_code "const_int,const_double,const_vector")
61        (match_test "logical_immediate_p (op, TImode)")))
62
63 (define_constraint "Z"
64   "An immediate for iohl instruction.  const_int is sign extended to 128 bit."
65   (and (match_code "const_int,const_double,const_vector")
66        (match_test "iohl_immediate_p (op, TImode)")))
67
68 (define_constraint "a"
69   "An immediate which can be loaded with the il/ila/ilh/ilhu instructions.  const_int is treated as a 64-bit value."
70   (and (match_code "const_int")
71        (match_test "immediate_load_p (op, DImode)")))
72
73 (define_constraint "c"
74   "An immediate for and/xor/or instructions.  const_int is treated as a 64-bit value."
75   (and (match_code "const_int")
76        (match_test "logical_immediate_p (op, DImode)")))
77
78 (define_constraint "d"
79   "An immediate for iohl instruction.  const_int is treated as a 64-bit value."
80   (and (match_code "const_int")
81        (match_test "iohl_immediate_p (op, DImode)")))
82
83 (define_constraint "f"
84   "An immediate which can be loaded with fsmbi."
85   (and (match_code "const_int,const_double,const_vector")
86        (match_test "fsmbi_const_p (op)")))
87
88 (define_constraint "j"
89   "An immediate which can be loaded with one of the cbd/chd/cwd/cdd instructions.  const_int is treated as a 32-bit value."
90   (and (match_code "const_int,const_double,const_vector")
91        (match_test "cpat_const_p (op, SImode)")))
92
93 (define_constraint "k"
94   "An immediate which can be loaded with one of the cbd/chd/cwd/cdd instructions.  const_int is treated as a 64-bit value."
95   (and (match_code "const_int,const_double,const_vector")
96        (match_test "cpat_const_p (op, DImode)")))
97
98 (define_constraint "l"
99   "An immediate which can be loaded with one of the cbd/chd/cwd/cdd instructions."
100   (and (match_code "const_double,const_vector")
101        (match_test "cpat_const_p (op, TImode)")))
102
103 \f
104 ;; Integer constraints
105
106 (define_constraint "I"
107   "A constant in the range [-64, 63] for shift/rotate instructions."
108   (and (match_code "const_int")
109        (match_test "ival >= -0x40 && ival <= 0x3f")))
110
111 (define_constraint "J"
112   "An unsigned 7-bit constant for conversion/nop/channel instructions."
113   (and (match_code "const_int")
114        (match_test "ival >= 0 && ival <= 0x7f")))
115
116 (define_constraint "K"
117   "A signed 10-bit constant for most arithmetic instructions."
118   (and (match_code "const_int")
119        (match_test "ival >= -0x200 && ival <= 0x1ff")))
120  
121 (define_constraint "M"
122   "A signed 16-bit immediate for @code{stop}."
123   (and (match_code "const_int")
124        (match_test "ival >= -0x8000ll && ival <= 0x7fffll")))
125
126 (define_constraint "N"
127   "An unsigned 16-bit constant for @code{iohl} and @code{fsmbi}."
128   (and (match_code "const_int")
129        (match_test "ival >= 0 && ival <= 0xffff")))
130
131 (define_constraint "O"
132   "An unsigned 7-bit constant whose 3 least significant bits are 0."
133   (and (match_code "const_int")
134        (match_test "(ival & 7) == 0")))
135
136 (define_constraint "P"
137   "An unsigned 3-bit constant for 16-byte rotates and shifts"
138   (and (match_code "const_int")
139        (match_test "ival >= 0 && ival <= 7")))
140
141 \f
142 ;; Memory constraints
143
144 (define_memory_constraint "R"
145   "Call operand, reg, for indirect calls"
146   (and (match_code "mem")
147        (match_test "GET_CODE(XEXP(op, 0)) == REG")))
148
149 (define_memory_constraint "S"
150   "Call operand, symbol, for relative calls."
151   (and (match_code "mem")
152        (match_test "!TARGET_LARGE_MEM
153                     && ((GET_CODE (XEXP (op, 0)) == SYMBOL_REF
154                          || GET_CODE (XEXP (op, 0)) == LABEL_REF))")))
155
156 (define_memory_constraint "T"
157   "Call operand, const_int, for absolute calls."
158   (and (match_code "mem")
159        (match_test "GET_CODE (XEXP (op, 0)) == CONST_INT
160                     && INTVAL (XEXP (op, 0)) >= 0
161                     && INTVAL (XEXP (op, 0)) <= 0x3ffff")))
162
163