summaryrefslogtreecommitdiff
path: root/gcc/config/c6x/constraints.md
blob: e2721d9a71d2d9e582f57f200278e5cea48f2240 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
;; Constraint definitions for TI C6X.
;; Copyright (C) 2010-2014 Free Software Foundation, Inc.
;; Contributed by Andrew Jenner <andrew@codesourcery.com>
;; Contributed by Bernd Schmidt <bernds@codesourcery.com>
;; Contributed by CodeSourcery.
;;
;; This file is part of GCC.
;;
;; GCC is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;;
;; GCC is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GCC; see the file COPYING3.  If not see
;; <http://www.gnu.org/licenses/>.

(define_register_constraint "a" "A_REGS"
  "Register file A (A0--A31).")

(define_register_constraint "b" "B_REGS"
  "Register file B (B0--B31).")

(define_register_constraint "A" "PREDICATE_A_REGS"
  "Predicate registers in register file A (A0--A2 on C64X and higher,
   A1 and A2 otherwise).")

(define_register_constraint "B" "PREDICATE_B_REGS"
  "Predicate registers in register file B (B0--B2).")

(define_register_constraint "C" "CALL_USED_B_REGS"
  "A call-used register in register file B (B0--B9, B16--B31).")

(define_register_constraint "Da" "NONPREDICATE_A_REGS"
  "Register file A, excluding predicate registers (A3--A31, plus A0 if
not C64X or higher).")

(define_register_constraint "Db" "NONPREDICATE_B_REGS"
  "Register file B, excluding predicate registers (B3--B31).")

(define_register_constraint "Z" "PICREG"
  "Register B14 (aka DP).")

(define_register_constraint "z" "SPREG"
  "Register B15 (aka SP).")

(define_constraint "Iu4"
  "Integer constant in the range 0 @dots{} 15, aka ucst4."
  (and (match_code "const_int")
       (match_test "ival >= 0 && ival <= 15")))

(define_constraint "Iu5"
  "Integer constant in the range 0 @dots{} 31, aka ucst5."
  (and (match_code "const_int")
       (match_test "ival >= 0 && ival <= 31")))

(define_constraint "In5"
  "Integer constant in the range @minus{}31 @dots{} 0, negation of ucst5."
  (and (match_code "const_int")
       (match_test "ival >= -31 && ival <= 0")))

(define_constraint "Is5"
  "Integer constant in the range @minus{}16 @dots{} 15, aka scst5."
  (and (match_code "const_int")
       (match_test "ival >= -16 && ival <= 15")))

(define_constraint "I5x"
  "Integer constant that can be the operand of an ADDA or a SUBA insn."
  (and (match_code "const_int")
       (match_test "(ival >= -31 && ival <= 31)
		    || ((ival & 1) == 0 && ival >= -62 && ival <= 62)
		    || ((ival & 3) == 0 && ival >= -124 && ival <= 124)
		    || ((TARGET_INSNS_64 || TARGET_INSNS_67)
 			&& (ival & 7) == 0 && ival > 0 && ival <= 248)")))

(define_constraint "Iux"
  "Integer constant that can be the operand of a long ADDA or a SUBA insn,
   i.e. one involving B14 or B15 as source operand."
  (and (match_code "const_int")
       (and (match_test "TARGET_INSNS_64PLUS")
	    (match_test "ival >= 0
 			 && (ival < 32768
		     	     || ((ival & 1) == 0 && ival < 65536)
			     || ((ival & 3) == 0 && ival < 131072))"))))

(define_constraint "IuB"
  "Integer constant in the range 0 @dots{} 65535, aka ucst16."
  (and (match_code "const_int")
       (match_test "ival >= 0 && ival <= 65535")))

(define_constraint "IsB"
  "Integer constant in the range @minus{}32768 @dots{} 32767."
  (and (match_code "const_int")
       (match_test "ival >= -32768 && ival <= 32767")))

(define_constraint "IsC"
  "Integer constant in the range @math{-2^{20}} @dots{} @math{2^{20} - 1}."
  (and (match_code "const_int")
       (match_test "ival >= -0x100000 && ival <= 0xfffff")))

(define_constraint "JA"
  "@internal
   Integer constant in the range 0 @dots{} 31, corresponding to an A register
   number."
  (and (match_code "const_int")
       (match_test "ival >= 0 && ival < 32")))

(define_constraint "JB"
  "@internal
   Integer constant in the range 32 @dots{} 63, corresponding to a B register
   number."
  (and (match_code "const_int")
       (match_test "ival >= 32 && ival < 64")))

(define_constraint "Jc"
  "Integer constant that is a valid mask for the clr instruction"
  (and (match_code "const_int")
       (match_test "c6x_valid_mask_p (ival)")))

(define_constraint "Js"
  "Integer constant that is a valid mask for the set instruction"
  (and (match_code "const_int")
       (match_test "c6x_valid_mask_p (~ival)")))

(define_memory_constraint "Q"
  "Memory location with A base register."
  (and (match_code "mem")
       (match_test "c6x_mem_operand (op, A_REGS, false)")))

(define_memory_constraint "R"
  "Memory location with B base register."
  (and (match_code "mem")
       (match_test "c6x_mem_operand (op, B_REGS, false)")))

(define_memory_constraint "T"
  "@internal
   Memory location with B base register, but not using a long offset."
  (and (match_code "mem")
       (match_test "c6x_mem_operand (op, B_REGS, true)")))

(define_constraint "S0"
  "@internal
   On C64x+ targets, a GP-relative small data reference"
  (and (match_test "TARGET_INSNS_64PLUS")
       (match_operand 0 "sdata_symbolic_operand")))

(define_constraint "S1"
  "@internal
   Any kind of @code{SYMBOL_REF}, for use in a call address."
  (and (match_code "symbol_ref")
       (match_operand 0 "c6x_call_operand")))

(define_constraint "S2"
  "@internal
   Any SYMBOL_REF or LABEL_REF."
  (ior (match_code "symbol_ref") (match_code "label_ref")))

(define_constraint "Si"
  "@internal
   Any immediate value, unless it matches the S0 constraint."
  (and (match_operand 0 "immediate_operand")
       (match_test "!satisfies_constraint_S0 (op)")))

(define_memory_constraint "W"
  "@internal
   A memory operand with an address that can't be used in an unaligned access."
  (and (match_code "mem")
       (match_test "!c6x_legitimate_address_p_1 (GET_MODE (op), XEXP (op, 0),
 						 reload_completed, true)")))