OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [config/] [or32/] [or32.md] - Blame information for rev 203

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 julius
;; Machine description for GNU compiler, OpenRISC 1000 family, OR32 ISA
2
;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
3
;; Contributed by Damjan Lampret  in 1999.
4
;; Major optimizations by Matjaz Breskvar  in 2005.
5 133 jeremybenn
;; Floating point additions by Jungsook Yang  and Julius Baxter 
6 38 julius
 
7
;; This file is part of GNU CC.
8
 
9
;; GNU CC is free software; you can redistribute it and/or modify
10
;; it under the terms of the GNU General Public License as published by
11
;; the Free Software Foundation; either version 1, or (at your option)
12
;; any later version.
13
 
14
;; GNU CC is distributed in the hope that it will be useful,
15
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
;; GNU General Public License for more details.
18
 
19
;; You should have received a copy of the GNU General Public License
20
;; along with GNU CC; see the file COPYING.  If not, write to
21
;; the Free Software Foundation, 59 Temple Place - Suite 330,
22
;; Boston, MA 02111-1307, USA.
23
 
24
(include "predicates.md")
25
 
26
(define_attr "type"
27
  "unknown,load,store,move,extend,logic,add,mul,shift,compare,branch,jump,fp"
28
  (const_string "unknown"))
29
 
30
;; Number of instructions
31
(define_attr "length" "" (const_int 1))
32
 
33
(define_delay (eq_attr "type" "branch,jump")
34
               [(and (eq_attr "type" "!branch,jump")
35
                     (eq_attr "length" "1")) (nil) (nil)])
36
 
37
;; (define_function_unit NAME MULTIPLICITY SIMULTANEITY
38
;;                       TEST READY-DELAY ISSUE-DELAY [CONFLICT-LIST])
39
;; MULTIPLICITY - Number of functional units of this type
40
;; SIMULTANEITY - Zero for pipelined functional unit
41
;; READY-DELAY - Number of cycles before result is available
42
;; ISSUE-DELAY - Number of cycles before unit can accept new instruction
43
;;
44
;(define_function_unit "bit_unit" 1 0 (eq_attr "type" "shift") 3 1)
45
;(define_function_unit "lsu" 1 0 (eq_attr "type" "load") 3 3)
46
;(define_function_unit "lsu" 1 0 (eq_attr "type" "store") 2 1)
47
;(define_function_unit "alu" 1 0 (eq_attr "type" "add,logic,extend,move,compare") 2 1)
48
;(define_function_unit "mul_unit" 1 0 (eq_attr "type" "mul") 16 16)
49
(define_cpu_unit "or32_alu")
50
(define_insn_reservation "bit_unit" 3 (eq_attr "type" "shift") "or32_alu")
51
(define_insn_reservation "lsu_load" 3 (eq_attr "type" "load") "or32_alu*3")
52
(define_insn_reservation "lsu_store" 2 (eq_attr "type" "store") "or32_alu")
53
(define_insn_reservation "alu_unit" 2 (eq_attr "type" "add,logic,extend,move,compare") "or32_alu")
54
(define_insn_reservation "mul_unit" 16 (eq_attr "type" "mul") "or32_alu*16")
55
 
56
 
57
;; Called after register allocation to add any instructions needed for the
58
;; prologue.  Using a prologue insn is favored compared to putting all of the
59
;; instructions in output_function_prologue(), since it allows the scheduler
60
;; to intermix instructions with the saves of the caller saved registers.  In
61
;; some cases, it might be necessary to emit a barrier instruction as the last
62
;; insn to prevent such scheduling.
63
 
64
(define_expand "prologue"
65
  [(use (const_int 1))]
66
  "TARGET_MASK_SCHED_LOGUE"
67
{
68
  or32_expand_prologue ();
69
  DONE;
70
})
71
 
72
;; Called after register allocation to add any instructions needed for the
73
;; epilogue.  Using an epilogue insn is favored compared to putting all of the
74
;; instructions in output_function_epilogue(), since it allows the scheduler
75
;; to intermix instructions with the restores of the caller saved registers.
76
;; In some cases, it might be necessary to emit a barrier instruction as the
77
;; first insn to prevent such scheduling.
78
(define_expand "epilogue"
79
  [(use (const_int 2))]
80
  "TARGET_MASK_SCHED_LOGUE"
81
{
82
  or32_expand_epilogue (false);
83
  DONE;
84
})
85
 
86
(define_expand "sibcall_epilogue"
87
  [(use (const_int 2))]
88
  "TARGET_MASK_SCHED_LOGUE"
89
{
90
  or32_expand_epilogue (true);
91
  DONE;
92
})
93
 
94
(define_insn "return_internal"
95
  [(return)
96
   (use (match_operand 0 "pmode_register_operand" ""))]
97
  "TARGET_MASK_SCHED_LOGUE"
98
  "l.jr    \t%0%("
99
  [(set_attr "type" "jump")
100
   (set_attr "length" "1")])
101
 
102
;;
103
;; Sibcalls
104
;;
105
 
106
(define_expand "sibcall"
107
  [(parallel [(call (match_operand 0 "" "")
108
                    (match_operand 1 "" ""))
109
              (use (match_operand 2 "" ""))     ;; next_arg_reg
110
              (use (match_operand 3 "" ""))])]  ;; struct_value_size_rtx
111
  "TARGET_MASK_SIBCALL"
112
  "
113
{
114
  or32_expand_sibcall (0, XEXP (operands[0], 0), operands[1]);
115
  DONE;
116
}")
117
 
118
(define_expand "sibcall_value"
119
  [(set (match_operand 0 "" "")
120
                   (call (match_operand:SI 1 "" "")
121
                         (match_operand 2 "" "")))]
122
  "TARGET_MASK_SIBCALL"
123
  "
124
{
125
  or32_expand_sibcall (operands[0], XEXP (operands[1], 0), operands[2]);
126
  DONE;
127
}")
128
 
129
(define_insn "sibcall_internal"
130
  [(call (mem:SI (match_operand:SI 0 "sibcall_insn_operand" "s,r"))
131
         (match_operand 1 "" ""))
132
   (use (reg:SI 9))]
133
  "TARGET_MASK_SIBCALL"
134
  "@
135
   l.j     \t%S0%(\t    # sibcall s
136
   l.jr    \t%0%(\t     # sibcall r"
137
  [(set_attr "type" "jump,jump")])
138
 
139
 
140
 
141
;;
142
;; movQI
143
;;
144
 
145
(define_expand "movqi"
146
  [(set (match_operand:QI 0 "general_operand" "")
147
        (match_operand:QI 1 "general_operand" ""))]
148
  ""
149
  "
150
      if (!no_new_pseudos)
151
        {
152
          if (GET_CODE (operands[1]) == CONST_INT)
153
            {
154
              rtx reg = gen_reg_rtx (SImode);
155
 
156
              emit_insn (gen_movsi (reg, operands[1]));
157
              operands[1] = gen_lowpart (QImode, reg);
158
            }
159
          if (GET_CODE (operands[1]) == MEM && optimize > 0)
160
            {
161
              rtx reg = gen_reg_rtx (SImode);
162
 
163
              emit_insn (gen_rtx_SET (SImode, reg,
164
                                  gen_rtx_ZERO_EXTEND (SImode,
165
                                                       operands[1])));
166
 
167
              operands[1] = gen_lowpart (QImode, reg);
168
            }
169
          if (GET_CODE (operands[0]) != REG)
170
            operands[1] = force_reg (QImode, operands[1]);
171
        }
172
")
173
 
174
(define_insn "*movqi_internal"
175
  [(set (match_operand:QI 0 "nonimmediate_operand" "=m,r,r,r,r")
176
        (match_operand:QI 1 "general_operand"       "r,r,I,K,m"))]
177
  ""
178
  "@
179
   l.sb    \t%0,%1\t    # movqi
180
   l.ori   \t%0,%1,0\t  # movqi: move reg to reg
181
   l.addi  \t%0,r0,%1\t # movqi: move immediate
182
   l.ori   \t%0,r0,%1\t # movqi: move immediate
183
   l.lbz   \t%0,%1\t    # movqi"
184
  [(set_attr "type" "store,add,add,logic,load")])
185
 
186
 
187
;;
188
;; movHI
189
;;
190
 
191
(define_expand "movhi"
192
  [(set (match_operand:HI 0 "general_operand" "")
193
        (match_operand:HI 1 "general_operand" ""))]
194
  ""
195
  "
196
      if (!no_new_pseudos)
197
        {
198
          if (GET_CODE (operands[1]) == CONST_INT)
199
            {
200
              rtx reg = gen_reg_rtx (SImode);
201
 
202
              emit_insn (gen_movsi (reg, operands[1]));
203
              operands[1] = gen_lowpart (HImode, reg);
204
            }
205
          if (GET_CODE (operands[1]) == MEM && optimize > 0)
206
            {
207
              rtx reg = gen_reg_rtx (SImode);
208
 
209
              emit_insn (gen_rtx_SET (SImode, reg,
210
                                      gen_rtx_ZERO_EXTEND (SImode,
211
                                                           operands[1])));
212
              operands[1] = gen_lowpart (HImode, reg);
213
            }
214
          if (GET_CODE (operands[0]) != REG)
215
            operands[1] = force_reg (HImode, operands[1]);
216
        }
217
")
218
 
219
(define_insn "*movhi_internal"
220
  [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r,r,r,r")
221
        (match_operand:HI 1 "general_operand"       "r,r,I,K,m"))]
222
  ""
223
  "@
224
   l.sh    \t%0,%1\t # movhi
225
   l.ori   \t%0,%1,0\t # movhi: move reg to reg
226
   l.addi  \t%0,r0,%1\t # movhi: move immediate
227
   l.ori   \t%0,r0,%1\t # movhi: move immediate
228
   l.lhz   \t%0,%1\t # movhi"
229
  [(set_attr "type" "store,add,add,logic,load")])
230
 
231
(define_expand "movsi"
232
  [(set (match_operand:SI 0 "general_operand" "")
233
        (match_operand:SI 1 "general_operand" ""))]
234
  ""
235
{
236
  /* Working with CONST_INTs is easier, so convert
237
     a double if needed.  */
238
 
239
     if (GET_CODE (operands[1]) == CONST_DOUBLE) {
240
           operands[1] = GEN_INT (CONST_DOUBLE_LOW (operands[1]));
241
  }
242
 
243
  /* Handle sets of MEM first.  */
244
  if (GET_CODE (operands[0]) == MEM)
245
  {
246
   if (register_operand(operands[1], SImode)
247
                       || (operands[1] == const0_rtx))
248
        goto movsi_is_ok;
249
 
250
      if (! reload_in_progress)
251
        {
252
          operands[0] = validize_mem (operands[0]);
253
          operands[1] = force_reg (SImode, operands[1]);
254
        }
255
    }
256
 
257
  /* This makes sure we will not get rematched due to splittage.  */
258
  if (! CONSTANT_P (operands[1]) || input_operand (operands[1], SImode))
259
    ;
260
  else if (CONSTANT_P (operands[1])
261
           && GET_CODE (operands[1]) != HIGH
262
           && GET_CODE (operands[1]) != LO_SUM)
263
    {
264
      or32_emit_set_const32 (operands[0], operands[1]);
265
      DONE;
266
    }
267
 movsi_is_ok:
268
  ;
269
})
270
 
271
;;
272
;; movSI
273
;;
274
 
275
(define_insn "*movsi_insn"
276
  [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,r,r,r,m")
277
        (match_operand:SI 1 "input_operand"       "I,K,M,r,m,r"))]
278
  "(register_operand (operands[0], SImode)
279
    || register_operand (operands[1], SImode)
280
    || (operands[1] == const0_rtx))"
281
  "@
282
   l.addi  \t%0,r0,%1\t # move immediate I
283
   l.ori   \t%0,r0,%1\t # move immediate K
284
   l.movhi \t%0,hi(%1)\t # move immediate M
285
   l.ori   \t%0,%1,0\t # move reg to reg
286
   l.lwz   \t%0,%1\t # SI load
287
   l.sw    \t%0,%1\t # SI store"
288
  [(set_attr "type" "add,load,store,add,logic,move")
289
   (set_attr "length" "1,1,1,1,1,1")])
290
 
291
(define_insn "*movsi_lo_sum"
292
  [(set (match_operand:SI 0 "register_operand" "=r")
293
        (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
294
                   (match_operand:SI 2 "immediate_operand" "i")))]
295
  ""
296
  "l.ori   \t%0,%1,lo(%2)"
297
 [(set_attr "type" "logic")
298
   (set_attr "length" "1")])
299
 
300
(define_insn "*movsi_high"
301
  [(set (match_operand:SI 0 "register_operand" "=r")
302
        (high:SI (match_operand:SI 1 "immediate_operand" "i")))]
303
  ""
304
  "l.movhi  \t%0,hi(%1)"
305
[(set_attr "type" "move")
306
   (set_attr "length" "1")])
307
 
308
(define_insn "movsi_insn_big"
309
  [(set (match_operand:SI 0 "nonimmediate_operand" "=r")
310
        (match_operand:SI 1 "immediate_operand" "i"))]
311
  "GET_CODE(operands[1]) != CONST_INT"
312
  "l.movhi \t%0,hi(%1)\;l.ori   \t%0,%0,lo(%1)"
313
  [(set_attr "type" "move")
314
   (set_attr "length" "2")])
315
 
316
 
317
;;
318
;; Conditional Branches & Moves
319
;;
320
 
321
(define_expand "addsicc"
322
  [(match_operand:SI 0 "register_operand" "")
323
   (match_operand 1 "comparison_operator" "")
324
   (match_operand:SI 2 "register_operand" "")
325
   (match_operand:SI 3 "register_operand" "")]
326
  ""
327
  "FAIL;")
328
 
329
(define_expand "addhicc"
330
  [(match_operand:HI 0 "register_operand" "")
331
   (match_operand 1 "comparison_operator" "")
332
   (match_operand:HI 2 "register_operand" "")
333
   (match_operand:HI 3 "register_operand" "")]
334
  ""
335
  "FAIL;")
336
 
337
(define_expand "addqicc"
338
  [(match_operand:QI 0 "register_operand" "")
339
   (match_operand 1 "comparison_operator" "")
340
   (match_operand:QI 2 "register_operand" "")
341
   (match_operand:QI 3 "register_operand" "")]
342
  ""
343
  "FAIL;")
344
 
345
 
346
;;
347
;; conditional moves
348
;;
349
 
350
(define_expand "movsicc"
351
   [(set (match_operand:SI 0 "register_operand" "")
352
         (if_then_else:SI (match_operand 1 "comparison_operator" "")
353
                          (match_operand:SI 2 "register_operand" "")
354
                          (match_operand:SI 3 "register_operand" "")))]
355
  "TARGET_MASK_CMOV"
356
  "
357
{
358
  if (or32_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
359
    DONE;
360
}")
361
 
362
(define_expand "movhicc"
363
   [(set (match_operand:HI 0 "register_operand" "")
364
         (if_then_else:SI (match_operand 1 "comparison_operator" "")
365
                          (match_operand:HI 2 "register_operand" "")
366
                          (match_operand:HI 3 "register_operand" "")))]
367
  ""
368
  "
369
{
370
    FAIL;
371
}")
372
 
373
(define_expand "movqicc"
374
   [(set (match_operand:QI 0 "register_operand" "")
375
         (if_then_else:SI (match_operand 1 "comparison_operator" "")
376
                          (match_operand:QI 2 "register_operand" "")
377
                          (match_operand:QI 3 "register_operand" "")))]
378
  ""
379
  "
380
{
381
    FAIL;
382
}")
383
 
384
 
385
;; We use the BASE_REGS for the cmov input operands because, if rA is
386
;; 0, the value of 0 is placed in rD upon truth.  Similarly for rB
387
;; because we may switch the operands and rB may end up being rA.
388
 
389
(define_insn "cmov"
390
  [(set (match_operand:SI 0 "register_operand" "=r")
391
        (if_then_else:SI
392
         (match_operator 1 "comparison_operator"
393
                         [(match_operand 4 "cc_reg_operand" "")
394
                          (const_int 0)])
395
         (match_operand:SI 2 "register_operand" "r")
396
         (match_operand:SI 3 "register_operand" "r")))]
397
  "TARGET_MASK_CMOV"
398
  "*
399
   return or32_output_cmov(operands);
400
  ")
401
 
402
;;
403
;;  ....................
404
;;
405
;;      COMPARISONS
406
;;
407
;;  ....................
408
 
409
;; Flow here is rather complex:
410
;;
411
;;  1)  The cmp{si,di,sf,df} routine is called.  It deposits the
412
;;      arguments into the branch_cmp array, and the type into
413
;;      branch_type.  No RTL is generated.
414
;;
415
;;  2)  The appropriate branch define_expand is called, which then
416
;;      creates the appropriate RTL for the comparison and branch.
417
;;      Different CC modes are used, based on what type of branch is
418
;;      done, so that we can constrain things appropriately.  There
419
;;      are assumptions in the rest of GCC that break if we fold the
420
;;      operands into the branches for integer operations, and use cc0
421
;;      for floating point, so we use the fp status register instead.
422
;;      If needed, an appropriate temporary is created to hold the
423
;;      of the integer compare.
424
 
425
;; Compare insns are next.  Note that the RS/6000 has two types of compares,
426
;; signed & unsigned, and one type of branch.
427
;;
428
;; Start with the DEFINE_EXPANDs to generate the rtl for compares, scc
429
;; insns, and branches.  We store the operands of compares until we see
430
;; how it is used.
431
 
432
(define_expand "cmpsi"
433
  [(set (reg:CC 32)
434
        (compare:CC (match_operand:SI 0 "register_operand" "")
435
                    (match_operand:SI 1 "nonmemory_operand" "")))]
436
  ""
437 133 jeremybenn
  {
438
   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
439
      operands[0] = force_reg (SImode, operands[0]);
440
      or32_compare_op0 = operands[0];
441
      or32_compare_op1 = operands[1];
442
      DONE;
443
      })
444 38 julius
 
445 133 jeremybenn
(define_expand "cmpsf"
446
  [(set (reg:CC 32)
447
        (compare:CC (match_operand:SF 0 "register_operand" "")
448
                    (match_operand:SF 1 "register_operand" "")))]
449
  "TARGET_HARD_FLOAT"
450
  {
451
   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
452
      operands[0] = force_reg (SFmode, operands[0]);
453
      or32_compare_op0 = operands[0];
454
      or32_compare_op1 = operands[1];
455
      DONE;
456
      })
457
 
458 38 julius
 
459
 
460
;;
461
;; Conditional branches
462
;;
463
 
464
(define_expand "beq"
465
  [(use (match_operand 0 "" ""))]
466
  ""
467
  "or32_expand_branch (EQ, operands[0]); DONE;")
468
 
469
(define_expand "bne"
470
  [(use (match_operand 0 "" ""))]
471
  ""
472
  "or32_expand_branch (NE, operands[0]); DONE;")
473
 
474
(define_expand "bgt"
475
  [(use (match_operand 0 "" ""))]
476
  ""
477
  "or32_expand_branch (GT, operands[0]); DONE;")
478
 
479
(define_expand "bgtu"
480
  [(use (match_operand 0 "" ""))]
481
  ""
482
  "or32_expand_branch (GTU, operands[0]); DONE;")
483
 
484
(define_expand "blt"
485
  [(use (match_operand 0 "" ""))]
486
  ""
487
  "or32_expand_branch (LT, operands[0]); DONE;")
488
 
489
(define_expand "bltu"
490
  [(use (match_operand 0 "" ""))]
491
  ""
492
  "or32_expand_branch (LTU, operands[0]); DONE;")
493
 
494
(define_expand "bge"
495
  [(use (match_operand 0 "" ""))]
496
  ""
497
  "or32_expand_branch (GE, operands[0]); DONE;")
498
 
499
(define_expand "bgeu"
500
  [(use (match_operand 0 "" ""))]
501
  ""
502
  "or32_expand_branch (GEU, operands[0]); DONE;")
503
 
504
(define_expand "ble"
505
  [(use (match_operand 0 "" ""))]
506
  ""
507
  "or32_expand_branch (LE, operands[0]); DONE;")
508
 
509
(define_expand "bleu"
510
  [(use (match_operand 0 "" ""))]
511
  ""
512
  "or32_expand_branch (LEU, operands[0]); DONE;")
513
 
514
 
515
 
516
;;
517
;; Setting a CCxx registers from comparision
518
;;
519
 
520
 
521
 
522
;; Here are the actual compare insns.
523
(define_insn "*cmpsi_eq"
524
  [(set (reg:CCEQ 32)
525
        (compare:CCEQ (match_operand:SI 0 "register_operand" "r,r")
526
                      (match_operand:SI 1 "nonmemory_operand" "I,r")))]
527
  ""
528
  "@
529
   l.sfeqi\t%0,%1
530
   l.sfeq \t%0,%1")
531
 
532
(define_insn "*cmpsi_ne"
533
  [(set (reg:CCNE 32)
534
        (compare:CCNE (match_operand:SI 0 "register_operand" "r,r")
535
                      (match_operand:SI 1 "nonmemory_operand" "I,r")))]
536
  ""
537
  "@
538
   l.sfnei\t%0,%1
539
   l.sfne \t%0,%1")
540
 
541
(define_insn "*cmpsi_gt"
542
  [(set (reg:CCGT 32)
543
        (compare:CCGT (match_operand:SI 0 "register_operand" "r,r")
544
                      (match_operand:SI 1 "nonmemory_operand" "I,r")))]
545
  ""
546
  "@
547
   l.sfgtsi\t%0,%1
548
   l.sfgts \t%0,%1")
549
 
550
(define_insn "*cmpsi_gtu"
551
  [(set (reg:CCGTU 32)
552
        (compare:CCGTU (match_operand:SI 0 "register_operand" "r,r")
553
                       (match_operand:SI 1 "nonmemory_operand" "I,r")))]
554
  ""
555
  "@
556
   l.sfgtui\t%0,%1
557
   l.sfgtu \t%0,%1")
558
 
559
(define_insn "*cmpsi_lt"
560
  [(set (reg:CCLT 32)
561
        (compare:CCLT (match_operand:SI 0 "register_operand" "r,r")
562
                      (match_operand:SI 1 "nonmemory_operand" "I,r")))]
563
  ""
564
  "@
565
   l.sfltsi\t%0,%1
566
   l.sflts \t%0,%1")
567
 
568
(define_insn "*cmpsi_ltu"
569
  [(set (reg:CCLTU 32)
570
        (compare:CCLTU (match_operand:SI 0 "register_operand" "r,r")
571
                       (match_operand:SI 1 "nonmemory_operand" "I,r")))]
572
  ""
573
  "@
574
   l.sfltui\t%0,%1
575
   l.sfltu \t%0,%1")
576
 
577
(define_insn "*cmpsi_ge"
578
  [(set (reg:CCGE 32)
579
        (compare:CCGE (match_operand:SI 0 "register_operand" "r,r")
580
                      (match_operand:SI 1 "nonmemory_operand" "I,r")))]
581
  ""
582
  "@
583
   l.sfgesi\t%0,%1
584
   l.sfges \t%0,%1")
585
 
586
 
587
(define_insn "*cmpsi_geu"
588
  [(set (reg:CCGEU 32)
589
        (compare:CCGEU (match_operand:SI 0 "register_operand" "r,r")
590
                       (match_operand:SI 1 "nonmemory_operand" "I,r")))]
591
  ""
592
  "@
593
   l.sfgeui\t%0,%1
594
   l.sfgeu \t%0,%1")
595
 
596
 
597
(define_insn "*cmpsi_le"
598
  [(set (reg:CCLE 32)
599
        (compare:CCLE (match_operand:SI 0 "register_operand" "r,r")
600
                      (match_operand:SI 1 "nonmemory_operand" "I,r")))]
601
  ""
602
  "@
603
   l.sflesi\t%0,%1
604
   l.sfles \t%0,%1")
605
 
606
(define_insn "*cmpsi_leu"
607
  [(set (reg:CCLEU 32)
608
        (compare:CCLEU (match_operand:SI 0 "register_operand" "r,r")
609
                       (match_operand:SI 1 "nonmemory_operand" "I,r")))]
610
  ""
611
  "@
612
   l.sfleui\t%0,%1
613
   l.sfleu \t%0,%1")
614
 
615 133 jeremybenn
;; Single precision floating point evaluation instructions
616
(define_insn "*cmpsf_eq"
617
  [(set (reg:CCEQ 32)
618
        (compare:CCEQ (match_operand:SF 0 "register_operand" "r,r")
619
                      (match_operand:SF 1 "register_operand" "r,r")))]
620
  "TARGET_HARD_FLOAT"
621
  "lf.sfeq.s\t%0,%1")
622
 
623
(define_insn "*cmpsf_ne"
624
  [(set (reg:CCNE 32)
625
        (compare:CCNE (match_operand:SF 0 "register_operand" "r,r")
626
                      (match_operand:SF 1 "register_operand" "r,r")))]
627
  "TARGET_HARD_FLOAT"
628
  "lf.sfne.s\t%0,%1")
629
 
630
 
631
(define_insn "*cmpsf_gt"
632
  [(set (reg:CCGT 32)
633
        (compare:CCGT (match_operand:SF 0 "register_operand" "r,r")
634
                      (match_operand:SF 1 "register_operand" "r,r")))]
635
  "TARGET_HARD_FLOAT"
636
  "lf.sfgt.s\t%0,%1")
637
 
638
(define_insn "*cmpsf_ge"
639
  [(set (reg:CCGE 32)
640
        (compare:CCGE (match_operand:SF 0 "register_operand" "r,r")
641
                      (match_operand:SF 1 "register_operand" "r,r")))]
642
  "TARGET_HARD_FLOAT"
643
  "lf.sfge.s\t%0,%1")
644
 
645
 
646
(define_insn "*cmpsf_lt"
647
  [(set (reg:CCLT 32)
648
        (compare:CCLT (match_operand:SF 0 "register_operand" "r,r")
649
                      (match_operand:SF 1 "register_operand" "r,r")))]
650
  "TARGET_HARD_FLOAT"
651
  "lf.sflt.s\t%0,%1")
652
 
653
(define_insn "*cmpsf_le"
654
  [(set (reg:CCLE 32)
655
        (compare:CCLE (match_operand:SF 0 "register_operand" "r,r")
656
                      (match_operand:SF 1 "register_operand" "r,r")))]
657
  "TARGET_HARD_FLOAT"
658
  "lf.sfle.s\t%0,%1")
659
 
660 38 julius
(define_insn "*bf"
661
  [(set (pc)
662
        (if_then_else (match_operator 1 "comparison_operator"
663
                                      [(match_operand 2
664
                                                      "cc_reg_operand" "")
665
                                       (const_int 0)])
666
                      (label_ref (match_operand 0 "" ""))
667
                      (pc)))]
668
  ""
669
  "*
670
   return or32_output_bf(operands);
671
  "
672
  [(set_attr "type" "branch")
673
   (set_attr "length" "1")])
674
 
675
;;
676
;;
677
;;
678
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
679
;;
680
;;
681
(define_insn "movdi"
682
        [(set (match_operand:DI 0 "nonimmediate_operand" "=r, r, m, r")
683
              (match_operand:DI 1 "general_operand"      " r, m, r, i"))]
684
        ""
685
        "*
686
         return or32_output_move_double (operands);
687
        "
688
        [(set_attr "length" "2,2,2,3")])
689
 
690
(define_insn "movdf"
691
        [(set (match_operand:DF 0 "nonimmediate_operand" "=r, r, m, r")
692
              (match_operand:DF 1 "general_operand"      " r, m, r, i"))]
693
        ""
694
        "*
695
         return or32_output_move_double (operands);
696
        "
697
        [(set_attr "length" "2,2,2,3")])
698
 
699
 
700
(define_insn "movsf"
701
  [(set (match_operand:SF 0 "general_operand" "=r,r,m")
702
        (match_operand:SF 1 "general_operand"  "r,m,r"))]
703
  ""
704
  "@
705
   l.ori   \t%0,%1,0\t # movsf
706
   l.lwz   \t%0,%1\t # movsf
707
   l.sw    \t%0,%1\t # movsf"
708
[(set_attr "type" "move,load,store")
709
   (set_attr "length" "1,1,1")])
710
 
711
;;
712
;; extendqisi2
713
;;
714
 
715
(define_expand "extendqisi2"
716
  [(use (match_operand:SI 0 "register_operand" ""))
717
   (use (match_operand:QI 1 "nonimmediate_operand" ""))]
718
  ""
719
  "
720
{
721
  if (TARGET_MASK_SEXT)
722
    emit_insn (gen_extendqisi2_sext(operands[0], operands[1]));
723
  else {
724
    if ( GET_CODE(operands[1]) == MEM ) {
725
      emit_insn (gen_extendqisi2_no_sext_mem(operands[0], operands[1]));
726
    }
727
    else {
728
      emit_insn (gen_extendqisi2_no_sext_reg(operands[0], operands[1]));
729
    }
730
 }
731
 DONE;
732
}")
733
 
734
(define_insn "extendqisi2_sext"
735
  [(set (match_operand:SI 0 "register_operand" "=r,r")
736
        (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "r,m")))]
737
  "TARGET_MASK_SEXT"
738
  "@
739
   l.extbs \t%0,%1\t # extendqisi2_has_signed_extend
740
   l.lbs   \t%0,%1\t # extendqisi2_has_signed_extend"
741
  [(set_attr "length" "1,1")
742
   (set_attr "type" "extend,load")])
743
 
744
(define_insn "extendqisi2_no_sext_mem"
745
  [(set (match_operand:SI 0 "register_operand" "=r")
746
        (sign_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
747
  "!TARGET_MASK_SEXT"
748
  "l.lbs   \t%0,%1\t # extendqisi2_no_sext_mem"
749
  [(set_attr "length" "1")
750
   (set_attr "type" "load")])
751
 
752
(define_expand "extendqisi2_no_sext_reg"
753
  [(set (match_dup 2)
754
        (ashift:SI (match_operand:QI 1 "register_operand" "")
755
                   (const_int 24)))
756
   (set (match_operand:SI 0 "register_operand" "")
757
        (ashiftrt:SI (match_dup 2)
758
                     (const_int 24)))]
759
  "!TARGET_MASK_SEXT"
760
  "
761
{
762
  operands[1] = gen_lowpart (SImode, operands[1]);
763
  operands[2] = gen_reg_rtx (SImode); }")
764
 
765
;;
766
;; extendhisi2
767
;;
768
 
769
(define_expand "extendhisi2"
770
  [(use (match_operand:SI 0 "register_operand" ""))
771
   (use (match_operand:HI 1 "nonimmediate_operand" ""))]
772
  ""
773
  "
774
{
775
  if (TARGET_MASK_SEXT)
776
    emit_insn (gen_extendhisi2_sext(operands[0], operands[1]));
777
  else {
778
    if ( GET_CODE(operands[1]) == MEM ) {
779
      emit_insn (gen_extendhisi2_no_sext_mem(operands[0], operands[1]));
780
    }
781
    else {
782
      emit_insn (gen_extendhisi2_no_sext_reg(operands[0], operands[1]));
783
    }
784
 }
785
 DONE;
786
}")
787
 
788
(define_insn "extendhisi2_sext"
789
  [(set (match_operand:SI 0 "register_operand" "=r,r")
790
        (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "r,m")))]
791
  "TARGET_MASK_SEXT"
792
  "@
793
   l.exths \t%0,%1\t # extendhisi2_has_signed_extend
794
   l.lhs   \t%0,%1\t # extendhisi2_has_signed_extend"
795
  [(set_attr "length" "1,1")
796
   (set_attr "type" "extend,load")])
797
 
798
(define_insn "extendhisi2_no_sext_mem"
799
  [(set (match_operand:SI 0 "register_operand" "=r")
800
        (sign_extend:SI (match_operand:HI 1 "memory_operand" "m")))]
801
  "!TARGET_MASK_SEXT"
802
  "l.lhs   \t%0,%1\t # extendhisi2_no_sext_mem"
803
  [(set_attr "length" "1")
804
   (set_attr "type" "load")])
805
 
806
(define_expand "extendhisi2_no_sext_reg"
807
  [(set (match_dup 2)
808
        (ashift:SI (match_operand:HI 1 "register_operand" "")
809
                   (const_int 16)))
810
   (set (match_operand:SI 0 "register_operand" "")
811
        (ashiftrt:SI (match_dup 2)
812
                     (const_int 16)))]
813
  "!TARGET_MASK_SEXT"
814
  "
815
{
816
  operands[1] = gen_lowpart (SImode, operands[1]);
817
  operands[2] = gen_reg_rtx (SImode); }")
818
 
819
 
820
;;
821
;; zero_extend2
822
;;
823
 
824
(define_insn "zero_extendqisi2"
825
  [(set (match_operand:SI 0 "register_operand" "=r,r")
826
        (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "r,m")))]
827
  ""
828
  "@
829
   l.andi  \t%0,%1,0xff\t # zero_extendqisi2
830
   l.lbz   \t%0,%1\t # zero_extendqisi2"
831
  [(set_attr "type" "logic,load")
832
   (set_attr "length" "1,1")])
833
 
834
 
835
(define_insn "zero_extendhisi2"
836
  [(set (match_operand:SI 0 "register_operand" "=r,r")
837
        (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "r,m")))]
838
  ""
839
  "@
840
   l.andi  \t%0,%1,0xffff\t # zero_extendqisi2
841
   l.lhz   \t%0,%1\t # zero_extendqisi2"
842
  [(set_attr "type" "logic,load")
843
   (set_attr "length" "1,1")])
844
 
845
;;
846
;; Shift/rotate operations
847
;;
848
 
849
(define_insn "ashlsi3"
850
  [(set (match_operand:SI 0 "register_operand" "=r,r")
851
        (ashift:SI (match_operand:SI 1 "register_operand" "r,r")
852
                   (match_operand:SI 2 "nonmemory_operand" "r,L")))]
853
  ""
854
  "@
855
   l.sll   \t%0,%1,%2
856
   l.slli  \t%0,%1,%2"
857
  [(set_attr "type" "shift,shift")
858
   (set_attr "length" "1,1")])
859
 
860
(define_insn "ashrsi3"
861
  [(set (match_operand:SI 0 "register_operand" "=r,r")
862
        (ashiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
863
                   (match_operand:SI 2 "nonmemory_operand" "r,L")))]
864
  ""
865
  "@
866
   l.sra   \t%0,%1,%2
867
   l.srai  \t%0,%1,%2"
868
  [(set_attr "type" "shift,shift")
869
   (set_attr "length" "1,1")])
870
 
871
(define_insn "lshrsi3"
872
  [(set (match_operand:SI 0 "register_operand" "=r,r")
873
        (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
874
                   (match_operand:SI 2 "nonmemory_operand" "r,L")))]
875
  ""
876
  "@
877
   l.srl   \t%0,%1,%2
878
   l.srli  \t%0,%1,%2"
879
  [(set_attr "type" "shift,shift")
880
   (set_attr "length" "1,1")])
881
 
882
(define_insn "rotrsi3"
883
  [(set (match_operand:SI 0 "register_operand" "=r,r")
884
        (rotatert:SI (match_operand:SI 1 "register_operand" "r,r")
885
                   (match_operand:SI 2 "nonmemory_operand" "r,L")))]
886
  "TARGET_MASK_ROR"
887
  "@
888
   l.ror   \t%0,%1,%2
889
   l.rori  \t%0,%1,%2"
890
  [(set_attr "type" "shift,shift")
891
   (set_attr "length" "1,1")])
892
 
893
;;
894
;; Logical bitwise operations
895
;;
896
 
897
(define_insn "andsi3"
898
  [(set (match_operand:SI 0 "register_operand" "=r,r")
899
        (and:SI (match_operand:SI 1 "register_operand" "%r,r")
900
                (match_operand:SI 2 "nonmemory_operand" "r,K")))]
901
  ""
902
  "@
903
   l.and   \t%0,%1,%2
904
   l.andi  \t%0,%1,%2"
905
  [(set_attr "type" "logic,logic")
906
   (set_attr "length" "1,1")])
907
 
908
(define_insn "iorsi3"
909
  [(set (match_operand:SI 0 "register_operand" "=r,r")
910
        (ior:SI (match_operand:SI 1 "register_operand" "%r,r")
911
                (match_operand:SI 2 "nonmemory_operand" "r,K")))]
912
  ""
913
  "@
914
   l.or    \t%0,%1,%2
915
   l.ori   \t%0,%1,%2"
916
  [(set_attr "type" "logic,logic")
917
   (set_attr "length" "1,1")])
918
 
919
(define_insn "xorsi3"
920
  [(set (match_operand:SI 0 "register_operand" "=r,r")
921
        (xor:SI (match_operand:SI 1 "register_operand" "%r,r")
922
                (match_operand:SI 2 "nonmemory_operand" "r,I")))]
923
  ""
924
  "@
925
   l.xor   \t%0,%1,%2
926
   l.xori  \t%0,%1,%2"
927
  [(set_attr "type" "logic,logic")
928
   (set_attr "length" "1,1")])
929
 
930
(define_insn "one_cmplqi2"
931
  [(set (match_operand:QI 0 "register_operand" "=r")
932
        (not:QI (match_operand:QI 1 "register_operand" "r")))]
933
  ""
934
  "l.xori  \t%0,%1,0x00ff"
935
  [(set_attr "type" "logic")
936
   (set_attr "length" "1")])
937
 
938
(define_insn "one_cmplsi2"
939
  [(set (match_operand:SI 0 "register_operand" "=r")
940
        (not:SI (match_operand:SI 1 "register_operand" "r")))]
941
  ""
942
  "l.xori  \t%0,%1,0xffff"
943
  [(set_attr "type" "logic")
944
   (set_attr "length" "1")])
945
 
946
;;
947
;; Arithmetic operations
948
;;
949
 
950
(define_insn "negsi2"
951
  [(set (match_operand:SI 0 "register_operand" "=r")
952
        (neg:SI (match_operand:SI 1 "register_operand" "r")))]
953
  ""
954
  "l.sub   \t%0,r0,%1"
955
  [(set_attr "type" "add")
956
   (set_attr "length" "1")])
957
 
958
(define_insn "addsi3"
959
  [(set (match_operand:SI 0 "register_operand" "=r,r")
960
        (plus:SI (match_operand:SI 1 "register_operand" "%r,r")
961
                 (match_operand:SI 2 "nonmemory_operand" "r,I")))]
962
  ""
963
  "@
964
   l.add   \t%0,%1,%2
965
   l.addi  \t%0,%1,%2"
966
  [(set_attr "type" "add,add")
967
   (set_attr "length" "1,1")])
968
 
969
(define_insn "subsi3"
970
  [(set (match_operand:SI 0 "register_operand" "=r,r")
971
        (minus:SI (match_operand:SI 1 "register_operand" "r,r")
972
                  (match_operand:SI 2 "nonmemory_operand" "r,I")))]
973
  ""
974
  "@
975
   l.sub   \t%0,%1,%2
976
   l.addi  \t%0,%1,%n2"
977
  [(set_attr "type" "add,add")]
978
)
979
 
980
;;
981
;; mul and div
982
;;
983
 
984
(define_insn "mulsi3"
985
  [(set (match_operand:SI 0 "register_operand" "=r")
986
        (mult:SI (match_operand:SI 1 "register_operand" "r")
987
                 (match_operand:SI 2 "register_operand" "r")))]
988
  "TARGET_HARD_MUL"
989
  "l.mul   \t%0,%1,%2"
990
  [(set_attr "type" "mul")
991
   (set_attr "length" "1")])
992
 
993
(define_insn "divsi3"
994
  [(set (match_operand:SI 0 "register_operand" "=r")
995
        (div:SI (match_operand:SI 1 "register_operand" "r")
996
                 (match_operand:SI 2 "register_operand" "r")))]
997
  "TARGET_HARD_DIV"
998
  "l.div   \t%0,%1,%2"
999
  [(set_attr "type" "mul")
1000
   (set_attr "length" "1")])
1001
 
1002
(define_insn "udivsi3"
1003
  [(set (match_operand:SI 0 "register_operand" "=r")
1004
        (udiv:SI (match_operand:SI 1 "register_operand" "r")
1005
                 (match_operand:SI 2 "register_operand" "r")))]
1006
  "TARGET_HARD_DIV"
1007
  "l.divu  \t%0,%1,%2"
1008
  [(set_attr "type" "mul")
1009
   (set_attr "length" "1")])
1010
 
1011
;;
1012
;; jumps
1013
;;
1014
 
1015
;; jump
1016
 
1017
(define_expand "jump"
1018
  [(set (pc)
1019
        (label_ref (match_operand 0 "" "")))]
1020
  ""
1021
  "
1022
{
1023
  if (!TARGET_MASK_ALIGNED_JUMPS)
1024
    emit_jump_insn (gen_jump_internal (operands[0]));
1025
  else
1026
    emit_jump_insn (gen_jump_aligned (operands[0]));
1027
  DONE;
1028
}")
1029
 
1030
(define_insn "jump_internal"
1031
  [(set (pc)
1032
        (label_ref (match_operand 0 "" "")))]
1033
  "!TARGET_MASK_ALIGNED_JUMPS"
1034
  "l.j     \t%l0%("
1035
  [(set_attr "type" "jump")
1036
   (set_attr "length" "1")])
1037
 
1038
(define_insn "jump_aligned"
1039
  [(set (pc)
1040
        (label_ref (match_operand 0 "" "")))]
1041
  "TARGET_MASK_ALIGNED_JUMPS"
1042
  ".balignl 0x8,0x15000015,0x4\;l.j     \t%l0%("
1043
  [(set_attr "type" "jump")
1044
   (set_attr "length" "1")])
1045
 
1046
;; indirect jump
1047
 
1048
(define_expand "indirect_jump"
1049
  [(set (pc) (match_operand:SI 0 "register_operand" "r"))]
1050
  ""
1051
  "
1052
{
1053
  if (!TARGET_MASK_ALIGNED_JUMPS)
1054
    emit_jump_insn (gen_indirect_jump_internal (operands[0]));
1055
  else
1056
    emit_jump_insn (gen_indirect_jump_aligned (operands[0]));
1057
  DONE;
1058
 
1059
}")
1060
 
1061
(define_insn "indirect_jump_internal"
1062
  [(set (pc) (match_operand:SI 0 "register_operand" "r"))]
1063
  "!TARGET_MASK_ALIGNED_JUMPS"
1064
  "l.jr    \t%0%("
1065
  [(set_attr "type" "jump")
1066
   (set_attr "length" "1")])
1067
 
1068
(define_insn "indirect_jump_aligned"
1069
  [(set (pc) (match_operand:SI 0 "register_operand" "r"))]
1070
  "TARGET_MASK_ALIGNED_JUMPS"
1071
  ".balignl 0x8,0x15000015,0x4\;l.jr    \t%0%("
1072
  [(set_attr "type" "jump")
1073
   (set_attr "length" "1")])
1074
 
1075
;;
1076
;; calls
1077
;;
1078
 
1079
;; call
1080
 
1081
(define_expand "call"
1082
  [(parallel [(call (match_operand:SI 0 "sym_ref_mem_operand" "")
1083
                    (match_operand 1 "" "i"))
1084
              (clobber (reg:SI 9))])]
1085
  ""
1086
  "
1087
{
1088
  if (!TARGET_MASK_ALIGNED_JUMPS)
1089
    emit_call_insn (gen_call_internal (operands[0], operands[1]));
1090
  else
1091
    emit_call_insn (gen_call_aligned (operands[0], operands[1]));
1092
  DONE;
1093
}")
1094
 
1095
(define_insn "call_internal"
1096
[(parallel [(call (match_operand:SI 0 "sym_ref_mem_operand" "")
1097
                  (match_operand 1 "" "i"))
1098
            (clobber (reg:SI 9))])]
1099
  "!TARGET_MASK_ALIGNED_JUMPS"
1100
  "l.jal   \t%S0%("
1101
  [(set_attr "type" "jump")
1102
   (set_attr "length" "1")])
1103
 
1104
(define_insn "call_aligned"
1105
[(parallel [(call (match_operand:SI 0 "sym_ref_mem_operand" "")
1106
                  (match_operand 1 "" "i"))
1107
            (clobber (reg:SI 9))])]
1108
  "TARGET_MASK_ALIGNED_JUMPS"
1109
  ".balignl 0x8,0x15000015,0x4\;l.jal   \t%S0%("
1110
  [(set_attr "type" "jump")
1111
   (set_attr "length" "1")])
1112
 
1113
;; call value
1114
 
1115
(define_expand "call_value"
1116
  [(parallel [(set (match_operand 0 "register_operand" "=r")
1117
                   (call (match_operand:SI 1 "sym_ref_mem_operand" "")
1118
                         (match_operand 2 "" "i")))
1119
              (clobber (reg:SI 9))])]
1120
  ""
1121
  "
1122
{
1123
  if (!TARGET_MASK_ALIGNED_JUMPS)
1124
    emit_call_insn (gen_call_value_internal (operands[0], operands[1], operands[2]));
1125
  else
1126
    emit_call_insn (gen_call_value_aligned (operands[0], operands[1], operands[2]));
1127
  DONE;
1128
}")
1129
 
1130
(define_insn "call_value_internal"
1131
[(parallel [(set (match_operand 0 "register_operand" "=r")
1132
                  (call (match_operand:SI 1 "sym_ref_mem_operand" "")
1133
                        (match_operand 2 "" "i")))
1134
            (clobber (reg:SI 9))])]
1135
  "!TARGET_MASK_ALIGNED_JUMPS"
1136
  "l.jal   \t%S1%("
1137
  [(set_attr "type" "jump")
1138
   (set_attr "length" "1")])
1139
 
1140
(define_insn "call_value_aligned"
1141
[(parallel [(set (match_operand 0 "register_operand" "=r")
1142
                  (call (match_operand:SI 1 "sym_ref_mem_operand" "")
1143
                        (match_operand 2 "" "i")))
1144
            (clobber (reg:SI 9))])]
1145
  "TARGET_MASK_ALIGNED_JUMPS"
1146
  ".balignl 0x8,0x15000015,0x4\;l.jal   \t%S1%("
1147
  [(set_attr "type" "jump")
1148
   (set_attr "length" "1")])
1149
 
1150
;; indirect call value
1151
 
1152
(define_expand "call_value_indirect"
1153
  [(parallel [(set (match_operand 0 "register_operand" "=r")
1154
                   (call (mem:SI (match_operand:SI 1 "register_operand" "r"))
1155
                         (match_operand 2 "" "i")))
1156
              (clobber (reg:SI 9))])]
1157
  ""
1158
  "
1159
{
1160
  if (!TARGET_MASK_ALIGNED_JUMPS)
1161
    emit_call_insn (gen_call_value_indirect_internal (operands[0], operands[1], operands[2]));
1162
  else
1163
    emit_call_insn (gen_call_value_indirect_aligned (operands[0], operands[1], operands[2]));
1164
  DONE;
1165
}")
1166
 
1167
(define_insn "call_value_indirect_internal"
1168
  [(parallel [(set (match_operand 0 "register_operand" "=r")
1169
                   (call (mem:SI (match_operand:SI 1 "register_operand" "r"))
1170
                         (match_operand 2 "" "i")))
1171
              (clobber (reg:SI 9))])]
1172
  "!TARGET_MASK_ALIGNED_JUMPS"
1173
  "l.jalr  \t%1%("
1174
  [(set_attr "type" "jump")
1175
   (set_attr "length" "1")])
1176
 
1177
(define_insn "call_value_indirect_aligned"
1178
  [(parallel [(set (match_operand 0 "register_operand" "=r")
1179
                   (call (mem:SI (match_operand:SI 1 "register_operand" "r"))
1180
                         (match_operand 2 "" "i")))
1181
              (clobber (reg:SI 9))])]
1182
  "TARGET_MASK_ALIGNED_JUMPS"
1183
  ".balignl 0x8,0x15000015,0x4\;l.jalr  \t%1%("
1184
  [(set_attr "type" "jump")
1185
   (set_attr "length" "1")])
1186
 
1187
;; indirect call
1188
 
1189
(define_expand "call_indirect"
1190
  [(parallel [(call (mem:SI (match_operand:SI 0 "register_operand" "r"))
1191
                    (match_operand 1 "" "i"))
1192
              (clobber (reg:SI 9))])]
1193
  ""
1194
  "
1195
{
1196
  if (!TARGET_MASK_ALIGNED_JUMPS)
1197
    emit_call_insn (gen_call_indirect_internal (operands[0], operands[1]));
1198
  else
1199
    emit_call_insn (gen_call_indirect_aligned (operands[0], operands[1]));
1200
  DONE;
1201
}")
1202
 
1203
(define_insn "call_indirect_internal"
1204
[(parallel [(call (mem:SI (match_operand:SI 0 "register_operand" "r"))
1205
                  (match_operand 1 "" "i"))
1206
              (clobber (reg:SI 9))])]
1207
  "!TARGET_MASK_ALIGNED_JUMPS"
1208
  "l.jalr  \t%0%("
1209
  [(set_attr "type" "jump")
1210
   (set_attr "length" "1")])
1211
 
1212
(define_insn "call_indirect_aligned"
1213
[(parallel [(call (mem:SI (match_operand:SI 0 "register_operand" "r"))
1214
                  (match_operand 1 "" "i"))
1215
              (clobber (reg:SI 9))])]
1216
  "TARGET_MASK_ALIGNED_JUMPS"
1217
  ".balignl 0x8,0x15000015,0x4\;l.jalr  \t%0%("
1218
  [(set_attr "type" "jump")
1219
   (set_attr "length" "1")])
1220
 
1221
;; table jump
1222
 
1223
(define_expand "tablejump"
1224
  [(set (pc) (match_operand:SI 0 "register_operand" "r"))
1225
   (use (label_ref (match_operand 1 "" "")))]
1226
   ""
1227
  "
1228
{
1229
  if (!TARGET_MASK_ALIGNED_JUMPS)
1230
    emit_jump_insn (gen_tablejump_internal (operands[0], operands[1]));
1231
  else
1232
    emit_jump_insn (gen_tablejump_aligned (operands[0], operands[1]));
1233
  DONE;
1234
}")
1235
 
1236
(define_insn "tablejump_internal"
1237
  [(set (pc) (match_operand:SI 0 "register_operand" "r"))
1238
   (use (label_ref (match_operand 1 "" "")))]
1239
  "!TARGET_MASK_ALIGNED_JUMPS"
1240
  "l.jr    \t%0%("
1241
  [(set_attr "type" "jump")
1242
   (set_attr "length" "1")])
1243
 
1244
(define_insn "tablejump_aligned"
1245
  [(set (pc) (match_operand:SI 0 "register_operand" "r"))
1246
   (use (label_ref (match_operand 1 "" "")))]
1247
  "TARGET_MASK_ALIGNED_JUMPS"
1248
  ".balignl 0x8,0x15000015,0x4\;l.jr    \t%0%("
1249
  [(set_attr "type" "jump")
1250
   (set_attr "length" "1")])
1251
 
1252
 
1253
;; no-op
1254
 
1255
(define_insn "nop"
1256
  [(const_int 0)]
1257
  ""
1258
  "l.nop"
1259
  [(set_attr "type" "logic")
1260
   (set_attr "length" "1")])
1261
 
1262
;;
1263
;; floating point
1264
;;
1265
 
1266 133 jeremybenn
;; floating point arithmetic
1267
 
1268 38 julius
(define_insn "addsf3"
1269
  [(set (match_operand:SF 0 "register_operand" "=r")
1270
        (plus:SF (match_operand:SF 1 "register_operand" "r")
1271
                 (match_operand:SF 2 "register_operand" "r")))]
1272
  "TARGET_HARD_FLOAT"
1273
  "lf.add.s\t%0,%1,%2"
1274
  [(set_attr "type"     "fp")
1275
   (set_attr "length"   "1")])
1276
 
1277
(define_insn "adddf3"
1278
  [(set (match_operand:DF 0 "register_operand" "=r")
1279
        (plus:DF (match_operand:DF 1 "register_operand" "r")
1280
                 (match_operand:DF 2 "register_operand" "r")))]
1281 133 jeremybenn
  "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
1282 38 julius
  "lf.add.d\t%0,%1,%2"
1283
  [(set_attr "type"     "fp")
1284
   (set_attr "length"   "1")])
1285
 
1286
(define_insn "subsf3"
1287
  [(set (match_operand:SF 0 "register_operand" "=r")
1288
        (minus:SF (match_operand:SF 1 "register_operand" "r")
1289
                 (match_operand:SF 2 "register_operand" "r")))]
1290
  "TARGET_HARD_FLOAT"
1291
  "lf.sub.s\t%0,%1,%2"
1292
  [(set_attr "type"     "fp")
1293
   (set_attr "length"   "1")])
1294
 
1295
(define_insn "subdf3"
1296
  [(set (match_operand:DF 0 "register_operand" "=r")
1297
        (minus:DF (match_operand:DF 1 "register_operand" "r")
1298 133 jeremybenn
                  (match_operand:DF 2 "register_operand" "r")))]
1299
  "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
1300 38 julius
  "lf.sub.d\t%0,%1,%2"
1301
  [(set_attr "type"     "fp")
1302
   (set_attr "length"   "1")])
1303
 
1304
(define_insn "mulsf3"
1305
  [(set (match_operand:SF 0 "register_operand" "=r")
1306
        (mult:SF (match_operand:SF 1 "register_operand" "r")
1307
                 (match_operand:SF 2 "register_operand" "r")))]
1308
  "TARGET_HARD_FLOAT"
1309
  "lf.mul.s\t%0,%1,%2"
1310
  [(set_attr "type"     "fp")
1311
   (set_attr "length"   "1")])
1312
 
1313
(define_insn "muldf3"
1314
  [(set (match_operand:DF 0 "register_operand" "=r")
1315
        (mult:DF (match_operand:DF 1 "register_operand" "r")
1316
                 (match_operand:DF 2 "register_operand" "r")))]
1317 133 jeremybenn
  "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
1318 38 julius
  "lf.mul.d\t%0,%1,%2"
1319
  [(set_attr "type"     "fp")
1320
   (set_attr "length"   "1")])
1321
 
1322
(define_insn "divsf3"
1323
  [(set (match_operand:SF 0 "register_operand" "=r")
1324
        (div:SF (match_operand:SF 1 "register_operand" "r")
1325 133 jeremybenn
                (match_operand:SF 2 "register_operand" "r")))]
1326 38 julius
  "TARGET_HARD_FLOAT"
1327
  "lf.div.s\t%0,%1,%2"
1328
  [(set_attr "type"     "fp")
1329
   (set_attr "length"   "1")])
1330
 
1331
(define_insn "divdf3"
1332
  [(set (match_operand:DF 0 "register_operand" "=r")
1333
        (div:DF (match_operand:DF 1 "register_operand" "r")
1334 133 jeremybenn
                (match_operand:DF 2 "register_operand" "r")))]
1335
  "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
1336 38 julius
  "lf.div.d\t%0,%1,%2"
1337
  [(set_attr "type"     "fp")
1338
   (set_attr "length"   "1")])
1339
 
1340 133 jeremybenn
;; Conversion between fixed point and floating point.
1341 38 julius
 
1342 133 jeremybenn
 
1343
(define_insn "floatsisf2"
1344
  [(set (match_operand:SF 0 "register_operand" "=r")
1345
        (float:SF (match_operand:SI 1 "register_operand" "r")))]
1346
  "TARGET_HARD_FLOAT"
1347
  "lf.itof.s\t%0, %1"
1348
  [(set_attr "type" "fp")
1349
   (set_attr "length" "1")])
1350
 
1351
;; not working
1352
(define_insn "fixunssfsi2"
1353
  [(set (match_operand:SI 0 "register_operand" "=r")
1354
        (fix:SI (match_operand:SF 1 "register_operand" "r")))]
1355
  "TARGET_HARD_FLOAT"
1356
  "lf.ftoi.s\t%0, %1"
1357
  [(set_attr "type" "fp")
1358
   (set_attr "length" "1")])
1359
 
1360
 
1361 38 julius
;; Local variables:
1362
;; mode:emacs-lisp
1363
;; comment-start: ";; "
1364
;; eval: (set-syntax-table (copy-sequence (syntax-table)))
1365
;; eval: (modify-syntax-entry ?[ "(]")
1366
;; eval: (modify-syntax-entry ?] ")[")
1367
;; eval: (modify-syntax-entry ?{ "(}")
1368
;; eval: (modify-syntax-entry ?} "){")
1369
;; eval: (setq indent-tabs-mode t)
1370
;; End:

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.