| 1 |
;; microblaze.md -- Machine description for Xilinx MicroBlaze processors. |
| 2 |
;; Copyright (C) 2009-2025 Free Software Foundation, Inc. |
| 3 |
|
| 4 |
;; Contributed by Michael Eager <[email protected]>. |
| 5 |
|
| 6 |
;; This file is part of GCC. |
| 7 |
|
| 8 |
;; GCC is free software; you can redistribute it and/or modify |
| 9 |
;; it under the terms of the GNU General Public License as published by |
| 10 |
;; the Free Software Foundation; either version 3, or (at your option) |
| 11 |
;; any later version. |
| 12 |
|
| 13 |
;; GCC is distributed in the hope that it will be useful, |
| 14 |
;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
;; GNU General Public License for more details. |
| 17 |
|
| 18 |
;; You should have received a copy of the GNU General Public License |
| 19 |
;; along with GCC; see the file COPYING3. If not see |
| 20 |
;; <http://www.gnu.org/licenses/>. */ |
| 21 |
|
| 22 |
(include "constraints.md") |
| 23 |
(include "predicates.md") |
| 24 |
(include "iterators.md") |
| 25 |
|
| 26 |
;;---------------------------------------------------- |
| 27 |
;; Constants |
| 28 |
;;---------------------------------------------------- |
| 29 |
(define_constants [ |
| 30 |
(R_SP 1) ;; Stack pointer reg |
| 31 |
(R_SR 15) ;; Sub-routine return addr reg |
| 32 |
(R_IR 14) ;; Interrupt return addr reg |
| 33 |
(R_DR 16) ;; Debug trap return addr reg |
| 34 |
(R_ER 17) ;; Exception return addr reg |
| 35 |
(R_TMP 18) ;; Assembler temporary reg |
| 36 |
(R_GOT 20) ;; GOT ptr reg |
| 37 |
(MB_PIPE_3 0) ;; Microblaze 3-stage pipeline |
| 38 |
(MB_PIPE_5 1) ;; Microblaze 5-stage pipeline |
| 39 |
(UNSPEC_SET_GOT 101) ;; |
| 40 |
(UNSPEC_GOTOFF 102) ;; GOT offset |
| 41 |
(UNSPEC_PLT 103) ;; jump table |
| 42 |
(UNSPEC_CMP 104) ;; signed compare |
| 43 |
(UNSPEC_CMPU 105) ;; unsigned compare |
| 44 |
(UNSPEC_TLS 106) ;; jump table |
| 45 |
(UNSPEC_SET_TEXT 107) ;; set text start |
| 46 |
(UNSPEC_TEXT 108) ;; data text relative |
| 47 |
(UNSPECV_CAS_BOOL 201) ;; compare and swap (bool) |
| 48 |
(UNSPECV_CAS_VAL 202) ;; compare and swap (val) |
| 49 |
(UNSPECV_CAS_MEM 203) ;; compare and swap (mem) |
| 50 |
(UNSPECV_ATOMIC_FETCH_OP 204) ;; atomic fetch op |
| 51 |
]) |
| 52 |
|
| 53 |
(define_c_enum "unspec" [ |
| 54 |
UNSPEC_IPREFETCH |
| 55 |
]) |
| 56 |
|
| 57 |
;;---------------------------------------------------- |
| 58 |
;; Instruction Attributes |
| 59 |
;;---------------------------------------------------- |
| 60 |
|
| 61 |
;; Classification of each insn. |
| 62 |
;; branch conditional branch |
| 63 |
;; jump unconditional jump |
| 64 |
;; call unconditional call |
| 65 |
;; load load instruction(s) |
| 66 |
;; store store instruction(s) |
| 67 |
;; move data movement within same register set |
| 68 |
;; arith integer arithmetic instruction |
| 69 |
;; darith double precision integer arithmetic instructions |
| 70 |
;; imul integer multiply |
| 71 |
;; idiv integer divide |
| 72 |
;; icmp integer compare |
| 73 |
;; Xfadd floating point add/subtract |
| 74 |
;; Xfmul floating point multiply |
| 75 |
;; Xfmadd floating point multiply-add |
| 76 |
;; Xfdiv floating point divide |
| 77 |
;; Xfabs floating point absolute value |
| 78 |
;; Xfneg floating point negation |
| 79 |
;; Xfcmp floating point compare |
| 80 |
;; Xfcvt floating point convert |
| 81 |
;; Xfsqrt floating point square root |
| 82 |
;; multi multiword sequence (or user asm statements) |
| 83 |
;; nop no operation |
| 84 |
;; bshift Shift operations |
| 85 |
|
| 86 |
(define_attr "type" |
| 87 |
"unknown,branch,jump,call,load,store,move,arith,darith,imul,idiv,icmp,multi,nop,no_delay_arith,no_delay_load,no_delay_store,no_delay_imul,no_delay_move,bshift,fadd,frsub,fmul,fdiv,fcmp,fsl,fsqrt,fcvt,trap,atomic" |
| 88 |
(const_string "unknown")) |
| 89 |
|
| 90 |
;; Main data type used by the insn |
| 91 |
(define_attr "mode" "unknown,none,QI,HI,SI,DI,SF,DF" (const_string "unknown")) |
| 92 |
|
| 93 |
;; # instructions (4 bytes each) |
| 94 |
(define_attr "length" "" (const_int 4)) |
| 95 |
|
| 96 |
(define_code_iterator any_return [return simple_return]) |
| 97 |
|
| 98 |
;; <optab> expands to the name of the optab for a particular code. |
| 99 |
(define_code_attr optab [(return "return") |
| 100 |
(simple_return "simple_return")]) |
| 101 |
|
| 102 |
|
| 103 |
;;---------------------------------------------------- |
| 104 |
;; Attribute describing the processor. |
| 105 |
;;---------------------------------------------------- |
| 106 |
|
| 107 |
;; Describe a user's asm statement. |
| 108 |
(define_asm_attributes |
| 109 |
[(set_attr "type" "multi")]) |
| 110 |
|
| 111 |
;; whether or not generating calls to position independent functions |
| 112 |
(define_attr "abicalls" "no,yes" |
| 113 |
(const (symbol_ref "microblaze_abicalls_attr"))) |
| 114 |
|
| 115 |
;;---------------------------------------------------------------- |
| 116 |
;; Microblaze DFA Pipeline description |
| 117 |
;;---------------------------------------------------------------- |
| 118 |
|
| 119 |
;;----------------------------------------------------------------- |
| 120 |
/* |
| 121 |
This is description of pipeline hazards based on DFA. The |
| 122 |
following constructions can be used for this: |
| 123 |
|
| 124 |
o define_cpu_unit string [string]) describes a cpu functional unit |
| 125 |
(separated by comma). |
| 126 |
|
| 127 |
1st operand: Names of cpu function units. |
| 128 |
2nd operand: Name of automaton (see comments for |
| 129 |
DEFINE_AUTOMATON). |
| 130 |
|
| 131 |
All define_reservations and define_cpu_units should have unique |
| 132 |
names which cannot be "nothing". |
| 133 |
|
| 134 |
o (exclusion_set string string) means that each CPU function unit |
| 135 |
in the first string cannot be reserved simultaneously with each |
| 136 |
unit whose name is in the second string and vise versa. CPU |
| 137 |
units in the string are separated by commas. For example, it is |
| 138 |
useful for description CPU with fully pipelined floating point |
| 139 |
functional unit which can execute simultaneously only single |
| 140 |
floating point insns or only double floating point insns. |
| 141 |
|
| 142 |
o (presence_set string string) means that each CPU function unit in |
| 143 |
the first string cannot be reserved unless at least one of units |
| 144 |
whose names are in the second string is reserved. This is an |
| 145 |
asymmetric relation. CPU units in the string are separated by |
| 146 |
commas. For example, it is useful for description that slot1 is |
| 147 |
reserved after slot0 reservation for a VLIW processor. |
| 148 |
|
| 149 |
o (absence_set string string) means that each CPU function unit in |
| 150 |
the first string cannot be reserved only if each unit whose name |
| 151 |
is in the second string is not reserved. This is an asymmetric |
| 152 |
relation (actually exclusion set is analogous to this one but it |
| 153 |
is symmetric). CPU units in the string are separated by commas. |
| 154 |
For example, it is useful for description that slot0 cannot be |
| 155 |
reserved after slot1 or slot2 reservation for a VLIW processor. |
| 156 |
|
| 157 |
o (define_bypass number out_insn_names in_insn_names) names bypass with |
| 158 |
given latency (the first number) from insns given by the first |
| 159 |
string (see define_insn_reservation) into insns given by the |
| 160 |
second string. Insn names in the strings are separated by |
| 161 |
commas. |
| 162 |
|
| 163 |
o (define_automaton string) describes names of an automaton |
| 164 |
generated and used for pipeline hazards recognition. The names |
| 165 |
are separated by comma. Actually it is possibly to generate the |
| 166 |
single automaton but unfortunately it can be very large. If we |
| 167 |
use more one automata, the summary size of the automata usually |
| 168 |
is less than the single one. The automaton name is used in |
| 169 |
define_cpu_unit. All automata should have unique names. |
| 170 |
|
| 171 |
o (define_reservation string string) names reservation (the first |
| 172 |
string) of cpu functional units (the 2nd string). Sometimes unit |
| 173 |
reservations for different insns contain common parts. In such |
| 174 |
case, you describe common part and use one its name (the 1st |
| 175 |
parameter) in regular expression in define_insn_reservation. All |
| 176 |
define_reservations, define results and define_cpu_units should |
| 177 |
have unique names which cannot be "nothing". |
| 178 |
|
| 179 |
o (define_insn_reservation name default_latency condition regexpr) |
| 180 |
describes reservation of cpu functional units (the 3nd operand) |
| 181 |
for instruction which is selected by the condition (the 2nd |
| 182 |
parameter). The first parameter is used for output of debugging |
| 183 |
information. The reservations are described by a regular |
| 184 |
expression according the following syntax: |
| 185 |
|
| 186 |
regexp = regexp "," oneof |
| 187 |
| oneof |
| 188 |
|
| 189 |
oneof = oneof "|" allof |
| 190 |
| allof |
| 191 |
|
| 192 |
allof = allof "+" repeat |
| 193 |
| repeat |
| 194 |
|
| 195 |
repeat = element "*" number |
| 196 |
| element |
| 197 |
|
| 198 |
element = cpu_function_name |
| 199 |
| reservation_name |
| 200 |
| result_name |
| 201 |
| "nothing" |
| 202 |
| "(" regexp ")" |
| 203 |
|
| 204 |
1. "," is used for describing start of the next cycle in |
| 205 |
reservation. |
| 206 |
|
| 207 |
2. "|" is used for describing the reservation described by the |
| 208 |
first regular expression *or* the reservation described by |
| 209 |
the second regular expression *or* etc. |
| 210 |
|
| 211 |
3. "+" is used for describing the reservation described by the |
| 212 |
first regular expression *and* the reservation described by |
| 213 |
the second regular expression *and* etc. |
| 214 |
|
| 215 |
4. "*" is used for convenience and simply means sequence in |
| 216 |
which the regular expression are repeated NUMBER times with |
| 217 |
cycle advancing (see ","). |
| 218 |
|
| 219 |
5. cpu function unit name which means reservation. |
| 220 |
|
| 221 |
6. reservation name -- see define_reservation. |
| 222 |
|
| 223 |
7. string "nothing" means no units reservation. |
| 224 |
|
| 225 |
*/ |
| 226 |
;;----------------------------------------------------------------- |
| 227 |
|
| 228 |
|
| 229 |
;;---------------------------------------------------------------- |
| 230 |
;; Microblaze 5-stage pipeline description (v5.00.a and later) |
| 231 |
;;---------------------------------------------------------------- |
| 232 |
|
| 233 |
(define_automaton "mbpipe_5") |
| 234 |
(define_cpu_unit "mb_issue,mb_iu,mb_wb,mb_fpu,mb_fpu_2,mb_mul,mb_mul_2,mb_div,mb_div_2,mb_bs,mb_bs_2" "mbpipe_5") |
| 235 |
|
| 236 |
(define_insn_reservation "mb-integer" 1 |
| 237 |
(and (eq_attr "type" "branch,jump,call,arith,darith,icmp,nop,no_delay_arith") |
| 238 |
(eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_5))) |
| 239 |
"mb_issue,mb_iu,mb_wb") |
| 240 |
|
| 241 |
(define_insn_reservation "mb-special-move" 2 |
| 242 |
(and (eq_attr "type" "move") |
| 243 |
(eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_5))) |
| 244 |
"mb_issue,mb_iu*2,mb_wb") |
| 245 |
|
| 246 |
(define_insn_reservation "mb-mem-load" 3 |
| 247 |
(and (eq_attr "type" "load,no_delay_load") |
| 248 |
(eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_5))) |
| 249 |
"mb_issue,mb_iu,mb_wb") |
| 250 |
|
| 251 |
(define_insn_reservation "mb-mem-store" 1 |
| 252 |
(and (eq_attr "type" "store,no_delay_store") |
| 253 |
(eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_5))) |
| 254 |
"mb_issue,mb_iu,mb_wb") |
| 255 |
|
| 256 |
(define_insn_reservation "mb-mul" 3 |
| 257 |
(and (eq_attr "type" "imul,no_delay_imul") |
| 258 |
(eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_5))) |
| 259 |
"mb_issue,mb_mul,mb_mul_2*2,mb_wb") |
| 260 |
|
| 261 |
(define_insn_reservation "mb-div" 34 |
| 262 |
(and (eq_attr "type" "idiv") |
| 263 |
(eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_5))) |
| 264 |
"mb_issue,mb_div,mb_div_2*33,mb_wb") |
| 265 |
|
| 266 |
(define_insn_reservation "mb-bs" 2 |
| 267 |
(and (eq_attr "type" "bshift") |
| 268 |
(eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_5))) |
| 269 |
"mb_issue,mb_bs,mb_bs_2,mb_wb") |
| 270 |
|
| 271 |
(define_insn_reservation "mb-fpu-add-sub-mul" 6 |
| 272 |
(and (eq_attr "type" "fadd,frsub,fmul") |
| 273 |
(eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_5))) |
| 274 |
"mb_issue,mb_fpu,mb_fpu_2*5,mb_wb") |
| 275 |
|
| 276 |
(define_insn_reservation "mb-fpu-fcmp" 3 |
| 277 |
(and (eq_attr "type" "fcmp") |
| 278 |
(eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_5))) |
| 279 |
"mb_issue,mb_fpu,mb_fpu*2,mb_wb") |
| 280 |
|
| 281 |
(define_insn_reservation "mb-fpu-div" 30 |
| 282 |
(and (eq_attr "type" "fdiv") |
| 283 |
(eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_5))) |
| 284 |
"mb_issue,mb_fpu,mb_fpu_2*29,mb_wb") |
| 285 |
|
| 286 |
(define_insn_reservation "mb-fpu-sqrt" 30 |
| 287 |
(and (eq_attr "type" "fsqrt") |
| 288 |
(eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_5))) |
| 289 |
"mb_issue,mb_fpu,mb_fpu_2*29,mb_wb") |
| 290 |
|
| 291 |
(define_insn_reservation "mb-fpu-fcvt" 4 |
| 292 |
(and (eq_attr "type" "fcvt") |
| 293 |
(eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_5))) |
| 294 |
"mb_issue,mb_fpu,mb_fpu_2*3,mb_wb") |
| 295 |
|
| 296 |
;;---------------------------------------------------------------- |
| 297 |
;; Microblaze 3-stage pipeline description (for v4.00.a and earlier) |
| 298 |
;;---------------------------------------------------------------- |
| 299 |
|
| 300 |
(define_automaton "mbpipe_3") |
| 301 |
(define_cpu_unit "mb3_iu" "mbpipe_3") |
| 302 |
|
| 303 |
(define_insn_reservation "mb3-integer" 1 |
| 304 |
(and (eq_attr "type" "branch,jump,call,arith,darith,icmp,nop,no_delay_arith") |
| 305 |
(eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_3))) |
| 306 |
"mb3_iu") |
| 307 |
|
| 308 |
(define_insn_reservation "mb3-special-move" 2 |
| 309 |
(and (eq_attr "type" "move") |
| 310 |
(eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_3))) |
| 311 |
"mb3_iu*2") |
| 312 |
|
| 313 |
(define_insn_reservation "mb3-mem-load" 2 |
| 314 |
(and (eq_attr "type" "load,no_delay_load") |
| 315 |
(eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_3))) |
| 316 |
"mb3_iu") |
| 317 |
|
| 318 |
(define_insn_reservation "mb3-mem-store" 1 |
| 319 |
(and (eq_attr "type" "store,no_delay_store") |
| 320 |
(eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_3))) |
| 321 |
"mb3_iu") |
| 322 |
|
| 323 |
(define_insn_reservation "mb3-mul" 3 |
| 324 |
(and (eq_attr "type" "imul,no_delay_imul") |
| 325 |
(eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_3))) |
| 326 |
"mb3_iu") |
| 327 |
|
| 328 |
(define_insn_reservation "mb3-div" 34 |
| 329 |
(and (eq_attr "type" "idiv") |
| 330 |
(eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_3))) |
| 331 |
"mb3_iu") |
| 332 |
|
| 333 |
(define_insn_reservation "mb3-bs" 2 |
| 334 |
(and (eq_attr "type" "bshift") |
| 335 |
(eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_3))) |
| 336 |
"mb3_iu") |
| 337 |
|
| 338 |
(define_insn_reservation "mb3-fpu-add-sub-mul" 6 |
| 339 |
(and (eq_attr "type" "fadd,frsub,fmul") |
| 340 |
(eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_3))) |
| 341 |
"mb3_iu") |
| 342 |
|
| 343 |
(define_insn_reservation "mb3-fpu-fcmp" 3 |
| 344 |
(and (eq_attr "type" "fcmp") |
| 345 |
(eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_3))) |
| 346 |
"mb3_iu") |
| 347 |
|
| 348 |
(define_insn_reservation "mb3-fpu-div" 30 |
| 349 |
(and (eq_attr "type" "fdiv") |
| 350 |
(eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_3))) |
| 351 |
"mb3_iu") |
| 352 |
|
| 353 |
(define_insn_reservation "mb3-fpu-sqrt" 30 |
| 354 |
(and (eq_attr "type" "fsqrt") |
| 355 |
(eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_3))) |
| 356 |
"mb3_iu") |
| 357 |
|
| 358 |
(define_insn_reservation "mb3-fpu-fcvt" 4 |
| 359 |
(and (eq_attr "type" "fcvt") |
| 360 |
(eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_3))) |
| 361 |
"mb3_iu") |
| 362 |
|
| 363 |
(automata_option "v") |
| 364 |
(automata_option "time") |
| 365 |
(automata_option "progress") |
| 366 |
|
| 367 |
(define_insn "bswapsi2" |
| 368 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 369 |
(bswap:SI (match_operand:SI 1 "register_operand" "r")))] |
| 370 |
"TARGET_REORDER" |
| 371 |
"swapb %0, %1" |
| 372 |
[(set_attr "type" "no_delay_arith") |
| 373 |
(set_attr "mode" "SI") |
| 374 |
(set_attr "length" "4")] |
| 375 |
) |
| 376 |
|
| 377 |
(define_insn "bswaphi2" |
| 378 |
[(set (match_operand:HI 0 "register_operand" "=r") |
| 379 |
(bswap:HI (match_operand:HI 1 "register_operand" "r")))] |
| 380 |
"TARGET_REORDER" |
| 381 |
"swapb %0, %1 |
| 382 |
swaph %0, %0" |
| 383 |
[(set_attr "type" "no_delay_arith") |
| 384 |
(set_attr "mode" "SI") |
| 385 |
(set_attr "length" "8")] |
| 386 |
) |
| 387 |
|
| 388 |
;;---------------------------------------------------------------- |
| 389 |
;; Microblaze delay slot description |
| 390 |
;;---------------------------------------------------------------- |
| 391 |
(define_delay (eq_attr "type" "branch,call,jump") |
| 392 |
[(and (eq_attr "type" "!branch,call,jump,icmp,multi,no_delay_arith,no_delay_load,no_delay_store,no_delay_imul,no_delay_move,darith") |
| 393 |
(ior (not (match_test "microblaze_no_unsafe_delay")) |
| 394 |
(eq_attr "type" "!fadd,frsub,fmul,fdiv,fcmp,store,load") |
| 395 |
)) |
| 396 |
(nil) (nil)]) |
| 397 |
|
| 398 |
|
| 399 |
;;---------------------------------------------------------------- |
| 400 |
;; Microblaze FPU |
| 401 |
;;---------------------------------------------------------------- |
| 402 |
|
| 403 |
(define_insn "addsf3" |
| 404 |
[(set (match_operand:SF 0 "register_operand" "=d") |
| 405 |
(plus:SF (match_operand:SF 1 "register_operand" "d") |
| 406 |
(match_operand:SF 2 "register_operand" "d")))] |
| 407 |
"TARGET_HARD_FLOAT" |
| 408 |
"fadd\t%0,%1,%2" |
| 409 |
[(set_attr "type" "fadd") |
| 410 |
(set_attr "mode" "SF") |
| 411 |
(set_attr "length" "4")]) |
| 412 |
|
| 413 |
(define_insn "subsf3" |
| 414 |
[(set (match_operand:SF 0 "register_operand" "=d") |
| 415 |
(minus:SF (match_operand:SF 1 "register_operand" "d") |
| 416 |
(match_operand:SF 2 "register_operand" "d")))] |
| 417 |
"TARGET_HARD_FLOAT" |
| 418 |
"frsub\t%0,%2,%1" |
| 419 |
[(set_attr "type" "frsub") |
| 420 |
(set_attr "mode" "SF") |
| 421 |
(set_attr "length" "4")]) |
| 422 |
|
| 423 |
(define_insn "mulsf3" |
| 424 |
[(set (match_operand:SF 0 "register_operand" "=d") |
| 425 |
(mult:SF (match_operand:SF 1 "register_operand" "d") |
| 426 |
(match_operand:SF 2 "register_operand" "d")))] |
| 427 |
"TARGET_HARD_FLOAT" |
| 428 |
"fmul\t%0,%1,%2" |
| 429 |
[(set_attr "type" "fmul") |
| 430 |
(set_attr "mode" "SF") |
| 431 |
(set_attr "length" "4")]) |
| 432 |
|
| 433 |
|
| 434 |
(define_insn "divsf3" |
| 435 |
[(set (match_operand:SF 0 "register_operand" "=d") |
| 436 |
(div:SF (match_operand:SF 1 "register_operand" "d") |
| 437 |
(match_operand:SF 2 "register_operand" "d")))] |
| 438 |
"TARGET_HARD_FLOAT" |
| 439 |
"fdiv\t%0,%2,%1" |
| 440 |
[(set_attr "type" "fdiv") |
| 441 |
(set_attr "mode" "SF") |
| 442 |
(set_attr "length" "4")]) |
| 443 |
|
| 444 |
(define_insn "sqrtsf2" |
| 445 |
[(set (match_operand:SF 0 "register_operand" "=d") |
| 446 |
(sqrt:SF (match_operand:SF 1 "register_operand" "d")))] |
| 447 |
"TARGET_HARD_FLOAT && TARGET_FLOAT_SQRT" |
| 448 |
"fsqrt\t%0,%1" |
| 449 |
[(set_attr "type" "fsqrt") |
| 450 |
(set_attr "mode" "SF") |
| 451 |
(set_attr "length" "4")]) |
| 452 |
|
| 453 |
(define_insn "floatsisf2" |
| 454 |
[(set (match_operand:SF 0 "register_operand" "=d") |
| 455 |
(float:SF (match_operand:SI 1 "register_operand" "d")))] |
| 456 |
"TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT" |
| 457 |
"flt\t%0,%1" |
| 458 |
[(set_attr "type" "fcvt") |
| 459 |
(set_attr "mode" "SF") |
| 460 |
(set_attr "length" "4")]) |
| 461 |
|
| 462 |
(define_insn "fix_truncsfsi2" |
| 463 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 464 |
(fix:SI (match_operand:SF 1 "register_operand" "d")))] |
| 465 |
"TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT" |
| 466 |
"fint\t%0,%1" |
| 467 |
[(set_attr "type" "fcvt") |
| 468 |
(set_attr "mode" "SF") |
| 469 |
(set_attr "length" "4")]) |
| 470 |
|
| 471 |
;;---------------------------------------------------------------- |
| 472 |
;; Add |
| 473 |
;;---------------------------------------------------------------- |
| 474 |
|
| 475 |
;; Add 2 SImode integers [ src1 = reg ; src2 = arith ; dest = reg ] |
| 476 |
;; Leave carry as is |
| 477 |
(define_insn "addsi3" |
| 478 |
[(set (match_operand:SI 0 "register_operand" "=d,d,d") |
| 479 |
(plus:SI (match_operand:SI 1 "reg_or_0_operand" "%dJ,dJ,dJ") |
| 480 |
(match_operand:SI 2 "arith_plus_operand" "d,I,i")))] |
| 481 |
"" |
| 482 |
"@ |
| 483 |
addk\t%0,%z1,%2 |
| 484 |
addik\t%0,%z1,%2 |
| 485 |
addik\t%0,%z1,%2" |
| 486 |
[(set_attr "type" "arith,arith,no_delay_arith") |
| 487 |
(set_attr "mode" "SI,SI,SI") |
| 488 |
(set_attr "length" "4,4,8")]) |
| 489 |
|
| 490 |
;;---------------------------------------------------------------- |
| 491 |
;; Double Precision Additions |
| 492 |
;;---------------------------------------------------------------- |
| 493 |
|
| 494 |
;; reg_DI_dest = reg_DI_src1 + DI_src2 |
| 495 |
|
| 496 |
;; Adding 2 DI operands in register or reg/imm |
| 497 |
|
| 498 |
(define_insn "adddi3" |
| 499 |
[(set (match_operand:DI 0 "register_operand" "=d,d,d") |
| 500 |
(plus:DI (match_operand:DI 1 "register_operand" "%d,d,d") |
| 501 |
(match_operand:DI 2 "arith_operand32" "d,P,N")))] |
| 502 |
"" |
| 503 |
"@ |
| 504 |
add\t%L0,%L1,%L2\;addc\t%M0,%M1,%M2 |
| 505 |
addi\t%L0,%L1,%2\;addc\t%M0,%M1,r0 |
| 506 |
addi\t%L0,%L1,%2\;addc\t%M0,%M1,r0\;addi\t%M0,%M0,-1" |
| 507 |
[(set_attr "type" "darith") |
| 508 |
(set_attr "mode" "DI") |
| 509 |
(set_attr "length" "8,8,12")]) |
| 510 |
|
| 511 |
;;---------------------------------------------------------------- |
| 512 |
;; Subtraction |
| 513 |
;;---------------------------------------------------------------- |
| 514 |
|
| 515 |
(define_insn "subsi3" |
| 516 |
[(set (match_operand:SI 0 "register_operand" "=d,d") |
| 517 |
(minus:SI (match_operand:SI 1 "arith_operand" "d,d") |
| 518 |
(match_operand:SI 2 "arith_operand" "d,n")))] |
| 519 |
"" |
| 520 |
"@ |
| 521 |
rsubk\t%0,%2,%z1 |
| 522 |
addik\t%0,%z1,-%2" |
| 523 |
[(set_attr "type" "arith,no_delay_arith") |
| 524 |
(set_attr "mode" "SI") |
| 525 |
(set_attr "length" "4,8")]) |
| 526 |
|
| 527 |
(define_insn "iprefetch" |
| 528 |
[(unspec [(match_operand:SI 0 "const_int_operand" "n")] UNSPEC_IPREFETCH) |
| 529 |
(clobber (mem:BLK (scratch)))] |
| 530 |
"TARGET_PREFETCH" |
| 531 |
{ |
| 532 |
operands[2] = gen_rtx_REG (SImode, MB_ABI_ASM_TEMP_REGNUM); |
| 533 |
return "mfs\t%2,rpc\n\twic\t%2,r0"; |
| 534 |
} |
| 535 |
[(set_attr "type" "arith") |
| 536 |
(set_attr "mode" "SI") |
| 537 |
(set_attr "length" "8")]) |
| 538 |
|
| 539 |
;;---------------------------------------------------------------- |
| 540 |
;; Double Precision Subtraction |
| 541 |
;;---------------------------------------------------------------- |
| 542 |
|
| 543 |
(define_insn "subdi3" |
| 544 |
[(set (match_operand:DI 0 "register_operand" "=&d") |
| 545 |
(minus:DI (match_operand:DI 1 "register_operand" "d") |
| 546 |
(match_operand:DI 2 "arith_operand32" "d")))] |
| 547 |
"" |
| 548 |
"rsub\t%L0,%L2,%L1\;rsubc\t%M0,%M2,%M1" |
| 549 |
[(set_attr "type" "darith") |
| 550 |
(set_attr "mode" "DI") |
| 551 |
(set_attr "length" "8")]) |
| 552 |
|
| 553 |
|
| 554 |
;;---------------------------------------------------------------- |
| 555 |
;; Multiplication |
| 556 |
;;---------------------------------------------------------------- |
| 557 |
|
| 558 |
(define_insn "mulsi3" |
| 559 |
[(set (match_operand:SI 0 "register_operand" "=d,d,d") |
| 560 |
(mult:SI (match_operand:SI 1 "register_operand" "d,d,d") |
| 561 |
(match_operand:SI 2 "arith_operand" "d,I,i")))] |
| 562 |
"!TARGET_SOFT_MUL" |
| 563 |
"@ |
| 564 |
mul\t%0,%1,%2 |
| 565 |
muli\t%0,%1,%2 |
| 566 |
muli\t%0,%1,%2" |
| 567 |
[(set_attr "type" "imul,imul,no_delay_imul") |
| 568 |
(set_attr "mode" "SI") |
| 569 |
(set_attr "length" "4,4,8")]) |
| 570 |
|
| 571 |
(define_insn "mulsidi3" |
| 572 |
[(set (match_operand:DI 0 "register_operand" "=&d") |
| 573 |
(mult:DI |
| 574 |
(sign_extend:DI (match_operand:SI 1 "register_operand" "d")) |
| 575 |
(sign_extend:DI (match_operand:SI 2 "register_operand" "d"))))] |
| 576 |
"!TARGET_SOFT_MUL && TARGET_MULTIPLY_HIGH" |
| 577 |
"mul\t%L0,%1,%2\;mulh\t%M0,%1,%2" |
| 578 |
[(set_attr "type" "no_delay_arith") |
| 579 |
(set_attr "mode" "DI") |
| 580 |
(set_attr "length" "8")]) |
| 581 |
|
| 582 |
(define_insn "umulsidi3" |
| 583 |
[(set (match_operand:DI 0 "register_operand" "=&d") |
| 584 |
(mult:DI |
| 585 |
(zero_extend:DI (match_operand:SI 1 "register_operand" "d")) |
| 586 |
(zero_extend:DI (match_operand:SI 2 "register_operand" "d"))))] |
| 587 |
"!TARGET_SOFT_MUL && TARGET_MULTIPLY_HIGH" |
| 588 |
"mul\t%L0,%1,%2\;mulhu\t%M0,%1,%2" |
| 589 |
[(set_attr "type" "no_delay_arith") |
| 590 |
(set_attr "mode" "DI") |
| 591 |
(set_attr "length" "8")]) |
| 592 |
|
| 593 |
(define_insn "usmulsidi3" |
| 594 |
[(set (match_operand:DI 0 "register_operand" "=&d") |
| 595 |
(mult:DI |
| 596 |
(zero_extend:DI (match_operand:SI 1 "register_operand" "d")) |
| 597 |
(sign_extend:DI (match_operand:SI 2 "register_operand" "d"))))] |
| 598 |
"!TARGET_SOFT_MUL && TARGET_MULTIPLY_HIGH" |
| 599 |
"mul\t%L0,%1,%2\;mulhsu\t%M0,%2,%1" |
| 600 |
[(set_attr "type" "no_delay_arith") |
| 601 |
(set_attr "mode" "DI") |
| 602 |
(set_attr "length" "8")]) |
| 603 |
|
| 604 |
(define_insn "*smulsi3_highpart" |
| 605 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 606 |
(truncate:SI |
| 607 |
(lshiftrt:DI |
| 608 |
(mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d")) |
| 609 |
(sign_extend:DI (match_operand:SI 2 "register_operand" "d"))) |
| 610 |
(const_int 32))))] |
| 611 |
"!TARGET_SOFT_MUL && TARGET_MULTIPLY_HIGH" |
| 612 |
"mulh\t%0,%1,%2" |
| 613 |
[(set_attr "type" "imul") |
| 614 |
(set_attr "mode" "SI") |
| 615 |
(set_attr "length" "4")]) |
| 616 |
|
| 617 |
(define_insn "*umulsi3_highpart" |
| 618 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 619 |
(truncate:SI |
| 620 |
(lshiftrt:DI |
| 621 |
(mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "d")) |
| 622 |
(zero_extend:DI (match_operand:SI 2 "register_operand" "d")) |
| 623 |
) |
| 624 |
(const_int 32))))] |
| 625 |
"!TARGET_SOFT_MUL && TARGET_MULTIPLY_HIGH" |
| 626 |
"mulhu\t%0,%1,%2" |
| 627 |
[(set_attr "type" "imul") |
| 628 |
(set_attr "mode" "SI") |
| 629 |
(set_attr "length" "4")]) |
| 630 |
|
| 631 |
(define_insn "*usmulsi3_highpart" |
| 632 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 633 |
(truncate:SI |
| 634 |
(lshiftrt:DI |
| 635 |
(mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "d")) |
| 636 |
(sign_extend:DI (match_operand:SI 2 "register_operand" "d")) |
| 637 |
) |
| 638 |
(const_int 32))))] |
| 639 |
"!TARGET_SOFT_MUL && TARGET_MULTIPLY_HIGH" |
| 640 |
"mulhsu\t%0,%2,%1" |
| 641 |
[(set_attr "type" "imul") |
| 642 |
(set_attr "mode" "SI") |
| 643 |
(set_attr "length" "4")]) |
| 644 |
|
| 645 |
|
| 646 |
;;---------------------------------------------------------------- |
| 647 |
;; Division and remainder |
| 648 |
;;---------------------------------------------------------------- |
| 649 |
(define_expand "divsi3" |
| 650 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 651 |
(div:SI (match_operand:SI 1 "register_operand" "d") |
| 652 |
(match_operand:SI 2 "register_operand" "d"))) |
| 653 |
] |
| 654 |
"(!TARGET_SOFT_DIV) || (TARGET_BARREL_SHIFT && TARGET_SMALL_DIVIDES)" |
| 655 |
{ |
| 656 |
if (TARGET_SOFT_DIV && TARGET_BARREL_SHIFT && TARGET_SMALL_DIVIDES) |
| 657 |
{ |
| 658 |
microblaze_expand_divide (operands); |
| 659 |
DONE; |
| 660 |
} |
| 661 |
else if (!TARGET_SOFT_DIV) |
| 662 |
{ |
| 663 |
emit_insn (gen_divsi3_internal (operands[0], operands[1], operands[2])); |
| 664 |
DONE; |
| 665 |
} |
| 666 |
} |
| 667 |
) |
| 668 |
|
| 669 |
|
| 670 |
(define_insn "divsi3_internal" |
| 671 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 672 |
(div:SI (match_operand:SI 1 "register_operand" "d") |
| 673 |
(match_operand:SI 2 "register_operand" "d"))) |
| 674 |
] |
| 675 |
"!TARGET_SOFT_DIV" |
| 676 |
"idiv\t%0,%2,%1" |
| 677 |
[(set_attr "type" "idiv") |
| 678 |
(set_attr "mode" "SI") |
| 679 |
(set_attr "length" "4")] |
| 680 |
) |
| 681 |
|
| 682 |
(define_insn "udivsi3" |
| 683 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 684 |
(udiv:SI (match_operand:SI 1 "register_operand" "d") |
| 685 |
(match_operand:SI 2 "register_operand" "d"))) |
| 686 |
] |
| 687 |
"!TARGET_SOFT_DIV" |
| 688 |
"idivu\t%0,%2,%1" |
| 689 |
[(set_attr "type" "idiv") |
| 690 |
(set_attr "mode" "SI") |
| 691 |
(set_attr "length" "4")]) |
| 692 |
|
| 693 |
(define_peephole2 |
| 694 |
[(set (match_operand:SI 0 "register_operand") |
| 695 |
(fix:SI (match_operand:SF 1 "register_operand"))) |
| 696 |
(set (pc) |
| 697 |
(if_then_else (match_operator 2 "ordered_comparison_operator" |
| 698 |
[(match_operand:SI 3 "register_operand") |
| 699 |
(match_operand:SI 4 "arith_operand")]) |
| 700 |
(label_ref (match_operand 5)) |
| 701 |
(pc)))] |
| 702 |
"TARGET_HARD_FLOAT" |
| 703 |
[(set (match_dup 1) (match_dup 3))] |
| 704 |
|
| 705 |
{ |
| 706 |
rtx condition; |
| 707 |
rtx cmp_op0 = operands[3]; |
| 708 |
rtx cmp_op1 = operands[4]; |
| 709 |
rtx comp_reg = gen_rtx_REG (SImode, MB_ABI_ASM_TEMP_REGNUM); |
| 710 |
|
| 711 |
emit_insn (gen_cstoresf4 (comp_reg, operands[2], |
| 712 |
gen_rtx_REG (SFmode, REGNO (cmp_op0)), |
| 713 |
gen_rtx_REG (SFmode, REGNO (cmp_op1)))); |
| 714 |
condition = gen_rtx_NE (SImode, comp_reg, const0_rtx); |
| 715 |
emit_jump_insn (gen_condjump (condition, operands[5])); |
| 716 |
} |
| 717 |
) |
| 718 |
|
| 719 |
;;---------------------------------------------------------------- |
| 720 |
;; Negation and one's complement |
| 721 |
;;---------------------------------------------------------------- |
| 722 |
|
| 723 |
(define_insn "negsi2" |
| 724 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 725 |
(neg:SI (match_operand:SI 1 "register_operand" "d")))] |
| 726 |
"" |
| 727 |
"rsubk\t%0,%1,r0" |
| 728 |
[(set_attr "type" "arith") |
| 729 |
(set_attr "mode" "SI") |
| 730 |
(set_attr "length" "4")]) |
| 731 |
|
| 732 |
(define_insn "negdi2" |
| 733 |
[(set (match_operand:DI 0 "register_operand" "=d") |
| 734 |
(neg:DI (match_operand:DI 1 "register_operand" "d")))] |
| 735 |
"" |
| 736 |
"rsub\t%L0,%L1,r0\;rsubc\t%M0,%M1,r0" |
| 737 |
[(set_attr "type" "darith") |
| 738 |
(set_attr "mode" "DI") |
| 739 |
(set_attr "length" "8")]) |
| 740 |
|
| 741 |
|
| 742 |
(define_insn "one_cmplsi2" |
| 743 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 744 |
(not:SI (match_operand:SI 1 "register_operand" "d")))] |
| 745 |
"" |
| 746 |
"xori\t%0,%1,-1" |
| 747 |
[(set_attr "type" "arith") |
| 748 |
(set_attr "mode" "SI") |
| 749 |
(set_attr "length" "4")]) |
| 750 |
|
| 751 |
(define_insn "*one_cmpldi2" |
| 752 |
[(set (match_operand:DI 0 "register_operand" "=d") |
| 753 |
(not:DI (match_operand:DI 1 "register_operand" "d")))] |
| 754 |
"" |
| 755 |
"nor\t%M0,r0,%M1\;nor\t%L0,r0,%L1" |
| 756 |
[(set_attr "type" "darith") |
| 757 |
(set_attr "mode" "DI") |
| 758 |
(set_attr "length" "8")] |
| 759 |
) |
| 760 |
|
| 761 |
(define_split |
| 762 |
[(set (match_operand:DI 0 "register_operand" "") |
| 763 |
(not:DI (match_operand:DI 1 "register_operand" "")))] |
| 764 |
"reload_completed |
| 765 |
&& GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0])) |
| 766 |
&& GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))" |
| 767 |
|
| 768 |
[(set (subreg:SI (match_dup 0) 0) (not:SI (subreg:SI (match_dup 1) 0))) |
| 769 |
(set (subreg:SI (match_dup 0) 4) (not:SI (subreg:SI (match_dup 1) 4)))] |
| 770 |
"") |
| 771 |
|
| 772 |
|
| 773 |
;;---------------------------------------------------------------- |
| 774 |
;; Logical |
| 775 |
;;---------------------------------------------------------------- |
| 776 |
|
| 777 |
(define_insn "andsi3" |
| 778 |
[(set (match_operand:SI 0 "register_operand" "=d,d,d,d") |
| 779 |
(and:SI (match_operand:SI 1 "arith_operand" "%d,d,d,d") |
| 780 |
(match_operand:SI 2 "arith_operand" "d,I,i,M")))] |
| 781 |
"" |
| 782 |
"@ |
| 783 |
and\t%0,%1,%2 |
| 784 |
andi\t%0,%1,%2 #and1 |
| 785 |
andi\t%0,%1,%2 #and2 |
| 786 |
andi\t%0,%1,%2 #and3" |
| 787 |
[(set_attr "type" "arith,arith,no_delay_arith,no_delay_arith") |
| 788 |
(set_attr "mode" "SI,SI,SI,SI") |
| 789 |
(set_attr "length" "4,8,8,8")]) |
| 790 |
|
| 791 |
|
| 792 |
(define_insn "iorsi3" |
| 793 |
[(set (match_operand:SI 0 "register_operand" "=d,d,d,d") |
| 794 |
(ior:SI (match_operand:SI 1 "arith_operand" "%d,d,d,d") |
| 795 |
(match_operand:SI 2 "arith_operand" "d,I,M,i")))] |
| 796 |
"" |
| 797 |
"@ |
| 798 |
or\t%0,%1,%2 |
| 799 |
ori\t%0,%1,%2 |
| 800 |
ori\t%0,%1,%2 |
| 801 |
ori\t%0,%1,%2" |
| 802 |
[(set_attr "type" "arith,no_delay_arith,no_delay_arith,no_delay_arith") |
| 803 |
(set_attr "mode" "SI,SI,SI,SI") |
| 804 |
(set_attr "length" "4,8,8,8")]) |
| 805 |
|
| 806 |
(define_insn "xorsi3" |
| 807 |
[(set (match_operand:SI 0 "register_operand" "=d,d,d") |
| 808 |
(xor:SI (match_operand:SI 1 "arith_operand" "%d,d,d") |
| 809 |
(match_operand:SI 2 "arith_operand" "d,I,i")))] |
| 810 |
"" |
| 811 |
"@ |
| 812 |
xor\t%0,%1,%2 |
| 813 |
xori\t%0,%1,%2 |
| 814 |
xori\t%0,%1,%2" |
| 815 |
[(set_attr "type" "arith,arith,no_delay_arith") |
| 816 |
(set_attr "mode" "SI,SI,SI") |
| 817 |
(set_attr "length" "4,8,8")]) |
| 818 |
|
| 819 |
;;---------------------------------------------------------------- |
| 820 |
;; Zero extension |
| 821 |
;;---------------------------------------------------------------- |
| 822 |
|
| 823 |
(define_insn "zero_extendhisi2" |
| 824 |
[(set (match_operand:SI 0 "register_operand" "=d,d,d") |
| 825 |
(zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "d,R,m")))] |
| 826 |
"" |
| 827 |
"@ |
| 828 |
andi\t%0,%1,0xffff |
| 829 |
lhu%i1\t%0,%1 |
| 830 |
lhu%i1\t%0,%1" |
| 831 |
[(set_attr "type" "no_delay_arith,load,no_delay_load") |
| 832 |
(set_attr "mode" "SI,SI,SI") |
| 833 |
(set_attr "length" "8,4,8")]) |
| 834 |
|
| 835 |
(define_insn "zero_extendqihi2" |
| 836 |
[(set (match_operand:HI 0 "register_operand" "=d,d,d") |
| 837 |
(zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "d,R,m")))] |
| 838 |
"" |
| 839 |
"@ |
| 840 |
andi\t%0,%1,0x00ff |
| 841 |
lbu%i1\t%0,%1 |
| 842 |
lbu%i1\t%0,%1" |
| 843 |
[(set_attr "type" "arith,load,no_delay_load") |
| 844 |
(set_attr "mode" "HI") |
| 845 |
(set_attr "length" "4,4,8")]) |
| 846 |
|
| 847 |
(define_insn "zero_extendqisi2" |
| 848 |
[(set (match_operand:SI 0 "register_operand" "=d,d,d") |
| 849 |
(zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "d,R,m")))] |
| 850 |
"" |
| 851 |
"@ |
| 852 |
andi\t%0,%1,0x00ff |
| 853 |
lbu%i1\t%0,%1 |
| 854 |
lbu%i1\t%0,%1" |
| 855 |
[(set_attr "type" "arith,load,no_delay_load") |
| 856 |
(set_attr "mode" "SI,SI,SI") |
| 857 |
(set_attr "length" "4,4,8")]) |
| 858 |
|
| 859 |
;;---------------------------------------------------------------- |
| 860 |
;; Sign extension |
| 861 |
;;---------------------------------------------------------------- |
| 862 |
|
| 863 |
;; basic Sign Extend Operations |
| 864 |
|
| 865 |
(define_insn "extendqisi2" |
| 866 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 867 |
(sign_extend:SI (match_operand:QI 1 "register_operand" "d")))] |
| 868 |
"" |
| 869 |
"sext8\t%0,%1" |
| 870 |
[(set_attr "type" "arith") |
| 871 |
(set_attr "mode" "SI") |
| 872 |
(set_attr "length" "4")]) |
| 873 |
|
| 874 |
(define_insn "extendhisi2" |
| 875 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 876 |
(sign_extend:SI (match_operand:HI 1 "register_operand" "d")))] |
| 877 |
"" |
| 878 |
"sext16\t%0,%1" |
| 879 |
[(set_attr "type" "arith") |
| 880 |
(set_attr "mode" "SI") |
| 881 |
(set_attr "length" "4")]) |
| 882 |
|
| 883 |
;; Those for integer source operand are ordered |
| 884 |
;; widest source type first. |
| 885 |
|
| 886 |
(define_insn "extendsidi2" |
| 887 |
[(set (match_operand:DI 0 "register_operand" "=d,d,d") |
| 888 |
(sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,R,m")))] |
| 889 |
"" |
| 890 |
{ |
| 891 |
if (which_alternative == 0) |
| 892 |
output_asm_insn ("addk\t%L0,r0,%1", operands); |
| 893 |
else |
| 894 |
output_asm_insn ("lw%i1\t%L0,%1", operands); |
| 895 |
|
| 896 |
output_asm_insn ("add\t%M0,%L0,%L0", operands); |
| 897 |
output_asm_insn ("addc\t%M0,r0,r0", operands); |
| 898 |
output_asm_insn ("beqi\t%M0,.+8", operands); |
| 899 |
return "addi\t%M0,r0,0xffffffff"; |
| 900 |
} |
| 901 |
[(set_attr "type" "multi,multi,multi") |
| 902 |
(set_attr "mode" "DI") |
| 903 |
(set_attr "length" "20,20,20")]) |
| 904 |
|
| 905 |
;;---------------------------------------------------------------- |
| 906 |
;; Data movement |
| 907 |
;;---------------------------------------------------------------- |
| 908 |
|
| 909 |
;; 64-bit integer moves |
| 910 |
|
| 911 |
;; Unlike most other insns, the move insns can't be split with |
| 912 |
;; different predicates, because register spilling and other parts of |
| 913 |
;; the compiler, have memoized the insn number already. |
| 914 |
|
| 915 |
(define_expand "movdi" |
| 916 |
[(set (match_operand:DI 0 "nonimmediate_operand" "") |
| 917 |
(match_operand:DI 1 "general_operand" ""))] |
| 918 |
"" |
| 919 |
{ |
| 920 |
/* If operands[1] is a constant address illegal for pic, then we need to |
| 921 |
handle it just like microblaze_legitimize_address does. */ |
| 922 |
if (flag_pic && pic_address_needs_scratch (operands[1])) |
| 923 |
{ |
| 924 |
rtx temp = force_reg (DImode, XEXP (XEXP (operands[1], 0), 0)); |
| 925 |
rtx temp2 = XEXP (XEXP (operands[1], 0), 1); |
| 926 |
emit_move_insn (operands[0], gen_rtx_PLUS (DImode, temp, temp2)); |
| 927 |
DONE; |
| 928 |
} |
| 929 |
|
| 930 |
|
| 931 |
if ((reload_in_progress | reload_completed) == 0 |
| 932 |
&& !register_operand (operands[0], DImode) |
| 933 |
&& !register_operand (operands[1], DImode) |
| 934 |
&& (((GET_CODE (operands[1]) != CONST_INT || INTVAL (operands[1]) != 0) |
| 935 |
&& operands[1] != CONST0_RTX (DImode)))) |
| 936 |
{ |
| 937 |
|
| 938 |
rtx temp = force_reg (DImode, operands[1]); |
| 939 |
emit_move_insn (operands[0], temp); |
| 940 |
DONE; |
| 941 |
} |
| 942 |
} |
| 943 |
) |
| 944 |
|
| 945 |
|
| 946 |
|
| 947 |
(define_insn "*movdi_internal" |
| 948 |
[(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,R,o") |
| 949 |
(match_operand:DI 1 "general_operand" " d,i,J,R,o,d,d"))] |
| 950 |
"" |
| 951 |
{ |
| 952 |
switch (which_alternative) |
| 953 |
{ |
| 954 |
case 0: |
| 955 |
return "addk\t%0,%1\n\taddk\t%D0,%d1"; |
| 956 |
case 1: |
| 957 |
return "addik\t%M0,r0,%h1\n\taddik\t%L0,r0,%j1 #li => la"; |
| 958 |
case 2: |
| 959 |
return "addk\t%0,r0,r0\n\taddk\t%D0,r0,r0"; |
| 960 |
case 3: |
| 961 |
case 4: |
| 962 |
if (reg_mentioned_p (operands[0], operands[1])) |
| 963 |
return "lwi\t%D0,%o1\n\tlwi\t%0,%1"; |
| 964 |
else |
| 965 |
return "lwi\t%0,%1\n\tlwi\t%D0,%o1"; |
| 966 |
case 5: |
| 967 |
case 6: |
| 968 |
return "swi\t%1,%0\n\tswi\t%D1,%o0"; |
| 969 |
} |
| 970 |
return "unreachable"; |
| 971 |
} |
| 972 |
[(set_attr "type" "no_delay_move,no_delay_arith,no_delay_arith,no_delay_load,no_delay_load,no_delay_store,no_delay_store") |
| 973 |
(set_attr "mode" "DI") |
| 974 |
(set_attr "length" "8,8,8,8,12,8,12")]) |
| 975 |
|
| 976 |
(define_split |
| 977 |
[(set (match_operand:DI 0 "register_operand" "") |
| 978 |
(match_operand:DI 1 "register_operand" ""))] |
| 979 |
"reload_completed |
| 980 |
&& GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0])) |
| 981 |
&& GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1])) |
| 982 |
&& (REGNO(operands[0]) == (REGNO(operands[1]) + 1))" |
| 983 |
|
| 984 |
[(set (subreg:SI (match_dup 0) 4) (subreg:SI (match_dup 1) 4)) |
| 985 |
(set (subreg:SI (match_dup 0) 0) (subreg:SI (match_dup 1) 0))] |
| 986 |
"") |
| 987 |
|
| 988 |
(define_split |
| 989 |
[(set (match_operand:DI 0 "register_operand" "") |
| 990 |
(match_operand:DI 1 "register_operand" ""))] |
| 991 |
"reload_completed |
| 992 |
&& GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0])) |
| 993 |
&& GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1])) |
| 994 |
&& (REGNO (operands[0]) != (REGNO (operands[1]) + 1))" |
| 995 |
|
| 996 |
[(set (subreg:SI (match_dup 0) 0) (subreg:SI (match_dup 1) 0)) |
| 997 |
(set (subreg:SI (match_dup 0) 4) (subreg:SI (match_dup 1) 4))] |
| 998 |
"") |
| 999 |
|
| 1000 |
;; Unlike most other insns, the move insns can't be split with |
| 1001 |
;; different predicates, because register spilling and other parts of |
| 1002 |
;; the compiler, have memoized the insn number already. |
| 1003 |
|
| 1004 |
(define_expand "movsi" |
| 1005 |
[(set (match_operand:SI 0 "nonimmediate_operand" "") |
| 1006 |
(match_operand:SI 1 "general_operand" ""))] |
| 1007 |
"" |
| 1008 |
{ |
| 1009 |
if (microblaze_expand_move (SImode, operands)) DONE; |
| 1010 |
} |
| 1011 |
) |
| 1012 |
|
| 1013 |
;; Added for status registers |
| 1014 |
(define_insn "movsi_status" |
| 1015 |
[(set (match_operand:SI 0 "register_operand" "=d,d,z") |
| 1016 |
(match_operand:SI 1 "register_operand" "z,d,d"))] |
| 1017 |
"microblaze_is_interrupt_variant ()" |
| 1018 |
"@ |
| 1019 |
mfs\t%0,%1 #mfs |
| 1020 |
addk\t%0,%1,r0 #add movsi |
| 1021 |
mts\t%0,%1 #mts" |
| 1022 |
[(set_attr "type" "move") |
| 1023 |
(set_attr "mode" "SI") |
| 1024 |
(set_attr "length" "12")]) |
| 1025 |
|
| 1026 |
;; This move will be not be moved to delay slot. |
| 1027 |
(define_insn "*movsi_internal3" |
| 1028 |
[(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d") |
| 1029 |
(match_operand:SI 1 "immediate_operand" "J,I,Mnis"))] |
| 1030 |
"(register_operand (operands[0], SImode) && |
| 1031 |
(GET_CODE (operands[1]) == CONST_INT && |
| 1032 |
(INTVAL (operands[1]) <= 32767 && INTVAL (operands[1]) >= -32768)))" |
| 1033 |
"@ |
| 1034 |
addk\t%0,r0,r0 |
| 1035 |
addik\t%0,r0,%1\t# %X1 |
| 1036 |
addik\t%0,r0,%1\t# %X1" |
| 1037 |
[(set_attr "type" "arith,arith,no_delay_arith") |
| 1038 |
(set_attr "mode" "SI") |
| 1039 |
(set_attr "length" "4")]) |
| 1040 |
|
| 1041 |
;; This move may be used for PLT label operand |
| 1042 |
(define_insn "*movsi_internal5_pltop" |
| 1043 |
[(set (match_operand:SI 0 "register_operand" "=d,d") |
| 1044 |
(match_operand:SI 1 "call_insn_operand" ""))] |
| 1045 |
"(register_operand (operands[0], Pmode) && |
| 1046 |
PLT_ADDR_P (operands[1]))" |
| 1047 |
{ |
| 1048 |
gcc_unreachable (); |
| 1049 |
} |
| 1050 |
[(set_attr "type" "load") |
| 1051 |
(set_attr "mode" "SI") |
| 1052 |
(set_attr "length" "4")]) |
| 1053 |
|
| 1054 |
(define_insn "*movsi_internal2" |
| 1055 |
[(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d, d,d,R,m") |
| 1056 |
(match_operand:SI 1 "move_src_operand" " d,I,Mnis,R,m,dJ,dJ"))] |
| 1057 |
"" |
| 1058 |
"@ |
| 1059 |
addk\t%0,%1,r0 |
| 1060 |
addik\t%0,r0,%1\t# %X1 |
| 1061 |
addik\t%0,%a1 |
| 1062 |
lw%i1\t%0,%1 |
| 1063 |
lw%i1\t%0,%1 |
| 1064 |
sw%i0\t%z1,%0 |
| 1065 |
sw%i0\t%z1,%0" |
| 1066 |
[(set_attr "type" "load,load,no_delay_load,load,no_delay_load,store,no_delay_store") |
| 1067 |
(set_attr "mode" "SI") |
| 1068 |
(set_attr "length" "4,4,8,4,8,4,8")]) |
| 1069 |
|
| 1070 |
|
| 1071 |
;; 16-bit Integer moves |
| 1072 |
|
| 1073 |
;; Unlike most other insns, the move insns can't be split with |
| 1074 |
;; different predicates, because register spilling and other parts of |
| 1075 |
;; the compiler, have memoized the insn number already. |
| 1076 |
;; Unsigned loads are used because BYTE_LOADS_ZERO_EXTEND is defined |
| 1077 |
|
| 1078 |
(define_expand "movhi" |
| 1079 |
[(set (match_operand:HI 0 "nonimmediate_operand" "") |
| 1080 |
(match_operand:HI 1 "general_operand" ""))] |
| 1081 |
"" |
| 1082 |
{ |
| 1083 |
if ((reload_in_progress | reload_completed) == 0 |
| 1084 |
&& !register_operand (operands[0], HImode) |
| 1085 |
&& !register_operand (operands[1], HImode) |
| 1086 |
&& ((GET_CODE (operands[1]) != CONST_INT |
| 1087 |
|| INTVAL (operands[1]) != 0))) |
| 1088 |
{ |
| 1089 |
rtx temp = force_reg (HImode, operands[1]); |
| 1090 |
emit_move_insn (operands[0], temp); |
| 1091 |
DONE; |
| 1092 |
} |
| 1093 |
} |
| 1094 |
) |
| 1095 |
|
| 1096 |
(define_insn "*movhi_internal2" |
| 1097 |
[(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,d,R,m") |
| 1098 |
(match_operand:HI 1 "general_operand" "I,d,R,m,dJ,dJ"))] |
| 1099 |
"" |
| 1100 |
"@ |
| 1101 |
addik\t%0,r0,%1\t# %X1 |
| 1102 |
addk\t%0,%1,r0 |
| 1103 |
lhu%i1\t%0,%1 |
| 1104 |
lhu%i1\t%0,%1 |
| 1105 |
sh%i0\t%z1,%0 |
| 1106 |
sh%i0\t%z1,%0" |
| 1107 |
[(set_attr "type" "arith,move,load,no_delay_load,store,no_delay_store") |
| 1108 |
(set_attr "mode" "HI") |
| 1109 |
(set_attr "length" "4,4,4,8,8,8")]) |
| 1110 |
|
| 1111 |
;; 8-bit Integer moves |
| 1112 |
|
| 1113 |
;; Unlike most other insns, the move insns can't be split with |
| 1114 |
;; different predicates, because register spilling and other parts of |
| 1115 |
;; the compiler, have memoized the insn number already. |
| 1116 |
;; Unsigned loads are used because BYTE_LOADS_ZERO_EXTEND is defined |
| 1117 |
|
| 1118 |
(define_expand "movqi" |
| 1119 |
[(set (match_operand:QI 0 "nonimmediate_operand" "") |
| 1120 |
(match_operand:QI 1 "general_operand" ""))] |
| 1121 |
"" |
| 1122 |
{ |
| 1123 |
if ((reload_in_progress | reload_completed) == 0 |
| 1124 |
&& !register_operand (operands[0], QImode) |
| 1125 |
&& !register_operand (operands[1], QImode) |
| 1126 |
&& ((GET_CODE (operands[1]) != CONST_INT |
| 1127 |
|| INTVAL (operands[1]) != 0))) |
| 1128 |
{ |
| 1129 |
rtx temp = force_reg (QImode, operands[1]); |
| 1130 |
emit_move_insn (operands[0], temp); |
| 1131 |
DONE; |
| 1132 |
} |
| 1133 |
} |
| 1134 |
) |
| 1135 |
|
| 1136 |
(define_insn "*movqi_internal2" |
| 1137 |
[(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,d,d,R,m") |
| 1138 |
(match_operand:QI 1 "general_operand" "J,I,d,R,m,dJ,dJ"))] |
| 1139 |
"" |
| 1140 |
"@ |
| 1141 |
addk\t%0,r0,%z1 |
| 1142 |
addik\t%0,r0,%1\t# %X1 |
| 1143 |
addk\t%0,%1,r0 |
| 1144 |
lbu%i1\t%0,%1 |
| 1145 |
lbu%i1\t%0,%1 |
| 1146 |
sb%i0\t%z1,%0 |
| 1147 |
sbi\t%z1,%0" |
| 1148 |
[(set_attr "type" "arith,arith,move,load,no_delay_load,store,no_delay_store") |
| 1149 |
(set_attr "mode" "QI") |
| 1150 |
(set_attr "length" "4,4,8,4,8,4,8")]) |
| 1151 |
|
| 1152 |
;; Block moves, see microblaze.cc for more details. |
| 1153 |
;; Argument 0 is the destination |
| 1154 |
;; Argument 1 is the source |
| 1155 |
;; Argument 2 is the length |
| 1156 |
;; Argument 3 is the alignment |
| 1157 |
|
| 1158 |
(define_expand "cpymemsi" |
| 1159 |
[(parallel [(set (match_operand:BLK 0 "general_operand") |
| 1160 |
(match_operand:BLK 1 "general_operand")) |
| 1161 |
(use (match_operand:SI 2 "")) |
| 1162 |
(use (match_operand:SI 3 "const_int_operand"))])] |
| 1163 |
"" |
| 1164 |
{ |
| 1165 |
if (microblaze_expand_block_move (operands[0], operands[1], |
| 1166 |
operands[2], operands[3])) |
| 1167 |
DONE; |
| 1168 |
else |
| 1169 |
FAIL; |
| 1170 |
} |
| 1171 |
) |
| 1172 |
|
| 1173 |
;;Load and store reverse |
| 1174 |
(define_insn "movsi4_rev" |
| 1175 |
[(set (match_operand:SI 0 "reg_or_mem_operand" "=r,Q") |
| 1176 |
(bswap:SI (match_operand:SF 1 "reg_or_mem_operand" "Q,r")))] |
| 1177 |
"TARGET_REORDER" |
| 1178 |
"@ |
| 1179 |
lwr\t%0,%y1,r0 |
| 1180 |
swr\t%1,%y0,r0" |
| 1181 |
[(set_attr "type" "load,store") |
| 1182 |
(set_attr "mode" "SI") |
| 1183 |
(set_attr "length" "4,4")]) |
| 1184 |
|
| 1185 |
;; 32-bit floating point moves |
| 1186 |
|
| 1187 |
(define_expand "movsf" |
| 1188 |
[(set (match_operand:SF 0 "nonimmediate_operand" "") |
| 1189 |
(match_operand:SF 1 "general_operand" ""))] |
| 1190 |
"" |
| 1191 |
{ |
| 1192 |
if ((reload_in_progress | reload_completed) == 0 |
| 1193 |
&& !register_operand (operands[0], SFmode) |
| 1194 |
&& !register_operand (operands[1], SFmode) |
| 1195 |
&& ( ((GET_CODE (operands[1]) != CONST_INT || INTVAL (operands[1]) != 0) |
| 1196 |
&& operands[1] != CONST0_RTX (SFmode)))) |
| 1197 |
{ |
| 1198 |
rtx temp = force_reg (SFmode, operands[1]); |
| 1199 |
emit_move_insn (operands[0], temp); |
| 1200 |
DONE; |
| 1201 |
} |
| 1202 |
} |
| 1203 |
) |
| 1204 |
|
| 1205 |
;; Applies to both TARGET_SOFT_FLOAT and TARGET_HARD_FLOAT |
| 1206 |
;; |
| 1207 |
(define_insn "*movsf_internal" |
| 1208 |
[(set (match_operand:SF 0 "nonimmediate_operand" "=d,d,d,d,d,R,m") |
| 1209 |
(match_operand:SF 1 "general_operand" "G,d,R,F,m,d,d"))] |
| 1210 |
"(register_operand (operands[0], SFmode) |
| 1211 |
|| register_operand (operands[1], SFmode) |
| 1212 |
|| operands[1] == CONST0_RTX (SFmode))" |
| 1213 |
"@ |
| 1214 |
addk\t%0,r0,r0 |
| 1215 |
addk\t%0,%1,r0 |
| 1216 |
lw%i1\t%0,%1 |
| 1217 |
addik\t%0,r0,%F1 |
| 1218 |
lw%i1\t%0,%1 |
| 1219 |
sw%i0\t%z1,%0 |
| 1220 |
swi\t%z1,%0" |
| 1221 |
[(set_attr "type" "move,no_delay_load,load,no_delay_load,no_delay_load,store,no_delay_store") |
| 1222 |
(set_attr "mode" "SF") |
| 1223 |
(set_attr "length" "4,4,4,4,4,4,4")]) |
| 1224 |
|
| 1225 |
;; 64-bit floating point moves |
| 1226 |
(define_expand "movdf" |
| 1227 |
[(set (match_operand:DF 0 "nonimmediate_operand" "") |
| 1228 |
(match_operand:DF 1 "general_operand" ""))] |
| 1229 |
"" |
| 1230 |
{ |
| 1231 |
if (flag_pic == 2) { |
| 1232 |
if (GET_CODE (operands[1]) == MEM |
| 1233 |
&& !microblaze_legitimate_address_p (DFmode, XEXP (operands[1],0), 0)) |
| 1234 |
{ |
| 1235 |
rtx ptr_reg; |
| 1236 |
rtx result; |
| 1237 |
ptr_reg = force_reg (Pmode, XEXP (operands[1],0)); |
| 1238 |
result = gen_rtx_MEM (DFmode, ptr_reg); |
| 1239 |
emit_move_insn (operands[0], result); |
| 1240 |
DONE; |
| 1241 |
} |
| 1242 |
} |
| 1243 |
if ((reload_in_progress | reload_completed) == 0 |
| 1244 |
&& !register_operand (operands[0], DFmode) |
| 1245 |
&& !register_operand (operands[1], DFmode) |
| 1246 |
&& (((GET_CODE (operands[1]) != CONST_INT || INTVAL (operands[1]) != 0) |
| 1247 |
&& operands[1] != CONST0_RTX (DFmode)))) |
| 1248 |
{ |
| 1249 |
rtx temp = force_reg (DFmode, operands[1]); |
| 1250 |
emit_move_insn (operands[0], temp); |
| 1251 |
DONE; |
| 1252 |
} |
| 1253 |
} |
| 1254 |
) |
| 1255 |
|
| 1256 |
;; movdf_internal |
| 1257 |
;; Applies to both TARGET_SOFT_FLOAT and TARGET_HARD_FLOAT |
| 1258 |
;; |
| 1259 |
(define_insn "*movdf_internal" |
| 1260 |
[(set (match_operand:DF 0 "nonimmediate_operand" "=d,d,d,d,o") |
| 1261 |
(match_operand:DF 1 "general_operand" "dG,o,F,T,d"))] |
| 1262 |
"" |
| 1263 |
{ |
| 1264 |
switch (which_alternative) |
| 1265 |
{ |
| 1266 |
case 0: |
| 1267 |
return "addk\t%0,r0,r0\n\taddk\t%D0,r0,r0"; |
| 1268 |
case 1: |
| 1269 |
case 3: |
| 1270 |
if (reg_mentioned_p (operands[0], operands[1])) |
| 1271 |
return "lwi\t%D0,%o1\n\tlwi\t%0,%1"; |
| 1272 |
else |
| 1273 |
return "lwi\t%0,%1\n\tlwi\t%D0,%o1"; |
| 1274 |
case 2: |
| 1275 |
{ |
| 1276 |
return "addik\t%0,r0,%h1 \n\taddik\t%D0,r0,%j1 #Xfer Lo"; |
| 1277 |
} |
| 1278 |
case 4: |
| 1279 |
return "swi\t%1,%0\n\tswi\t%D1,%o0"; |
| 1280 |
} |
| 1281 |
gcc_unreachable (); |
| 1282 |
} |
| 1283 |
[(set_attr "type" "no_delay_move,no_delay_load,no_delay_load,no_delay_load,no_delay_store") |
| 1284 |
(set_attr "mode" "DF") |
| 1285 |
(set_attr "length" "4,8,8,16,8")]) |
| 1286 |
|
| 1287 |
(define_split |
| 1288 |
[(set (match_operand:DF 0 "register_operand" "") |
| 1289 |
(match_operand:DF 1 "register_operand" ""))] |
| 1290 |
"reload_completed |
| 1291 |
&& GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0])) |
| 1292 |
&& GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1])) |
| 1293 |
&& (REGNO (operands[0]) == (REGNO (operands[1]) + 1))" |
| 1294 |
[(set (subreg:SI (match_dup 0) 4) (subreg:SI (match_dup 1) 4)) |
| 1295 |
(set (subreg:SI (match_dup 0) 0) (subreg:SI (match_dup 1) 0))] |
| 1296 |
"") |
| 1297 |
|
| 1298 |
(define_split |
| 1299 |
[(set (match_operand:DF 0 "register_operand" "") |
| 1300 |
(match_operand:DF 1 "register_operand" ""))] |
| 1301 |
"reload_completed |
| 1302 |
&& GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0])) |
| 1303 |
&& GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1])) |
| 1304 |
&& (REGNO (operands[0]) != (REGNO (operands[1]) + 1))" |
| 1305 |
[(set (subreg:SI (match_dup 0) 0) (subreg:SI (match_dup 1) 0)) |
| 1306 |
(set (subreg:SI (match_dup 0) 4) (subreg:SI (match_dup 1) 4))] |
| 1307 |
"") |
| 1308 |
|
| 1309 |
;;---------------------------------------------------------------- |
| 1310 |
;; Shifts |
| 1311 |
;;---------------------------------------------------------------- |
| 1312 |
|
| 1313 |
;;---------------------------------------------------------------- |
| 1314 |
;; 32-bit left shifts |
| 1315 |
;;---------------------------------------------------------------- |
| 1316 |
(define_expand "ashlsi3" |
| 1317 |
[(set (match_operand:SI 0 "register_operand" "=&d") |
| 1318 |
(ashift:SI (match_operand:SI 1 "register_operand" "d") |
| 1319 |
(match_operand:SI 2 "arith_operand" "")))] |
| 1320 |
"" |
| 1321 |
{ |
| 1322 |
/* Avoid recursion for trivial cases. */ |
| 1323 |
if (!((GET_CODE (operands [2]) == CONST_INT) && (INTVAL (operands[2]) == 1))) |
| 1324 |
if (microblaze_expand_shift (operands)) |
| 1325 |
DONE; |
| 1326 |
} |
| 1327 |
) |
| 1328 |
|
| 1329 |
;; Irrespective of if we have a barrel-shifter or not, we want to match |
| 1330 |
;; shifts by 1 with a special pattern. When a barrel shifter is present, |
| 1331 |
;; saves a cycle. If not, allows us to annotate the instruction for delay |
| 1332 |
;; slot optimization |
| 1333 |
(define_insn "*ashlsi3_byone" |
| 1334 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 1335 |
(ashift:SI (match_operand:SI 1 "register_operand" "d") |
| 1336 |
(match_operand:SI 2 "arith_operand" "I")))] |
| 1337 |
"(operands[2] == const1_rtx)" |
| 1338 |
"addk\t%0,%1,%1" |
| 1339 |
[(set_attr "type" "arith") |
| 1340 |
(set_attr "mode" "SI") |
| 1341 |
(set_attr "length" "4")] |
| 1342 |
) |
| 1343 |
|
| 1344 |
;; Barrel shift left |
| 1345 |
(define_insn "ashlsi3_bshift" |
| 1346 |
[(set (match_operand:SI 0 "register_operand" "=d,d") |
| 1347 |
(ashift:SI (match_operand:SI 1 "register_operand" "d,d") |
| 1348 |
(match_operand:SI 2 "arith_operand" "I,d")))] |
| 1349 |
"TARGET_BARREL_SHIFT" |
| 1350 |
"@ |
| 1351 |
bslli\t%0,%1,%2 |
| 1352 |
bsll\t%0,%1,%2" |
| 1353 |
[(set_attr "type" "bshift,bshift") |
| 1354 |
(set_attr "mode" "SI,SI") |
| 1355 |
(set_attr "length" "4,4")] |
| 1356 |
) |
| 1357 |
|
| 1358 |
;; The following patterns apply when there is no barrel shifter present |
| 1359 |
|
| 1360 |
(define_insn "*ashlsi3_with_mul_delay" |
| 1361 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 1362 |
(ashift:SI (match_operand:SI 1 "register_operand" "d") |
| 1363 |
(match_operand:SI 2 "immediate_operand" "I")))] |
| 1364 |
"!TARGET_SOFT_MUL |
| 1365 |
&& ((1 << INTVAL (operands[2])) <= 32767 && (1 << INTVAL (operands[2])) >= -32768)" |
| 1366 |
"muli\t%0,%1,%m2" |
| 1367 |
;; This MUL will not generate an imm. Can go into a delay slot. |
| 1368 |
[(set_attr "type" "arith") |
| 1369 |
(set_attr "mode" "SI") |
| 1370 |
(set_attr "length" "4")] |
| 1371 |
) |
| 1372 |
|
| 1373 |
(define_insn "*ashlsi3_with_mul_nodelay" |
| 1374 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 1375 |
(ashift:SI (match_operand:SI 1 "register_operand" "d") |
| 1376 |
(match_operand:SI 2 "immediate_operand" "I")))] |
| 1377 |
"!TARGET_SOFT_MUL" |
| 1378 |
"muli\t%0,%1,%m2" |
| 1379 |
;; This MUL will generate an IMM. Cannot go into a delay slot |
| 1380 |
[(set_attr "type" "no_delay_arith") |
| 1381 |
(set_attr "mode" "SI") |
| 1382 |
(set_attr "length" "8")] |
| 1383 |
) |
| 1384 |
|
| 1385 |
(define_insn "*ashlsi3_with_size_opt" |
| 1386 |
[(set (match_operand:SI 0 "register_operand" "=&d") |
| 1387 |
(ashift:SI (match_operand:SI 1 "register_operand" "d") |
| 1388 |
(match_operand:SI 2 "immediate_operand" "I")))] |
| 1389 |
"(INTVAL (operands[2]) > 5 && optimize_size)" |
| 1390 |
{ |
| 1391 |
operands[3] = gen_rtx_REG (SImode, MB_ABI_ASM_TEMP_REGNUM); |
| 1392 |
|
| 1393 |
output_asm_insn ("ori\t%3,r0,%2", operands); |
| 1394 |
if (REGNO (operands[0]) != REGNO (operands[1])) |
| 1395 |
output_asm_insn ("addk\t%0,%1,r0", operands); |
| 1396 |
|
| 1397 |
output_asm_insn ("addik\t%3,%3,-1", operands); |
| 1398 |
output_asm_insn ("bneid\t%3,.-4", operands); |
| 1399 |
return "addk\t%0,%0,%0"; |
| 1400 |
} |
| 1401 |
[(set_attr "type" "multi") |
| 1402 |
(set_attr "mode" "SI") |
| 1403 |
(set_attr "length" "20")] |
| 1404 |
) |
| 1405 |
|
| 1406 |
(define_insn "*ashlsi3_with_rotate" |
| 1407 |
[(set (match_operand:SI 0 "register_operand" "=&d") |
| 1408 |
(ashift:SI (match_operand:SI 1 "register_operand" "d") |
| 1409 |
(match_operand:SI 2 "immediate_operand" "I")))] |
| 1410 |
"(INTVAL (operands[2]) > 17 && !optimize_size)" |
| 1411 |
{ |
| 1412 |
int i, nshift; |
| 1413 |
|
| 1414 |
nshift = INTVAL (operands[2]); |
| 1415 |
operands[3] = gen_int_mode (0xFFFFFFFF << nshift, SImode); |
| 1416 |
|
| 1417 |
/* We do one extra shift so that the first bit (carry) coming into the MSB |
| 1418 |
will be masked out */ |
| 1419 |
output_asm_insn ("src\t%0,%1", operands); |
| 1420 |
for (i = 0; i < (32 - nshift); i++) |
| 1421 |
output_asm_insn ("src\t%0,%0", operands); |
| 1422 |
|
| 1423 |
return "andi\t%0,%0,%3"; |
| 1424 |
} |
| 1425 |
[(set_attr "type" "multi") |
| 1426 |
(set_attr "mode" "SI") |
| 1427 |
(set_attr "length" "80")] |
| 1428 |
) |
| 1429 |
|
| 1430 |
(define_insn "*ashlsi_inline" |
| 1431 |
[(set (match_operand:SI 0 "register_operand" "=&d") |
| 1432 |
(ashift:SI (match_operand:SI 1 "register_operand" "d") |
| 1433 |
(match_operand:SI 2 "immediate_operand" "I")))] |
| 1434 |
"" |
| 1435 |
{ |
| 1436 |
int i; |
| 1437 |
int nshift = INTVAL (operands[2]); |
| 1438 |
if (REGNO (operands[0]) != REGNO (operands[1])) |
| 1439 |
output_asm_insn ("addk\t%0,r0,%1", operands); |
| 1440 |
output_asm_insn ("addk\t%0,%1,%1", operands); |
| 1441 |
for (i = 0; i < (nshift - 2); i++) |
| 1442 |
output_asm_insn ("addk\t%0,%0,%0", operands); |
| 1443 |
return "addk\t%0,%0,%0"; |
| 1444 |
} |
| 1445 |
[(set_attr "type" "multi") |
| 1446 |
(set_attr "mode" "SI") |
| 1447 |
(set_attr "length" "124")] |
| 1448 |
) |
| 1449 |
|
| 1450 |
(define_insn "*ashlsi_reg" |
| 1451 |
[(set (match_operand:SI 0 "register_operand" "=&d") |
| 1452 |
(ashift:SI (match_operand:SI 1 "register_operand" "d") |
| 1453 |
(match_operand:SI 2 "register_operand" "d")))] |
| 1454 |
"" |
| 1455 |
{ |
| 1456 |
operands[3] = gen_rtx_REG (SImode, MB_ABI_ASM_TEMP_REGNUM); |
| 1457 |
output_asm_insn ("andi\t%3,%2,31", operands); |
| 1458 |
if (REGNO (operands[0]) != REGNO (operands[1])) |
| 1459 |
output_asm_insn ("addk\t%0,r0,%1", operands); |
| 1460 |
/* Exit the loop if zero shift. */ |
| 1461 |
output_asm_insn ("beqid\t%3,.+20", operands); |
| 1462 |
/* Emit the loop. */ |
| 1463 |
output_asm_insn ("addk\t%0,%0,r0", operands); |
| 1464 |
output_asm_insn ("addik\t%3,%3,-1", operands); |
| 1465 |
output_asm_insn ("bneid\t%3,.-4", operands); |
| 1466 |
return "addk\t%0,%0,%0"; |
| 1467 |
} |
| 1468 |
[(set_attr "type" "multi") |
| 1469 |
(set_attr "mode" "SI") |
| 1470 |
(set_attr "length" "28")] |
| 1471 |
) |
| 1472 |
|
| 1473 |
|
| 1474 |
;;---------------------------------------------------------------- |
| 1475 |
;; 32-bit right shifts |
| 1476 |
;;---------------------------------------------------------------- |
| 1477 |
(define_expand "ashrsi3" |
| 1478 |
[(set (match_operand:SI 0 "register_operand" "=&d") |
| 1479 |
(ashiftrt:SI (match_operand:SI 1 "register_operand" "d") |
| 1480 |
(match_operand:SI 2 "arith_operand" "")))] |
| 1481 |
"" |
| 1482 |
{ |
| 1483 |
/* Avoid recursion for trivial cases. */ |
| 1484 |
if (!((GET_CODE (operands [2]) == CONST_INT) && (INTVAL (operands[2]) == 1))) |
| 1485 |
if (microblaze_expand_shift (operands)) |
| 1486 |
DONE; |
| 1487 |
} |
| 1488 |
) |
| 1489 |
|
| 1490 |
;; Irrespective of if we have a barrel-shifter or not, we want to match |
| 1491 |
;; shifts by 1 with a special pattern. When a barrel shifter is present, |
| 1492 |
;; saves a cycle. If not, allows us to annotate the instruction for delay |
| 1493 |
;; slot optimization |
| 1494 |
(define_insn "*ashrsi3_byone" |
| 1495 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 1496 |
(ashiftrt:SI (match_operand:SI 1 "register_operand" "d") |
| 1497 |
(match_operand:SI 2 "arith_operand" "I")))] |
| 1498 |
"(operands[2] == const1_rtx)" |
| 1499 |
"sra\t%0,%1" |
| 1500 |
[(set_attr "type" "arith") |
| 1501 |
(set_attr "mode" "SI") |
| 1502 |
(set_attr "length" "4")] |
| 1503 |
) |
| 1504 |
|
| 1505 |
;; Barrel shift right logical |
| 1506 |
(define_insn "*ashrsi3_bshift" |
| 1507 |
[(set (match_operand:SI 0 "register_operand" "=d,d") |
| 1508 |
(ashiftrt:SI (match_operand:SI 1 "register_operand" "d,d") |
| 1509 |
(match_operand:SI 2 "arith_operand" "I,d")))] |
| 1510 |
"TARGET_BARREL_SHIFT" |
| 1511 |
"@ |
| 1512 |
bsrai\t%0,%1,%2 |
| 1513 |
bsra\t%0,%1,%2" |
| 1514 |
[(set_attr "type" "bshift,bshift") |
| 1515 |
(set_attr "mode" "SI,SI") |
| 1516 |
(set_attr "length" "4,4")] |
| 1517 |
) |
| 1518 |
|
| 1519 |
(define_insn "*ashrsi_inline" |
| 1520 |
[(set (match_operand:SI 0 "register_operand" "=&d") |
| 1521 |
(ashiftrt:SI (match_operand:SI 1 "register_operand" "d") |
| 1522 |
(match_operand:SI 2 "immediate_operand" "I")))] |
| 1523 |
"" |
| 1524 |
{ |
| 1525 |
int i; |
| 1526 |
int nshift = INTVAL (operands[2]); |
| 1527 |
if (REGNO (operands[0]) != REGNO (operands[1])) |
| 1528 |
output_asm_insn ("addk\t%0,r0,%1", operands); |
| 1529 |
output_asm_insn ("sra\t%0,%1", operands); |
| 1530 |
for (i = 0; i < (nshift - 2); i++) |
| 1531 |
output_asm_insn ("sra\t%0,%0", operands); |
| 1532 |
return "sra\t%0,%0"; |
| 1533 |
} |
| 1534 |
[(set_attr "type" "multi") |
| 1535 |
(set_attr "mode" "SI") |
| 1536 |
(set_attr "length" "124")] |
| 1537 |
) |
| 1538 |
|
| 1539 |
(define_insn "*ashrsi_reg" |
| 1540 |
[(set (match_operand:SI 0 "register_operand" "=&d") |
| 1541 |
(ashiftrt:SI (match_operand:SI 1 "register_operand" "d") |
| 1542 |
(match_operand:SI 2 "register_operand" "d")))] |
| 1543 |
"" |
| 1544 |
{ |
| 1545 |
operands[3] = gen_rtx_REG (SImode, MB_ABI_ASM_TEMP_REGNUM); |
| 1546 |
output_asm_insn ("andi\t%3,%2,31", operands); |
| 1547 |
if (REGNO (operands[0]) != REGNO (operands[1])) |
| 1548 |
output_asm_insn ("addk\t%0,r0,%1", operands); |
| 1549 |
/* Exit the loop if zero shift. */ |
| 1550 |
output_asm_insn ("beqid\t%3,.+20", operands); |
| 1551 |
/* Emit the loop. */ |
| 1552 |
output_asm_insn ("addk\t%0,%0,r0", operands); |
| 1553 |
output_asm_insn ("addik\t%3,%3,-1", operands); |
| 1554 |
output_asm_insn ("bneid\t%3,.-4", operands); |
| 1555 |
return "sra\t%0,%0"; |
| 1556 |
} |
| 1557 |
[(set_attr "type" "multi") |
| 1558 |
(set_attr "mode" "SI") |
| 1559 |
(set_attr "length" "28")] |
| 1560 |
) |
| 1561 |
|
| 1562 |
;;---------------------------------------------------------------- |
| 1563 |
;; 32-bit right shifts (logical) |
| 1564 |
;;---------------------------------------------------------------- |
| 1565 |
|
| 1566 |
(define_expand "lshrsi3" |
| 1567 |
[(set (match_operand:SI 0 "register_operand" "=&d") |
| 1568 |
(lshiftrt:SI (match_operand:SI 1 "register_operand" "d") |
| 1569 |
(match_operand:SI 2 "arith_operand" "")))] |
| 1570 |
"" |
| 1571 |
{ |
| 1572 |
/* Avoid recursion for trivial cases. */ |
| 1573 |
if (!((GET_CODE (operands [2]) == CONST_INT) && (INTVAL (operands[2]) == 1))) |
| 1574 |
if (microblaze_expand_shift (operands)) |
| 1575 |
DONE; |
| 1576 |
} |
| 1577 |
) |
| 1578 |
|
| 1579 |
;; Irrespective of if we have a barrel-shifter or not, we want to match |
| 1580 |
;; shifts by 1 with a special pattern. When a barrel shifter is present, |
| 1581 |
;; saves a cycle. If not, allows us to annotate the instruction for delay |
| 1582 |
;; slot optimization |
| 1583 |
(define_insn "*lshrsi3_byone" |
| 1584 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 1585 |
(lshiftrt:SI (match_operand:SI 1 "register_operand" "d") |
| 1586 |
(match_operand:SI 2 "arith_operand" "I")))] |
| 1587 |
"(operands[2] == const1_rtx)" |
| 1588 |
"srl\t%0,%1" |
| 1589 |
[(set_attr "type" "arith") |
| 1590 |
(set_attr "mode" "SI") |
| 1591 |
(set_attr "length" "4")] |
| 1592 |
) |
| 1593 |
|
| 1594 |
;; Barrel shift right logical |
| 1595 |
(define_insn "*lshrsi3_bshift" |
| 1596 |
[(set (match_operand:SI 0 "register_operand" "=d,d") |
| 1597 |
(lshiftrt:SI (match_operand:SI 1 "register_operand" "d,d") |
| 1598 |
(match_operand:SI 2 "arith_operand" "I,d")))] |
| 1599 |
"TARGET_BARREL_SHIFT" |
| 1600 |
"@ |
| 1601 |
bsrli\t%0,%1,%2 |
| 1602 |
bsrl\t%0,%1,%2" |
| 1603 |
[(set_attr "type" "bshift,bshift") |
| 1604 |
(set_attr "mode" "SI,SI") |
| 1605 |
(set_attr "length" "4,4")] |
| 1606 |
) |
| 1607 |
|
| 1608 |
(define_insn "*lshrsi_inline" |
| 1609 |
[(set (match_operand:SI 0 "register_operand" "=&d") |
| 1610 |
(lshiftrt:SI (match_operand:SI 1 "register_operand" "d") |
| 1611 |
(match_operand:SI 2 "immediate_operand" "I")))] |
| 1612 |
"" |
| 1613 |
{ |
| 1614 |
int i; |
| 1615 |
int nshift = INTVAL (operands[2]); |
| 1616 |
if (REGNO (operands[0]) != REGNO (operands[1])) |
| 1617 |
output_asm_insn ("addk\t%0,r0,%1", operands); |
| 1618 |
output_asm_insn ("srl\t%0,%1", operands); |
| 1619 |
for (i = 0; i < (nshift - 2); i++) |
| 1620 |
output_asm_insn ("srl\t%0,%0", operands); |
| 1621 |
return "srl\t%0,%0"; |
| 1622 |
} |
| 1623 |
[(set_attr "type" "multi") |
| 1624 |
(set_attr "mode" "SI") |
| 1625 |
(set_attr "length" "124")] |
| 1626 |
) |
| 1627 |
|
| 1628 |
(define_insn "*lshrsi_reg" |
| 1629 |
[(set (match_operand:SI 0 "register_operand" "=&d") |
| 1630 |
(lshiftrt:SI (match_operand:SI 1 "register_operand" "d") |
| 1631 |
(match_operand:SI 2 "register_operand" "d")))] |
| 1632 |
"" |
| 1633 |
{ |
| 1634 |
operands[3] = gen_rtx_REG (SImode, MB_ABI_ASM_TEMP_REGNUM); |
| 1635 |
output_asm_insn ("andi\t%3,%2,31", operands); |
| 1636 |
if (REGNO (operands[0]) != REGNO (operands[1])) |
| 1637 |
output_asm_insn ("addk\t%0,r0,%1", operands); |
| 1638 |
/* Exit the loop if zero shift. */ |
| 1639 |
output_asm_insn ("beqid\t%3,.+20", operands); |
| 1640 |
/* Emit the loop. */ |
| 1641 |
output_asm_insn ("addk\t%0,%0,r0", operands); |
| 1642 |
output_asm_insn ("addik\t%3,%3,-1", operands); |
| 1643 |
output_asm_insn ("bneid\t%3,.-4", operands); |
| 1644 |
return "srl\t%0,%0"; |
| 1645 |
} |
| 1646 |
[(set_attr "type" "multi") |
| 1647 |
(set_attr "mode" "SI") |
| 1648 |
(set_attr "length" "28")] |
| 1649 |
) |
| 1650 |
|
| 1651 |
;;---------------------------------------------------------------- |
| 1652 |
;; Setting a register from an integer comparison. |
| 1653 |
;;---------------------------------------------------------------- |
| 1654 |
(define_expand "cstoresi4" |
| 1655 |
[(set (match_operand:SI 0 "register_operand") |
| 1656 |
(match_operator:SI 1 "ordered_comparison_operator" |
| 1657 |
[(match_operand:SI 2 "register_operand") |
| 1658 |
(match_operand:SI 3 "register_operand")]))] |
| 1659 |
"TARGET_PATTERN_COMPARE" |
| 1660 |
"if (GET_CODE (operand1) != EQ && GET_CODE (operand1) != NE) |
| 1661 |
FAIL; |
| 1662 |
" |
| 1663 |
) |
| 1664 |
|
| 1665 |
(define_insn "seq_internal_pat" |
| 1666 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 1667 |
(eq:SI |
| 1668 |
(match_operand:SI 1 "register_operand" "d") |
| 1669 |
(match_operand:SI 2 "register_operand" "d")))] |
| 1670 |
"TARGET_PATTERN_COMPARE" |
| 1671 |
"pcmpeq\t%0,%1,%2" |
| 1672 |
[(set_attr "type" "arith") |
| 1673 |
(set_attr "mode" "SI") |
| 1674 |
(set_attr "length" "4")] |
| 1675 |
) |
| 1676 |
|
| 1677 |
(define_insn "sne_internal_pat" |
| 1678 |
[(set (match_operand:SI 0 "register_operand" "=d") |
| 1679 |
(ne:SI |
| 1680 |
(match_operand:SI 1 "register_operand" "d") |
| 1681 |
(match_operand:SI 2 "register_operand" "d")))] |
| 1682 |
"TARGET_PATTERN_COMPARE" |
| 1683 |
"pcmpne\t%0,%1,%2" |
| 1684 |
[(set_attr "type" "arith") |
| 1685 |
(set_attr "mode" "SI") |
| 1686 |
(set_attr "length" "4")] |
| 1687 |
) |
| 1688 |
|
| 1689 |
;;---------------------------------------------------------------- |
| 1690 |
;; Setting a register from an floating point comparison. |
| 1691 |
;;---------------------------------------------------------------- |
| 1692 |
(define_insn "cstoresf4" |
| 1693 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 1694 |
(match_operator:SI 1 "ordered_comparison_operator" |
| 1695 |
[(match_operand:SF 2 "register_operand" "r") |
| 1696 |
(match_operand:SF 3 "register_operand" "r")]))] |
| 1697 |
"TARGET_HARD_FLOAT" |
| 1698 |
"fcmp.%C1\t%0,%3,%2" |
| 1699 |
[(set_attr "type" "fcmp") |
| 1700 |
(set_attr "mode" "SF") |
| 1701 |
(set_attr "length" "4")] |
| 1702 |
) |
| 1703 |
|
| 1704 |
;;---------------------------------------------------------------- |
| 1705 |
;; Conditional branches |
| 1706 |
;;---------------------------------------------------------------- |
| 1707 |
|
| 1708 |
(define_expand "cbranchsi4" |
| 1709 |
[(set (pc) |
| 1710 |
(if_then_else (match_operator 0 "ordered_comparison_operator" |
| 1711 |
[(match_operand:SI 1 "register_operand") |
| 1712 |
(match_operand:SI 2 "arith_operand" "I,i")]) |
| 1713 |
(label_ref (match_operand 3 "")) |
| 1714 |
(pc)))] |
| 1715 |
"" |
| 1716 |
{ |
| 1717 |
microblaze_expand_conditional_branch (SImode, operands); |
| 1718 |
DONE; |
| 1719 |
}) |
| 1720 |
|
| 1721 |
(define_expand "cbranchsi4_reg" |
| 1722 |
[(set (pc) |
| 1723 |
(if_then_else (match_operator 0 "ordered_comparison_operator" |
| 1724 |
[(match_operand:SI 1 "register_operand") |
| 1725 |
(match_operand:SI 2 "register_operand")]) |
| 1726 |
(label_ref (match_operand 3 "")) |
| 1727 |
(pc)))] |
| 1728 |
"" |
| 1729 |
{ |
| 1730 |
microblaze_expand_conditional_branch_reg (SImode, operands); |
| 1731 |
DONE; |
| 1732 |
}) |
| 1733 |
|
| 1734 |
(define_expand "cbranchsf4" |
| 1735 |
[(set (pc) |
| 1736 |
(if_then_else (match_operator 0 "ordered_comparison_operator" |
| 1737 |
[(match_operand:SF 1 "register_operand") |
| 1738 |
(match_operand:SF 2 "register_operand")]) |
| 1739 |
(label_ref (match_operand 3 "")) |
| 1740 |
(pc)))] |
| 1741 |
"TARGET_HARD_FLOAT" |
| 1742 |
{ |
| 1743 |
microblaze_expand_conditional_branch_sf (operands); |
| 1744 |
DONE; |
| 1745 |
|
| 1746 |
}) |
| 1747 |
|
| 1748 |
;; Used to implement comparison instructions |
| 1749 |
(define_expand "condjump" |
| 1750 |
[(set (pc) |
| 1751 |
(if_then_else (match_operand 0) |
| 1752 |
(label_ref (match_operand 1)) |
| 1753 |
(pc)))]) |
| 1754 |
|
| 1755 |
(define_insn "branch_zero" |
| 1756 |
[(set (pc) |
| 1757 |
(if_then_else (match_operator:SI 0 "ordered_comparison_operator" |
| 1758 |
[(match_operand:SI 1 "register_operand" "d") |
| 1759 |
(const_int 0)]) |
| 1760 |
(match_operand:SI 2 "pc_or_label_operand" "") |
| 1761 |
(match_operand:SI 3 "pc_or_label_operand" ""))) |
| 1762 |
] |
| 1763 |
"" |
| 1764 |
{ |
| 1765 |
if (operands[3] == pc_rtx) |
| 1766 |
return "b%C0i%?\t%z1,%2"; |
| 1767 |
else |
| 1768 |
return "b%N0i%?\t%z1,%3"; |
| 1769 |
} |
| 1770 |
[(set_attr "type" "branch") |
| 1771 |
(set_attr "mode" "none") |
| 1772 |
(set_attr "length" "4")] |
| 1773 |
) |
| 1774 |
|
| 1775 |
(define_insn "branch_compare" |
| 1776 |
[(set (pc) |
| 1777 |
(if_then_else (match_operator:SI 0 "cmp_op" |
| 1778 |
[(match_operand:SI 1 "register_operand" "d") |
| 1779 |
(match_operand:SI 2 "register_operand" "d") |
| 1780 |
]) |
| 1781 |
(label_ref (match_operand 3)) |
| 1782 |
(pc))) |
| 1783 |
(clobber(reg:SI R_TMP))] |
| 1784 |
"" |
| 1785 |
{ |
| 1786 |
operands[4] = gen_rtx_REG (SImode, MB_ABI_ASM_TEMP_REGNUM); |
| 1787 |
enum rtx_code code = GET_CODE (operands[0]); |
| 1788 |
|
| 1789 |
if (code == GT || code == LE) |
| 1790 |
{ |
| 1791 |
output_asm_insn ("cmp\tr18,%z1,%z2", operands); |
| 1792 |
code = swap_condition (code); |
| 1793 |
} |
| 1794 |
else if (code == GTU || code == LEU) |
| 1795 |
{ |
| 1796 |
output_asm_insn ("cmpu\tr18,%z1,%z2", operands); |
| 1797 |
code = swap_condition (code); |
| 1798 |
} |
| 1799 |
else if (code == GE || code == LT) |
| 1800 |
{ |
| 1801 |
output_asm_insn ("cmp\tr18,%z2,%z1", operands); |
| 1802 |
} |
| 1803 |
else if (code == GEU || code == LTU) |
| 1804 |
{ |
| 1805 |
output_asm_insn ("cmpu\tr18,%z2,%z1", operands); |
| 1806 |
} |
| 1807 |
|
| 1808 |
operands[0] = gen_rtx_fmt_ee (signed_condition (code), SImode, operands[4], const0_rtx); |
| 1809 |
return "b%C0i%?\tr18,%3"; |
| 1810 |
} |
| 1811 |
[(set_attr "type" "branch") |
| 1812 |
(set_attr "mode" "none") |
| 1813 |
(set_attr "length" "12")] |
| 1814 |
) |
| 1815 |
|
| 1816 |
;;---------------------------------------------------------------- |
| 1817 |
;; Unconditional branches |
| 1818 |
;;---------------------------------------------------------------- |
| 1819 |
(define_insn "jump" |
| 1820 |
[(set (pc) |
| 1821 |
(label_ref (match_operand 0 "" "")))] |
| 1822 |
"" |
| 1823 |
{ |
| 1824 |
if (GET_CODE (operands[0]) == REG) |
| 1825 |
return "br%?\t%0"; |
| 1826 |
else |
| 1827 |
return "bri%?\t%l0"; |
| 1828 |
} |
| 1829 |
[(set_attr "type" "jump") |
| 1830 |
(set_attr "mode" "none") |
| 1831 |
(set_attr "length" "4")]) |
| 1832 |
|
| 1833 |
(define_expand "indirect_jump" |
| 1834 |
[(set (pc) (match_operand 0 "register_operand" "d"))] |
| 1835 |
"" |
| 1836 |
{ |
| 1837 |
rtx dest = operands[0]; |
| 1838 |
if (GET_CODE (dest) != REG || GET_MODE (dest) != Pmode) |
| 1839 |
operands[0] = copy_to_mode_reg (Pmode, dest); |
| 1840 |
|
| 1841 |
emit_jump_insn (gen_indirect_jump_internal1 (operands[0])); |
| 1842 |
DONE; |
| 1843 |
} |
| 1844 |
) |
| 1845 |
|
| 1846 |
;; Indirect jumps. Jump to register values. Assuming absolute jumps |
| 1847 |
|
| 1848 |
(define_insn "indirect_jump_internal1" |
| 1849 |
[(set (pc) (match_operand:SI 0 "register_operand" "d"))] |
| 1850 |
"" |
| 1851 |
"bra%?\t%0" |
| 1852 |
[(set_attr "type" "jump") |
| 1853 |
(set_attr "mode" "none") |
| 1854 |
(set_attr "length" "4")]) |
| 1855 |
|
| 1856 |
(define_expand "tablejump" |
| 1857 |
[(set (pc) |
| 1858 |
(match_operand 0 "register_operand" "d")) |
| 1859 |
(use (label_ref (match_operand 1 "" "")))] |
| 1860 |
"" |
| 1861 |
{ |
| 1862 |
gcc_assert (GET_MODE (operands[0]) == Pmode); |
| 1863 |
|
| 1864 |
if (!flag_pic || TARGET_PIC_DATA_TEXT_REL) |
| 1865 |
emit_jump_insn (gen_tablejump_internal1 (operands[0], operands[1])); |
| 1866 |
else |
| 1867 |
emit_jump_insn (gen_tablejump_internal3 (operands[0], operands[1])); |
| 1868 |
DONE; |
| 1869 |
} |
| 1870 |
) |
| 1871 |
|
| 1872 |
(define_insn "tablejump_internal1" |
| 1873 |
[(set (pc) |
| 1874 |
(match_operand:SI 0 "register_operand" "d")) |
| 1875 |
(use (label_ref (match_operand 1 "" "")))] |
| 1876 |
"" |
| 1877 |
"bra%?\t%0 " |
| 1878 |
[(set_attr "type" "jump") |
| 1879 |
(set_attr "mode" "none") |
| 1880 |
(set_attr "length" "4")]) |
| 1881 |
|
| 1882 |
(define_expand "tablejump_internal3" |
| 1883 |
[(parallel [(set (pc) |
| 1884 |
(plus:SI (match_operand:SI 0 "register_operand" "d") |
| 1885 |
(label_ref:SI (match_operand:SI 1 "" "")))) |
| 1886 |
(use (label_ref:SI (match_dup 1)))])] |
| 1887 |
"" |
| 1888 |
"" |
| 1889 |
) |
| 1890 |
|
| 1891 |
;; need to change for MicroBlaze PIC |
| 1892 |
(define_insn "" |
| 1893 |
[(set (pc) |
| 1894 |
(plus:SI (match_operand:SI 0 "register_operand" "d") |
| 1895 |
(label_ref:SI (match_operand 1 "" "")))) |
| 1896 |
(use (label_ref:SI (match_dup 1)))] |
| 1897 |
"NEXT_INSN (as_a <rtx_insn *> (operands[1])) != 0 |
| 1898 |
&& GET_CODE (PATTERN (NEXT_INSN (as_a <rtx_insn *> (operands[1])))) == ADDR_DIFF_VEC |
| 1899 |
&& flag_pic" |
| 1900 |
{ |
| 1901 |
output_asm_insn ("addk\t%0,%0,r20",operands); |
| 1902 |
return "bra%?\t%0"; |
| 1903 |
} |
| 1904 |
[(set_attr "type" "jump") |
| 1905 |
(set_attr "mode" "none") |
| 1906 |
(set_attr "length" "4")]) |
| 1907 |
|
| 1908 |
(define_expand "tablejump_internal4" |
| 1909 |
[(parallel [(set (pc) |
| 1910 |
(plus:DI (match_operand:DI 0 "register_operand" "d") |
| 1911 |
(label_ref:DI (match_operand:SI 1 "" "")))) |
| 1912 |
(use (label_ref:DI (match_dup 1)))])] |
| 1913 |
"" |
| 1914 |
"" |
| 1915 |
) |
| 1916 |
|
| 1917 |
;;---------------------------------------------------------------- |
| 1918 |
;; Function prologue/epilogue and stack allocation |
| 1919 |
;;---------------------------------------------------------------- |
| 1920 |
(define_expand "prologue" |
| 1921 |
[(const_int 1)] |
| 1922 |
"" |
| 1923 |
{ |
| 1924 |
microblaze_expand_prologue (); |
| 1925 |
DONE; |
| 1926 |
} |
| 1927 |
) |
| 1928 |
|
| 1929 |
(define_expand "epilogue" |
| 1930 |
[(use (const_int 0))] |
| 1931 |
"" |
| 1932 |
{ |
| 1933 |
microblaze_expand_epilogue (); |
| 1934 |
DONE; |
| 1935 |
} |
| 1936 |
) |
| 1937 |
|
| 1938 |
;; An insn to allocate new stack space for dynamic use (e.g., alloca). |
| 1939 |
;; We copy the return address, decrement the stack pointer and save the |
| 1940 |
;; return address again at the new stack top |
| 1941 |
|
| 1942 |
(define_expand "allocate_stack" |
| 1943 |
[(set (match_operand 0 "register_operand" "=r") |
| 1944 |
(minus (reg 1) (match_operand 1 "register_operand" ""))) |
| 1945 |
(set (reg 1) |
| 1946 |
(minus (reg 1) (match_dup 1)))] |
| 1947 |
"" |
| 1948 |
{ |
| 1949 |
rtx retaddr = gen_rtx_MEM (Pmode, stack_pointer_rtx); |
| 1950 |
rtx rtmp = gen_rtx_REG (SImode, R_TMP); |
| 1951 |
rtx neg_op0; |
| 1952 |
|
| 1953 |
emit_move_insn (rtmp, retaddr); |
| 1954 |
if (GET_CODE (operands[1]) != CONST_INT) |
| 1955 |
{ |
| 1956 |
neg_op0 = gen_reg_rtx (Pmode); |
| 1957 |
emit_insn (gen_negsi2 (neg_op0, operands[1])); |
| 1958 |
} else |
| 1959 |
neg_op0 = GEN_INT (- INTVAL (operands[1])); |
| 1960 |
|
| 1961 |
emit_insn (gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx, neg_op0)); |
| 1962 |
emit_move_insn (gen_rtx_MEM (Pmode, stack_pointer_rtx), rtmp); |
| 1963 |
emit_move_insn (operands[0], virtual_stack_dynamic_rtx); |
| 1964 |
emit_insn (gen_rtx_CLOBBER (SImode, rtmp)); |
| 1965 |
DONE; |
| 1966 |
} |
| 1967 |
) |
| 1968 |
|
| 1969 |
(define_expand "save_stack_block" |
| 1970 |
[(match_operand 0 "register_operand" "") |
| 1971 |
(match_operand 1 "register_operand" "")] |
| 1972 |
"" |
| 1973 |
{ |
| 1974 |
emit_move_insn (operands[0], operands[1]); |
| 1975 |
DONE; |
| 1976 |
} |
| 1977 |
) |
| 1978 |
|
| 1979 |
(define_expand "restore_stack_block" |
| 1980 |
[(match_operand 0 "register_operand" "") |
| 1981 |
(match_operand 1 "register_operand" "")] |
| 1982 |
"" |
| 1983 |
{ |
| 1984 |
rtx retaddr = gen_rtx_MEM (Pmode, stack_pointer_rtx); |
| 1985 |
rtx rtmp = gen_rtx_REG (SImode, R_TMP); |
| 1986 |
|
| 1987 |
/* Move the retaddr. */ |
| 1988 |
emit_move_insn (rtmp, retaddr); |
| 1989 |
emit_move_insn (operands[0], operands[1]); |
| 1990 |
emit_move_insn (gen_rtx_MEM (Pmode, operands[0]), rtmp); |
| 1991 |
DONE; |
| 1992 |
} |
| 1993 |
) |
| 1994 |
|
| 1995 |
;; Trivial return. Make it look like a normal return insn as that |
| 1996 |
;; allows jump optimizations to work better . |
| 1997 |
(define_expand "return" |
| 1998 |
[(simple_return)] |
| 1999 |
"microblaze_can_use_return_insn ()" |
| 2000 |
{} |
| 2001 |
) |
| 2002 |
|
| 2003 |
(define_expand "simple_return" |
| 2004 |
[(simple_return)] |
| 2005 |
"" |
| 2006 |
{} |
| 2007 |
) |
| 2008 |
|
| 2009 |
(define_insn "*<optab>" |
| 2010 |
[(any_return)] |
| 2011 |
"" |
| 2012 |
{ |
| 2013 |
if (microblaze_is_break_handler ()) |
| 2014 |
return "rtbd\tr16, 8\;%#"; |
| 2015 |
else if (microblaze_is_interrupt_variant ()) |
| 2016 |
return "rtid\tr14, 0\;%#"; |
| 2017 |
else |
| 2018 |
return "rtsd\tr15, 8\;%#"; |
| 2019 |
} |
| 2020 |
[(set_attr "type" "jump") |
| 2021 |
(set_attr "mode" "none") |
| 2022 |
(set_attr "length" "4")] |
| 2023 |
) |
| 2024 |
|
| 2025 |
;; Normal return. |
| 2026 |
|
| 2027 |
(define_insn "<optab>_internal" |
| 2028 |
[(any_return) |
| 2029 |
(use (match_operand:SI 0 "register_operand" ""))] |
| 2030 |
"" |
| 2031 |
{ |
| 2032 |
if (microblaze_is_break_handler ()) |
| 2033 |
return "rtbd\tr16,8\;%#"; |
| 2034 |
else if (microblaze_is_interrupt_variant ()) |
| 2035 |
return "rtid\tr14,0 \;%#"; |
| 2036 |
else |
| 2037 |
return "rtsd\tr15,8 \;%#"; |
| 2038 |
} |
| 2039 |
[(set_attr "type" "jump") |
| 2040 |
(set_attr "mode" "none") |
| 2041 |
(set_attr "length" "4")]) |
| 2042 |
|
| 2043 |
|
| 2044 |
;; Block any insns from across this point |
| 2045 |
;; Useful to group sequences together. |
| 2046 |
(define_insn "blockage" |
| 2047 |
[(unspec_volatile [(const_int 0)] 0)] |
| 2048 |
"" |
| 2049 |
"" |
| 2050 |
[(set_attr "type" "unknown") |
| 2051 |
(set_attr "mode" "none") |
| 2052 |
(set_attr "length" "0")]) |
| 2053 |
|
| 2054 |
|
| 2055 |
;;---------------------------------------------------------------- |
| 2056 |
;; Function calls |
| 2057 |
;;---------------------------------------------------------------- |
| 2058 |
|
| 2059 |
(define_expand "call" |
| 2060 |
[(parallel [(call (match_operand 0 "memory_operand" "m") |
| 2061 |
(match_operand 1 "" "i")) |
| 2062 |
(clobber (reg:SI R_SR)) |
| 2063 |
(use (match_operand 2 "" "")) |
| 2064 |
(use (match_operand 3 "" ""))])] |
| 2065 |
"" |
| 2066 |
{ |
| 2067 |
rtx addr = XEXP (operands[0], 0); |
| 2068 |
|
| 2069 |
if (flag_pic == 2 && !TARGET_PIC_DATA_TEXT_REL |
| 2070 |
&& GET_CODE (addr) == SYMBOL_REF |
| 2071 |
&& !SYMBOL_REF_LOCAL_P (addr)) |
| 2072 |
{ |
| 2073 |
rtx temp = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, addr), UNSPEC_PLT); |
| 2074 |
XEXP (operands[0], 0) = temp; |
| 2075 |
} |
| 2076 |
|
| 2077 |
if ((GET_CODE (addr) != REG && !CONSTANT_ADDRESS_P (addr)) |
| 2078 |
|| !call_insn_operand (addr, VOIDmode)) |
| 2079 |
XEXP (operands[0], 0) = copy_to_mode_reg (Pmode, addr); |
| 2080 |
|
| 2081 |
if (GET_CODE (XEXP (operands[0], 0)) == UNSPEC) |
| 2082 |
emit_call_insn (gen_call_internal_plt0 (operands[0], operands[1], |
| 2083 |
gen_rtx_REG (SImode, |
| 2084 |
GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM), |
| 2085 |
pic_offset_table_rtx)); |
| 2086 |
else |
| 2087 |
emit_call_insn (gen_call_internal0 (operands[0], operands[1], |
| 2088 |
gen_rtx_REG (SImode, |
| 2089 |
GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM))); |
| 2090 |
|
| 2091 |
DONE; |
| 2092 |
} |
| 2093 |
) |
| 2094 |
|
| 2095 |
(define_expand "call_internal0" |
| 2096 |
[(parallel [(call (match_operand 0 "" "") |
| 2097 |
(match_operand 1 "" "")) |
| 2098 |
(clobber (match_operand:SI 2 "" ""))])] |
| 2099 |
"" |
| 2100 |
{ |
| 2101 |
} |
| 2102 |
) |
| 2103 |
|
| 2104 |
(define_expand "call_internal_plt0" |
| 2105 |
[(parallel [(call (match_operand 0 "" "") |
| 2106 |
(match_operand 1 "" "")) |
| 2107 |
(clobber (match_operand:SI 2 "" "")) |
| 2108 |
(use (match_operand:SI 3 "" ""))])] |
| 2109 |
"" |
| 2110 |
{ |
| 2111 |
} |
| 2112 |
) |
| 2113 |
|
| 2114 |
(define_insn "call_internal_plt" |
| 2115 |
[(call (mem (match_operand:SI 0 "call_insn_plt_operand" "")) |
| 2116 |
(match_operand:SI 1 "" "i")) |
| 2117 |
(clobber (reg:SI R_SR)) |
| 2118 |
(use (reg:SI R_GOT))] |
| 2119 |
"flag_pic" |
| 2120 |
{ |
| 2121 |
rtx target2 |
| 2122 |
= gen_rtx_REG (Pmode, GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM); |
| 2123 |
gen_rtx_CLOBBER (VOIDmode, target2); |
| 2124 |
return "brlid\tr15,%0\;%#"; |
| 2125 |
} |
| 2126 |
[(set_attr "type" "call") |
| 2127 |
(set_attr "mode" "none") |
| 2128 |
(set_attr "length" "4")]) |
| 2129 |
|
| 2130 |
(define_insn "call_internal1" |
| 2131 |
[(call (mem (match_operand:VOID 0 "call_insn_simple_operand" "ri")) |
| 2132 |
(match_operand:SI 1 "" "i")) |
| 2133 |
(clobber (reg:SI R_SR))] |
| 2134 |
"" |
| 2135 |
{ |
| 2136 |
rtx target = operands[0]; |
| 2137 |
rtx target2 |
| 2138 |
= gen_rtx_REG (Pmode, GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM); |
| 2139 |
if (GET_CODE (target) == SYMBOL_REF) { |
| 2140 |
if (microblaze_break_function_p (SYMBOL_REF_DECL (target))) { |
| 2141 |
gen_rtx_CLOBBER (VOIDmode, target2); |
| 2142 |
return "brki\tr16,%0\;%#"; |
| 2143 |
} |
| 2144 |
else { |
| 2145 |
gen_rtx_CLOBBER (VOIDmode, target2); |
| 2146 |
return "brlid\tr15,%0\;%#"; |
| 2147 |
} |
| 2148 |
} else if (GET_CODE (target) == CONST_INT) |
| 2149 |
return "la\t%@,r0,%0\;brald\tr15,%@\;%#"; |
| 2150 |
else if (GET_CODE (target) == REG) |
| 2151 |
return "brald\tr15,%0\;%#"; |
| 2152 |
else { |
| 2153 |
fprintf (stderr,"Unsupported call insn\n"); |
| 2154 |
return NULL; |
| 2155 |
} |
| 2156 |
} |
| 2157 |
[(set_attr "type" "call") |
| 2158 |
(set_attr "mode" "none") |
| 2159 |
(set_attr "length" "4")]) |
| 2160 |
|
| 2161 |
;; calls.cc now passes a fourth argument, make saber happy |
| 2162 |
|
| 2163 |
(define_expand "call_value" |
| 2164 |
[(parallel [(set (match_operand 0 "register_operand" "=d") |
| 2165 |
(call (match_operand 1 "memory_operand" "m") |
| 2166 |
(match_operand 2 "" "i"))) |
| 2167 |
(clobber (reg:SI R_SR)) |
| 2168 |
(use (match_operand 3 "" ""))])] ;; next_arg_reg |
| 2169 |
"" |
| 2170 |
{ |
| 2171 |
rtx addr = XEXP (operands[1], 0); |
| 2172 |
|
| 2173 |
if (flag_pic == 2 && !TARGET_PIC_DATA_TEXT_REL |
| 2174 |
&& GET_CODE (addr) == SYMBOL_REF |
| 2175 |
&& !SYMBOL_REF_LOCAL_P (addr)) |
| 2176 |
{ |
| 2177 |
rtx temp = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, addr), UNSPEC_PLT); |
| 2178 |
XEXP (operands[1], 0) = temp; |
| 2179 |
} |
| 2180 |
|
| 2181 |
if ((GET_CODE (addr) != REG && !CONSTANT_ADDRESS_P (addr)) |
| 2182 |
|| !call_insn_operand (addr, VOIDmode)) |
| 2183 |
XEXP (operands[1], 0) = copy_to_mode_reg (Pmode, addr); |
| 2184 |
|
| 2185 |
if (GET_CODE (XEXP (operands[1], 0)) == UNSPEC) |
| 2186 |
emit_call_insn (gen_call_value_intern_plt0 (operands[0], operands[1], |
| 2187 |
operands[2], |
| 2188 |
gen_rtx_REG (SImode, |
| 2189 |
GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM), |
| 2190 |
pic_offset_table_rtx)); |
| 2191 |
else |
| 2192 |
emit_call_insn (gen_call_value_internal (operands[0], operands[1], |
| 2193 |
operands[2], |
| 2194 |
gen_rtx_REG (SImode, |
| 2195 |
GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM))); |
| 2196 |
|
| 2197 |
DONE; |
| 2198 |
} |
| 2199 |
) |
| 2200 |
|
| 2201 |
|
| 2202 |
(define_expand "call_value_internal" |
| 2203 |
[(parallel [(set (match_operand 0 "" "") |
| 2204 |
(call (match_operand 1 "" "") |
| 2205 |
(match_operand 2 "" ""))) |
| 2206 |
(clobber (match_operand:SI 3 "" "")) |
| 2207 |
])] |
| 2208 |
"" |
| 2209 |
{} |
| 2210 |
) |
| 2211 |
|
| 2212 |
(define_expand "call_value_intern_plt0" |
| 2213 |
[(parallel[(set (match_operand 0 "" "") |
| 2214 |
(call (match_operand 1 "" "") |
| 2215 |
(match_operand 2 "" ""))) |
| 2216 |
(clobber (match_operand:SI 3 "" "")) |
| 2217 |
(use (match_operand:SI 4 "" ""))])] |
| 2218 |
"flag_pic" |
| 2219 |
{} |
| 2220 |
) |
| 2221 |
|
| 2222 |
(define_insn "call_value_intern_plt" |
| 2223 |
[(set (match_operand:VOID 0 "register_operand" "=d") |
| 2224 |
(call (mem (match_operand:SI 1 "call_insn_plt_operand" "")) |
| 2225 |
(match_operand:SI 2 "" "i"))) |
| 2226 |
(clobber (match_operand:SI 3 "register_operand" "=d")) |
| 2227 |
(use (match_operand:SI 4 "register_operand"))] |
| 2228 |
"flag_pic" |
| 2229 |
{ |
| 2230 |
rtx target2 |
| 2231 |
= gen_rtx_REG (Pmode,GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM); |
| 2232 |
|
| 2233 |
gen_rtx_CLOBBER (VOIDmode,target2); |
| 2234 |
return "brlid\tr15,%1\;%#"; |
| 2235 |
} |
| 2236 |
[(set_attr "type" "call") |
| 2237 |
(set_attr "mode" "none") |
| 2238 |
(set_attr "length" "4")]) |
| 2239 |
|
| 2240 |
(define_insn "call_value_intern" |
| 2241 |
[(set (match_operand:VOID 0 "register_operand" "=d") |
| 2242 |
(call (mem (match_operand:VOID 1 "call_insn_operand" "ri")) |
| 2243 |
(match_operand:SI 2 "" "i"))) |
| 2244 |
(clobber (match_operand:SI 3 "register_operand" "=d"))] |
| 2245 |
"" |
| 2246 |
{ |
| 2247 |
rtx target = operands[1]; |
| 2248 |
rtx target2 |
| 2249 |
= gen_rtx_REG (Pmode,GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM); |
| 2250 |
|
| 2251 |
if (GET_CODE (target) == SYMBOL_REF) |
| 2252 |
{ |
| 2253 |
gen_rtx_CLOBBER (VOIDmode,target2); |
| 2254 |
if (microblaze_break_function_p (SYMBOL_REF_DECL (target))) |
| 2255 |
return "brki\tr16,%1\;%#"; |
| 2256 |
else if (SYMBOL_REF_FLAGS (target) & SYMBOL_FLAG_FUNCTION) |
| 2257 |
{ |
| 2258 |
return "brlid\tr15,%1\;%#"; |
| 2259 |
} |
| 2260 |
else |
| 2261 |
{ |
| 2262 |
return "bralid\tr15,%1\;%#"; |
| 2263 |
} |
| 2264 |
} |
| 2265 |
else if (GET_CODE (target) == CONST_INT) |
| 2266 |
return "la\t%@,r0,%1\;brald\tr15,%@\;%#"; |
| 2267 |
else if (GET_CODE (target) == REG) |
| 2268 |
return "brald\tr15,%1\;%#"; |
| 2269 |
else |
| 2270 |
return "Unsupported call insn\n"; |
| 2271 |
} |
| 2272 |
[(set_attr "type" "call") |
| 2273 |
(set_attr "mode" "none") |
| 2274 |
(set_attr "length" "4")]) |
| 2275 |
|
| 2276 |
|
| 2277 |
;; Call subroutine returning any type. |
| 2278 |
(define_expand "untyped_call" |
| 2279 |
[(parallel [(call (match_operand 0 "" "") |
| 2280 |
(const_int 0)) |
| 2281 |
(match_operand 1 "" "") |
| 2282 |
(match_operand 2 "" "")])] |
| 2283 |
"" |
| 2284 |
{ |
| 2285 |
if (operands[0]) /* silence statement not reached warnings */ |
| 2286 |
{ |
| 2287 |
int i; |
| 2288 |
|
| 2289 |
emit_call_insn (gen_call (operands[0], const0_rtx, NULL, const0_rtx)); |
| 2290 |
|
| 2291 |
for (i = 0; i < XVECLEN (operands[2], 0); i++) |
| 2292 |
{ |
| 2293 |
rtx set = XVECEXP (operands[2], 0, i); |
| 2294 |
emit_move_insn (SET_DEST (set), SET_SRC (set)); |
| 2295 |
} |
| 2296 |
|
| 2297 |
emit_insn (gen_blockage ()); |
| 2298 |
DONE; |
| 2299 |
} |
| 2300 |
} |
| 2301 |
) |
| 2302 |
|
| 2303 |
;;---------------------------------------------------------------- |
| 2304 |
;; Misc. |
| 2305 |
;;---------------------------------------------------------------- |
| 2306 |
|
| 2307 |
(define_insn "nop" |
| 2308 |
[(const_int 0)] |
| 2309 |
"" |
| 2310 |
"nop" |
| 2311 |
[(set_attr "type" "nop") |
| 2312 |
(set_attr "mode" "none") |
| 2313 |
(set_attr "length" "4")]) |
| 2314 |
|
| 2315 |
;; Trap instruction pattern for __builtin_trap. Same as the glibc ABORT_INSTRUCTION |
| 2316 |
(define_insn "trap" |
| 2317 |
[(trap_if (const_int 1) (const_int 0))] |
| 2318 |
"" |
| 2319 |
"bri\t0" |
| 2320 |
[(set_attr "type" "trap")] |
| 2321 |
) |
| 2322 |
|
| 2323 |
;; The insn to set GOT. The hardcoded number "8" accounts for $pc difference |
| 2324 |
;; between "mfs" and "addik" instructions. |
| 2325 |
(define_insn "set_got" |
| 2326 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 2327 |
(unspec:SI [(const_int 0)] UNSPEC_SET_GOT))] |
| 2328 |
"" |
| 2329 |
"mfs\t%0,rpc\n\taddik\t%0,%0,_GLOBAL_OFFSET_TABLE_+8" |
| 2330 |
[(set_attr "type" "multi") |
| 2331 |
(set_attr "length" "12")]) |
| 2332 |
|
| 2333 |
;; The insn to set TEXT. |
| 2334 |
;; The hardcoded number "8" accounts for $pc difference |
| 2335 |
;; between "mfs" and "addik" instructions. |
| 2336 |
(define_insn "set_text" |
| 2337 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 2338 |
(unspec:SI[(const_int 0)] UNSPEC_SET_TEXT))] |
| 2339 |
"" |
| 2340 |
"mfs\t%0,rpc\n\taddik\t%0,%0,8@TXTPCREL" |
| 2341 |
[(set_attr "type" "multi") |
| 2342 |
(set_attr "length" "12")]) |
| 2343 |
|
| 2344 |
|
| 2345 |
;; This insn gives the count of leading number of zeros for the second |
| 2346 |
;; operand and stores the result in first operand. |
| 2347 |
(define_insn "clzsi2" |
| 2348 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 2349 |
(clz:SI (match_operand:SI 1 "register_operand" "r")))] |
| 2350 |
"TARGET_HAS_CLZ" |
| 2351 |
"clz\t%0,%1" |
| 2352 |
[(set_attr "type" "arith") |
| 2353 |
(set_attr "mode" "SI") |
| 2354 |
(set_attr "length" "4")]) |
| 2355 |
|
| 2356 |
; This is used in compiling the unwind routines. |
| 2357 |
(define_expand "eh_return" |
| 2358 |
[(use (match_operand 0 "general_operand" ""))] |
| 2359 |
"" |
| 2360 |
" |
| 2361 |
{ |
| 2362 |
microblaze_eh_return (operands[0]); |
| 2363 |
DONE; |
| 2364 |
}") |
| 2365 |
|
| 2366 |
(include "sync.md") |