1169689Skan;; Constraint definitions for RS6000
2169689Skan;; Copyright (C) 2006 Free Software Foundation, Inc.
3169689Skan;;
4169689Skan;; This file is part of GCC.
5169689Skan;;
6169689Skan;; GCC is free software; you can redistribute it and/or modify
7169689Skan;; it under the terms of the GNU General Public License as published by
8169689Skan;; the Free Software Foundation; either version 2, or (at your option)
9169689Skan;; any later version.
10169689Skan;;
11169689Skan;; GCC is distributed in the hope that it will be useful,
12169689Skan;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13169689Skan;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14169689Skan;; GNU General Public License for more details.
15169689Skan;;
16169689Skan;; You should have received a copy of the GNU General Public License
17169689Skan;; along with GCC; see the file COPYING.  If not, write to
18169689Skan;; the Free Software Foundation, 51 Franklin Street, Fifth Floor,
19169689Skan;; Boston, MA 02110-1301, USA.
20169689Skan
21169689Skan;; Register constraints
22169689Skan
23169689Skan(define_register_constraint "f" "TARGET_HARD_FLOAT && TARGET_FPRS
24169689Skan			 	 ? FLOAT_REGS : NO_REGS"
25169689Skan  "@internal")
26169689Skan
27169689Skan(define_register_constraint "b" "BASE_REGS"
28169689Skan  "@internal")
29169689Skan
30169689Skan(define_register_constraint "h" "SPECIAL_REGS"
31169689Skan  "@internal")
32169689Skan
33169689Skan(define_register_constraint "q" "MQ_REGS"
34169689Skan  "@internal")
35169689Skan
36169689Skan(define_register_constraint "c" "CTR_REGS"
37169689Skan  "@internal")
38169689Skan
39169689Skan(define_register_constraint "l" "LINK_REGS"
40169689Skan  "@internal")
41169689Skan
42169689Skan(define_register_constraint "v" "ALTIVEC_REGS"
43169689Skan  "@internal")
44169689Skan
45169689Skan(define_register_constraint "x" "CR0_REGS"
46169689Skan  "@internal")
47169689Skan
48169689Skan(define_register_constraint "y" "CR_REGS"
49169689Skan  "@internal")
50169689Skan
51169689Skan(define_register_constraint "z" "XER_REGS"
52169689Skan  "@internal")
53169689Skan
54169689Skan;; Integer constraints
55169689Skan
56169689Skan(define_constraint "I"
57169689Skan  "A signed 16-bit constant"
58169689Skan  (and (match_code "const_int")
59169689Skan       (match_test "(unsigned HOST_WIDE_INT) (ival + 0x8000) < 0x10000")))
60169689Skan
61169689Skan(define_constraint "J"
62169689Skan  "high-order 16 bits nonzero"
63169689Skan  (and (match_code "const_int")
64169689Skan       (match_test "(ival & (~ (unsigned HOST_WIDE_INT) 0xffff0000)) == 0")))
65169689Skan
66169689Skan(define_constraint "K"
67169689Skan  "low-order 16 bits nonzero"
68169689Skan  (and (match_code "const_int")
69169689Skan       (match_test "(ival & (~ (HOST_WIDE_INT) 0xffff)) == 0")))
70169689Skan
71169689Skan(define_constraint "L"
72169689Skan  "signed 16-bit constant shifted left 16 bits"
73169689Skan  (and (match_code "const_int")
74169689Skan       (match_test "((ival & 0xffff) == 0
75169689Skan		      && (ival >> 31 == -1 || ival >> 31 == 0))")))
76169689Skan
77169689Skan(define_constraint "M"
78169689Skan  "constant greater than 31"
79169689Skan  (and (match_code "const_int")
80169689Skan       (match_test "ival > 31")))
81169689Skan
82169689Skan(define_constraint "N"
83169689Skan  "positive constant that is an exact power of two"
84169689Skan  (and (match_code "const_int")
85169689Skan       (match_test "ival > 0 && exact_log2 (ival) >= 0")))
86169689Skan
87169689Skan(define_constraint "O"
88169689Skan  "constant zero"
89169689Skan  (and (match_code "const_int")
90169689Skan       (match_test "ival == 0")))
91169689Skan
92169689Skan(define_constraint "P"
93169689Skan  "constant whose negation is signed 16-bit constant"
94169689Skan  (and (match_code "const_int")
95169689Skan       (match_test "(unsigned HOST_WIDE_INT) ((- ival) + 0x8000) < 0x10000")))
96169689Skan
97169689Skan;; Floating-point constraints
98169689Skan
99169689Skan(define_constraint "G"
100169689Skan  "Constant that can be copied into GPR with two insns for DF/DI
101169689Skan   and one for SF."
102169689Skan  (and (match_code "const_double")
103169689Skan       (match_test "num_insns_constant (op, mode)
104169689Skan		    == (mode == SFmode ? 1 : 2)")))
105169689Skan
106169689Skan(define_constraint "H"
107169689Skan  "DF/DI constant that takes three insns."
108169689Skan  (and (match_code "const_double")
109169689Skan       (match_test "num_insns_constant (op, mode) == 3")))
110169689Skan
111169689Skan;; Memory constraints
112169689Skan
113169689Skan(define_memory_constraint "Q"
114169689Skan  "Memory operand that is just an offset from a reg"
115169689Skan  (and (match_code "mem")
116169689Skan       (match_test "GET_CODE (XEXP (op, 0)) == REG")))
117169689Skan
118169689Skan(define_memory_constraint "Y"
119169689Skan  "Indexed or word-aligned displacement memory operand"
120169689Skan  (match_operand 0 "word_offset_memref_operand"))
121169689Skan
122169689Skan(define_memory_constraint "Z"
123169689Skan  "Indexed or indirect memory operand"
124169689Skan  (match_operand 0 "indexed_or_indirect_operand"))
125169689Skan
126169689Skan;; Address constraints
127169689Skan
128169689Skan(define_address_constraint "a"
129169689Skan  "Indexed or indirect address operand"
130169689Skan  (match_operand 0 "indexed_or_indirect_address"))
131169689Skan
132169689Skan(define_constraint "R"
133169689Skan  "AIX TOC entry"
134169689Skan  (match_test "legitimate_constant_pool_address_p (op)"))
135169689Skan
136169689Skan;; General constraints
137169689Skan
138169689Skan(define_constraint "S"
139169689Skan  "Constant that can be placed into a 64-bit mask operand"
140169689Skan  (match_operand 0 "mask64_operand"))
141169689Skan
142169689Skan(define_constraint "T"
143169689Skan  "Constant that can be placed into a 32-bit mask operand"
144169689Skan  (match_operand 0 "mask_operand"))
145169689Skan
146169689Skan(define_constraint "U"
147169689Skan  "V.4 small data reference"
148169689Skan  (and (match_test "DEFAULT_ABI == ABI_V4")
149169689Skan       (match_operand 0 "small_data_operand")))
150169689Skan
151169689Skan(define_constraint "t"
152169689Skan  "AND masks that can be performed by two rldic{l,r} insns
153169689Skan   (but excluding those that could match other constraints of anddi3)"
154169689Skan  (and (and (and (match_operand 0 "mask64_2_operand")
155169689Skan		 (match_test "(fixed_regs[CR0_REGNO]
156169689Skan			      || !logical_operand (op, DImode))"))
157169689Skan	    (not (match_operand 0 "mask_operand")))
158169689Skan       (not (match_operand 0 "mask64_operand"))))
159169689Skan
160169689Skan(define_constraint "W"
161169689Skan  "vector constant that does not require memory"
162169689Skan  (match_operand 0 "easy_vector_constant"))
163