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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [config/] [or32/] [or32.md] - Blame information for rev 490

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

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

powered by: WebSVN 2.1.0

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