| 1 |
;; GCC machine description for CRIS cpu cores. |
| 2 |
;; Copyright (C) 1998-2025 Free Software Foundation, Inc. |
| 3 |
;; Contributed by Axis Communications. |
| 4 |
|
| 5 |
;; This file is part of GCC. |
| 6 |
;; |
| 7 |
;; GCC is free software; you can redistribute it and/or modify |
| 8 |
;; it under the terms of the GNU General Public License as published by |
| 9 |
;; the Free Software Foundation; either version 3, or (at your option) |
| 10 |
;; any later version. |
| 11 |
;; |
| 12 |
;; GCC is distributed in the hope that it will be useful, |
| 13 |
;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
;; GNU General Public License for more details. |
| 16 |
;; |
| 17 |
;; You should have received a copy of the GNU General Public License |
| 18 |
;; along with GCC; see the file COPYING3. If not see |
| 19 |
;; <http://www.gnu.org/licenses/>. |
| 20 |
|
| 21 |
;; The original PO technology requires these to be ordered by speed, |
| 22 |
;; so that assigner will pick the fastest. |
| 23 |
|
| 24 |
;; See files "md.texi" and "rtl.def" for documentation on define_insn, |
| 25 |
;; match_*, et. al. |
| 26 |
|
| 27 |
;; There are several instructions that are orthogonal in size, and seems |
| 28 |
;; they could be matched by a single pattern without a specified size |
| 29 |
;; for the operand that is orthogonal. However, this did not work on |
| 30 |
;; gcc-2.7.2 (and probably not on gcc-2.8.1), relating to that when a |
| 31 |
;; constant is substituted into an operand, the actual mode must be |
| 32 |
;; deduced from the pattern. There is reasonable hope that that has been |
| 33 |
;; fixed, so FIXME: try again. |
| 34 |
|
| 35 |
;; You will notice that three-operand alternatives ("=r", "r", "!To") |
| 36 |
;; are marked with a "!" constraint modifier to avoid being reloaded |
| 37 |
;; into. This is because gcc would otherwise prefer to use the constant |
| 38 |
;; pool and its offsettable address instead of reloading to an |
| 39 |
;; ("=r", "0", "i") alternative. Also, the constant-pool support was not |
| 40 |
;; only suboptimal but also buggy in 2.7.2, ??? maybe only in 2.6.3. |
| 41 |
|
| 42 |
;; All insns that look like (set (...) (plus (...) (reg:SI 8))) |
| 43 |
;; get problems when reloading r8 (frame pointer) to r14 + offs (stack |
| 44 |
;; pointer). Thus the instructions that get into trouble have specific |
| 45 |
;; checks against matching frame_pointer_rtx. |
| 46 |
;; ??? But it should be re-checked for gcc > 2.7.2 |
| 47 |
;; FIXME: This changed some time ago (from 2000-03-16) for gcc-2.9x. |
| 48 |
|
| 49 |
(define_c_enum "" |
| 50 |
[ |
| 51 |
;; Stack frame deallocation barrier. |
| 52 |
CRIS_UNSPEC_FRAME_DEALLOC |
| 53 |
]) |
| 54 |
|
| 55 |
;; Register numbers. |
| 56 |
(define_constants |
| 57 |
[(CRIS_STATIC_CHAIN_REGNUM 7) |
| 58 |
(CRIS_REAL_FP_REGNUM 8) |
| 59 |
(CRIS_SP_REGNUM 14) |
| 60 |
(CRIS_SRP_REGNUM 16) |
| 61 |
(CRIS_MOF_REGNUM 17) |
| 62 |
(CRIS_AP_REGNUM 18) |
| 63 |
(CRIS_CC0_REGNUM 19) |
| 64 |
(CRIS_FP_REGNUM 20)] |
| 65 |
) |
| 66 |
|
| 67 |
;; We need an attribute to define whether an instruction can be put in |
| 68 |
;; a branch-delay slot or not, and whether it has a delay slot. |
| 69 |
;; |
| 70 |
;; Branches and return instructions have a delay slot, and cannot |
| 71 |
;; themselves be put in a delay slot. This has changed *for short |
| 72 |
;; branches only* between architecture variants, but the possible win |
| 73 |
;; is presumed negligible compared to the added complexity of the machine |
| 74 |
;; description: one would have to add always-correct infrastructure to |
| 75 |
;; distinguish short branches. |
| 76 |
;; |
| 77 |
;; Whether an instruction can be put in a delay slot depends on the |
| 78 |
;; instruction (all short instructions except jumps and branches) |
| 79 |
;; and the addressing mode (must not be prefixed or referring to pc). |
| 80 |
;; In short, any "slottable" instruction must be 16 bit and not refer |
| 81 |
;; to pc, or alter it. |
| 82 |
;; |
| 83 |
;; The possible values are "yes", "no", "has_slot", and "has_return_slot". |
| 84 |
;; Yes/no tells whether the insn is slottable or not. |
| 85 |
;; Of special concern is that no RTX_FRAME_RELATED insn must go in that |
| 86 |
;; call delay slot, as it's located in the address *after* the call insn, |
| 87 |
;; and the unwind machinery doesn't know about delay slots. |
| 88 |
;; Has_slot means that the insn is a branch insn (which are |
| 89 |
;; not considered slottable since that is generally true). Having the |
| 90 |
;; seemingly illogical value "has_slot" means we do not have to add |
| 91 |
;; another attribute just to say that an insn has a delay-slot, since it |
| 92 |
;; also infers that it is not slottable. Better names for the attribute |
| 93 |
;; were found to be longer and not add readability to the machine |
| 94 |
;; description. |
| 95 |
;; Has_return_slot is similar, for the return insn. |
| 96 |
;; |
| 97 |
;; The default that is defined here for this attribute is "no", not |
| 98 |
;; slottable, not having a delay-slot, so there's no need to worry about |
| 99 |
;; it being wrong for non-branch and return instructions. |
| 100 |
;; The default could depend on the kind of insn and the addressing |
| 101 |
;; mode, but that would need more attributes and hairier, more error |
| 102 |
;; prone code. |
| 103 |
;; |
| 104 |
;; There is an extra memory constraint, 'Q', which recognizes an indirect |
| 105 |
;; register. The constraints 'Q' and '>' together match all possible |
| 106 |
;; memory operands that are slottable. |
| 107 |
;; For other operands, you need to check if it has a valid "slottable" |
| 108 |
;; quick-immediate operand, where the particular signedness-variation |
| 109 |
;; may match the constraints 'I' or 'J'.), and include it in the |
| 110 |
;; constraint pattern for the slottable pattern. An alternative using |
| 111 |
;; only "r" constraints is most often slottable. |
| 112 |
|
| 113 |
(define_attr "slottable" "no,yes,has_slot,has_return_slot" |
| 114 |
(const_string "no")) |
| 115 |
|
| 116 |
;; We also need attributes to sanely determine the condition code |
| 117 |
;; state. This attribute isn't used as-is, just as a template, |
| 118 |
;; effectively a dummy except in a substitution setting CRIS_CC0_REGNUM |
| 119 |
;; to a specific value. |
| 120 |
(define_attr "cc" "none,clobber,normal" (const_string "normal")) |
| 121 |
|
| 122 |
;; The attribute "_enabled" is appended to "cc", forming "cc_enabled" to |
| 123 |
;; pick out certain alternatives when generating a useful |
| 124 |
;; condition-code-setting. See the "enabled" attribute. |
| 125 |
(define_attr "cc_enabled" "none,clobber,normal" (const_string "normal")) |
| 126 |
|
| 127 |
;; At the moment, this attribute is just used to help bb-reorder do its |
| 128 |
;; work; the default 0 doesn't help it. Many insns have other lengths, |
| 129 |
;; though none are shorter. |
| 130 |
(define_attr "length" "" (const_int 2)) |
| 131 |
|
| 132 |
;; A branch has one delay-slot. The instruction in the |
| 133 |
;; delay-slot is always executed, independent of whether the branch is |
| 134 |
;; taken or not. Note that besides setting "slottable" to "has_slot", |
| 135 |
;; there also has to be a "%#" at the end of a "delayed" instruction |
| 136 |
;; output pattern (for "jump" this means "ba %l0%#"), so print_operand can |
| 137 |
;; catch it and print a "nop" if necessary. This method was stolen from |
| 138 |
;; sparc.md. |
| 139 |
|
| 140 |
(define_delay (eq_attr "slottable" "has_slot") |
| 141 |
[(eq_attr "slottable" "yes") (nil) (nil)]) |
| 142 |
|
| 143 |
;; The insn in the return insn slot must not be the |
| 144 |
;; return-address-register restore. FIXME: Use has_slot and express |
| 145 |
;; as a parallel with a use of the return-address-register (currently |
| 146 |
;; only SRP). However, this requires an amount of fixing tests for |
| 147 |
;; naked RETURN in middle-end. |
| 148 |
(define_delay (eq_attr "slottable" "has_return_slot") |
| 149 |
[(and (eq_attr "slottable" "yes") |
| 150 |
(not (match_test "dead_or_set_regno_p (insn, CRIS_SRP_REGNUM)"))) |
| 151 |
(nil) (nil)]) |
| 152 |
|
| 153 |
;; Enable choosing particular instructions. The discriminator choice |
| 154 |
;; "v0" stands for "pre-v10", for brevity. |
| 155 |
(define_attr "cpu_variant" "default,v0,v10" (const_string "default")) |
| 156 |
|
| 157 |
(define_attr "enabled" "no,yes" |
| 158 |
(if_then_else |
| 159 |
(and |
| 160 |
(eq_attr "cc_enabled" "normal") |
| 161 |
(ior |
| 162 |
(eq_attr "cpu_variant" "default") |
| 163 |
(and (eq_attr "cpu_variant" "v10") |
| 164 |
(match_test "TARGET_HAS_MUL_INSNS")) |
| 165 |
(and (eq_attr "cpu_variant" "v0") |
| 166 |
(not (match_test "TARGET_HAS_MUL_INSNS"))))) |
| 167 |
(const_string "yes") |
| 168 |
(const_string "no"))) |
| 169 |
|
| 170 |
;; Iterator definitions. |
| 171 |
|
| 172 |
;; For the "usual" pattern size alternatives. |
| 173 |
(define_mode_iterator BWD [SI HI QI]) |
| 174 |
(define_mode_iterator BWDD [DI SI HI QI]) |
| 175 |
|
| 176 |
;; To be able to refer to the same mode_attr for both a multi-mode |
| 177 |
;; and a mode-specific pattern, we use some singleton iterators. |
| 178 |
(define_mode_iterator DI_ [DI]) |
| 179 |
(define_mode_iterator SI_ [SI]) |
| 180 |
|
| 181 |
(define_mode_iterator WD [SI HI]) |
| 182 |
(define_mode_iterator BW [HI QI]) |
| 183 |
|
| 184 |
; Another "BW" for use where an independent iteration is needed. |
| 185 |
(define_mode_iterator BW2 [HI QI]) |
| 186 |
|
| 187 |
(define_mode_attr S [(SI "HI") (HI "QI")]) |
| 188 |
(define_mode_attr s [(SI "hi") (HI "qi")]) |
| 189 |
(define_mode_attr m [(SI ".d") (HI ".w") (QI ".b")]) |
| 190 |
(define_mode_attr mm [(SI ".w") (HI ".b")]) |
| 191 |
(define_mode_attr nbitsm1 [(SI "31") (HI "15") (QI "7")]) |
| 192 |
|
| 193 |
;; For the sign_extend+zero_extend variants. |
| 194 |
(define_code_iterator szext [sign_extend zero_extend]) |
| 195 |
(define_code_attr u [(sign_extend "") (zero_extend "u")]) |
| 196 |
(define_code_attr su [(sign_extend "s") (zero_extend "u")]) |
| 197 |
|
| 198 |
;; For extended-operand variants. |
| 199 |
(define_code_iterator plusminus [plus minus]) |
| 200 |
(define_code_attr addsub [(plus "add") (minus "sub")]) |
| 201 |
|
| 202 |
;; Similar, other cases also matching bound/umin. |
| 203 |
(define_code_iterator plusminusumin [plus minus umin]) |
| 204 |
|
| 205 |
;; Ditto, commutative operators (i.e. not minus). |
| 206 |
(define_code_iterator plusumin [plus umin]) |
| 207 |
|
| 208 |
;; For opsplit1. |
| 209 |
(define_code_iterator splitop [and plus]) |
| 210 |
|
| 211 |
;; The addsubbo and nd code-attributes form a hack. We need to output |
| 212 |
;; "addu.b", "subu.b" but "bound.b" (no "u"-suffix) which means we'd |
| 213 |
;; need to refer to one iterator from the next. But, that can't be |
| 214 |
;; done. Instead output the "u" for unsigned as the "u" in "bound", |
| 215 |
;; i.e. the mnemonic as three parts including the extend-letter, and |
| 216 |
;; with an empty third part for "add" and "sub". |
| 217 |
(define_code_attr addsubbo [(plus "add") (minus "sub") (umin "bo")]) |
| 218 |
(define_code_attr nd [(plus "") (minus "") (umin "nd")]) |
| 219 |
|
| 220 |
;; For the shift variants. |
| 221 |
(define_code_iterator shift [ashiftrt lshiftrt ashift]) |
| 222 |
(define_code_iterator shiftrt [ashiftrt lshiftrt]) |
| 223 |
(define_code_attr shlr [(ashiftrt "ashr") (lshiftrt "lshr") (ashift "ashl")]) |
| 224 |
(define_code_attr slr [(ashiftrt "asr") (lshiftrt "lsr") (ashift "lsl")]) |
| 225 |
|
| 226 |
;; Compares, branches, cbranch, cstore. Conditions gt and le are CC_NZVC. |
| 227 |
;; Others start out as CCmode and can degenerate to CC_NZmode. |
| 228 |
;; Incidental setters are either CC_NZVCmode or CC_NZmode. See also |
| 229 |
;; cris-modes.def. |
| 230 |
(define_mode_iterator NZSET [CC_NZ]) |
| 231 |
(define_mode_iterator NZUSE [CC CC_NZ CC_NZVC]) |
| 232 |
(define_mode_iterator NZVCSET [CC CC_NZVC CC_NZ]) |
| 233 |
(define_mode_iterator NZVCUSE [CC_NZVC]) |
| 234 |
(define_mode_iterator ZnNNZSET [CC_ZnN CC_NZ]) |
| 235 |
(define_mode_iterator ZnNNZUSE [CC CC_ZnN CC_NZ CC_NZVC]) |
| 236 |
|
| 237 |
;; All conditions. |
| 238 |
(define_code_iterator cond [eq ne gtu ltu geu leu gt le lt ge]) |
| 239 |
|
| 240 |
;; Just equal and not equal. |
| 241 |
(define_code_iterator zcond [eq ne]) |
| 242 |
|
| 243 |
;; Conditions that look only at Z and/or N (or can do with that). |
| 244 |
(define_code_iterator nzcond [eq ne gtu leu lt ge]) |
| 245 |
|
| 246 |
;; The complement of nzcond within cond; conditions that look (also) on V |
| 247 |
;; or C. |
| 248 |
(define_code_iterator nzvccond [geu ltu gt le]) |
| 249 |
|
| 250 |
;; Within nzcond, those that give different opcodes when operands are |
| 251 |
;; reversed or that can ignore V or C. Also, the complement of zcond |
| 252 |
;; within nzcond. |
| 253 |
(define_code_iterator rnzcond [gtu leu lt ge]) |
| 254 |
|
| 255 |
;; CRIS condition mnemonic. |
| 256 |
(define_code_attr CC [(eq "eq") (ne "ne") (gt "gt") (gtu "hi") (lt "lt") |
| 257 |
(ltu "lo") (ge "ge") (geu "hs") (le "le") (leu "ls")]) |
| 258 |
|
| 259 |
;; CRIS reverse condition mnemonic. |
| 260 |
(define_code_attr rCC [(eq "ne") (ne "eq") (gt "le") (gtu "ls") (lt "ge") |
| 261 |
(ltu "hs") (ge "lt") (geu "lo") (le "gt") (leu "hi")]) |
| 262 |
|
| 263 |
;; Mnemomic for the CRIS condition when V or C can be ignored. |
| 264 |
(define_code_attr oCC [(lt "mi") (ge "pl") (gtu "eq") (ltu "ne")]) |
| 265 |
|
| 266 |
;; Reverse of oCC. |
| 267 |
(define_code_attr roCC [(lt "pl") (ge "mi") (gtu "eq") (ltu "ne")]) |
| 268 |
|
| 269 |
;; CC_Z_IN_NOT_N, a.k.a. CC_ZnNmode. |
| 270 |
(define_code_attr znnCC [(eq "pl") (ne "mi")]) |
| 271 |
|
| 272 |
;;; ...and the reverse |
| 273 |
(define_code_attr rznnCC [(eq "mi") (ne "pl")]) |
| 274 |
|
| 275 |
;; Required unoptimized CCmode, different for nzcond and nzvccond. |
| 276 |
(define_code_attr xCC [(eq "CC") (ne "CC") (gtu "CC") (ltu "CC_NZVC") |
| 277 |
(geu "CC_NZVC") (leu "CC") (lt "CC") (ge "CC") |
| 278 |
(gt "CC_NZVC") (le "CC_NZVC")]) |
| 279 |
|
| 280 |
;; Substitutions to describe condition-code settings. |
| 281 |
|
| 282 |
(define_subst_attr "setnz" "setnz_subst" "" "_setnz") |
| 283 |
(define_subst_attr "ccnz" "setnz_subst" "" "_enabled") |
| 284 |
(define_subst_attr "anz" "setnz_subst" "" "*") |
| 285 |
|
| 286 |
(define_subst "setnz_subst" |
| 287 |
[(set (match_operand 0) |
| 288 |
(match_operand 1)) |
| 289 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 290 |
"reload_completed" |
| 291 |
[(set (reg:CC_NZ CRIS_CC0_REGNUM) |
| 292 |
(compare:CC_NZ (match_dup 1) (const_int 0))) |
| 293 |
(set (match_dup 0) (match_dup 1))]) |
| 294 |
|
| 295 |
(define_subst_attr "setnzvc" "setnzvc_subst" "" "_setnzvc") |
| 296 |
(define_subst_attr "ccnzvc" "setnzvc_subst" "" "_enabled") |
| 297 |
(define_subst_attr "anzvc" "setnzvc_subst" "" "*") |
| 298 |
|
| 299 |
(define_subst "setnzvc_subst" |
| 300 |
[(set (match_operand 0) |
| 301 |
(match_operand 1)) |
| 302 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 303 |
"reload_completed" |
| 304 |
[(set (reg:CC_NZVC CRIS_CC0_REGNUM) |
| 305 |
(compare:CC_NZVC (match_dup 1) (const_int 0))) |
| 306 |
(set (match_dup 0) (match_dup 1))]) |
| 307 |
|
| 308 |
(define_subst_attr "setcc" "setcc_subst" "" "_setcc") |
| 309 |
(define_subst_attr "cccc" "setcc_subst" "" "_enabled") |
| 310 |
(define_subst_attr "acc" "setcc_subst" "" "*") |
| 311 |
|
| 312 |
(define_subst "setcc_subst" |
| 313 |
[(set (match_operand 0) |
| 314 |
(match_operand 1)) |
| 315 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 316 |
"reload_completed" |
| 317 |
[(set (reg:CC CRIS_CC0_REGNUM) |
| 318 |
(compare:CC (match_dup 1) (const_int 0))) |
| 319 |
(set (match_dup 0) (match_dup 1))]) |
| 320 |
|
| 321 |
;; Operand and operator predicates. |
| 322 |
|
| 323 |
(include "predicates.md") |
| 324 |
(include "constraints.md") |
| 325 |
|
| 326 |
;; It seems that the position of the sign-bit and the fact that 0.0 is |
| 327 |
;; all 0-bits would make "tstsf" a straight-forward implementation; |
| 328 |
;; either "test.d" it for positive/negative or "btstq 30,r" it for |
| 329 |
;; zeroness. |
| 330 |
;; |
| 331 |
;; FIXME: Do that some time. |
| 332 |
|
| 333 |
;; Compare insns. |
| 334 |
|
| 335 |
;; These are used for compare insn, cbranch and cstore. |
| 336 |
;; FIXME: Port-local reversing of operands is not done. Still needed? |
| 337 |
;; (It shouldn't be; it should be done as part of register allocation.) |
| 338 |
(define_mode_attr sCC_destc |
| 339 |
[(DI "r, r,r,r,r,r,r") (SI "r,r, r, r,r,r") (HI "r, r, r,r") (QI "r, r, r,r")]) |
| 340 |
(define_mode_attr cmp_op0c |
| 341 |
[(DI "rm,r,r,r,r,r,r") (SI "r,r, rQ>,r,r,m") (HI "r, rQ>,r,m") (QI "r, rQ>,r,m")]) |
| 342 |
(define_mode_attr cmp_op1c |
| 343 |
[(DI "M,Kc,I,P,n,r,o") (SI "I,rQ>,M, P,g,M") (HI "rQ>,M, g,M") (QI "rQ>,M, g,M")]) |
| 344 |
|
| 345 |
;; We could optimize the sizes of the immediate operands for various |
| 346 |
;; cases, but that is not worth it because of the very little usage of |
| 347 |
;; DImode for anything else but a structure/block-mode. Just do the |
| 348 |
;; obvious stuff for the straight-forward constraint letters. |
| 349 |
|
| 350 |
(define_insn "*cmpdi<NZVCSET:mode>" |
| 351 |
[(set (reg:NZVCSET CRIS_CC0_REGNUM) |
| 352 |
(compare:NZVCSET |
| 353 |
(match_operand:DI_ 0 "nonimmediate_operand" "<cmp_op0c>") |
| 354 |
(match_operand:DI_ 1 "general_operand" "<cmp_op1c>")))] |
| 355 |
"reload_completed" |
| 356 |
"@ |
| 357 |
test.d %M0\;ax\;test.d %H0 |
| 358 |
cmpq %1,%M0\;ax\;cmpq 0,%H0 |
| 359 |
cmpq %1,%M0\;ax\;cmpq -1,%H0 |
| 360 |
cmp%e1.%z1 %1,%M0\;ax\;cmpq %H1,%H0 |
| 361 |
cmp.d %M1,%M0\;ax\;cmp.d %H1,%H0 |
| 362 |
cmp.d %M1,%M0\;ax\;cmp.d %H1,%H0 |
| 363 |
cmp.d %M1,%M0\;ax\;cmp.d %H1,%H0") |
| 364 |
|
| 365 |
;; Note that compare insns with side effect addressing mode (e.g.): |
| 366 |
;; |
| 367 |
;; cmp.S [rx=ry+i],rz; |
| 368 |
;; cmp.S [%3=%1+%2],%0 |
| 369 |
;; |
| 370 |
;; are *not* usable for gcc since the reloader *does not accept* |
| 371 |
;; cc0-changing insns with side-effects other than setting the condition |
| 372 |
;; codes. The reason is that the reload stage *may* cause another insn to |
| 373 |
;; be output after the main instruction, in turn invalidating cc0 for the |
| 374 |
;; insn using the test. (This does not apply to the CRIS case, since a |
| 375 |
;; reload for output -- move to memory -- does not change the condition |
| 376 |
;; code. Unfortunately we have no way to describe that at the moment. I |
| 377 |
;; think code would improve being in the order of one percent faster. |
| 378 |
|
| 379 |
;; We have cmps and cmpu (compare reg w. sign/zero extended mem). |
| 380 |
;; These are mostly useful for compares in SImode, using 8 or 16-bit |
| 381 |
;; constants, but sometimes gcc will find its way to use it for other |
| 382 |
;; (memory) operands. Avoid side-effect patterns, though (see above). |
| 383 |
|
| 384 |
(define_insn "*cmp_ext<BW:mode><NZVCSET:mode>" |
| 385 |
[(set (reg:NZVCSET CRIS_CC0_REGNUM) |
| 386 |
(compare:NZVCSET |
| 387 |
(match_operand:SI 0 "register_operand" "r,r") |
| 388 |
(match_operator:SI 2 "cris_extend_operator" |
| 389 |
[(match_operand:BW 1 "memory_operand" "Q>,m")])))] |
| 390 |
"reload_completed" |
| 391 |
"cmp%e2<m> %1,%0" |
| 392 |
[(set_attr "slottable" "yes,no")]) |
| 393 |
|
| 394 |
;; The "normal" compare patterns, from SI on. Special-cases with zero |
| 395 |
;; are covered above. |
| 396 |
|
| 397 |
(define_insn "*cmpsi<NZVCSET:mode>" |
| 398 |
[(set (reg:NZVCSET CRIS_CC0_REGNUM) |
| 399 |
(compare:NZVCSET |
| 400 |
(match_operand:SI_ 0 "nonimmediate_operand" "<cmp_op0c>") |
| 401 |
(match_operand:SI_ 1 "general_operand" "<cmp_op1c>")))] |
| 402 |
"reload_completed" |
| 403 |
"@ |
| 404 |
cmpq %1,%0 |
| 405 |
cmp.d %1,%0 |
| 406 |
test.d %0 |
| 407 |
cmp%e1.%z1 %1,%0 |
| 408 |
cmp.d %1,%0 |
| 409 |
test.d %0" |
| 410 |
[(set_attr "slottable" "yes,yes,yes,no,no,no")]) |
| 411 |
|
| 412 |
(define_insn "*cmp<BW:mode><NZVCSET:mode>" |
| 413 |
[(set (reg:NZVCSET CRIS_CC0_REGNUM) |
| 414 |
(compare:NZVCSET |
| 415 |
(match_operand:BW 0 "nonimmediate_operand" "<cmp_op0c>") |
| 416 |
(match_operand:BW 1 "general_operand" "<cmp_op1c>")))] |
| 417 |
"reload_completed" |
| 418 |
"@ |
| 419 |
cmp<m> %1,%0 |
| 420 |
test<m> %0 |
| 421 |
cmp<m> %1,%0 |
| 422 |
test<m> %0" |
| 423 |
[(set_attr "slottable" "yes,yes,no,no")]) |
| 424 |
|
| 425 |
;; Pattern matching the BTST insn. |
| 426 |
;; It is useful for "if (i & val)" constructs, where val is an exact |
| 427 |
;; power of 2, or if val + 1 is a power of two, where we check for a bunch |
| 428 |
;; of zeros starting at bit 0). |
| 429 |
|
| 430 |
;; SImode. This mode is the only one needed, since gcc automatically |
| 431 |
;; extends subregs for lower-size modes. |
| 432 |
(define_insn "*btst<mode>" |
| 433 |
[(set (reg:ZnNNZSET CRIS_CC0_REGNUM) |
| 434 |
(compare:ZnNNZSET |
| 435 |
(zero_extract:SI |
| 436 |
(match_operand:SI 0 "nonmemory_operand" "r, r,r, r,r, r,Kp") |
| 437 |
(match_operand:SI 1 "const_int_operand" "Kc,n,Kc,n,Kc,n,n") |
| 438 |
(match_operand:SI 2 "nonmemory_operand" "M, M,Kc,n,r, r,r")) |
| 439 |
(const_int 0)))] |
| 440 |
;; Either it is a single bit, or consecutive ones starting at 0. |
| 441 |
"reload_completed |
| 442 |
&& CONST_INT_P (operands[1]) |
| 443 |
&& ((operands[1] == const1_rtx && <MODE>mode == CC_ZnNmode) |
| 444 |
|| (operands[2] == const0_rtx && <MODE>mode == CC_NZmode)) |
| 445 |
&& (REG_S_P (operands[0]) |
| 446 |
|| (operands[1] == const1_rtx |
| 447 |
&& REG_S_P (operands[2]) |
| 448 |
&& CONST_INT_P (operands[0]) |
| 449 |
&& exact_log2 (INTVAL (operands[0])) >= 0)) |
| 450 |
&& !TARGET_CCINIT" |
| 451 |
|
| 452 |
;; The next-to-last "&&" condition above should be caught by some kind of |
| 453 |
;; canonicalization in gcc, but we can easily help with it here. |
| 454 |
;; It results from expressions of the type |
| 455 |
;; "power_of_2_value & (1 << y)". FIXME: Add testcase. |
| 456 |
;; |
| 457 |
;; Since there may be codes with tests in on bits (in constant position) |
| 458 |
;; beyond the size of a word, handle that by assuming those bits are 0. |
| 459 |
;; GCC should handle that, but it's a matter of easily-added belts while |
| 460 |
;; having suspenders. |
| 461 |
|
| 462 |
"@ |
| 463 |
btstq (%1-1),%0 |
| 464 |
cmpq 0,%0 |
| 465 |
btstq %2,%0 |
| 466 |
clearf nz |
| 467 |
btst %2,%0 |
| 468 |
clearf nz |
| 469 |
cmpq %p0,%2" |
| 470 |
[(set_attr "slottable" "yes")]) |
| 471 |
|
| 472 |
;; Move insns. |
| 473 |
|
| 474 |
;; The whole mandatory movdi family is here; expander, "anonymous" |
| 475 |
;; recognizer and splitter. We're forced to have a movdi pattern, |
| 476 |
;; although GCC should be able to split it up itself. Normally it can, |
| 477 |
;; but if other insns have DI operands (as is the case here), reload |
| 478 |
;; must be able to generate or match a movdi. many testcases fail at |
| 479 |
;; -O3 or -fssa if we don't have this. FIXME: Fix GCC... See |
| 480 |
;; <URL:http://gcc.gnu.org/ml/gcc-patches/2000-04/msg00104.html>. |
| 481 |
;; However, a patch from Richard Kenner (similar to the cause of |
| 482 |
;; discussion at the URL above), indicates otherwise. See |
| 483 |
;; <URL:http://gcc.gnu.org/ml/gcc-patches/2000-04/msg00554.html>. |
| 484 |
;; The truth has IMO is not been decided yet, so check from time to |
| 485 |
;; time by disabling the movdi patterns. |
| 486 |
|
| 487 |
;; To appease testcase gcc.c-torture/execute/920501-2.c (and others) at |
| 488 |
;; -O0, we need a movdi as a temporary measure. Here's how things fail: |
| 489 |
;; A cmpdi RTX needs reloading (global): |
| 490 |
;; (insn 185 326 186 (set (cc0) |
| 491 |
;; (compare (mem/f:DI (reg/v:SI 22) 0) |
| 492 |
;; (const_int 1 [0x1]))) 4 {cmpdi} (nil) |
| 493 |
;; (nil)) |
| 494 |
;; Now, reg 22 is reloaded for input address, and the mem is also moved |
| 495 |
;; out of the instruction (into a register), since one of the operands |
| 496 |
;; must be a register. Reg 22 is reloaded (into reg 10), and the mem is |
| 497 |
;; moved out and synthesized in SImode parts (reg 9, reg 10 - should be ok |
| 498 |
;; wrt. overlap). The bad things happen with the synthesis in |
| 499 |
;; emit_move_insn_1; the location where to substitute reg 10 is lost into |
| 500 |
;; two new RTX:es, both still having reg 22. Later on, the left-over reg |
| 501 |
;; 22 is recognized to have an equivalent in memory which is substituted |
| 502 |
;; straight in, and we end up with an unrecognizable insn: |
| 503 |
;; (insn 325 324 326 (set (reg:SI 9 r9) |
| 504 |
;; (mem/f:SI (mem:SI (plus:SI (reg:SI 8 r8) |
| 505 |
;; (const_int -84 [0xffffffac])) 0) 0)) -1 (nil) |
| 506 |
;; (nil)) |
| 507 |
;; which is the first part of the reloaded synthesized "movdi". |
| 508 |
;; The right thing would be to add equivalent replacement locations for |
| 509 |
;; insn with pseudos that need more reloading. The question is where. |
| 510 |
|
| 511 |
(define_expand "movdi" |
| 512 |
[(parallel |
| 513 |
[(set (match_operand:DI 0 "nonimmediate_operand") |
| 514 |
(match_operand:DI 1 "general_operand")) |
| 515 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 516 |
"" |
| 517 |
{ |
| 518 |
if (MEM_P (operands[0]) |
| 519 |
&& operands[1] != const0_rtx |
| 520 |
&& can_create_pseudo_p ()) |
| 521 |
operands[1] = copy_to_mode_reg (DImode, operands[1]); |
| 522 |
|
| 523 |
/* Some other ports (as of 2001-09-10 for example mcore and romp) also |
| 524 |
prefer to split up constants early, like this. The testcase in |
| 525 |
gcc.c-torture/execute/961213-1.c shows that CSE2 gets confused by the |
| 526 |
resulting subreg sets when using the construct from mcore (as of FSF |
| 527 |
CVS, version -r 1.5), and it believes that the high part (the last one |
| 528 |
emitted) is the final value. */ |
| 529 |
if ((CONST_INT_P (operands[1]) || GET_CODE (operands[1]) == CONST_DOUBLE) |
| 530 |
&& ! reload_completed |
| 531 |
&& ! lra_in_progress) |
| 532 |
{ |
| 533 |
rtx insns; |
| 534 |
rtx op0 = operands[0]; |
| 535 |
rtx op1 = operands[1]; |
| 536 |
|
| 537 |
start_sequence (); |
| 538 |
emit_move_insn (operand_subword (op0, 0, 1, DImode), |
| 539 |
operand_subword (op1, 0, 1, DImode)); |
| 540 |
emit_move_insn (operand_subword (op0, 1, 1, DImode), |
| 541 |
operand_subword (op1, 1, 1, DImode)); |
| 542 |
insns = get_insns (); |
| 543 |
end_sequence (); |
| 544 |
|
| 545 |
emit_insn (insns); |
| 546 |
DONE; |
| 547 |
} |
| 548 |
}) |
| 549 |
|
| 550 |
(define_insn_and_split "*movdi_insn" |
| 551 |
[(set (match_operand:DI 0 "nonimmediate_operand" "=r,rx,m") |
| 552 |
(match_operand:DI 1 "general_operand" "rx,g,rxM")) |
| 553 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 554 |
"(register_operand (operands[0], DImode) |
| 555 |
|| register_operand (operands[1], DImode) |
| 556 |
|| operands[1] == const0_rtx)" |
| 557 |
"#" |
| 558 |
"&& reload_completed" |
| 559 |
[(match_dup 2)] |
| 560 |
"operands[2] = cris_split_movdx (operands);") |
| 561 |
|
| 562 |
;; Normal move patterns from SI on. |
| 563 |
|
| 564 |
(define_expand "movsi" |
| 565 |
[(parallel |
| 566 |
[(set |
| 567 |
(match_operand:SI 0 "nonimmediate_operand") |
| 568 |
(match_operand:SI 1 "general_operand")) |
| 569 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 570 |
"" |
| 571 |
{ |
| 572 |
/* If the output goes to a MEM, make sure we have zero or a register as |
| 573 |
input. */ |
| 574 |
if (MEM_P (operands[0]) |
| 575 |
&& ! REG_S_P (operands[1]) |
| 576 |
&& operands[1] != const0_rtx |
| 577 |
&& can_create_pseudo_p ()) |
| 578 |
operands[1] = force_reg (SImode, operands[1]); |
| 579 |
|
| 580 |
/* At post-reload time, we'll get here for e.g. split multi-mode insns |
| 581 |
with a memory destination. Go directly to the clobber-less variant. |
| 582 |
FIXME: Also applies to special-register source or destination. */ |
| 583 |
if (reload_completed |
| 584 |
&& (MEM_P (operands[0]) || operands[1] == const0_rtx)) |
| 585 |
{ |
| 586 |
emit_insn (gen_rtx_SET (operands[0], operands[1])); |
| 587 |
DONE; |
| 588 |
} |
| 589 |
}) |
| 590 |
|
| 591 |
;; We provide CC, CC_NZ and CC_NZVC variants, as moves clear V and C |
| 592 |
;; and the result is thus usable in a compare against 0. |
| 593 |
(define_insn "*movsi_internal<setcc><setnz><setnzvc>" |
| 594 |
[(set |
| 595 |
(match_operand:SI 0 "nonimmediate_operand" |
| 596 |
"=r,r, r,Q>,r,Q>,g,r,r,g,rQ>,x, m,x, Q>,r,g") |
| 597 |
(match_operand:SI 1 "general_operand" |
| 598 |
"r,Q>,M,M, I,r, M,n,g,r,x, rQ>,x,gi,r, g,r")) |
| 599 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 600 |
;; Avoid matching insns we know must be reloaded. Without one |
| 601 |
;; operand being a (pseudo-)register, reload chooses |
| 602 |
;; reload-registers suboptimally. |
| 603 |
"REG_S_P (operands[0]) || REG_S_P (operands[1]) || operands[1] == const0_rtx" |
| 604 |
{ |
| 605 |
/* Better to have c-switch here; it is worth it to optimize the size of |
| 606 |
move insns. The alternative would be to try to find more constraint |
| 607 |
letters. FIXME: Check again. It seems this could shrink a bit. */ |
| 608 |
switch (which_alternative) |
| 609 |
{ |
| 610 |
case 0: |
| 611 |
case 1: |
| 612 |
case 5: |
| 613 |
case 8: |
| 614 |
case 9: |
| 615 |
case 14: |
| 616 |
case 15: |
| 617 |
case 16: |
| 618 |
return "move.d %1,%0"; |
| 619 |
|
| 620 |
case 10: |
| 621 |
case 11: |
| 622 |
case 12: |
| 623 |
case 13: |
| 624 |
return "move %1,%0"; |
| 625 |
|
| 626 |
case 2: |
| 627 |
case 3: |
| 628 |
case 6: |
| 629 |
return "clear.d %0"; |
| 630 |
|
| 631 |
/* Constants -32..31 except 0. */ |
| 632 |
case 4: |
| 633 |
return "moveq %1,%0"; |
| 634 |
|
| 635 |
/* We can win a little on constants -32768..-33, 32..65535. */ |
| 636 |
case 7: |
| 637 |
if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) < 65536) |
| 638 |
{ |
| 639 |
if (INTVAL (operands[1]) < 256) |
| 640 |
return "movu.b %1,%0"; |
| 641 |
return "movu.w %1,%0"; |
| 642 |
} |
| 643 |
else if (INTVAL (operands[1]) >= -32768 && INTVAL (operands[1]) < 32768) |
| 644 |
{ |
| 645 |
if (INTVAL (operands[1]) >= -128 && INTVAL (operands[1]) < 128) |
| 646 |
return "movs.b %1,%0"; |
| 647 |
return "movs.w %1,%0"; |
| 648 |
} |
| 649 |
return "move.d %1,%0"; |
| 650 |
|
| 651 |
default: |
| 652 |
gcc_unreachable (); |
| 653 |
} |
| 654 |
} |
| 655 |
[(set_attr "cpu_variant" "*,*,*,*,*,v0,*,*,v0,v0,*,*,*,*,v10,v10,v10") |
| 656 |
(set_attr "slottable" "yes,yes,yes,yes,yes,yes,no,no,no,no,yes,yes,no,no,yes,no,no") |
| 657 |
(set_attr "cc<cccc><ccnz><ccnzvc>" |
| 658 |
"*,*,none,none,*,none,none,*,*,none,none,none,none,none,none,*,none")]) |
| 659 |
|
| 660 |
;; FIXME: See movsi. |
| 661 |
|
| 662 |
(define_insn "<acc><anz><anzvc>movhi<setcc><setnz><setnzvc>" |
| 663 |
[(set |
| 664 |
(match_operand:HI 0 "nonimmediate_operand" "=r,r, r,Q>,r,Q>,r,r,r,g,g,r,r,x") |
| 665 |
(match_operand:HI 1 "general_operand" "r,Q>,M,M, I,r, L,O,n,M,r,g,x,r")) |
| 666 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 667 |
"" |
| 668 |
{ |
| 669 |
switch (which_alternative) |
| 670 |
{ |
| 671 |
case 0: |
| 672 |
case 1: |
| 673 |
case 5: |
| 674 |
case 10: |
| 675 |
case 11: |
| 676 |
return "move.w %1,%0"; |
| 677 |
case 12: |
| 678 |
case 13: |
| 679 |
return "move %1,%0"; |
| 680 |
case 2: |
| 681 |
case 3: |
| 682 |
case 9: |
| 683 |
return "clear.w %0"; |
| 684 |
case 4: |
| 685 |
return "moveq %1,%0"; |
| 686 |
case 6: |
| 687 |
case 8: |
| 688 |
if (INTVAL (operands[1]) < 256 && INTVAL (operands[1]) >= -128) |
| 689 |
{ |
| 690 |
if (INTVAL (operands[1]) > 0) |
| 691 |
return "movu.b %1,%0"; |
| 692 |
return "movs.b %1,%0"; |
| 693 |
} |
| 694 |
return "move.w %1,%0"; |
| 695 |
case 7: |
| 696 |
return "movEq %b1,%0"; |
| 697 |
default: |
| 698 |
return "BOGUS: %1 to %0"; |
| 699 |
} |
| 700 |
} |
| 701 |
[(set_attr "slottable" "yes,yes,yes,yes,yes,yes,no,yes,no,no,no,no,yes,yes") |
| 702 |
(set_attr "cc<cccc><ccnz><ccnzvc>" "*,*,none,none,*,none,*,clobber,*,none,none,*,none,none")]) |
| 703 |
|
| 704 |
(define_insn "movstricthi" |
| 705 |
[(set |
| 706 |
(strict_low_part |
| 707 |
(match_operand:HI 0 "nonimmediate_operand" "+r,r, r,Q>,Q>,g,r,g")) |
| 708 |
(match_operand:HI 1 "general_operand" "r,Q>,M,M, r, M,g,r")) |
| 709 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 710 |
"" |
| 711 |
"@ |
| 712 |
move.w %1,%0 |
| 713 |
move.w %1,%0 |
| 714 |
clear.w %0 |
| 715 |
clear.w %0 |
| 716 |
move.w %1,%0 |
| 717 |
clear.w %0 |
| 718 |
move.w %1,%0 |
| 719 |
move.w %1,%0" |
| 720 |
[(set_attr "slottable" "yes,yes,yes,yes,yes,no,no,no")]) |
| 721 |
|
| 722 |
(define_expand "reload_in<mode>" |
| 723 |
[(set (match_operand:BW 2 "register_operand" "=r") |
| 724 |
(match_operand:BW 1 "memory_operand" "m")) |
| 725 |
(set (match_operand:BW 0 "register_operand" "=x") |
| 726 |
(match_dup 2))] |
| 727 |
"" |
| 728 |
"") |
| 729 |
|
| 730 |
(define_expand "reload_out<mode>" |
| 731 |
[(set (match_operand:BW 2 "register_operand" "=&r") |
| 732 |
(match_operand:BW 1 "register_operand" "x")) |
| 733 |
(set (match_operand:BW 0 "memory_operand" "=m") |
| 734 |
(match_dup 2))] |
| 735 |
"" |
| 736 |
"") |
| 737 |
|
| 738 |
(define_insn "<acc><anz><anzvc>movqi<setcc><setnz><setnzvc>" |
| 739 |
[(set (match_operand:QI 0 "nonimmediate_operand" "=r,Q>,r, r,Q>,r,g,g,r,r,r,x") |
| 740 |
(match_operand:QI 1 "general_operand" "r,r, Q>,M,M, I,M,r,O,g,x,r")) |
| 741 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 742 |
"" |
| 743 |
"@ |
| 744 |
move.b %1,%0 |
| 745 |
move.b %1,%0 |
| 746 |
move.b %1,%0 |
| 747 |
clear.b %0 |
| 748 |
clear.b %0 |
| 749 |
moveq %1,%0 |
| 750 |
clear.b %0 |
| 751 |
move.b %1,%0 |
| 752 |
moveq %b1,%0 |
| 753 |
move.b %1,%0 |
| 754 |
move %1,%0 |
| 755 |
move %1,%0" |
| 756 |
[(set_attr "slottable" "yes,yes,yes,yes,yes,yes,no,no,yes,no,yes,yes") |
| 757 |
(set_attr "cc<cccc><ccnz><ccnzvc>" |
| 758 |
"*,none,*,none,none,*,none,none,clobber,*,none,none")]) |
| 759 |
|
| 760 |
(define_insn "movstrictqi" |
| 761 |
[(set (strict_low_part |
| 762 |
(match_operand:QI 0 "nonimmediate_operand" "+r,Q>,r, r,Q>,g,g,r")) |
| 763 |
(match_operand:QI 1 "general_operand" "r,r, Q>,M,M, M,r,g")) |
| 764 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 765 |
"" |
| 766 |
"@ |
| 767 |
move.b %1,%0 |
| 768 |
move.b %1,%0 |
| 769 |
move.b %1,%0 |
| 770 |
clear.b %0 |
| 771 |
clear.b %0 |
| 772 |
clear.b %0 |
| 773 |
move.b %1,%0 |
| 774 |
move.b %1,%0" |
| 775 |
[(set_attr "slottable" "yes,yes,yes,yes,yes,no,no,no")]) |
| 776 |
|
| 777 |
;; The valid "quick" bit-patterns are, except for 0.0, denormalized |
| 778 |
;; values REALLY close to 0, and some NaN:s (I think; their exponent is |
| 779 |
;; all ones); the worthwhile one is "0.0". |
| 780 |
;; It will use clear, so we know ALL types of immediate 0 never change cc. |
| 781 |
|
| 782 |
(define_insn "movsf" |
| 783 |
[(set (match_operand:SF 0 "nonimmediate_operand" "=r,Q>,r, r,Q>,g,g,r,r,x,Q>,m,x, x") |
| 784 |
(match_operand:SF 1 "general_operand" "r,r, Q>,G,G, G,r,g,x,r,x, x,Q>,g")) |
| 785 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 786 |
"" |
| 787 |
"@ |
| 788 |
move.d %1,%0 |
| 789 |
move.d %1,%0 |
| 790 |
move.d %1,%0 |
| 791 |
clear.d %0 |
| 792 |
clear.d %0 |
| 793 |
clear.d %0 |
| 794 |
move.d %1,%0 |
| 795 |
move.d %1,%0 |
| 796 |
move %1,%0 |
| 797 |
move %1,%0 |
| 798 |
move %1,%0 |
| 799 |
move %1,%0 |
| 800 |
move %1,%0 |
| 801 |
move %1,%0" |
| 802 |
[(set_attr "slottable" "yes,yes,yes,yes,yes,no,no,no,yes,yes,yes,no,yes,no")]) |
| 803 |
|
| 804 |
;; Post-reload, for memory destinations, split the clobber-variant and |
| 805 |
;; get rid of the clobber. |
| 806 |
|
| 807 |
(define_split ;; "*mov_tomem<mode>_split" |
| 808 |
[(set (match_operand:BWD 0 "memory_operand") |
| 809 |
(match_operand:BWD 1 "nonmemory_operand")) |
| 810 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 811 |
"reload_completed" |
| 812 |
[(set (match_dup 0) (match_dup 1))] |
| 813 |
"") |
| 814 |
|
| 815 |
;; Exclude moving special-registers to memory from matching for |
| 816 |
;; less-than-SImode, as they are SImode only (or actually, the size of |
| 817 |
;; the register, but the ones free for "x" are naturally SImode; see |
| 818 |
;; special measures taken for reload). |
| 819 |
;; This might be a belt-and-suspenders thing, as a move from special |
| 820 |
;; register to memory in less-than-SImode should not have made it here. |
| 821 |
|
| 822 |
(define_mode_attr mov_tomem_enabled |
| 823 |
[(SI "yes,yes,yes,yes,yes,yes") |
| 824 |
(HI "yes,yes,no,yes,yes,no") |
| 825 |
(QI "yes,yes,no,yes,yes,no")]) |
| 826 |
|
| 827 |
(define_insn "*mov_tomem<mode>" |
| 828 |
[(set (match_operand:BWD 0 "memory_operand" "=Q>,Q>,Q>,m,m,m") |
| 829 |
(match_operand:BWD 1 "nonmemory_operand" "M, r, x, M,r,x"))] |
| 830 |
"reload_completed" |
| 831 |
"@ |
| 832 |
clear<m> %0 |
| 833 |
move<m> %1,%0 |
| 834 |
move %1,%0 |
| 835 |
clear<m> %0 |
| 836 |
move<m> %1,%0 |
| 837 |
move %1,%0" |
| 838 |
[(set_attr "slottable" "yes,yes,yes,no,no,no") |
| 839 |
(set_attr "enabled" "<mov_tomem_enabled>")]) |
| 840 |
|
| 841 |
(define_split ;; "*mov_fromzero<mode>_split" |
| 842 |
[(set (match_operand:BWD 0 "register_operand") (const_int 0)) |
| 843 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 844 |
"reload_completed |
| 845 |
&& REGNO(operands[0]) <= CRIS_LAST_GENERAL_REGISTER" |
| 846 |
[(set (match_dup 0) (const_int 0))] |
| 847 |
"") |
| 848 |
|
| 849 |
(define_insn "*mov_fromzero<mode>" |
| 850 |
[(set (match_operand:BWD 0 "register_operand" "=r") (const_int 0))] |
| 851 |
"reload_completed" |
| 852 |
"clear<m> %0" |
| 853 |
[(set_attr "slottable" "yes")]) |
| 854 |
|
| 855 |
;; Movem patterns. Primarily for use in function prologue and epilogue. |
| 856 |
;; Unfortunately, movem stores R0 in the highest memory location, thus |
| 857 |
;; the opposite of the expectation for the standard names "load_multiple" |
| 858 |
;; and "store_multiple". |
| 859 |
|
| 860 |
(define_insn "*cris_load_multiple" |
| 861 |
[(match_parallel 0 "cris_load_multiple_op" |
| 862 |
[(set (match_operand:SI 1 "register_operand" "=r,r") |
| 863 |
(match_operand:SI 2 "memory_operand" "Q,m"))])] |
| 864 |
"" |
| 865 |
"movem %O0,%o0" |
| 866 |
[(set_attr "cc" "none") |
| 867 |
(set_attr "slottable" "yes,no") |
| 868 |
;; Not true, but setting the length to 0 causes return sequences (ret |
| 869 |
;; movem) to have the cost they had when (return) included the movem |
| 870 |
;; and reduces the performance penalty taken for needing to emit an |
| 871 |
;; epilogue (in turn copied by bb-reorder) instead of return patterns. |
| 872 |
;; FIXME: temporary change until all insn lengths are correctly |
| 873 |
;; described. FIXME: have better target control over bb-reorder. |
| 874 |
(set_attr "length" "0")]) |
| 875 |
|
| 876 |
(define_insn "*cris_store_multiple" |
| 877 |
[(match_parallel 0 "cris_store_multiple_op" |
| 878 |
[(set (match_operand:SI 2 "memory_operand" "=Q,m") |
| 879 |
(match_operand:SI 1 "register_operand" "r,r"))])] |
| 880 |
"" |
| 881 |
"movem %o0,%O0" |
| 882 |
[(set_attr "cc" "none") |
| 883 |
(set_attr "slottable" "yes,no")]) |
| 884 |
|
| 885 |
|
| 886 |
;; Sign- and zero-extend insns with standard names. |
| 887 |
;; Those for integer source operand are ordered with the widest source |
| 888 |
;; type first. |
| 889 |
|
| 890 |
;; Sign-extend. |
| 891 |
|
| 892 |
(define_insn "extendsidi2" |
| 893 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 894 |
(sign_extend:DI (match_operand:SI 1 "general_operand" "g"))) |
| 895 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 896 |
"" |
| 897 |
"move.d %1,%M0\;smi %H0\;neg.d %H0,%H0") |
| 898 |
|
| 899 |
(define_insn "extend<mode>di2" |
| 900 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 901 |
(sign_extend:DI (match_operand:BW 1 "general_operand" "g"))) |
| 902 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 903 |
"" |
| 904 |
"movs<m> %1,%M0\;smi %H0\;neg.d %H0,%H0") |
| 905 |
|
| 906 |
(define_insn "<acc><anz><anzvc>extend<mode>si2<setcc><setnz><setnzvc>" |
| 907 |
[(set (match_operand:SI 0 "register_operand" "=r,r,r") |
| 908 |
(sign_extend:SI (match_operand:BW 1 "general_operand" "r,Q>,g"))) |
| 909 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 910 |
"" |
| 911 |
"movs<m> %1,%0" |
| 912 |
[(set_attr "slottable" "yes,yes,no")]) |
| 913 |
|
| 914 |
;; To do a byte->word extension, extend to dword, except that the top half |
| 915 |
;; of the register will be clobbered. FIXME: Perhaps this is not needed. |
| 916 |
|
| 917 |
(define_insn "extendqihi2" |
| 918 |
[(set (match_operand:HI 0 "register_operand" "=r,r,r") |
| 919 |
(sign_extend:HI (match_operand:QI 1 "general_operand" "r,Q>,g"))) |
| 920 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 921 |
"" |
| 922 |
"movs.b %1,%0" |
| 923 |
[(set_attr "slottable" "yes,yes,no")]) |
| 924 |
|
| 925 |
|
| 926 |
;; Zero-extend. The DImode ones are synthesized by gcc, so we don't |
| 927 |
;; specify them here. |
| 928 |
|
| 929 |
(define_insn "<acc><anz><anzvc>zero_extend<mode>si2<setcc><setnz><setnzvc>" |
| 930 |
[(set (match_operand:SI 0 "register_operand" "=r,r,r") |
| 931 |
(zero_extend:SI |
| 932 |
(match_operand:BW 1 "nonimmediate_operand" "r,Q>,m"))) |
| 933 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 934 |
"" |
| 935 |
"movu<m> %1,%0" |
| 936 |
[(set_attr "slottable" "yes,yes,no")]) |
| 937 |
|
| 938 |
;; Same comment as sign-extend QImode to HImode above applies. |
| 939 |
|
| 940 |
(define_insn "zero_extendqihi2" |
| 941 |
[(set (match_operand:HI 0 "register_operand" "=r,r,r") |
| 942 |
(zero_extend:HI |
| 943 |
(match_operand:QI 1 "nonimmediate_operand" "r,Q>,m"))) |
| 944 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 945 |
"" |
| 946 |
"movu.b %1,%0" |
| 947 |
[(set_attr "slottable" "yes,yes,no")]) |
| 948 |
|
| 949 |
;; Add operations, standard names. |
| 950 |
|
| 951 |
;; Note that for the 'P' constraint, the high part can be -1 or 0. We |
| 952 |
;; output the insn through the 'A' output modifier as "adds.w" and "addq", |
| 953 |
;; respectively. |
| 954 |
(define_expand "adddi3" |
| 955 |
[(parallel |
| 956 |
[(set (match_operand:DI 0 "register_operand") |
| 957 |
(plus:DI (match_operand:DI 1 "register_operand") |
| 958 |
(match_operand:DI 2 "general_operand"))) |
| 959 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 960 |
"" |
| 961 |
"") |
| 962 |
|
| 963 |
(define_insn "*adddi3<setnz>" |
| 964 |
[(set (match_operand:DI 0 "register_operand" "=r,r,r,&r,&r") |
| 965 |
(plus:DI (match_operand:DI 1 "register_operand" "%0,0,0,0,r") |
| 966 |
(match_operand:DI 2 "general_operand" "J,N,P,g,!To"))) |
| 967 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 968 |
"" |
| 969 |
"@ |
| 970 |
addq %2,%M0\;ax\;addq 0,%H0 |
| 971 |
subq %n2,%M0\;ax\;subq 0,%H0 |
| 972 |
add%e2.%z2 %2,%M0\;ax\;%A2 %H2,%H0 |
| 973 |
add.d %M2,%M0\;ax\;add.d %H2,%H0 |
| 974 |
add.d %M2,%M1,%M0\;ax\;add.d %H2,%H1,%H0") |
| 975 |
|
| 976 |
(define_expand "add<mode>3" |
| 977 |
[(parallel |
| 978 |
[(set (match_operand:BWD 0 "register_operand") |
| 979 |
(plus:BWD |
| 980 |
(match_operand:BWD 1 "register_operand") |
| 981 |
(match_operand:BWD 2 "general_operand"))) |
| 982 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 983 |
"" |
| 984 |
"") |
| 985 |
|
| 986 |
(define_insn "*addsi3<setnz>" |
| 987 |
[(set (match_operand:SI 0 "register_operand" "=r,r, r,r,r,r,r, r") |
| 988 |
(plus:SI |
| 989 |
(match_operand:SI 1 "register_operand" "%0,0, 0,0,0,0,r, r") |
| 990 |
(match_operand:SI 2 "general_operand" "r,Q>,J,N,n,g,!To,0"))) |
| 991 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 992 |
|
| 993 |
;; The last constraint is due to that after reload, the '%' is not |
| 994 |
;; honored, and canonicalization doesn't care about keeping the same |
| 995 |
;; register as in destination. This will happen after insn splitting. |
| 996 |
|
| 997 |
"" |
| 998 |
{ |
| 999 |
switch (which_alternative) |
| 1000 |
{ |
| 1001 |
case 0: |
| 1002 |
case 1: |
| 1003 |
return "add.d %2,%0"; |
| 1004 |
case 2: |
| 1005 |
return "addq %2,%0"; |
| 1006 |
case 3: |
| 1007 |
return "subq %n2,%0"; |
| 1008 |
case 4: |
| 1009 |
/* 'Known value', but not in -63..63. |
| 1010 |
Check if addu/subu may be used. */ |
| 1011 |
if (INTVAL (operands[2]) > 0) |
| 1012 |
{ |
| 1013 |
if (INTVAL (operands[2]) < 256) |
| 1014 |
return "addu.b %2,%0"; |
| 1015 |
if (INTVAL (operands[2]) < 65536) |
| 1016 |
return "addu.w %2,%0"; |
| 1017 |
} |
| 1018 |
else |
| 1019 |
{ |
| 1020 |
if (INTVAL (operands[2]) >= -255) |
| 1021 |
return "subu.b %n2,%0"; |
| 1022 |
if (INTVAL (operands[2]) >= -65535) |
| 1023 |
return "subu.w %n2,%0"; |
| 1024 |
} |
| 1025 |
return "add.d %2,%0"; |
| 1026 |
case 5: |
| 1027 |
return "add.d %2,%0"; |
| 1028 |
case 6: |
| 1029 |
return "add.d %2,%1,%0"; |
| 1030 |
case 7: |
| 1031 |
return "add.d %1,%0"; |
| 1032 |
default: |
| 1033 |
return "BOGUS addsi %2+%1 to %0"; |
| 1034 |
} |
| 1035 |
} |
| 1036 |
[(set_attr "slottable" "yes,yes,yes,yes,no,no,no,yes")]) |
| 1037 |
|
| 1038 |
(define_insn "*addhi3<setnz>" |
| 1039 |
[(set (match_operand:HI 0 "register_operand" "=r,r, r,r,r,r") |
| 1040 |
(plus:HI (match_operand:HI 1 "register_operand" "%0,0, 0,0,0,r") |
| 1041 |
(match_operand:HI 2 "general_operand" "r,Q>,J,N,g,!To"))) |
| 1042 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1043 |
"" |
| 1044 |
"@ |
| 1045 |
add.w %2,%0 |
| 1046 |
add.w %2,%0 |
| 1047 |
addq %2,%0 |
| 1048 |
subq %n2,%0 |
| 1049 |
add.w %2,%0 |
| 1050 |
add.w %2,%1,%0" |
| 1051 |
[(set_attr "slottable" "yes,yes,yes,yes,no,no") |
| 1052 |
(set_attr "cc<ccnz>" "normal,normal,clobber,clobber,normal,normal")]) |
| 1053 |
|
| 1054 |
(define_insn "*addqi3<setnz>" |
| 1055 |
[(set (match_operand:QI 0 "register_operand" "=r,r, r,r,r,r,r") |
| 1056 |
(plus:QI (match_operand:QI 1 "register_operand" "%0,0, 0,0,0,0,r") |
| 1057 |
(match_operand:QI 2 "general_operand" "r,Q>,J,N,O,g,!To"))) |
| 1058 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1059 |
"" |
| 1060 |
"@ |
| 1061 |
add.b %2,%0 |
| 1062 |
add.b %2,%0 |
| 1063 |
addq %2,%0 |
| 1064 |
subq %n2,%0 |
| 1065 |
subQ -%b2,%0 |
| 1066 |
add.b %2,%0 |
| 1067 |
add.b %2,%1,%0" |
| 1068 |
[(set_attr "slottable" "yes,yes,yes,yes,yes,no,no") |
| 1069 |
(set_attr "cc<ccnz>" "normal,normal,clobber,clobber,clobber,normal,normal")]) |
| 1070 |
|
| 1071 |
;; Subtract. |
| 1072 |
;; |
| 1073 |
;; Note that because of insn canonicalization these will *seldom* but |
| 1074 |
;; rarely be used with a known constant as an operand. |
| 1075 |
|
| 1076 |
;; Note that for the 'P' constraint, the high part can be -1 or 0. We |
| 1077 |
;; output the insn through the 'D' output modifier as "subs.w" and "subq", |
| 1078 |
;; respectively. |
| 1079 |
(define_expand "subdi3" |
| 1080 |
[(parallel |
| 1081 |
[(set (match_operand:DI 0 "register_operand") |
| 1082 |
(minus:DI (match_operand:DI 1 "register_operand") |
| 1083 |
(match_operand:DI 2 "general_operand"))) |
| 1084 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 1085 |
"" |
| 1086 |
"") |
| 1087 |
|
| 1088 |
(define_insn "*subdi3<setnz>" |
| 1089 |
[(set (match_operand:DI 0 "register_operand" "=r,r,r,&r,&r") |
| 1090 |
(minus:DI (match_operand:DI 1 "register_operand" "0,0,0,0,r") |
| 1091 |
(match_operand:DI 2 "general_operand" "J,N,P,g,!To"))) |
| 1092 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1093 |
"" |
| 1094 |
"@ |
| 1095 |
subq %2,%M0\;ax\;subq 0,%H0 |
| 1096 |
addq %n2,%M0\;ax\;addq 0,%H0 |
| 1097 |
sub%e2.%z2 %2,%M0\;ax\;%D2 %H2,%H0 |
| 1098 |
sub.d %M2,%M0\;ax\;sub.d %H2,%H0 |
| 1099 |
sub.d %M2,%M1,%M0\;ax\;sub.d %H2,%H1,%H0") |
| 1100 |
|
| 1101 |
(define_expand "sub<mode>3" |
| 1102 |
[(parallel |
| 1103 |
[(set (match_operand:BWD 0 "register_operand") |
| 1104 |
(minus:BWD |
| 1105 |
(match_operand:BWD 1 "register_operand") |
| 1106 |
(match_operand:BWD 2 "general_operand"))) |
| 1107 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 1108 |
"" |
| 1109 |
"") |
| 1110 |
|
| 1111 |
(define_insn "*subsi3<setnz>" |
| 1112 |
[(set (match_operand:SI 0 "register_operand" "=r,r, r,r,r,r,r,r") |
| 1113 |
(minus:SI |
| 1114 |
(match_operand:SI 1 "register_operand" "0,0, 0,0,0,0,0,r") |
| 1115 |
(match_operand:SI 2 "general_operand" "r,Q>,J,N,P,n,g,!To"))) |
| 1116 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1117 |
"" |
| 1118 |
|
| 1119 |
;; This does not do the optimal: "addu.w 65535,r0" when %2 is negative. |
| 1120 |
;; But then again, %2 should not be negative. |
| 1121 |
|
| 1122 |
"@ |
| 1123 |
sub.d %2,%0 |
| 1124 |
sub.d %2,%0 |
| 1125 |
subq %2,%0 |
| 1126 |
addq %n2,%0 |
| 1127 |
sub%e2.%z2 %2,%0 |
| 1128 |
sub.d %2,%0 |
| 1129 |
sub.d %2,%0 |
| 1130 |
sub.d %2,%1,%0" |
| 1131 |
[(set_attr "slottable" "yes,yes,yes,yes,no,no,no,no")]) |
| 1132 |
|
| 1133 |
(define_insn "*sub<mode>3<setnz>" |
| 1134 |
[(set (match_operand:BW 0 "register_operand" "=r,r, r,r,r,r") |
| 1135 |
(minus:BW (match_operand:BW 1 "register_operand" "0,0, 0,0,0,r") |
| 1136 |
(match_operand:BW 2 "general_operand" "r,Q>,J,N,g,!To"))) |
| 1137 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1138 |
"" |
| 1139 |
"@ |
| 1140 |
sub<m> %2,%0 |
| 1141 |
sub<m> %2,%0 |
| 1142 |
subq %2,%0 |
| 1143 |
addq %n2,%0 |
| 1144 |
sub<m> %2,%0 |
| 1145 |
sub<m> %2,%1,%0" |
| 1146 |
[(set_attr "slottable" "yes,yes,yes,yes,no,no") |
| 1147 |
(set_attr "cc<ccnz>" "normal,normal,clobber,clobber,normal,normal")]) |
| 1148 |
|
| 1149 |
;; Extend versions (zero/sign) of normal add/sub (no side-effects). |
| 1150 |
|
| 1151 |
;; QImode to HImode |
| 1152 |
;; FIXME: GCC should widen. |
| 1153 |
|
| 1154 |
(define_insn "*<addsub><su>qihi" |
| 1155 |
[(set (match_operand:HI 0 "register_operand" "=r,r,r,r") |
| 1156 |
(plusminus:HI |
| 1157 |
(match_operand:HI 1 "register_operand" "0,0,0,r") |
| 1158 |
(szext:HI (match_operand:QI 2 "nonimmediate_operand" "r,Q>,m,!To")))) |
| 1159 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1160 |
"GET_MODE_SIZE (GET_MODE (operands[0])) <= UNITS_PER_WORD |
| 1161 |
&& (operands[1] != frame_pointer_rtx || <plusminus:CODE> != PLUS)" |
| 1162 |
"@ |
| 1163 |
<addsub><su>.b %2,%0 |
| 1164 |
<addsub><su>.b %2,%0 |
| 1165 |
<addsub><su>.b %2,%0 |
| 1166 |
<addsub><su>.b %2,%1,%0" |
| 1167 |
[(set_attr "slottable" "yes,yes,no,no") |
| 1168 |
(set_attr "cc" "clobber")]) |
| 1169 |
|
| 1170 |
;; FIXME: bound is actually also <setnzvc>, but is so rarely used in this |
| 1171 |
;; form that it's not worthwhile to make that distinction. |
| 1172 |
(define_insn "*<addsubbo><su><nd><mode>si<setnz>" |
| 1173 |
[(set (match_operand:SI 0 "register_operand" "=r,r,r,r") |
| 1174 |
(plusminusumin:SI |
| 1175 |
(match_operand:SI 1 "register_operand" "0,0,0,r") |
| 1176 |
(szext:SI (match_operand:BW 2 "nonimmediate_operand" "r,Q>,m,!To")))) |
| 1177 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1178 |
"(<plusminusumin:CODE> != UMIN || <szext:CODE> == ZERO_EXTEND) |
| 1179 |
&& (operands[1] != frame_pointer_rtx || <plusminusumin:CODE> != PLUS)" |
| 1180 |
"@ |
| 1181 |
<addsubbo><su><nd><m> %2,%0 |
| 1182 |
<addsubbo><su><nd><m> %2,%0 |
| 1183 |
<addsubbo><su><nd><m> %2,%0 |
| 1184 |
<addsubbo><su><nd><m> %2,%1,%0" |
| 1185 |
[(set_attr "slottable" "yes,yes,no,no")]) |
| 1186 |
|
| 1187 |
;; We may have swapped operands for add or bound. |
| 1188 |
;; For commutative operands, these are the canonical forms. |
| 1189 |
|
| 1190 |
;; QImode to HImode |
| 1191 |
|
| 1192 |
(define_insn "*add<su>qihi_swap" |
| 1193 |
[(set (match_operand:HI 0 "register_operand" "=r,r,r,r") |
| 1194 |
(plus:HI |
| 1195 |
(szext:HI (match_operand:QI 2 "nonimmediate_operand" "r,Q>,m,!To")) |
| 1196 |
(match_operand:HI 1 "register_operand" "0,0,0,r"))) |
| 1197 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1198 |
"operands[1] != frame_pointer_rtx" |
| 1199 |
"@ |
| 1200 |
add<su>.b %2,%0 |
| 1201 |
add<su>.b %2,%0 |
| 1202 |
add<su>.b %2,%0 |
| 1203 |
add<su>.b %2,%1,%0" |
| 1204 |
[(set_attr "slottable" "yes,yes,no,no") |
| 1205 |
(set_attr "cc" "clobber")]) |
| 1206 |
|
| 1207 |
(define_insn "*<addsubbo><su><nd><mode>si<setnz>_swap" |
| 1208 |
[(set (match_operand:SI 0 "register_operand" "=r,r,r,r") |
| 1209 |
(plusumin:SI |
| 1210 |
(szext:SI (match_operand:BW 2 "nonimmediate_operand" "r,Q>,m,!To")) |
| 1211 |
(match_operand:SI 1 "register_operand" "0,0,0,r"))) |
| 1212 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1213 |
"(<plusumin:CODE> != UMIN || <szext:CODE> == ZERO_EXTEND) |
| 1214 |
&& operands[1] != frame_pointer_rtx" |
| 1215 |
"@ |
| 1216 |
<addsubbo><su><nd><m> %2,%0 |
| 1217 |
<addsubbo><su><nd><m> %2,%0 |
| 1218 |
<addsubbo><su><nd><m> %2,%0 |
| 1219 |
<addsubbo><su><nd><m> %2,%1,%0" |
| 1220 |
[(set_attr "slottable" "yes,yes,no,no")]) |
| 1221 |
|
| 1222 |
;; This is the special case when we use what corresponds to the |
| 1223 |
;; instruction above in "casesi". Do *not* change it to use the generic |
| 1224 |
;; pattern and "REG 15" as pc; I did that and it led to madness and |
| 1225 |
;; maintenance problems: Instead of (as imagined) recognizing and removing |
| 1226 |
;; or replacing this pattern with something simpler, other variant |
| 1227 |
;; patterns were recognized or combined, including some prefix variants |
| 1228 |
;; where the value in pc is not that of the next instruction (which means |
| 1229 |
;; this instruction actually *is* special and *should* be marked as such). |
| 1230 |
;; When switching from the "generic pattern match" approach to this simpler |
| 1231 |
;; approach, there were insignificant differences in gcc, ipps and |
| 1232 |
;; product code, somehow due to scratching reload behind the ear or |
| 1233 |
;; something. Testcase "gcc" looked .01% slower and 4 bytes bigger; |
| 1234 |
;; product code became .001% smaller but "looked better". The testcase |
| 1235 |
;; "ipps" was just different at register allocation). |
| 1236 |
;; |
| 1237 |
;; Assumptions in the jump optimizer forces us to use IF_THEN_ELSE in this |
| 1238 |
;; pattern with the default-label as the else, with the "if" being |
| 1239 |
;; index-is-less-than the max number of cases plus one. The default-label |
| 1240 |
;; is attached to the end of the case-table at time of output. |
| 1241 |
|
| 1242 |
(define_insn "*casesi_adds_w" |
| 1243 |
[(set (pc) |
| 1244 |
(if_then_else |
| 1245 |
(ltu (match_operand:SI 0 "register_operand" "r") |
| 1246 |
(match_operand:SI 1 "const_int_operand" "n")) |
| 1247 |
(plus:SI (sign_extend:SI |
| 1248 |
(mem:HI |
| 1249 |
(plus:SI (mult:SI (match_dup 0) (const_int 2)) |
| 1250 |
(pc)))) |
| 1251 |
(pc)) |
| 1252 |
(label_ref (match_operand 2 "" "")))) |
| 1253 |
(use (label_ref (match_operand 3 "" ""))) |
| 1254 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1255 |
"operands[0] != frame_pointer_rtx" |
| 1256 |
"adds.w [$pc+%0.w],$pc" |
| 1257 |
[(set_attr "cc" "clobber")]) |
| 1258 |
|
| 1259 |
;; Multiply instructions. |
| 1260 |
|
| 1261 |
;; Sometimes powers of 2 (which are normally canonicalized to a |
| 1262 |
;; left-shift) appear here, as a result of address reloading. |
| 1263 |
;; As a special, for values 3 and 5, we can match with an addi, so add those. |
| 1264 |
;; |
| 1265 |
;; FIXME: This may be unnecessary now. |
| 1266 |
;; Explicitly named for convenience of having a gen_... function. |
| 1267 |
|
| 1268 |
(define_insn "addi_mul" |
| 1269 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 1270 |
(mult:SI |
| 1271 |
(match_operand:SI 1 "register_operand" "%0") |
| 1272 |
(match_operand:SI 2 "const_int_operand" "n"))) |
| 1273 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1274 |
"operands[0] != frame_pointer_rtx |
| 1275 |
&& operands[1] != frame_pointer_rtx |
| 1276 |
&& CONST_INT_P (operands[2]) |
| 1277 |
&& (INTVAL (operands[2]) == 2 |
| 1278 |
|| INTVAL (operands[2]) == 4 || INTVAL (operands[2]) == 3 |
| 1279 |
|| INTVAL (operands[2]) == 5)" |
| 1280 |
{ |
| 1281 |
if (INTVAL (operands[2]) == 2) |
| 1282 |
return "lslq 1,%0"; |
| 1283 |
else if (INTVAL (operands[2]) == 4) |
| 1284 |
return "lslq 2,%0"; |
| 1285 |
else if (INTVAL (operands[2]) == 3) |
| 1286 |
return "addi %0.w,%0"; |
| 1287 |
else if (INTVAL (operands[2]) == 5) |
| 1288 |
return "addi %0.d,%0"; |
| 1289 |
return "BAD: adr_mulsi: %0=%1*%2"; |
| 1290 |
} |
| 1291 |
[(set_attr "slottable" "yes") |
| 1292 |
;; No flags are changed if this insn is "addi", but it does not seem |
| 1293 |
;; worth the trouble to distinguish that to the lslq cases. |
| 1294 |
(set_attr "cc" "clobber")]) |
| 1295 |
|
| 1296 |
;; The addi insn as it is normally used. |
| 1297 |
|
| 1298 |
(define_insn "*addi" |
| 1299 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 1300 |
(plus:SI |
| 1301 |
(ashift:SI (match_operand:SI 2 "register_operand" "r") |
| 1302 |
(match_operand:SI 3 "const_int_operand" "n")) |
| 1303 |
(match_operand:SI 1 "register_operand" "0")))] |
| 1304 |
"operands[0] != frame_pointer_rtx |
| 1305 |
&& operands[1] != frame_pointer_rtx |
| 1306 |
&& CONST_INT_P (operands[3]) |
| 1307 |
&& (INTVAL (operands[3]) == 1 || INTVAL (operands[3]) == 2)" |
| 1308 |
"addi %2%T3,%0" |
| 1309 |
[(set_attr "slottable" "yes") |
| 1310 |
(set_attr "cc" "none")]) |
| 1311 |
|
| 1312 |
;; The mult-vs-ashift canonicalization-cleanup plagues us: nothing in |
| 1313 |
;; reload transforms a "scaled multiplication" into an ashift in a |
| 1314 |
;; reloaded address; it's passed as-is and expected to be recognized, |
| 1315 |
;; or else we get a tell-tale "unrecognizable insn". |
| 1316 |
;; On top of that, we *should* match the bare insn, as a *matching |
| 1317 |
;; pattern* (as opposed to e.g. a reload_load_address expander |
| 1318 |
;; changing the mul into an ashift), so can_reload_into will re-use |
| 1319 |
;; registers in the reloaded expression instead of allocating a new |
| 1320 |
;; register. |
| 1321 |
(define_insn_and_split "*addi_reload" |
| 1322 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 1323 |
(plus:SI |
| 1324 |
(mult:SI (match_operand:SI 2 "register_operand" "r") |
| 1325 |
(match_operand:SI 3 "const_int_operand" "n")) |
| 1326 |
(match_operand:SI 1 "register_operand" "0")))] |
| 1327 |
"operands[0] != frame_pointer_rtx |
| 1328 |
&& operands[1] != frame_pointer_rtx |
| 1329 |
&& CONST_INT_P (operands[3]) |
| 1330 |
&& (INTVAL (operands[3]) == 2 || INTVAL (operands[3]) == 4) |
| 1331 |
&& (lra_in_progress || reload_completed)" |
| 1332 |
"#" |
| 1333 |
"&& 1" |
| 1334 |
[(set (match_dup 0) |
| 1335 |
(plus:SI (ashift:SI (match_dup 2) (match_dup 3)) (match_dup 1)))] |
| 1336 |
"operands[3] = operands[3] == const2_rtx ? const1_rtx : const2_rtx;") |
| 1337 |
|
| 1338 |
;; This pattern is usually generated after reload, so a '%' is |
| 1339 |
;; ineffective; use explicit combinations. |
| 1340 |
(define_insn "*addi_b_<mode>" |
| 1341 |
[(set (match_operand:BWD 0 "register_operand" "=r,r") |
| 1342 |
(plus:BWD |
| 1343 |
(match_operand:BWD 1 "register_operand" "0,r") |
| 1344 |
(match_operand:BWD 2 "register_operand" "r,0")))] |
| 1345 |
"" |
| 1346 |
"@ |
| 1347 |
addi %2.b,%0 |
| 1348 |
addi %1.b,%0" |
| 1349 |
[(set_attr "slottable" "yes")]) |
| 1350 |
|
| 1351 |
;; Strip the dccr clobber from addM3 with register operands, if the |
| 1352 |
;; next instruction isn't using it. |
| 1353 |
;; Not clobbering dccr may let cmpelim match a later compare with a |
| 1354 |
;; previous operation of interest. This has to run before cmpelim so it |
| 1355 |
;; can't be a peephole2. See gcc.target/cris/pr93372-45.c for a |
| 1356 |
;; test-case. |
| 1357 |
(define_split ;; "*add<mode>3_addi" |
| 1358 |
[(parallel |
| 1359 |
[(set (match_operand:BWD 0 "register_operand") |
| 1360 |
(plus:BWD |
| 1361 |
(match_operand:BWD 1 "register_operand") |
| 1362 |
(match_operand:BWD 2 "register_operand"))) |
| 1363 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 1364 |
"reload_completed" |
| 1365 |
[(set (match_dup 0) (plus:BWD (match_dup 1) (match_dup 2)))] |
| 1366 |
{ |
| 1367 |
rtx reg = operands[0]; |
| 1368 |
rtx_insn *i = next_nonnote_nondebug_insn_bb (curr_insn); |
| 1369 |
rtx x, src, dest; |
| 1370 |
|
| 1371 |
while (i != NULL_RTX && (!INSN_P (i) || DEBUG_INSN_P (i))) |
| 1372 |
i = next_nonnote_nondebug_insn_bb (i); |
| 1373 |
|
| 1374 |
/* We don't want to strip the clobber if the next insn possibly uses the |
| 1375 |
zeroness of the result. Preferably fail only if we see a compare insn |
| 1376 |
that looks eliminable and with the register "reg" compared. With some |
| 1377 |
effort we could also check for an equality test (EQ, NE) in the post-split |
| 1378 |
user, just not for now. */ |
| 1379 |
if (i == NULL_RTX) |
| 1380 |
FAIL; |
| 1381 |
|
| 1382 |
x = single_set (i); |
| 1383 |
|
| 1384 |
/* We explicitly need to bail on a BARRIER, but that's implied by a failing |
| 1385 |
single_set test. */ |
| 1386 |
if (x == NULL_RTX) |
| 1387 |
FAIL; |
| 1388 |
|
| 1389 |
src = SET_SRC (x); |
| 1390 |
dest = SET_DEST (x); |
| 1391 |
|
| 1392 |
/* Bail on (post-split) eliminable compares. */ |
| 1393 |
if (REG_P (dest) && REGNO (dest) == CRIS_CC0_REGNUM |
| 1394 |
&& GET_CODE (src) == COMPARE) |
| 1395 |
{ |
| 1396 |
rtx cop0 = XEXP (src, 0); |
| 1397 |
|
| 1398 |
if (REG_P (cop0) && REGNO (cop0) == REGNO (reg) |
| 1399 |
&& XEXP (src, 1) == const0_rtx) |
| 1400 |
FAIL; |
| 1401 |
} |
| 1402 |
|
| 1403 |
/* Bail out if we see a (pre-split) cbranch or cstore where the comparison |
| 1404 |
looks eliminable and uses the destination register in this addition. We |
| 1405 |
don't need to look very deep: a single_set which is a parallel clobbers |
| 1406 |
something, and (one of) that something, is always CRIS_CC0_REGNUM here. |
| 1407 |
Also, the entities we're looking for are two-element parallels. A |
| 1408 |
split-up cbranch or cstore doesn't clobber CRIS_CC0_REGNUM. A cbranch has |
| 1409 |
if_then_else as its source with a comparison operator as the condition, |
| 1410 |
and a cstore has a source with the comparison operator directly. That |
| 1411 |
also matches dstep, so look for pc as destination for the if_then_else. |
| 1412 |
We error on the safe side if we happen to catch other conditional entities |
| 1413 |
and FAIL, that just means the split won't happen. */ |
| 1414 |
if (GET_CODE (PATTERN (i)) == PARALLEL && XVECLEN (PATTERN (i), 0) == 2) |
| 1415 |
{ |
| 1416 |
rtx cmp |
| 1417 |
= (GET_CODE (src) == IF_THEN_ELSE && dest == pc_rtx |
| 1418 |
? XEXP (src, 0) |
| 1419 |
: (COMPARISON_P (src) ? src : NULL_RTX)); |
| 1420 |
gcc_assert (cmp == NULL_RTX || COMPARISON_P (cmp)); |
| 1421 |
|
| 1422 |
if (cmp && REG_P (XEXP (cmp, 0)) && XEXP (cmp, 1) == const0_rtx |
| 1423 |
&& REGNO (XEXP (cmp, 0)) == REGNO (reg)) |
| 1424 |
FAIL; |
| 1425 |
} |
| 1426 |
}) |
| 1427 |
|
| 1428 |
(define_insn "<u>mul<s><mode>3" |
| 1429 |
[(set (match_operand:WD 0 "register_operand" "=r") |
| 1430 |
(mult:WD |
| 1431 |
(szext:WD (match_operand:<S> 1 "register_operand" "%0")) |
| 1432 |
(szext:WD (match_operand:<S> 2 "register_operand" "r")))) |
| 1433 |
(clobber (match_scratch:SI 3 "=h")) |
| 1434 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1435 |
"TARGET_HAS_MUL_INSNS" |
| 1436 |
"%!mul<su><mm> %2,%0" |
| 1437 |
[(set (attr "slottable") |
| 1438 |
(if_then_else (match_test "TARGET_MUL_BUG") |
| 1439 |
(const_string "no") |
| 1440 |
(const_string "yes"))) |
| 1441 |
;; For umuls.[bwd] it's just N unusable here, but let's be safe. |
| 1442 |
;; For muls.b, this really extends to SImode, so cc should be |
| 1443 |
;; considered clobbered. |
| 1444 |
;; For muls.w, it's just N unusable here, but let's be safe. |
| 1445 |
(set_attr "cc" "clobber")]) |
| 1446 |
|
| 1447 |
;; Note that gcc does not make use of such a thing as umulqisi3. It gets |
| 1448 |
;; confused and will erroneously use it instead of umulhisi3, failing (at |
| 1449 |
;; least) gcc.c-torture/execute/arith-rand.c at all optimization levels. |
| 1450 |
;; Inspection of optab code shows that there must be only one widening |
| 1451 |
;; multiplication per mode widened to. |
| 1452 |
|
| 1453 |
(define_insn "mulsi3" |
| 1454 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 1455 |
(mult:SI (match_operand:SI 1 "register_operand" "%0") |
| 1456 |
(match_operand:SI 2 "register_operand" "r"))) |
| 1457 |
(clobber (match_scratch:SI 3 "=h")) |
| 1458 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1459 |
"TARGET_HAS_MUL_INSNS" |
| 1460 |
"%!muls.d %2,%0" |
| 1461 |
[(set (attr "slottable") |
| 1462 |
(if_then_else (match_test "TARGET_MUL_BUG") |
| 1463 |
(const_string "no") |
| 1464 |
(const_string "yes"))) |
| 1465 |
;; Just N unusable here, but let's be safe. |
| 1466 |
(set_attr "cc" "clobber")]) |
| 1467 |
|
| 1468 |
;; A few multiply variations. |
| 1469 |
|
| 1470 |
;; When needed, we can get the high 32 bits from the overflow |
| 1471 |
;; register. We don't care to split and optimize these. |
| 1472 |
|
| 1473 |
(define_insn "<u>mulsidi3" |
| 1474 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 1475 |
(mult:DI |
| 1476 |
(szext:DI (match_operand:SI 1 "register_operand" "%0")) |
| 1477 |
(szext:DI (match_operand:SI 2 "register_operand" "r")))) |
| 1478 |
(clobber (match_scratch:SI 3 "=h")) |
| 1479 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1480 |
"TARGET_HAS_MUL_INSNS" |
| 1481 |
"%!mul<su>.d %2,%M0\;move $mof,%H0") |
| 1482 |
|
| 1483 |
;; These two patterns may be expressible by other means, perhaps by making |
| 1484 |
;; [u]?mulsidi3 a define_expand. |
| 1485 |
|
| 1486 |
;; Due to register allocation braindamage, the clobber 1,2 alternatives |
| 1487 |
;; cause a move into the clobbered register *before* the insn, then |
| 1488 |
;; after the insn, mof is moved too, rather than the clobber assigned |
| 1489 |
;; the last mof target. This became apparent when making MOF and SRP |
| 1490 |
;; visible registers, with the necessary tweak to smulsi3_highpart. |
| 1491 |
;; Because these patterns are used in division by constants, that damage |
| 1492 |
;; is visible (ipps regression tests). Therefore the last two |
| 1493 |
;; alternatives, "helping" reload to avoid an unnecessary move, but |
| 1494 |
;; punished by force of one "?". Check code from "int d (int a) {return |
| 1495 |
;; a / 1000;}" and unsigned. FIXME: Comment above was for 3.2, revisit. |
| 1496 |
|
| 1497 |
(define_insn "<su>mulsi3_highpart" |
| 1498 |
[(set (match_operand:SI 0 "register_operand" "=h,h,?r,?r") |
| 1499 |
(truncate:SI |
| 1500 |
(lshiftrt:DI |
| 1501 |
(mult:DI |
| 1502 |
(szext:DI (match_operand:SI 1 "register_operand" "r,r,0,r")) |
| 1503 |
(szext:DI (match_operand:SI 2 "register_operand" "r,r,r,0"))) |
| 1504 |
(const_int 32)))) |
| 1505 |
(clobber (match_scratch:SI 3 "=1,2,h,h")) |
| 1506 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1507 |
"TARGET_HAS_MUL_INSNS" |
| 1508 |
"@ |
| 1509 |
%!mul<su>.d %2,%1 |
| 1510 |
%!mul<su>.d %1,%2 |
| 1511 |
%!mul<su>.d %2,%1\;move $mof,%0 |
| 1512 |
%!mul<su>.d %1,%2\;move $mof,%0" |
| 1513 |
[(set_attr "slottable" "yes,yes,no,no") |
| 1514 |
(set_attr "cc" "clobber")]) |
| 1515 |
|
| 1516 |
;; Divide and modulus instructions. CRIS only has a step instruction. |
| 1517 |
|
| 1518 |
(define_insn "dstep_shift" |
| 1519 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 1520 |
(if_then_else:SI |
| 1521 |
(geu:SI (ashift:SI (match_operand:SI 1 "register_operand" "0") |
| 1522 |
(const_int 1)) |
| 1523 |
(match_operand:SI 2 "register_operand" "r")) |
| 1524 |
(minus:SI (ashift:SI (match_operand:SI 3 "register_operand" "0") |
| 1525 |
(const_int 1)) |
| 1526 |
(match_operand:SI 4 "register_operand" "2")) |
| 1527 |
(ashift:SI (match_operand:SI 5 "register_operand" "0") |
| 1528 |
(const_int 1)))) |
| 1529 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1530 |
"" |
| 1531 |
"dstep %2,%0" |
| 1532 |
[(set_attr "slottable" "yes")]) |
| 1533 |
|
| 1534 |
;; Here's a variant with mult instead of ashift. |
| 1535 |
;; |
| 1536 |
;; FIXME: This should be investigated. Which one matches through combination? |
| 1537 |
|
| 1538 |
(define_insn "dstep_mul" |
| 1539 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 1540 |
(if_then_else:SI |
| 1541 |
(geu:SI (mult:SI (match_operand:SI 1 "register_operand" "0") |
| 1542 |
(const_int 2)) |
| 1543 |
(match_operand:SI 2 "register_operand" "r")) |
| 1544 |
(minus:SI (mult:SI (match_operand:SI 3 "register_operand" "0") |
| 1545 |
(const_int 2)) |
| 1546 |
(match_operand:SI 4 "register_operand" "2")) |
| 1547 |
(mult:SI (match_operand:SI 5 "register_operand" "0") |
| 1548 |
(const_int 2)))) |
| 1549 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1550 |
"operands[0] != frame_pointer_rtx |
| 1551 |
&& operands[1] != frame_pointer_rtx |
| 1552 |
&& operands[2] != frame_pointer_rtx |
| 1553 |
&& operands[3] != frame_pointer_rtx" |
| 1554 |
"dstep %2,%0" |
| 1555 |
[(set_attr "slottable" "yes")]) |
| 1556 |
|
| 1557 |
;; Logical operators. |
| 1558 |
|
| 1559 |
;; Bitwise "and". |
| 1560 |
|
| 1561 |
;; There is no use in defining "anddi3", because gcc can expand this by |
| 1562 |
;; itself, and make reasonable code without interference. |
| 1563 |
|
| 1564 |
;; If the first operand is memory or a register and is the same as the |
| 1565 |
;; second operand, and the third operand is -256 or -65536, we can use |
| 1566 |
;; CLEAR instead. Or, if the first operand is a register, and the third |
| 1567 |
;; operand is 255 or 65535, we can zero_extend. |
| 1568 |
;; GCC isn't smart enough to recognize these cases (yet), and they seem |
| 1569 |
;; to be common enough to be worthwhile. |
| 1570 |
;; FIXME: This should be made obsolete. |
| 1571 |
|
| 1572 |
(define_expand "andsi3" |
| 1573 |
[(parallel |
| 1574 |
[(set (match_operand:SI 0 "nonimmediate_operand") |
| 1575 |
(and:SI (match_operand:SI 1 "nonimmediate_operand") |
| 1576 |
(match_operand:SI 2 "general_operand"))) |
| 1577 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 1578 |
"" |
| 1579 |
{ |
| 1580 |
if (! (CONST_INT_P (operands[2]) |
| 1581 |
&& (((INTVAL (operands[2]) == -256 |
| 1582 |
|| INTVAL (operands[2]) == -65536) |
| 1583 |
&& rtx_equal_p (operands[1], operands[0])) |
| 1584 |
|| ((INTVAL (operands[2]) == 255 |
| 1585 |
|| INTVAL (operands[2]) == 65535) |
| 1586 |
&& REG_P (operands[0]))))) |
| 1587 |
{ |
| 1588 |
/* Make intermediate steps if operand0 is not a register or |
| 1589 |
operand1 is not a register, and hope that the reload pass will |
| 1590 |
make something useful out of it. Note that the operands are |
| 1591 |
*not* canonicalized. For the moment, I chicken out on this, |
| 1592 |
because all or most ports do not describe 'and' with |
| 1593 |
canonicalized operands, and I seem to remember magic in reload, |
| 1594 |
checking that operand1 has constraint '%0', in which case |
| 1595 |
operand0 and operand1 must have similar predicates. |
| 1596 |
FIXME: Investigate. */ |
| 1597 |
rtx reg0 = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (SImode); |
| 1598 |
rtx reg1 = operands[1]; |
| 1599 |
|
| 1600 |
if (! REG_P (reg1)) |
| 1601 |
{ |
| 1602 |
emit_move_insn (reg0, reg1); |
| 1603 |
reg1 = reg0; |
| 1604 |
} |
| 1605 |
|
| 1606 |
cris_emit_insn (gen_rtx_SET (reg0, gen_rtx_AND (SImode, reg1, |
| 1607 |
operands[2]))); |
| 1608 |
|
| 1609 |
/* Make sure we get the right *final* destination. */ |
| 1610 |
if (! REG_P (operands[0])) |
| 1611 |
emit_move_insn (operands[0], reg0); |
| 1612 |
|
| 1613 |
DONE; |
| 1614 |
} |
| 1615 |
}) |
| 1616 |
|
| 1617 |
;; Some special cases of andsi3. |
| 1618 |
|
| 1619 |
(define_insn "*andsi_movu" |
| 1620 |
[(set (match_operand:SI 0 "register_operand" "=r,r,r") |
| 1621 |
(and:SI (match_operand:SI 1 "nonimmediate_operand" "%r,Q,To") |
| 1622 |
(match_operand:SI 2 "const_int_operand" "n,n,n"))) |
| 1623 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1624 |
"(INTVAL (operands[2]) == 255 || INTVAL (operands[2]) == 65535) |
| 1625 |
&& !side_effects_p (operands[1])" |
| 1626 |
"movu.%z2 %1,%0" |
| 1627 |
[(set_attr "slottable" "yes,yes,no")]) |
| 1628 |
|
| 1629 |
;; FIXME: Remember, this does *not* actually affect condition codes; |
| 1630 |
;; get rid of the clobber. |
| 1631 |
(define_insn "*andsi_clear" |
| 1632 |
[(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,Q,Q,To,To") |
| 1633 |
(and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0,0,0") |
| 1634 |
(match_operand:SI 2 "const_int_operand" "P,n,P,n,P,n"))) |
| 1635 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1636 |
"(INTVAL (operands[2]) == -65536 || INTVAL (operands[2]) == -256) |
| 1637 |
&& !side_effects_p (operands[0])" |
| 1638 |
"@ |
| 1639 |
cLear.b %0 |
| 1640 |
cLear.w %0 |
| 1641 |
cLear.b %0 |
| 1642 |
cLear.w %0 |
| 1643 |
cLear.b %0 |
| 1644 |
cLear.w %0" |
| 1645 |
[(set_attr "slottable" "yes,yes,yes,yes,no,no") |
| 1646 |
(set_attr "cc" "none")]) |
| 1647 |
|
| 1648 |
;; This is a catch-all pattern, taking care of everything that was not |
| 1649 |
;; matched in the insns above. |
| 1650 |
;; |
| 1651 |
;; Sidenote: the tightening from "nonimmediate_operand" to |
| 1652 |
;; "register_operand" for operand 1 actually increased the register |
| 1653 |
;; pressure (worse code). That will hopefully change with an |
| 1654 |
;; improved reload pass. |
| 1655 |
|
| 1656 |
(define_insn "*expanded_andsi<setcc><setnz><setnzvc>" |
| 1657 |
[(set (match_operand:SI 0 "register_operand" "=r,r,r, r,r") |
| 1658 |
(and:SI (match_operand:SI 1 "register_operand" "%0,0,0, 0,r") |
| 1659 |
(match_operand:SI 2 "general_operand" "I,r,Q>,g,!To"))) |
| 1660 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1661 |
"" |
| 1662 |
"@ |
| 1663 |
andq %2,%0 |
| 1664 |
and.d %2,%0 |
| 1665 |
and.d %2,%0 |
| 1666 |
and.d %2,%0 |
| 1667 |
and.d %2,%1,%0" |
| 1668 |
[(set_attr "slottable" "yes,yes,yes,no,no")]) |
| 1669 |
|
| 1670 |
;; For both QI and HI we may use the quick patterns. This results in |
| 1671 |
;; useless condition codes, but that is used rarely enough for it to |
| 1672 |
;; normally be a win (could check ahead for use of CRIS_CC0_REGNUM, but |
| 1673 |
;; seems to be more pain than win). |
| 1674 |
|
| 1675 |
;; FIXME: See note for andsi3 |
| 1676 |
|
| 1677 |
(define_expand "andhi3" |
| 1678 |
[(parallel |
| 1679 |
[(set (match_operand:HI 0 "nonimmediate_operand") |
| 1680 |
(and:HI (match_operand:HI 1 "nonimmediate_operand") |
| 1681 |
(match_operand:HI 2 "general_operand"))) |
| 1682 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 1683 |
"" |
| 1684 |
{ |
| 1685 |
if (! (CONST_INT_P (operands[2]) |
| 1686 |
&& (((INTVAL (operands[2]) == -256 |
| 1687 |
|| INTVAL (operands[2]) == 65280) |
| 1688 |
&& rtx_equal_p (operands[1], operands[0])) |
| 1689 |
|| (INTVAL (operands[2]) == 255 |
| 1690 |
&& REG_P (operands[0]))))) |
| 1691 |
{ |
| 1692 |
/* See comment for andsi3. */ |
| 1693 |
rtx reg0 = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (HImode); |
| 1694 |
rtx reg1 = operands[1]; |
| 1695 |
|
| 1696 |
if (! REG_P (reg1)) |
| 1697 |
{ |
| 1698 |
emit_move_insn (reg0, reg1); |
| 1699 |
reg1 = reg0; |
| 1700 |
} |
| 1701 |
|
| 1702 |
cris_emit_insn (gen_rtx_SET (reg0, gen_rtx_AND (HImode, reg1, |
| 1703 |
operands[2]))); |
| 1704 |
|
| 1705 |
/* Make sure we get the right destination. */ |
| 1706 |
if (! REG_P (operands[0])) |
| 1707 |
emit_move_insn (operands[0], reg0); |
| 1708 |
|
| 1709 |
DONE; |
| 1710 |
} |
| 1711 |
}) |
| 1712 |
|
| 1713 |
;; Some fast andhi3 special cases. |
| 1714 |
|
| 1715 |
(define_insn "*andhi_movu" |
| 1716 |
[(set (match_operand:HI 0 "register_operand" "=r,r,r") |
| 1717 |
(and:HI (match_operand:HI 1 "nonimmediate_operand" "r,Q,To") |
| 1718 |
(const_int 255))) |
| 1719 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1720 |
"!side_effects_p (operands[1])" |
| 1721 |
"mOvu.b %1,%0" |
| 1722 |
[(set_attr "slottable" "yes,yes,no")]) |
| 1723 |
|
| 1724 |
(define_insn "*andhi_clear" |
| 1725 |
[(set (match_operand:HI 0 "nonimmediate_operand" "=r,Q,To") |
| 1726 |
(and:HI (match_operand:HI 1 "nonimmediate_operand" "0,0,0") |
| 1727 |
(const_int -256))) |
| 1728 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1729 |
"!side_effects_p (operands[0])" |
| 1730 |
"cLear.b %0" |
| 1731 |
[(set_attr "slottable" "yes,yes,no") |
| 1732 |
(set_attr "cc" "none")]) |
| 1733 |
|
| 1734 |
;; Catch-all andhi3 pattern. |
| 1735 |
|
| 1736 |
(define_insn "*expanded_andhi<setcc><setnz><setnzvc>" |
| 1737 |
[(set (match_operand:HI 0 "register_operand" "=r,r, r,r, r,r,r,r") |
| 1738 |
(and:HI (match_operand:HI 1 "register_operand" "%0,0, 0,0, 0,0,0,r") |
| 1739 |
(match_operand:HI 2 "general_operand" "I,Kc,r,Q>,L,O,g,!To"))) |
| 1740 |
;; The "Kc" alternative above, is there to match for cmpelim; |
| 1741 |
;; it will be dominated by the "I" alternative at other times. |
| 1742 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1743 |
|
| 1744 |
;; Sidenote: the tightening from "general_operand" to |
| 1745 |
;; "register_operand" for operand 1 actually increased the register |
| 1746 |
;; pressure (worse code). That will hopefully change with an |
| 1747 |
;; improved reload pass. |
| 1748 |
|
| 1749 |
"" |
| 1750 |
"@ |
| 1751 |
andq %2,%0 |
| 1752 |
andq %2,%0 |
| 1753 |
and.w %2,%0 |
| 1754 |
and.w %2,%0 |
| 1755 |
and.w %2,%0 |
| 1756 |
anDq %b2,%0 |
| 1757 |
and.w %2,%0 |
| 1758 |
and.w %2,%1,%0" |
| 1759 |
[(set_attr "slottable" "yes,yes,yes,yes,no,yes,no,no") |
| 1760 |
(set_attr "cc<cccc><ccnz><ccnzvc>" |
| 1761 |
"clobber,normal,normal,normal,normal,clobber,normal,normal")]) |
| 1762 |
|
| 1763 |
;; A strict_low_part pattern. |
| 1764 |
|
| 1765 |
;; Note the use of (match_dup 0) for the first operand of the operation |
| 1766 |
;; here. Reload can't handle an operand pair where one is read-write |
| 1767 |
;; and must match a read, like in: |
| 1768 |
;; (insn 80 79 81 4 |
| 1769 |
;; (set (strict_low_part |
| 1770 |
;; (subreg:QI (reg/v:SI 0 r0 [orig:36 data ] [36]) 0)) |
| 1771 |
;; (and:QI |
| 1772 |
;; (subreg:QI (reg:SI 15 acr [orig:27 D.7531 ] [27]) 0) |
| 1773 |
;; (const_int -64 [0xf..fc0]))) x.c:126 147 {*andqi_lowpart_v32} |
| 1774 |
;; (nil)) |
| 1775 |
;; (Note: the example is obsolete.) |
| 1776 |
;; In theory, it could reload this as a movstrictqi of the register |
| 1777 |
;; operand at the and:QI to the destination register and change the |
| 1778 |
;; and:QI operand to the same as the read-write output operand and the |
| 1779 |
;; result would be recognized, but it doesn't recognize that's a valid |
| 1780 |
;; reload for a strict_low_part-destination; it just sees a "+" at the |
| 1781 |
;; destination constraints. Better than adding complexity to reload is |
| 1782 |
;; to follow the lead of m68k (see comment that begins with "These insns |
| 1783 |
;; must use MATCH_DUP") since prehistoric times and make it just a |
| 1784 |
;; match_dup. FIXME: a sanity-check in gen* to refuse an insn with |
| 1785 |
;; input-constraints matching input-output-constraints, e.g. "+r" <- "0". |
| 1786 |
|
| 1787 |
(define_insn "*andhi_lowpart" |
| 1788 |
[(set (strict_low_part |
| 1789 |
(match_operand:HI 0 "register_operand" "+r,r,r")) |
| 1790 |
(and:HI (match_dup 0) |
| 1791 |
(match_operand:HI 1 "general_operand" "r,Q>,g"))) |
| 1792 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1793 |
"" |
| 1794 |
"@ |
| 1795 |
and.w %1,%0 |
| 1796 |
and.w %1,%0 |
| 1797 |
and.w %1,%0" |
| 1798 |
[(set_attr "slottable" "yes,yes,no")]) |
| 1799 |
|
| 1800 |
(define_expand "andqi3" |
| 1801 |
[(parallel |
| 1802 |
[(set (match_operand:QI 0 "register_operand") |
| 1803 |
(and:QI (match_operand:QI 1 "register_operand") |
| 1804 |
(match_operand:QI 2 "general_operand"))) |
| 1805 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 1806 |
"" |
| 1807 |
"") |
| 1808 |
|
| 1809 |
(define_insn "*andqi3<setcc><setnz><setnzvc>" |
| 1810 |
[(set (match_operand:QI 0 "register_operand" "=r,r, r,r, r,r,r") |
| 1811 |
(and:QI (match_operand:QI 1 "register_operand" "%0,0, 0,0, 0,0,r") |
| 1812 |
(match_operand:QI 2 "general_operand" "I,Kc,r,Q>,O,g,!To"))) |
| 1813 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1814 |
"" |
| 1815 |
"@ |
| 1816 |
andq %2,%0 |
| 1817 |
andq %2,%0 |
| 1818 |
and.b %2,%0 |
| 1819 |
and.b %2,%0 |
| 1820 |
andQ %b2,%0 |
| 1821 |
and.b %2,%0 |
| 1822 |
and.b %2,%1,%0" |
| 1823 |
[(set_attr "slottable" "yes,yes,yes,yes,yes,no,no") |
| 1824 |
(set_attr "cc<cccc><ccnz><ccnzvc>" |
| 1825 |
"clobber,normal,normal,normal,clobber,normal,normal")]) |
| 1826 |
|
| 1827 |
(define_insn "*andqi_lowpart" |
| 1828 |
[(set (strict_low_part |
| 1829 |
(match_operand:QI 0 "register_operand" "+r,r,r")) |
| 1830 |
(and:QI (match_dup 0) |
| 1831 |
(match_operand:QI 1 "general_operand" "r,Q>,g"))) |
| 1832 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1833 |
"" |
| 1834 |
"@ |
| 1835 |
and.b %1,%0 |
| 1836 |
and.b %1,%0 |
| 1837 |
and.b %1,%0" |
| 1838 |
[(set_attr "slottable" "yes,yes,no")]) |
| 1839 |
|
| 1840 |
;; Bitwise or. |
| 1841 |
|
| 1842 |
;; Same comment as anddi3 applies here - no need for such a pattern. |
| 1843 |
|
| 1844 |
;; It seems there's no need to jump through hoops to get good code such as |
| 1845 |
;; with andsi3. |
| 1846 |
|
| 1847 |
(define_expand "ior<mode>3" |
| 1848 |
[(parallel |
| 1849 |
[(set (match_operand:BWD 0 "register_operand") |
| 1850 |
(ior:BWD (match_operand:BWD 1 "register_operand") |
| 1851 |
(match_operand:BWD 2 "general_operand"))) |
| 1852 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 1853 |
"" |
| 1854 |
"") |
| 1855 |
|
| 1856 |
(define_insn "*iorsi3<setcc><setnz><setnzvc>" |
| 1857 |
[(set (match_operand:SI 0 "register_operand" "=r,r,r, r,r,r") |
| 1858 |
(ior:SI (match_operand:SI 1 "register_operand" "%0,0,0, 0,0,r") |
| 1859 |
(match_operand:SI 2 "general_operand" "I, r,Q>,n,g,!To"))) |
| 1860 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1861 |
"" |
| 1862 |
"@ |
| 1863 |
orq %2,%0 |
| 1864 |
or.d %2,%0 |
| 1865 |
or.d %2,%0 |
| 1866 |
oR.%s2 %2,%0 |
| 1867 |
or.d %2,%0 |
| 1868 |
or.d %2,%1,%0" |
| 1869 |
[(set_attr "slottable" "yes,yes,yes,no,no,no") |
| 1870 |
(set_attr "cc<cccc><ccnz><ccnzvc>" |
| 1871 |
"normal,normal,normal,clobber,normal,normal")]) |
| 1872 |
|
| 1873 |
(define_insn "*iorhi3<setcc><setnz><setnzvc>" |
| 1874 |
[(set (match_operand:HI 0 "register_operand" "=r,r,r, r,r,r,r") |
| 1875 |
(ior:HI (match_operand:HI 1 "register_operand" "%0,0,0, 0,0,0,r") |
| 1876 |
(match_operand:HI 2 "general_operand" "I,r,Q>,L,O,g,!To"))) |
| 1877 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1878 |
"" |
| 1879 |
"@ |
| 1880 |
orq %2,%0 |
| 1881 |
or.w %2,%0 |
| 1882 |
or.w %2,%0 |
| 1883 |
or.w %2,%0 |
| 1884 |
oRq %b2,%0 |
| 1885 |
or.w %2,%0 |
| 1886 |
or.w %2,%1,%0" |
| 1887 |
[(set_attr "slottable" "yes,yes,yes,no,yes,no,no") |
| 1888 |
(set_attr "cc<cccc><ccnz><ccnzvc>" |
| 1889 |
"clobber,normal,normal,normal,clobber,normal,normal")]) |
| 1890 |
|
| 1891 |
(define_insn "*iorqi3<setcc><setnz><setnzvc>" |
| 1892 |
[(set (match_operand:QI 0 "register_operand" "=r,r,r, r,r,r") |
| 1893 |
(ior:QI (match_operand:QI 1 "register_operand" "%0,0,0, 0,0,r") |
| 1894 |
(match_operand:QI 2 "general_operand" "I,r,Q>,O,g,!To"))) |
| 1895 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1896 |
"" |
| 1897 |
"@ |
| 1898 |
orq %2,%0 |
| 1899 |
or.b %2,%0 |
| 1900 |
or.b %2,%0 |
| 1901 |
orQ %b2,%0 |
| 1902 |
or.b %2,%0 |
| 1903 |
or.b %2,%1,%0" |
| 1904 |
[(set_attr "slottable" "yes,yes,yes,yes,no,no") |
| 1905 |
(set_attr "cc<cccc><ccnz><ccnzvc>" |
| 1906 |
"clobber,normal,normal,clobber,normal,normal")]) |
| 1907 |
|
| 1908 |
;; Exclusive-or |
| 1909 |
|
| 1910 |
;; See comment about "anddi3" for xordi3 - no need for such a pattern. |
| 1911 |
;; FIXME: Do we really need the shorter variants? |
| 1912 |
|
| 1913 |
(define_insn "<acc><anz><anzvc>xorsi3<setcc><setnz><setnzvc>" |
| 1914 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 1915 |
(xor:SI (match_operand:SI 1 "register_operand" "%0") |
| 1916 |
(match_operand:SI 2 "register_operand" "r"))) |
| 1917 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1918 |
"" |
| 1919 |
"xor %2,%0" |
| 1920 |
[(set_attr "slottable" "yes")]) |
| 1921 |
|
| 1922 |
(define_insn "xor<mode>3" |
| 1923 |
[(set (match_operand:BW 0 "register_operand" "=r") |
| 1924 |
(xor:BW (match_operand:BW 1 "register_operand" "%0") |
| 1925 |
(match_operand:BW 2 "register_operand" "r"))) |
| 1926 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1927 |
"" |
| 1928 |
"xor %2,%0" |
| 1929 |
[(set_attr "slottable" "yes") |
| 1930 |
(set_attr "cc" "clobber")]) |
| 1931 |
|
| 1932 |
;; Negation insns. |
| 1933 |
|
| 1934 |
;; Questionable use, here mostly as a (slightly usable) define_expand |
| 1935 |
;; example. |
| 1936 |
|
| 1937 |
(define_expand "negsf2" |
| 1938 |
[(parallel |
| 1939 |
[(set (match_dup 2) (match_dup 3)) |
| 1940 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 1941 |
(parallel [(set (match_operand:SF 0 "register_operand") |
| 1942 |
(neg:SF (match_operand:SF 1 "register_operand"))) |
| 1943 |
(use (match_dup 2)) |
| 1944 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 1945 |
"" |
| 1946 |
{ |
| 1947 |
operands[2] = gen_reg_rtx (SImode); |
| 1948 |
operands[3] = GEN_INT (1 << 31); |
| 1949 |
}) |
| 1950 |
|
| 1951 |
(define_insn "*expanded_negsf2" |
| 1952 |
[(set (match_operand:SF 0 "register_operand" "=r") |
| 1953 |
(neg:SF (match_operand:SF 1 "register_operand" "0"))) |
| 1954 |
(use (match_operand:SI 2 "register_operand" "r")) |
| 1955 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1956 |
"" |
| 1957 |
"xor %2,%0" |
| 1958 |
[(set_attr "slottable" "yes")]) |
| 1959 |
|
| 1960 |
;; No "negdi2" although we could make one up that may be faster than |
| 1961 |
;; the one in libgcc. |
| 1962 |
|
| 1963 |
(define_insn "<anz>neg<mode>2<setnz>" |
| 1964 |
[(set (match_operand:BWD 0 "register_operand" "=r") |
| 1965 |
(neg:BWD (match_operand:BWD 1 "register_operand" "r"))) |
| 1966 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1967 |
"" |
| 1968 |
"neg<m> %1,%0" |
| 1969 |
[(set_attr "slottable" "yes")]) |
| 1970 |
|
| 1971 |
;; One-complements. |
| 1972 |
|
| 1973 |
;; See comment on anddi3 - no need for a DImode pattern. |
| 1974 |
;; See also xor comment. |
| 1975 |
|
| 1976 |
(define_insn "<acc><anz><anzvc>one_cmplsi2<setcc><setnz><setnzvc>" |
| 1977 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 1978 |
(not:SI (match_operand:SI 1 "register_operand" "0"))) |
| 1979 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1980 |
"" |
| 1981 |
"not %0" |
| 1982 |
[(set_attr "slottable" "yes")]) |
| 1983 |
|
| 1984 |
(define_insn "one_cmpl<mode>2" |
| 1985 |
[(set (match_operand:BW 0 "register_operand" "=r") |
| 1986 |
(not:BW (match_operand:BW 1 "register_operand" "0"))) |
| 1987 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 1988 |
"" |
| 1989 |
"not %0" |
| 1990 |
[(set_attr "slottable" "yes") |
| 1991 |
(set_attr "cc" "clobber")]) |
| 1992 |
|
| 1993 |
;; Arithmetic/Logical shift right (and SI left). |
| 1994 |
|
| 1995 |
(define_insn "<acc><anz><anzvc><shlr>si3<setcc><setnz><setnzvc>" |
| 1996 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 1997 |
(shift:SI (match_operand:SI 1 "register_operand" "0") |
| 1998 |
(match_operand:SI 2 "nonmemory_operand" "Kcr"))) |
| 1999 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 2000 |
"" |
| 2001 |
{ |
| 2002 |
if (REG_S_P (operands[2])) |
| 2003 |
return "<slr>.d %2,%0"; |
| 2004 |
|
| 2005 |
return "<slr>q %2,%0"; |
| 2006 |
} |
| 2007 |
[(set_attr "slottable" "yes")]) |
| 2008 |
|
| 2009 |
;; Since gcc gets lost, and forgets to zero-extend the source (or mask |
| 2010 |
;; the destination) when it changes shifts of lower modes into SImode, |
| 2011 |
;; it is better to make these expands an anonymous patterns instead of |
| 2012 |
;; the more correct define_insns. This occurs when gcc thinks that is |
| 2013 |
;; is better to widen to SImode and use immediate shift count. |
| 2014 |
|
| 2015 |
;; FIXME: Is this legacy or still true for gcc >= 2.7.2? |
| 2016 |
|
| 2017 |
;; FIXME: Can't parametrize sign_extend and zero_extend (before |
| 2018 |
;; mentioning "shiftrt"), so we need two patterns. |
| 2019 |
(define_expand "ashr<mode>3" |
| 2020 |
[(parallel |
| 2021 |
[(set (match_dup 3) |
| 2022 |
(sign_extend:SI (match_operand:BW 1 "nonimmediate_operand"))) |
| 2023 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 2024 |
(parallel |
| 2025 |
[(set (match_dup 4) |
| 2026 |
(zero_extend:SI (match_operand:BW 2 "nonimmediate_operand"))) |
| 2027 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 2028 |
(parallel |
| 2029 |
[(set (match_dup 5) (ashiftrt:SI (match_dup 3) (match_dup 4))) |
| 2030 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 2031 |
(parallel |
| 2032 |
[(set (match_operand:BW 0 "general_operand") |
| 2033 |
(subreg:BW (match_dup 5) 0)) |
| 2034 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 2035 |
"" |
| 2036 |
{ |
| 2037 |
int i; |
| 2038 |
|
| 2039 |
for (i = 3; i < 6; i++) |
| 2040 |
operands[i] = gen_reg_rtx (SImode); |
| 2041 |
}) |
| 2042 |
|
| 2043 |
(define_expand "lshr<mode>3" |
| 2044 |
[(parallel |
| 2045 |
[(set (match_dup 3) |
| 2046 |
(zero_extend:SI (match_operand:BW 1 "nonimmediate_operand"))) |
| 2047 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 2048 |
(parallel |
| 2049 |
[(set (match_dup 4) |
| 2050 |
(zero_extend:SI (match_operand:BW 2 "nonimmediate_operand"))) |
| 2051 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 2052 |
(parallel |
| 2053 |
[(set (match_dup 5) (lshiftrt:SI (match_dup 3) (match_dup 4))) |
| 2054 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 2055 |
(parallel |
| 2056 |
[(set (match_operand:BW 0 "general_operand") |
| 2057 |
(subreg:BW (match_dup 5) 0)) |
| 2058 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 2059 |
"" |
| 2060 |
{ |
| 2061 |
int i; |
| 2062 |
|
| 2063 |
for (i = 3; i < 6; i++) |
| 2064 |
operands[i] = gen_reg_rtx (SImode); |
| 2065 |
}) |
| 2066 |
|
| 2067 |
(define_insn "*expanded_<shlr><mode>" |
| 2068 |
[(set (match_operand:BW 0 "register_operand" "=r") |
| 2069 |
(shiftrt:BW (match_operand:BW 1 "register_operand" "0") |
| 2070 |
(match_operand:BW 2 "register_operand" "r"))) |
| 2071 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 2072 |
"" |
| 2073 |
"<slr><m> %2,%0" |
| 2074 |
[(set_attr "slottable" "yes")]) |
| 2075 |
|
| 2076 |
(define_insn "*<shlr><mode>_lowpart" |
| 2077 |
[(set (strict_low_part (match_operand:BW 0 "register_operand" "+r")) |
| 2078 |
(shiftrt:BW (match_dup 0) |
| 2079 |
(match_operand:BW 1 "register_operand" "r"))) |
| 2080 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 2081 |
"" |
| 2082 |
"<slr><m> %1,%0" |
| 2083 |
[(set_attr "slottable" "yes")]) |
| 2084 |
|
| 2085 |
;; Arithmetic/logical shift left. |
| 2086 |
|
| 2087 |
;; For narrower modes than SI, we can use lslq although it makes cc |
| 2088 |
;; unusable. The win is that we do not have to reload the shift-count |
| 2089 |
;; into a register. |
| 2090 |
|
| 2091 |
(define_insn "ashl<mode>3" |
| 2092 |
[(set (match_operand:BW 0 "register_operand" "=r,r") |
| 2093 |
(ashift:BW (match_operand:BW 1 "register_operand" "0,0") |
| 2094 |
(match_operand:BW 2 "nonmemory_operand" "r,Kc"))) |
| 2095 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 2096 |
"" |
| 2097 |
{ |
| 2098 |
return |
| 2099 |
(CONST_INT_P (operands[2]) && INTVAL (operands[2]) > <nbitsm1>) |
| 2100 |
? "moveq 0,%0" |
| 2101 |
: (CONSTANT_P (operands[2]) |
| 2102 |
? "lslq %2,%0" : "lsl<m> %2,%0"); |
| 2103 |
} |
| 2104 |
[(set_attr "slottable" "yes") |
| 2105 |
(set_attr "cc" "*,clobber")]) |
| 2106 |
|
| 2107 |
;; A strict_low_part matcher. |
| 2108 |
|
| 2109 |
(define_insn "*ashl<mode>_lowpart" |
| 2110 |
[(set (strict_low_part (match_operand:BW 0 "register_operand" "+r")) |
| 2111 |
(ashift:BW (match_dup 0) |
| 2112 |
(match_operand:HI 1 "register_operand" "r"))) |
| 2113 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 2114 |
"" |
| 2115 |
"lsl<m> %1,%0" |
| 2116 |
[(set_attr "slottable" "yes")]) |
| 2117 |
|
| 2118 |
;; Various strange insns that gcc likes. |
| 2119 |
|
| 2120 |
;; Fortunately, it is simple to construct an abssf (although it may not |
| 2121 |
;; be very much used in practice). |
| 2122 |
|
| 2123 |
(define_insn "abssf2" |
| 2124 |
[(set (match_operand:SF 0 "register_operand" "=r") |
| 2125 |
(abs:SF (match_operand:SF 1 "register_operand" "0"))) |
| 2126 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 2127 |
"" |
| 2128 |
"lslq 1,%0\;lsrq 1,%0") |
| 2129 |
|
| 2130 |
(define_insn "abssi2" |
| 2131 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 2132 |
(abs:SI (match_operand:SI 1 "register_operand" "r"))) |
| 2133 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 2134 |
"" |
| 2135 |
"abs %1,%0" |
| 2136 |
[(set_attr "slottable" "yes")]) |
| 2137 |
|
| 2138 |
;; FIXME: GCC should be able to do these expansions itself. |
| 2139 |
|
| 2140 |
(define_expand "abs<mode>2" |
| 2141 |
[(parallel |
| 2142 |
[(set (match_dup 2) |
| 2143 |
(sign_extend:SI (match_operand:BW 1 "general_operand"))) |
| 2144 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 2145 |
(parallel |
| 2146 |
[(set (match_dup 3) (abs:SI (match_dup 2))) |
| 2147 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 2148 |
(parallel |
| 2149 |
[(set (match_operand:BW 0 "register_operand") |
| 2150 |
(subreg:BW (match_dup 3) 0)) |
| 2151 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 2152 |
"" |
| 2153 |
"operands[2] = gen_reg_rtx (SImode); operands[3] = gen_reg_rtx (SImode);") |
| 2154 |
|
| 2155 |
(define_insn "<acc><anz><anzvc>clzsi2<setcc><setnz><setnzvc>" |
| 2156 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 2157 |
(clz:SI (match_operand:SI 1 "register_operand" "r"))) |
| 2158 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 2159 |
"TARGET_HAS_LZ" |
| 2160 |
"lz %1,%0" |
| 2161 |
[(set_attr "slottable" "yes")]) |
| 2162 |
|
| 2163 |
(define_insn "<acc><anz><anzvc>bswapsi2<setcc><setnz><setnzvc>" |
| 2164 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 2165 |
(bswap:SI (match_operand:SI 1 "register_operand" "0"))) |
| 2166 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 2167 |
"TARGET_HAS_SWAP" |
| 2168 |
"swapwb %0" |
| 2169 |
[(set_attr "slottable" "yes")]) |
| 2170 |
|
| 2171 |
;; This instruction swaps all bits in a register. |
| 2172 |
;; That means that the most significant bit is put in the place |
| 2173 |
;; of the least significant bit, and so on. |
| 2174 |
|
| 2175 |
(define_insn "cris_swap_bits" |
| 2176 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 2177 |
(bitreverse:SI (match_operand:SI 1 "register_operand" "0"))) |
| 2178 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 2179 |
"TARGET_HAS_SWAP" |
| 2180 |
"swapwbr %0" |
| 2181 |
[(set_attr "slottable" "yes")]) |
| 2182 |
|
| 2183 |
;; Implement ctz using two instructions, one for bit swap and one for clz. |
| 2184 |
;; Defines a scratch register to avoid clobbering input. |
| 2185 |
|
| 2186 |
(define_expand "ctzsi2" |
| 2187 |
[(parallel |
| 2188 |
[(set (match_dup 2) |
| 2189 |
(match_operand:SI 1 "register_operand")) |
| 2190 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 2191 |
(parallel |
| 2192 |
[(set (match_dup 2) (bitreverse:SI (match_dup 2))) |
| 2193 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 2194 |
(parallel |
| 2195 |
[(set (match_operand:SI 0 "register_operand") |
| 2196 |
(clz:SI (match_dup 2))) |
| 2197 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 2198 |
"TARGET_HAS_LZ && TARGET_HAS_SWAP" |
| 2199 |
"operands[2] = gen_reg_rtx (SImode);") |
| 2200 |
|
| 2201 |
;; Bound-insn. Defined to be the same as an unsigned minimum, which is an |
| 2202 |
;; operation supported by gcc. Used in casesi, but used now and then in |
| 2203 |
;; normal code too. |
| 2204 |
|
| 2205 |
(define_expand "uminsi3" |
| 2206 |
[(parallel |
| 2207 |
[(set (match_operand:SI 0 "register_operand") |
| 2208 |
(umin:SI (match_operand:SI 1 "register_operand") |
| 2209 |
(match_operand:SI 2 "general_operand"))) |
| 2210 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 2211 |
"" |
| 2212 |
"") |
| 2213 |
|
| 2214 |
(define_insn "*uminsi3<setcc><setnz><setnzvc>" |
| 2215 |
[(set (match_operand:SI 0 "register_operand" "=r,r, r,r") |
| 2216 |
(umin:SI (match_operand:SI 1 "register_operand" "%0,0, 0,r") |
| 2217 |
(match_operand:SI 2 "general_operand" "r,Q>,g,!To"))) |
| 2218 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 2219 |
"" |
| 2220 |
{ |
| 2221 |
if (CONST_INT_P (operands[2])) |
| 2222 |
{ |
| 2223 |
/* Constant operands are zero-extended, so only 32-bit operands |
| 2224 |
may be negative. */ |
| 2225 |
if (INTVAL (operands[2]) >= 0) |
| 2226 |
{ |
| 2227 |
if (INTVAL (operands[2]) < 256) |
| 2228 |
return "bound.b %2,%0"; |
| 2229 |
|
| 2230 |
if (INTVAL (operands[2]) < 65536) |
| 2231 |
return "bound.w %2,%0"; |
| 2232 |
} |
| 2233 |
} |
| 2234 |
else if (which_alternative == 3) |
| 2235 |
return "bound.d %2,%1,%0"; |
| 2236 |
|
| 2237 |
return "bound.d %2,%0"; |
| 2238 |
} |
| 2239 |
[(set_attr "slottable" "yes,yes,no,no")]) |
| 2240 |
|
| 2241 |
;; Jump and branch insns. |
| 2242 |
|
| 2243 |
(define_insn "jump" |
| 2244 |
[(set (pc) |
| 2245 |
(label_ref (match_operand 0 "" "")))] |
| 2246 |
"" |
| 2247 |
"ba %l0%#" |
| 2248 |
[(set_attr "slottable" "has_slot")]) |
| 2249 |
|
| 2250 |
;; Testcase gcc.c-torture/compile/991213-3.c fails if we allow a constant |
| 2251 |
;; here, since the insn is not recognized as an indirect jump by |
| 2252 |
;; jmp_uses_reg_or_mem used by computed_jump_p. Perhaps it is a kludge to |
| 2253 |
;; change from general_operand to nonimmediate_operand (at least the docs |
| 2254 |
;; should be changed), but then again the pattern is called indirect_jump. |
| 2255 |
(define_expand "indirect_jump" |
| 2256 |
[(set (pc) (match_operand:SI 0 "nonimmediate_operand"))] |
| 2257 |
"" |
| 2258 |
"") |
| 2259 |
|
| 2260 |
(define_insn "*indirect_jump" |
| 2261 |
[(set (pc) (match_operand:SI 0 "nonimmediate_operand" "rm"))] |
| 2262 |
"" |
| 2263 |
"jump %0") |
| 2264 |
|
| 2265 |
;; Return insn. Used whenever the epilogue is very simple; if it is only |
| 2266 |
;; a single ret or jump [sp+]. No allocated stack space or saved |
| 2267 |
;; registers are allowed. |
| 2268 |
;; Note that for this pattern, although named, it is ok to check the |
| 2269 |
;; context of the insn in the test, not only compiler switches. |
| 2270 |
|
| 2271 |
(define_expand "return" |
| 2272 |
[(return)] |
| 2273 |
"cris_simple_epilogue ()" |
| 2274 |
"cris_expand_return (cris_return_address_on_stack ()); DONE;") |
| 2275 |
|
| 2276 |
(define_insn "*return_expanded" |
| 2277 |
[(return)] |
| 2278 |
"" |
| 2279 |
{ |
| 2280 |
return cris_return_address_on_stack_for_return () |
| 2281 |
? "jump [$sp+]" : "ret%#"; |
| 2282 |
} |
| 2283 |
[(set (attr "slottable") |
| 2284 |
(if_then_else |
| 2285 |
(match_test "cris_return_address_on_stack_for_return ()") |
| 2286 |
(const_string "no") |
| 2287 |
(const_string "has_return_slot")))]) |
| 2288 |
|
| 2289 |
(define_expand "prologue" |
| 2290 |
[(const_int 0)] |
| 2291 |
"" |
| 2292 |
"cris_expand_prologue (); DONE;") |
| 2293 |
|
| 2294 |
(define_expand "epilogue" |
| 2295 |
[(const_int 0)] |
| 2296 |
"" |
| 2297 |
"cris_expand_epilogue (); DONE;") |
| 2298 |
|
| 2299 |
;; Conditional branches. |
| 2300 |
|
| 2301 |
(define_expand "cbranch<mode>4" |
| 2302 |
[(parallel |
| 2303 |
[(set (pc) |
| 2304 |
(if_then_else |
| 2305 |
(match_operator 0 "ordered_comparison_operator" |
| 2306 |
[(match_operand:BWDD 1 "nonimmediate_operand") |
| 2307 |
(match_operand:BWDD 2 "general_operand")]) |
| 2308 |
(label_ref (match_operand 3 "")) |
| 2309 |
(pc))) |
| 2310 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 2311 |
"" |
| 2312 |
"cris_reduce_compare (&operands[0], &operands[1], &operands[2]);") |
| 2313 |
|
| 2314 |
(define_insn_and_split "*cbranch<mode><code>4" |
| 2315 |
[(set (pc) |
| 2316 |
(if_then_else |
| 2317 |
(cond |
| 2318 |
(match_operand:BWDD 0 "nonimmediate_operand" "<cmp_op0c>") |
| 2319 |
(match_operand:BWDD 1 "general_operand" "<cmp_op1c>")) |
| 2320 |
(label_ref (match_operand 2 "")) |
| 2321 |
(pc))) |
| 2322 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 2323 |
"" |
| 2324 |
"#" |
| 2325 |
"&& reload_completed" |
| 2326 |
[(set (reg:<xCC> CRIS_CC0_REGNUM) |
| 2327 |
(compare:<xCC> (match_dup 0) (match_dup 1))) |
| 2328 |
(set (pc) |
| 2329 |
(if_then_else (cond (reg:<xCC> CRIS_CC0_REGNUM) (const_int 0)) |
| 2330 |
(label_ref (match_dup 2)) |
| 2331 |
(pc)))] |
| 2332 |
"") |
| 2333 |
|
| 2334 |
;; Test a single bit at operand[0] against 0/non-0. |
| 2335 |
(define_insn_and_split "*cbranch<mode>4_btstrq1_<CC>" |
| 2336 |
[(set (pc) |
| 2337 |
(if_then_else |
| 2338 |
(zcond |
| 2339 |
(zero_extract:BWD |
| 2340 |
(match_operand:BWD 0 "register_operand" "r,r") |
| 2341 |
(const_int 1) |
| 2342 |
(match_operand:SI 1 "nonmemory_operand" "Kc,r")) |
| 2343 |
(const_int 0)) |
| 2344 |
(label_ref (match_operand 2 "")) |
| 2345 |
(pc))) |
| 2346 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 2347 |
"" |
| 2348 |
"#" |
| 2349 |
"&& reload_completed" |
| 2350 |
[(set (reg:CC_ZnN CRIS_CC0_REGNUM) |
| 2351 |
(compare:CC_ZnN |
| 2352 |
(zero_extract:SI (match_dup 0) (const_int 1) (match_dup 1)) |
| 2353 |
(const_int 0))) |
| 2354 |
(set (pc) |
| 2355 |
(if_then_else (zcond (reg:CC_ZnN CRIS_CC0_REGNUM) (const_int 0)) |
| 2356 |
(label_ref (match_dup 2)) |
| 2357 |
(pc)))] |
| 2358 |
"") |
| 2359 |
|
| 2360 |
;; Test a field of bits starting at bit 0 against 0/non-0. |
| 2361 |
(define_insn_and_split "*cbranch<mode>4_btstqb0_<CC>" |
| 2362 |
[(set (pc) |
| 2363 |
(if_then_else |
| 2364 |
(zcond |
| 2365 |
(zero_extract:BWD |
| 2366 |
(match_operand:BWD 0 "register_operand" "r") |
| 2367 |
(match_operand 1 "const_int_operand" "Kc") |
| 2368 |
(const_int 0)) |
| 2369 |
(const_int 0)) |
| 2370 |
(label_ref (match_operand 2 "")) |
| 2371 |
(pc))) |
| 2372 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 2373 |
"" |
| 2374 |
"#" |
| 2375 |
"&& reload_completed" |
| 2376 |
[(set (reg:CC_NZ CRIS_CC0_REGNUM) |
| 2377 |
(compare:CC_NZ |
| 2378 |
(zero_extract:SI (match_dup 0) (match_dup 1) (const_int 0)) |
| 2379 |
(const_int 0))) |
| 2380 |
(set (pc) |
| 2381 |
(if_then_else (zcond (reg:CC_NZ CRIS_CC0_REGNUM) (const_int 0)) |
| 2382 |
(label_ref (match_dup 2)) |
| 2383 |
(pc)))] |
| 2384 |
"") |
| 2385 |
|
| 2386 |
|
| 2387 |
;; We suffer from the same overflow-bit-gets-in-the-way problem as |
| 2388 |
;; e.g. m68k, so we have to check if overflow bit is set on all "signed" |
| 2389 |
;; conditions. |
| 2390 |
|
| 2391 |
(define_insn "*b<zcond:code><mode>" |
| 2392 |
[(set (pc) |
| 2393 |
(if_then_else (zcond (reg:ZnNNZUSE CRIS_CC0_REGNUM) |
| 2394 |
(const_int 0)) |
| 2395 |
(label_ref (match_operand 0 "" "")) |
| 2396 |
(pc)))] |
| 2397 |
"reload_completed" |
| 2398 |
{ |
| 2399 |
return <MODE>mode == CC_ZnNmode ? "b<znnCC> %l0%#" : "b<CC> %l0%#"; |
| 2400 |
} |
| 2401 |
[(set_attr "slottable" "has_slot")]) |
| 2402 |
|
| 2403 |
(define_insn "*b<nzvccond:code><mode>" |
| 2404 |
[(set (pc) |
| 2405 |
(if_then_else (nzvccond (reg:NZVCUSE CRIS_CC0_REGNUM) |
| 2406 |
(const_int 0)) |
| 2407 |
(label_ref (match_operand 0 "" "")) |
| 2408 |
(pc)))] |
| 2409 |
"reload_completed" |
| 2410 |
"b<CC> %l0%#" |
| 2411 |
[(set_attr "slottable" "has_slot")]) |
| 2412 |
|
| 2413 |
(define_insn "*b<rnzcond:code><mode>" |
| 2414 |
[(set (pc) |
| 2415 |
(if_then_else (rnzcond (reg:NZUSE CRIS_CC0_REGNUM) |
| 2416 |
(const_int 0)) |
| 2417 |
(label_ref (match_operand 0 "" "")) |
| 2418 |
(pc)))] |
| 2419 |
"reload_completed" |
| 2420 |
{ |
| 2421 |
return <MODE>mode == CC_NZmode ? "b<oCC> %l0%#" : "b<CC> %l0%#"; |
| 2422 |
} |
| 2423 |
[(set_attr "slottable" "has_slot")]) |
| 2424 |
|
| 2425 |
;; Reversed anonymous patterns to the ones above, as mandated. |
| 2426 |
|
| 2427 |
(define_insn "*b<nzcond:code>_reversed<mode>" |
| 2428 |
[(set (pc) |
| 2429 |
(if_then_else (nzcond (reg:ZnNNZUSE CRIS_CC0_REGNUM) |
| 2430 |
(const_int 0)) |
| 2431 |
(pc) |
| 2432 |
(label_ref (match_operand 0 "" ""))))] |
| 2433 |
"reload_completed" |
| 2434 |
{ |
| 2435 |
return <MODE>mode == CC_ZnNmode ? "b<rznnCC> %l0%#" : "b<rCC> %l0%#"; |
| 2436 |
} |
| 2437 |
[(set_attr "slottable" "has_slot")]) |
| 2438 |
|
| 2439 |
(define_insn "*b<nzvccond:code>_reversed<mode>" |
| 2440 |
[(set (pc) |
| 2441 |
(if_then_else (nzvccond (reg:NZVCUSE CRIS_CC0_REGNUM) |
| 2442 |
(const_int 0)) |
| 2443 |
(pc) |
| 2444 |
(label_ref (match_operand 0 "" ""))))] |
| 2445 |
"reload_completed" |
| 2446 |
"b<rCC> %l0%#" |
| 2447 |
[(set_attr "slottable" "has_slot")]) |
| 2448 |
|
| 2449 |
(define_insn "*b<rnzcond:code>_reversed<mode>" |
| 2450 |
[(set (pc) |
| 2451 |
(if_then_else (rnzcond (reg:NZUSE CRIS_CC0_REGNUM) |
| 2452 |
(const_int 0)) |
| 2453 |
(pc) |
| 2454 |
(label_ref (match_operand 0 "" ""))))] |
| 2455 |
"reload_completed" |
| 2456 |
{ |
| 2457 |
return <MODE>mode == CC_NZmode ? "b<roCC> %l0%#" : "b<rCC> %l0%#"; |
| 2458 |
} |
| 2459 |
[(set_attr "slottable" "has_slot")]) |
| 2460 |
|
| 2461 |
;; Set on condition: sCC. |
| 2462 |
|
| 2463 |
(define_expand "cstore<mode>4" |
| 2464 |
[(parallel |
| 2465 |
[(set (match_operand:SI 0 "register_operand") |
| 2466 |
(match_operator:SI 1 "ordered_comparison_operator" |
| 2467 |
[(match_operand:BWDD 2 "nonimmediate_operand") |
| 2468 |
(match_operand:BWDD 3 "general_operand")])) |
| 2469 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 2470 |
"" |
| 2471 |
"cris_reduce_compare (&operands[1], &operands[2], &operands[3]);") |
| 2472 |
|
| 2473 |
(define_insn_and_split "*cstore<mode><code>4" |
| 2474 |
[(set (match_operand:SI 0 "register_operand" "=<sCC_destc>") |
| 2475 |
(cond:SI |
| 2476 |
(match_operand:BWDD 1 "nonimmediate_operand" "<cmp_op0c>") |
| 2477 |
(match_operand:BWDD 2 "general_operand" "<cmp_op1c>"))) |
| 2478 |
(clobber (reg:CC CRIS_CC0_REGNUM))] |
| 2479 |
"" |
| 2480 |
"#" |
| 2481 |
"&& reload_completed" |
| 2482 |
[(set (reg:<xCC> CRIS_CC0_REGNUM) |
| 2483 |
(compare:<xCC> (match_dup 1) (match_dup 2))) |
| 2484 |
(set (match_dup 0) |
| 2485 |
(cond:SI (reg:<xCC> CRIS_CC0_REGNUM) (const_int 0)))] |
| 2486 |
"") |
| 2487 |
|
| 2488 |
;; Like bCC, we have to check the overflow bit for |
| 2489 |
;; signed conditions. |
| 2490 |
|
| 2491 |
(define_insn "*s<nzcond:code><mode>" |
| 2492 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 2493 |
(nzcond:SI (reg:NZUSE CRIS_CC0_REGNUM) (const_int 0)))] |
| 2494 |
"reload_completed" |
| 2495 |
"s<CC> %0" |
| 2496 |
[(set_attr "slottable" "yes") |
| 2497 |
(set_attr "cc" "none")]) |
| 2498 |
|
| 2499 |
(define_insn "*s<rnzcond:code><mode>" |
| 2500 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 2501 |
(rnzcond:SI (reg:NZUSE CRIS_CC0_REGNUM) (const_int 0)))] |
| 2502 |
"reload_completed" |
| 2503 |
{ |
| 2504 |
return <MODE>mode == CC_NZmode ? "s<oCC> %0" : "s<CC> %0"; |
| 2505 |
} |
| 2506 |
[(set_attr "slottable" "yes") |
| 2507 |
(set_attr "cc" "none")]) |
| 2508 |
|
| 2509 |
(define_insn "*s<nzvccond:code><mode>" |
| 2510 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 2511 |
(nzvccond:SI (reg:NZVCUSE CRIS_CC0_REGNUM) (const_int 0)))] |
| 2512 |
"reload_completed" |
| 2513 |
"s<CC> %0" |
| 2514 |
[(set_attr "slottable" "yes") |
| 2515 |
(set_attr "cc" "none")]) |
| 2516 |
|
| 2517 |
;; Call insns. |
| 2518 |
|
| 2519 |
;; We need to make these patterns "expand", since the real operand is |
| 2520 |
;; hidden in a (mem:QI ) inside operand[0] (call_value: operand[1]), |
| 2521 |
;; and cannot be checked if it were a "normal" pattern. |
| 2522 |
;; Note that "call" and "call_value" are *always* called with a |
| 2523 |
;; mem-operand for operand 0 and 1 respective. What happens for combined |
| 2524 |
;; instructions is a different issue. |
| 2525 |
|
| 2526 |
(define_expand "call" |
| 2527 |
[(parallel [(call (match_operand:SI 0 "indirect_operand") |
| 2528 |
(match_operand 1 "general_operand")) |
| 2529 |
(clobber (reg:SI CRIS_SRP_REGNUM))])] |
| 2530 |
"" |
| 2531 |
{ |
| 2532 |
operands[1] = const0_rtx; |
| 2533 |
}) |
| 2534 |
|
| 2535 |
;; Accept operands for operand 0 in order of preference. |
| 2536 |
|
| 2537 |
(define_insn "*expanded_call" |
| 2538 |
[(call (mem:QI (match_operand:SI 0 "general_operand" "r,Q>,g")) |
| 2539 |
(const_int 0)) |
| 2540 |
(clobber (reg:SI CRIS_SRP_REGNUM))] |
| 2541 |
"" |
| 2542 |
"jsr %0") |
| 2543 |
|
| 2544 |
(define_expand "call_value" |
| 2545 |
[(parallel [(set (match_operand 0 "") |
| 2546 |
(call (match_operand:SI 1 "indirect_operand") |
| 2547 |
(match_operand 2 ""))) |
| 2548 |
(clobber (reg:SI CRIS_SRP_REGNUM))])] |
| 2549 |
"" |
| 2550 |
{ |
| 2551 |
operands[2] = const0_rtx; |
| 2552 |
}) |
| 2553 |
|
| 2554 |
;; The validity other than "general" of |
| 2555 |
;; operand 0 will be checked elsewhere. Accept operands for operand 1 in |
| 2556 |
;; order of preference (Q includes r, but r is shorter, faster). |
| 2557 |
;; We also accept a PLT symbol. We output it as [rPIC+sym:GOTPLT] rather |
| 2558 |
;; than requiring getting rPIC + sym:PLT into a register. |
| 2559 |
|
| 2560 |
(define_insn "*expanded_call_value" |
| 2561 |
[(set (match_operand 0 "nonimmediate_operand" "=g,g,g") |
| 2562 |
(call (mem:QI (match_operand:SI 1 "general_operand" "r,Q>,g")) |
| 2563 |
(const_int 0))) |
| 2564 |
(clobber (reg:SI CRIS_SRP_REGNUM))] |
| 2565 |
"" |
| 2566 |
"Jsr %1" |
| 2567 |
[(set_attr "cc" "clobber")]) |
| 2568 |
|
| 2569 |
;; Used in debugging. No use for the direct pattern; unfilled |
| 2570 |
;; delayed-branches are taken care of by other means. |
| 2571 |
|
| 2572 |
(define_insn "nop" |
| 2573 |
[(const_int 0)] |
| 2574 |
"" |
| 2575 |
"nop" |
| 2576 |
[(set_attr "cc" "none")]) |
| 2577 |
|
| 2578 |
;; Same as the gdb trap breakpoint: would cause a SIGTRAP for |
| 2579 |
;; cris-linux* and will work in freestanding environments with |
| 2580 |
;; sufficient framework. |
| 2581 |
(define_insn "trap" |
| 2582 |
[(trap_if (const_int 1) (const_int 8))] |
| 2583 |
"TARGET_TRAP_USING_BREAK8" |
| 2584 |
"break 8") |
| 2585 |
|
| 2586 |
;; We need to stop accesses to the stack after the memory is |
| 2587 |
;; deallocated. Unfortunately, reorg doesn't look at naked clobbers, |
| 2588 |
;; e.g. (insn ... (clobber (mem:BLK (stack_pointer_rtx)))) and we don't |
| 2589 |
;; want to use a naked (unspec_volatile) as that would stop any |
| 2590 |
;; scheduling in the epilogue. Hence we model it as a "real" insn that |
| 2591 |
;; sets the memory in an unspecified manner. FIXME: Unfortunately it |
| 2592 |
;; still has the effect of an unspec_volatile. |
| 2593 |
(define_insn "cris_frame_deallocated_barrier" |
| 2594 |
[(set (mem:BLK (reg:SI CRIS_SP_REGNUM)) |
| 2595 |
(unspec:BLK [(const_int 0)] CRIS_UNSPEC_FRAME_DEALLOC))] |
| 2596 |
"" |
| 2597 |
"" |
| 2598 |
[(set_attr "length" "0")]) |
| 2599 |
|
| 2600 |
;; We expand on casesi so we can use "bound" and "add offset fetched from |
| 2601 |
;; a table to pc" (adds.w [pc+%0.w],pc). |
| 2602 |
|
| 2603 |
;; Note: if you change the "parallel" (or add anything after it) in |
| 2604 |
;; this expansion, you must change the macro ASM_OUTPUT_CASE_END |
| 2605 |
;; accordingly, to add the default case at the end of the jump-table. |
| 2606 |
|
| 2607 |
(define_expand "casesi" |
| 2608 |
[(parallel |
| 2609 |
[(set (match_dup 5) (match_operand:SI 0 "general_operand")) |
| 2610 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 2611 |
(parallel |
| 2612 |
[(set (match_dup 6) |
| 2613 |
(minus:SI (match_dup 5) |
| 2614 |
(match_operand:SI 1 "const_int_operand"))) |
| 2615 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 2616 |
(parallel |
| 2617 |
[(set (match_dup 7) |
| 2618 |
(umin:SI (match_dup 6) |
| 2619 |
(match_operand:SI 2 "const_int_operand"))) |
| 2620 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 2621 |
(parallel |
| 2622 |
[(set (pc) |
| 2623 |
(if_then_else |
| 2624 |
(ltu (match_dup 7) (match_dup 2)) |
| 2625 |
(plus:SI (sign_extend:SI |
| 2626 |
(mem:HI |
| 2627 |
(plus:SI (mult:SI (match_dup 7) (const_int 2)) |
| 2628 |
(pc)))) |
| 2629 |
(pc)) |
| 2630 |
(label_ref (match_operand 4 "")))) |
| 2631 |
(use (label_ref (match_operand 3 ""))) |
| 2632 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 2633 |
"" |
| 2634 |
{ |
| 2635 |
operands[2] = plus_constant (SImode, operands[2], 1); |
| 2636 |
operands[5] = gen_reg_rtx (SImode); |
| 2637 |
operands[6] = gen_reg_rtx (SImode); |
| 2638 |
operands[7] = gen_reg_rtx (SImode); |
| 2639 |
}) |
| 2640 |
|
| 2641 |
(include "sync.md") |
| 2642 |
|
| 2643 |
;; Various peephole optimizations. |
| 2644 |
;; |
| 2645 |
;; Do not add patterns that you do not know will be matched. |
| 2646 |
;; Please also add a self-contained testcase. |
| 2647 |
|
| 2648 |
;; We have trouble with and:s and shifts. Maybe something is broken in |
| 2649 |
;; gcc? Or it could just be that bit-field insn expansion is a bit |
| 2650 |
;; suboptimal when not having extzv insns. Or combine being over-eager |
| 2651 |
;; to canonicalize to "and", and ignorant on the benefits of the right |
| 2652 |
;; mixture of "and" and "zero-extend". |
| 2653 |
|
| 2654 |
;; Testcase for the following peephole: gcc.target/cris/peep2-movulsr.c |
| 2655 |
|
| 2656 |
;; Where equivalent and where the "and" argument doesn't fit "andq" but |
| 2657 |
;; is 16 bits or smaller, replace the "and" with a zero-extend preceding |
| 2658 |
;; the shift. A zero-extend is shorter and faster than "and" with a |
| 2659 |
;; 32-bit argument. |
| 2660 |
|
| 2661 |
(define_peephole2 ; movulsr |
| 2662 |
[(parallel |
| 2663 |
[(set (match_operand:SI 0 "register_operand") |
| 2664 |
(lshiftrt:SI (match_dup 0) |
| 2665 |
(match_operand:SI 1 "const_int_operand"))) |
| 2666 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 2667 |
(parallel |
| 2668 |
[(set (match_dup 0) |
| 2669 |
(and:SI (match_dup 0) |
| 2670 |
(match_operand 2 "const_int_operand"))) |
| 2671 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 2672 |
"INTVAL (operands[2]) > 31 && INTVAL (operands[2]) <= 0xffff |
| 2673 |
&& (((INTVAL (operands[2]) <= 0xff ? 0xff : 0xffff) >> INTVAL (operands[1])) |
| 2674 |
== INTVAL (operands[2]))" |
| 2675 |
[(parallel |
| 2676 |
;; The zero-extend is expressed as an "and", only because that's easier |
| 2677 |
;; than messing with zero-extend of a subreg. |
| 2678 |
[(set (match_dup 0) (and:SI (match_dup 0) (match_dup 3))) |
| 2679 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 2680 |
(parallel |
| 2681 |
[(set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 1))) |
| 2682 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 2683 |
{ |
| 2684 |
operands[3] |
| 2685 |
= INTVAL (operands[2]) <= 0xff ? GEN_INT (0xff) : GEN_INT (0xffff); |
| 2686 |
}) |
| 2687 |
|
| 2688 |
;; Avoid, after opsplit1 with AND (below), sequences of: |
| 2689 |
;; lsrq N,R |
| 2690 |
;; lslq M,R |
| 2691 |
;; lsrq M,R |
| 2692 |
;; (N < M), where we can fold the first lsrq into the lslq-lsrq, like: |
| 2693 |
;; lslq M-N,R |
| 2694 |
;; lsrq M,R |
| 2695 |
;; We have to match this before opsplit1 below and before other peephole2s of |
| 2696 |
;; lesser value, since peephole2 matching resumes at the first generated insn, |
| 2697 |
;; and thus wouldn't match a pattern of the three shifts after opsplit1/AND. |
| 2698 |
;; Note that this lsrandsplit1 is in turn of lesser value than movulsr, since |
| 2699 |
;; that one doesn't require the same operand for source and destination, but |
| 2700 |
;; they happen to be the same hard-register at peephole2 time even if |
| 2701 |
;; naturally separated like in peep2-movulsr2.c, thus this placement. (Source |
| 2702 |
;; and destination will be re-separated and the move optimized out in |
| 2703 |
;; cprop_hardreg at time of this writing.) |
| 2704 |
;; Testcase: gcc.target/cris/peep2-lsrandsplit1.c |
| 2705 |
(define_peephole2 ; lsrandsplit1 |
| 2706 |
[(parallel |
| 2707 |
[(set (match_operand:SI 0 "register_operand") |
| 2708 |
(lshiftrt:SI |
| 2709 |
(match_operand:SI 1 "register_operand") |
| 2710 |
(match_operand:SI 2 "const_int_operand"))) |
| 2711 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 2712 |
(parallel |
| 2713 |
[(set (match_operand 3 "register_operand") |
| 2714 |
(and |
| 2715 |
(match_operand 4 "register_operand") |
| 2716 |
(match_operand 5 "const_int_operand"))) |
| 2717 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 2718 |
"REGNO (operands[0]) == REGNO (operands[1]) |
| 2719 |
&& REGNO (operands[0]) == REGNO (operands[3]) |
| 2720 |
&& REGNO (operands[0]) == REGNO (operands[4]) |
| 2721 |
&& (INTVAL (operands[2]) |
| 2722 |
< (clz_hwi (INTVAL (operands[5])) - (HOST_BITS_PER_WIDE_INT - 32))) |
| 2723 |
&& cris_splittable_constant_p (INTVAL (operands[5]), AND, SImode, |
| 2724 |
optimize_function_for_speed_p (cfun)) == 2" |
| 2725 |
;; We're guaranteed by the above hw_clz test (certainly non-zero) and the |
| 2726 |
;; test for a two-insn return-value from cris_splittable_constant_p, that |
| 2727 |
;; the cris_splittable_constant_p AND-replacement would be lslq-lsrq. |
| 2728 |
[(parallel |
| 2729 |
[(set (match_dup 0) (ashift:SI (match_dup 0) (match_dup 9))) |
| 2730 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 2731 |
(parallel |
| 2732 |
[(set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 10))) |
| 2733 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 2734 |
{ |
| 2735 |
HOST_WIDE_INT shiftval |
| 2736 |
= clz_hwi (INTVAL (operands[5])) - (HOST_BITS_PER_WIDE_INT - 32); |
| 2737 |
operands[9] = GEN_INT (shiftval - INTVAL (operands[2])); |
| 2738 |
operands[10] = GEN_INT (shiftval); |
| 2739 |
}) |
| 2740 |
|
| 2741 |
;; Testcase for the following four peepholes: gcc.target/cris/peep2-xsrand.c |
| 2742 |
|
| 2743 |
(define_peephole2 ; asrandb |
| 2744 |
[(parallel |
| 2745 |
[(set (match_operand:SI 0 "register_operand") |
| 2746 |
(ashiftrt:SI (match_dup 0) |
| 2747 |
(match_operand:SI 1 "const_int_operand"))) |
| 2748 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 2749 |
(parallel |
| 2750 |
[(set (match_dup 0) |
| 2751 |
(and:SI (match_dup 0) |
| 2752 |
(match_operand 2 "const_int_operand"))) |
| 2753 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 2754 |
"INTVAL (operands[2]) > 31 |
| 2755 |
&& INTVAL (operands[2]) < 255 |
| 2756 |
&& INTVAL (operands[1]) > 23 |
| 2757 |
/* Check that the and-operation enables us to use logical-shift. */ |
| 2758 |
&& (INTVAL (operands[2]) |
| 2759 |
& ((HOST_WIDE_INT) (HOST_WIDE_INT_M1U |
| 2760 |
<< (32 - INTVAL (operands[1]))))) == 0" |
| 2761 |
[(parallel |
| 2762 |
[(set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 1))) |
| 2763 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 2764 |
(parallel |
| 2765 |
[(set (match_dup 3) (and:QI (match_dup 3) (match_dup 4))) |
| 2766 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 2767 |
{ |
| 2768 |
operands[3] = gen_rtx_REG (QImode, REGNO (operands[0])); |
| 2769 |
operands[4] = GEN_INT (trunc_int_for_mode (INTVAL (operands[2]), QImode)); |
| 2770 |
}) |
| 2771 |
|
| 2772 |
(define_peephole2 ; asrandw |
| 2773 |
[(parallel |
| 2774 |
[(set (match_operand:SI 0 "register_operand") |
| 2775 |
(ashiftrt:SI (match_dup 0) |
| 2776 |
(match_operand:SI 1 "const_int_operand"))) |
| 2777 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 2778 |
(parallel |
| 2779 |
[(set (match_dup 0) |
| 2780 |
(and:SI (match_dup 0) (match_operand 2 "const_int_operand"))) |
| 2781 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 2782 |
"INTVAL (operands[2]) > 31 |
| 2783 |
&& INTVAL (operands[2]) < 65535 |
| 2784 |
&& INTVAL (operands[2]) != 255 |
| 2785 |
&& INTVAL (operands[1]) > 15 |
| 2786 |
/* Check that the and-operation enables us to use logical-shift. */ |
| 2787 |
&& (INTVAL (operands[2]) |
| 2788 |
& ((HOST_WIDE_INT) (HOST_WIDE_INT_M1U |
| 2789 |
<< (32 - INTVAL (operands[1]))))) == 0" |
| 2790 |
[(parallel |
| 2791 |
[(set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 1))) |
| 2792 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 2793 |
(parallel |
| 2794 |
[(set (match_dup 3) (and:HI (match_dup 3) (match_dup 4))) |
| 2795 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 2796 |
{ |
| 2797 |
operands[3] = gen_rtx_REG (HImode, REGNO (operands[0])); |
| 2798 |
operands[4] = GEN_INT (trunc_int_for_mode (INTVAL (operands[2]), HImode)); |
| 2799 |
}) |
| 2800 |
|
| 2801 |
(define_peephole2 ; lsrandb |
| 2802 |
[(parallel |
| 2803 |
[(set (match_operand:SI 0 "register_operand") |
| 2804 |
(lshiftrt:SI (match_dup 0) |
| 2805 |
(match_operand:SI 1 "const_int_operand"))) |
| 2806 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 2807 |
(parallel |
| 2808 |
[(set (match_dup 0) |
| 2809 |
(and:SI (match_dup 0) (match_operand 2 "const_int_operand"))) |
| 2810 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 2811 |
"INTVAL (operands[2]) > 31 |
| 2812 |
&& INTVAL (operands[2]) < 255 |
| 2813 |
&& INTVAL (operands[1]) > 23" |
| 2814 |
[(parallel |
| 2815 |
[(set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 1))) |
| 2816 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 2817 |
(parallel |
| 2818 |
[(set (match_dup 3) (and:QI (match_dup 3) (match_dup 4))) |
| 2819 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 2820 |
{ |
| 2821 |
operands[3] = gen_rtx_REG (QImode, REGNO (operands[0])); |
| 2822 |
operands[4] = GEN_INT (trunc_int_for_mode (INTVAL (operands[2]), QImode)); |
| 2823 |
}) |
| 2824 |
|
| 2825 |
(define_peephole2 ; lsrandw |
| 2826 |
[(parallel |
| 2827 |
[(set (match_operand:SI 0 "register_operand") |
| 2828 |
(lshiftrt:SI (match_dup 0) |
| 2829 |
(match_operand:SI 1 "const_int_operand"))) |
| 2830 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 2831 |
(parallel |
| 2832 |
[(set (match_dup 0) |
| 2833 |
(and:SI (match_dup 0) (match_operand 2 "const_int_operand"))) |
| 2834 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 2835 |
"INTVAL (operands[2]) > 31 && INTVAL (operands[2]) < 65535 |
| 2836 |
&& INTVAL (operands[2]) != 255 |
| 2837 |
&& INTVAL (operands[1]) > 15" |
| 2838 |
[(parallel |
| 2839 |
[(set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 1))) |
| 2840 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 2841 |
(parallel |
| 2842 |
[(set (match_dup 3) (and:HI (match_dup 3) (match_dup 4))) |
| 2843 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 2844 |
{ |
| 2845 |
operands[3] = gen_rtx_REG (HImode, REGNO (operands[0])); |
| 2846 |
operands[4] = GEN_INT (trunc_int_for_mode (INTVAL (operands[2]), HImode)); |
| 2847 |
}) |
| 2848 |
|
| 2849 |
;; There seems to be no other way to make GCC (including 4.8/trunk at |
| 2850 |
;; r186932) optimally reload an instruction that looks like |
| 2851 |
;; and.d reg_or_mem,const_32__65535,other_reg |
| 2852 |
;; where other_reg is the destination. |
| 2853 |
;; It should be: |
| 2854 |
;; movu.[bw] reg_or_mem,reg_32 |
| 2855 |
;; and.[bw] trunc_int_for_mode([bw], const_32__65535),reg_32 ;; or andq |
| 2856 |
;; but it turns into: |
| 2857 |
;; move.d reg_or_mem,reg_32 |
| 2858 |
;; and.d const_32__65535,reg_32 |
| 2859 |
;; Fix it with these two peephole2's. |
| 2860 |
;; Testcases: gcc.target/cris/peep2-andu1.c gcc.target/cris/peep2-andu2.c |
| 2861 |
|
| 2862 |
(define_peephole2 ; andu |
| 2863 |
[(parallel |
| 2864 |
[(set (match_operand:SI 0 "register_operand") |
| 2865 |
(match_operand:SI 1 "nonimmediate_operand")) |
| 2866 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 2867 |
(parallel |
| 2868 |
[(set (match_operand:SI 2 "register_operand") |
| 2869 |
(and:SI (match_dup 0) |
| 2870 |
(match_operand:SI 3 "const_int_operand"))) |
| 2871 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 2872 |
;; Since the size of the memory access could be made different here, |
| 2873 |
;; don't do this for a mem-volatile access. |
| 2874 |
"REGNO (operands[2]) == REGNO (operands[0]) |
| 2875 |
&& INTVAL (operands[3]) <= 65535 && INTVAL (operands[3]) >= 0 |
| 2876 |
&& !satisfies_constraint_I (operands[3]) |
| 2877 |
&& !side_effects_p (operands[1]) |
| 2878 |
&& (!REG_P (operands[1]) |
| 2879 |
|| REGNO (operands[1]) <= CRIS_LAST_GENERAL_REGISTER)" |
| 2880 |
[(parallel |
| 2881 |
[(set (match_dup 0) (match_dup 4)) |
| 2882 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 2883 |
(parallel |
| 2884 |
[(set (match_dup 5) (match_dup 6)) |
| 2885 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 2886 |
{ |
| 2887 |
machine_mode zmode = INTVAL (operands[3]) <= 255 ? QImode : HImode; |
| 2888 |
machine_mode amode |
| 2889 |
= satisfies_constraint_O (operands[3]) ? SImode : zmode; |
| 2890 |
rtx op1 |
| 2891 |
= (REG_S_P (operands[1]) |
| 2892 |
? gen_rtx_REG (zmode, REGNO (operands[1])) |
| 2893 |
: adjust_address (operands[1], zmode, 0)); |
| 2894 |
operands[4] |
| 2895 |
= gen_rtx_ZERO_EXTEND (SImode, op1); |
| 2896 |
operands[5] = gen_rtx_REG (amode, REGNO (operands[0])); |
| 2897 |
operands[6] |
| 2898 |
= gen_rtx_AND (amode, gen_rtx_REG (amode, REGNO (operands[0])), |
| 2899 |
GEN_INT (trunc_int_for_mode (INTVAL (operands[3]), |
| 2900 |
amode == SImode |
| 2901 |
? QImode : amode))); |
| 2902 |
}) |
| 2903 |
|
| 2904 |
;; Since r186861, gcc.target/cris/peep2-andu2.c trigs this pattern, with which |
| 2905 |
;; we fix up e.g.: |
| 2906 |
;; movu.b 254,$r9. |
| 2907 |
;; and.d $r10,$r9 |
| 2908 |
;; into: |
| 2909 |
;; movu.b $r10,$r9 |
| 2910 |
;; andq -2,$r9. |
| 2911 |
;; Only do this for values fitting the quick immediate operand. |
| 2912 |
(define_peephole2 ; andqu |
| 2913 |
[(parallel |
| 2914 |
[(set (match_operand:SI 0 "register_operand") |
| 2915 |
(match_operand:SI 1 "const_int_operand")) |
| 2916 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 2917 |
(parallel |
| 2918 |
[(set (match_dup 0) |
| 2919 |
(and:SI (match_dup 0) (match_operand:SI 2 "nonimmediate_operand"))) |
| 2920 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 2921 |
;; Since the size of the memory access will be made different here, |
| 2922 |
;; don't do this for a volatile access or a post-incremented address. |
| 2923 |
"satisfies_constraint_O (operands[1]) |
| 2924 |
&& !side_effects_p (operands[2]) |
| 2925 |
&& !reg_overlap_mentioned_p (operands[0], operands[2])" |
| 2926 |
[(parallel |
| 2927 |
[(set (match_dup 0) (match_dup 3)) |
| 2928 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 2929 |
(parallel |
| 2930 |
[(set (match_dup 0) (and:SI (match_dup 0) (match_dup 4))) |
| 2931 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 2932 |
{ |
| 2933 |
machine_mode zmode = INTVAL (operands[1]) <= 255 ? QImode : HImode; |
| 2934 |
rtx op1 |
| 2935 |
= (REG_S_P (operands[2]) |
| 2936 |
? gen_rtx_REG (zmode, REGNO (operands[2])) |
| 2937 |
: adjust_address (operands[2], zmode, 0)); |
| 2938 |
operands[3] = gen_rtx_ZERO_EXTEND (SImode, op1); |
| 2939 |
operands[4] = GEN_INT (trunc_int_for_mode (INTVAL (operands[1]), QImode)); |
| 2940 |
}) |
| 2941 |
|
| 2942 |
;; Somewhat similar to andqu, but a different range and expansion, |
| 2943 |
;; intended to feed the output into opsplit1 with AND: |
| 2944 |
;; move.d 0x7ffff,$r10 |
| 2945 |
;; and.d $r11,$r10 |
| 2946 |
;; into: |
| 2947 |
;; move.d $r11,$r10 |
| 2948 |
;; and.d 0x7ffff,$r10 |
| 2949 |
;; which opsplit1/AND will change into: |
| 2950 |
;; move.d $r11,$r10 (unaffected by opsplit1/AND; shown only for context) |
| 2951 |
;; lslq 13,$r10 |
| 2952 |
;; lsrq 13,$r10 |
| 2953 |
;; thereby winning in space, but in time only if the 0x7ffff happened to |
| 2954 |
;; be unaligned in the code. |
| 2955 |
(define_peephole2 ; movandsplit1 |
| 2956 |
[(parallel |
| 2957 |
[(set (match_operand 0 "register_operand") |
| 2958 |
(match_operand 1 "const_int_operand")) |
| 2959 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 2960 |
(parallel |
| 2961 |
[(set (match_operand 2 "register_operand") |
| 2962 |
(and (match_operand 3 "register_operand") |
| 2963 |
(match_operand 4 "register_operand"))) |
| 2964 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 2965 |
"REGNO (operands[0]) == REGNO (operands[2]) |
| 2966 |
&& REGNO (operands[0]) == REGNO (operands[3]) |
| 2967 |
&& cris_splittable_constant_p (INTVAL (operands[1]), AND, |
| 2968 |
GET_MODE (operands[2]), |
| 2969 |
optimize_function_for_speed_p (cfun))" |
| 2970 |
[(parallel |
| 2971 |
[(set (match_dup 2) (match_dup 4)) |
| 2972 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 2973 |
(parallel |
| 2974 |
[(set (match_dup 2) (match_dup 5)) |
| 2975 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 2976 |
{ |
| 2977 |
operands[5] = gen_rtx_AND (GET_MODE (operands[2]), operands[2], operands[1]); |
| 2978 |
}) |
| 2979 |
|
| 2980 |
;; Large (read: non-quick) numbers can sometimes be AND:ed by other means. |
| 2981 |
;; Testcase: gcc.target/cris/peep2-andsplit1.c |
| 2982 |
;; |
| 2983 |
;; Another case is add<ext> N,rx with -126..-64,64..126: it has the same |
| 2984 |
;; size and execution time as two addq or subq, but addq and subq can fill |
| 2985 |
;; a delay-slot. |
| 2986 |
(define_peephole2 ; opsplit1 |
| 2987 |
[(parallel |
| 2988 |
[(set (match_operand 0 "register_operand") |
| 2989 |
(splitop |
| 2990 |
(match_operand 1 "register_operand") |
| 2991 |
(match_operand 2 "const_int_operand"))) |
| 2992 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 2993 |
;; Operands 0 and 1 can be separate identical objects, at least |
| 2994 |
;; after matching peepholes above. */ |
| 2995 |
"REGNO (operands[0]) == REGNO (operands[1]) |
| 2996 |
&& cris_splittable_constant_p (INTVAL (operands[2]), <CODE>, |
| 2997 |
GET_MODE (operands[0]), |
| 2998 |
optimize_function_for_speed_p (cfun))" |
| 2999 |
[(const_int 0)] |
| 3000 |
{ |
| 3001 |
cris_split_constant (INTVAL (operands[2]), <CODE>, GET_MODE (operands[0]), |
| 3002 |
optimize_function_for_speed_p (cfun), |
| 3003 |
true, operands[0], operands[0]); |
| 3004 |
DONE; |
| 3005 |
}) |
| 3006 |
|
| 3007 |
;; Fix a decomposed szext: fuse it with the memory operand of the |
| 3008 |
;; load. This is typically the sign-extension part of a decomposed |
| 3009 |
;; "indirect offset" address. |
| 3010 |
(define_peephole2 ; lra_szext_decomposed |
| 3011 |
[(parallel |
| 3012 |
[(set (match_operand:BW 0 "register_operand") |
| 3013 |
(match_operand:BW 1 "memory_operand")) |
| 3014 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 3015 |
(parallel |
| 3016 |
[(set (match_operand:SI 2 "register_operand") (szext:SI (match_dup 0))) |
| 3017 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 3018 |
"REGNO (operands[0]) == REGNO (operands[2]) |
| 3019 |
|| peep2_reg_dead_p (2, operands[0])" |
| 3020 |
[(parallel |
| 3021 |
[(set (match_dup 2) (szext:SI (match_dup 1))) |
| 3022 |
(clobber (reg:CC CRIS_CC0_REGNUM))])]) |
| 3023 |
|
| 3024 |
;; Re-compose a decomposed "indirect offset" address for a szext |
| 3025 |
;; operation. The non-clobbering "addi" is generated by LRA. |
| 3026 |
;; This and lra_szext_decomposed is covered by cris/rld-legit1.c. |
| 3027 |
;; (Unfortunately not true when enabling late-combine.) |
| 3028 |
(define_peephole2 ; lra_szext_decomposed_indirect_with_offset |
| 3029 |
[(parallel |
| 3030 |
[(set (match_operand:SI 0 "register_operand") |
| 3031 |
(sign_extend:SI (mem:BW (match_operand:SI 1 "register_operand")))) |
| 3032 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 3033 |
(set (match_dup 0) |
| 3034 |
(plus:SI (match_dup 0) (match_operand:SI 2 "register_operand"))) |
| 3035 |
(parallel |
| 3036 |
[(set (match_operand:SI 3 "register_operand") |
| 3037 |
(szext:SI (mem:BW2 (match_dup 0)))) |
| 3038 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 3039 |
"(REGNO (operands[0]) == REGNO (operands[3]) |
| 3040 |
|| peep2_reg_dead_p (3, operands[0])) |
| 3041 |
&& (REGNO (operands[0]) == REGNO (operands[1]) |
| 3042 |
|| peep2_reg_dead_p (3, operands[0]))" |
| 3043 |
[(parallel |
| 3044 |
[(set |
| 3045 |
(match_dup 3) |
| 3046 |
(szext:SI |
| 3047 |
(mem:BW2 (plus:SI (szext:SI (mem:BW (match_dup 1))) (match_dup 2))))) |
| 3048 |
(clobber (reg:CC CRIS_CC0_REGNUM))])]) |
| 3049 |
|
| 3050 |
;; When enabling late-combine, we get a slightly changed register |
| 3051 |
;; allocation. The two allocations for the pseudo-registers involved |
| 3052 |
;; in the matching pattern get "swapped" and the (plus ...) in the |
| 3053 |
;; pattern above is now a load from a stack-slot. If peephole2 is |
| 3054 |
;; disabled, we see that the original sequence is actually improved; |
| 3055 |
;; one less incoming instruction, a load. We need to "undo" that |
| 3056 |
;; improvement a bit and move that load "back" to before the sequence |
| 3057 |
;; we combine in lra_szext_decomposed_indirect_with_offset. But that |
| 3058 |
;; changed again, so there's no define_peephole2 for that sequence |
| 3059 |
;; here, because it'd be hard or impossible to write a matching |
| 3060 |
;; test-case. A few commits later, the incoming pattern sequence has |
| 3061 |
;; changed again: back to the original but with the (plus...) part of |
| 3062 |
;; the address inside the second memory reference. |
| 3063 |
;; Coverage: cris/rld-legit1.c@r15-1880-gce34fcc572a0dc or |
| 3064 |
;; r15-3386-gaf1500dd8c00 when adding -flate-combine-instructions. |
| 3065 |
|
| 3066 |
(define_peephole2 ; lra_szext_decomposed_indir_plus |
| 3067 |
[(parallel |
| 3068 |
[(set (match_operand:SI 0 "register_operand") |
| 3069 |
(sign_extend:SI (mem:BW (match_operand:SI 1 "register_operand")))) |
| 3070 |
(clobber (reg:CC CRIS_CC0_REGNUM))]) |
| 3071 |
(parallel |
| 3072 |
[(set (match_operand:SI 3 "register_operand") |
| 3073 |
(szext:SI (mem:BW2 (plus:SI |
| 3074 |
(match_operand:SI 4 "register_operand") |
| 3075 |
(match_operand:SI 2 "register_operand"))))) |
| 3076 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 3077 |
"(REGNO (operands[0]) == REGNO (operands[3]) |
| 3078 |
|| peep2_reg_dead_p (3, operands[0])) |
| 3079 |
&& (REGNO (operands[0]) == REGNO (operands[1]) |
| 3080 |
|| peep2_reg_dead_p (3, operands[0])) |
| 3081 |
&& (rtx_equal_p (operands[2], operands[0]) |
| 3082 |
|| rtx_equal_p (operands[4], operands[0]))" |
| 3083 |
[(parallel |
| 3084 |
[(set |
| 3085 |
(match_dup 3) |
| 3086 |
(szext:SI |
| 3087 |
(mem:BW2 (plus:SI (szext:SI (mem:BW (match_dup 1))) (match_dup 2))))) |
| 3088 |
(clobber (reg:CC CRIS_CC0_REGNUM))])] |
| 3089 |
{ |
| 3090 |
if (! rtx_equal_p (operands[4], operands[0])) |
| 3091 |
operands[2] = operands[4]; |
| 3092 |
}) |
| 3093 |
|
| 3094 |
;; Add operations with similar or same decomposed addresses here, when |
| 3095 |
;; encountered - but only when covered by mentioned test-cases for at |
| 3096 |
;; least one of the cases generalized in the pattern. |
| 3097 |
|
| 3098 |
;; Local variables: |
| 3099 |
;; mode:emacs-lisp |
| 3100 |
;; comment-start: ";; " |
| 3101 |
;; eval: (set-syntax-table (copy-sequence (syntax-table))) |
| 3102 |
;; eval: (modify-syntax-entry ?[ "(]") |
| 3103 |
;; eval: (modify-syntax-entry ?] ")[") |
| 3104 |
;; eval: (modify-syntax-entry ?{ "(}") |
| 3105 |
;; eval: (modify-syntax-entry ?} "){") |
| 3106 |
;; eval: (setq indent-tabs-mode t) |
| 3107 |
;; End: |