OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

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

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 518 julius
  "(GET_CODE (operands[1]) != CONST_INT
368
    || ! (CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[1]),'I', \"I\")
369
         || CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[1]),'K', \"K\")
370
         || CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[1]), 'M', \"M\")))
371
   && reload_completed
372 399 jeremybenn
   && GET_CODE (operands[1]) != HIGH && GET_CODE (operands[1]) != LO_SUM"
373
  [(pc)]
374
{
375
  emit_insn (gen_movsi_high (operands[0], operands[1]));
376
  emit_insn (gen_movsi_lo_sum (operands[0], operands[0], operands[1]));
377
  DONE;
378
}
379 282 jeremybenn
  [(set_attr "type" "move")
380
   (set_attr "length" "2")])
381
 
382
 
383
;;
384
;; Conditional Branches & Moves
385
;;
386
 
387
(define_expand "addsicc"
388
  [(match_operand:SI 0 "register_operand" "")
389
   (match_operand 1 "comparison_operator" "")
390
   (match_operand:SI 2 "register_operand" "")
391
   (match_operand:SI 3 "register_operand" "")]
392
  ""
393
  "FAIL;")
394
 
395
(define_expand "addhicc"
396
  [(match_operand:HI 0 "register_operand" "")
397
   (match_operand 1 "comparison_operator" "")
398
   (match_operand:HI 2 "register_operand" "")
399
   (match_operand:HI 3 "register_operand" "")]
400
  ""
401
  "FAIL;")
402
 
403
(define_expand "addqicc"
404
  [(match_operand:QI 0 "register_operand" "")
405
   (match_operand 1 "comparison_operator" "")
406
   (match_operand:QI 2 "register_operand" "")
407
   (match_operand:QI 3 "register_operand" "")]
408
  ""
409
  "FAIL;")
410
 
411
 
412
;;
413
;; conditional moves
414
;;
415
 
416
(define_expand "movsicc"
417
   [(set (match_operand:SI 0 "register_operand" "")
418
         (if_then_else:SI (match_operand 1 "comparison_operator" "")
419
                          (match_operand:SI 2 "register_operand" "")
420
                          (match_operand:SI 3 "register_operand" "")))]
421
  "TARGET_MASK_CMOV"
422
  "
423
{
424
  if (or32_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
425
    DONE;
426
}")
427
 
428
(define_expand "movhicc"
429
   [(set (match_operand:HI 0 "register_operand" "")
430
         (if_then_else:SI (match_operand 1 "comparison_operator" "")
431
                          (match_operand:HI 2 "register_operand" "")
432
                          (match_operand:HI 3 "register_operand" "")))]
433
  ""
434
  "
435
{
436
    FAIL;
437
}")
438
 
439
(define_expand "movqicc"
440
   [(set (match_operand:QI 0 "register_operand" "")
441
         (if_then_else:SI (match_operand 1 "comparison_operator" "")
442
                          (match_operand:QI 2 "register_operand" "")
443
                          (match_operand:QI 3 "register_operand" "")))]
444
  ""
445
  "
446
{
447
    FAIL;
448
}")
449
 
450
 
451
;; We use the BASE_REGS for the cmov input operands because, if rA is
452
;; 0, the value of 0 is placed in rD upon truth.  Similarly for rB
453
;; because we may switch the operands and rB may end up being rA.
454
 
455
(define_insn "cmov"
456
  [(set (match_operand:SI 0 "register_operand" "=r")
457
        (if_then_else:SI
458
         (match_operator 1 "comparison_operator"
459
                         [(match_operand 4 "cc_reg_operand" "")
460
                          (const_int 0)])
461
         (match_operand:SI 2 "register_operand" "r")
462
         (match_operand:SI 3 "register_operand" "r")))]
463
  "TARGET_MASK_CMOV"
464
  "*
465
   return or32_output_cmov(operands);
466
  ")
467
 
468
;;
469
;;  ....................
470
;;
471
;;      COMPARISONS
472
;;
473
;;  ....................
474
 
475
;; Flow here is rather complex:
476
;;
477
;;  1)  The cmp{si,di,sf,df} routine is called.  It deposits the
478
;;      arguments into the branch_cmp array, and the type into
479
;;      branch_type.  No RTL is generated.
480
;;
481
;;  2)  The appropriate branch define_expand is called, which then
482
;;      creates the appropriate RTL for the comparison and branch.
483
;;      Different CC modes are used, based on what type of branch is
484
;;      done, so that we can constrain things appropriately.  There
485
;;      are assumptions in the rest of GCC that break if we fold the
486
;;      operands into the branches for integer operations, and use cc0
487
;;      for floating point, so we use the fp status register instead.
488
;;      If needed, an appropriate temporary is created to hold the
489
;;      of the integer compare.
490
 
491
;; Compare insns are next.  Note that the RS/6000 has two types of compares,
492
;; signed & unsigned, and one type of branch.
493
;;
494
;; Start with the DEFINE_EXPANDs to generate the rtl for compares, scc
495
;; insns, and branches.  We store the operands of compares until we see
496
;; how it is used.
497
 
498
;; JPB 31-Aug-10: cmpxx appears to be obsolete in GCC 4.5. Needs more
499
;; investigation.
500
 
501
;;(define_expand "cmpsi"
502 399 jeremybenn
;;  [(set (reg:CC CC_REG)
503 282 jeremybenn
;;      (compare:CC (match_operand:SI 0 "register_operand" "")
504
;;                  (match_operand:SI 1 "nonmemory_operand" "")))]
505
;;  ""
506
;;  {
507
;;   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
508
;;      operands[0] = force_reg (SImode, operands[0]);
509
;;      or32_compare_op0 = operands[0];
510
;;     or32_compare_op1 = operands[1];
511
;;      DONE;
512
;;      })
513
 
514
;; (define_expand "cmpsf"
515 399 jeremybenn
;;   [(set (reg:CC CC_REG)
516 282 jeremybenn
;;      (compare:CC (match_operand:SF 0 "register_operand" "")
517
;;                  (match_operand:SF 1 "register_operand" "")))]
518
;;   "TARGET_HARD_FLOAT"
519
;;   {
520
;;    if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
521
;;       operands[0] = force_reg (SFmode, operands[0]);
522
;;       or32_compare_op0 = operands[0];
523
;;       or32_compare_op1 = operands[1];
524
;;       DONE;
525
;;       })
526
 
527
(define_expand "cbranchsi4"
528
  [(match_operator 0 "comparison_operator"
529
    [(match_operand:SI 1 "register_operand")
530
     (match_operand:SI 2 "nonmemory_operand")])
531
   (match_operand 3 "")]
532
   ""
533
   {
534
   or32_expand_conditional_branch (operands, SImode);
535
   DONE;
536
   })
537
 
538
(define_expand "cbranchsf4"
539
  [(match_operator 0 "comparison_operator"
540
    [(match_operand:SI 1 "register_operand")
541
     (match_operand:SI 2 "register_operand")])
542
   (match_operand 3 "")]
543
   "TARGET_HARD_FLOAT"
544
   {
545
   or32_expand_conditional_branch (operands, SFmode);
546
   DONE;
547
   })
548
 
549
;;
550
;; Setting a CCxx registers from comparision
551
;;
552
 
553
 
554
 
555
;; Here are the actual compare insns.
556
(define_insn "*cmpsi_eq"
557 399 jeremybenn
  [(set (reg:CCEQ CC_REG)
558 282 jeremybenn
        (compare:CCEQ (match_operand:SI 0 "register_operand" "r,r")
559
                      (match_operand:SI 1 "nonmemory_operand" "I,r")))]
560
  ""
561
  "@
562
   l.sfeqi\t%0,%1
563
   l.sfeq \t%0,%1")
564
 
565
(define_insn "*cmpsi_ne"
566 399 jeremybenn
  [(set (reg:CCNE CC_REG)
567 282 jeremybenn
        (compare:CCNE (match_operand:SI 0 "register_operand" "r,r")
568
                      (match_operand:SI 1 "nonmemory_operand" "I,r")))]
569
  ""
570
  "@
571
   l.sfnei\t%0,%1
572
   l.sfne \t%0,%1")
573
 
574
(define_insn "*cmpsi_gt"
575 399 jeremybenn
  [(set (reg:CCGT CC_REG)
576 282 jeremybenn
        (compare:CCGT (match_operand:SI 0 "register_operand" "r,r")
577
                      (match_operand:SI 1 "nonmemory_operand" "I,r")))]
578
  ""
579
  "@
580
   l.sfgtsi\t%0,%1
581
   l.sfgts \t%0,%1")
582
 
583
(define_insn "*cmpsi_gtu"
584 399 jeremybenn
  [(set (reg:CCGTU CC_REG)
585 282 jeremybenn
        (compare:CCGTU (match_operand:SI 0 "register_operand" "r,r")
586
                       (match_operand:SI 1 "nonmemory_operand" "I,r")))]
587
  ""
588
  "@
589
   l.sfgtui\t%0,%1
590
   l.sfgtu \t%0,%1")
591
 
592
(define_insn "*cmpsi_lt"
593 399 jeremybenn
  [(set (reg:CCLT CC_REG)
594 282 jeremybenn
        (compare:CCLT (match_operand:SI 0 "register_operand" "r,r")
595
                      (match_operand:SI 1 "nonmemory_operand" "I,r")))]
596
  ""
597
  "@
598
   l.sfltsi\t%0,%1
599
   l.sflts \t%0,%1")
600
 
601
(define_insn "*cmpsi_ltu"
602 399 jeremybenn
  [(set (reg:CCLTU CC_REG)
603 282 jeremybenn
        (compare:CCLTU (match_operand:SI 0 "register_operand" "r,r")
604
                       (match_operand:SI 1 "nonmemory_operand" "I,r")))]
605
  ""
606
  "@
607
   l.sfltui\t%0,%1
608
   l.sfltu \t%0,%1")
609
 
610
(define_insn "*cmpsi_ge"
611 399 jeremybenn
  [(set (reg:CCGE CC_REG)
612 282 jeremybenn
        (compare:CCGE (match_operand:SI 0 "register_operand" "r,r")
613
                      (match_operand:SI 1 "nonmemory_operand" "I,r")))]
614
  ""
615
  "@
616
   l.sfgesi\t%0,%1
617
   l.sfges \t%0,%1")
618
 
619
 
620
(define_insn "*cmpsi_geu"
621 399 jeremybenn
  [(set (reg:CCGEU CC_REG)
622 282 jeremybenn
        (compare:CCGEU (match_operand:SI 0 "register_operand" "r,r")
623
                       (match_operand:SI 1 "nonmemory_operand" "I,r")))]
624
  ""
625
  "@
626
   l.sfgeui\t%0,%1
627
   l.sfgeu \t%0,%1")
628
 
629
 
630
(define_insn "*cmpsi_le"
631 399 jeremybenn
  [(set (reg:CCLE CC_REG)
632 282 jeremybenn
        (compare:CCLE (match_operand:SI 0 "register_operand" "r,r")
633
                      (match_operand:SI 1 "nonmemory_operand" "I,r")))]
634
  ""
635
  "@
636
   l.sflesi\t%0,%1
637
   l.sfles \t%0,%1")
638
 
639
(define_insn "*cmpsi_leu"
640 399 jeremybenn
  [(set (reg:CCLEU CC_REG)
641 282 jeremybenn
        (compare:CCLEU (match_operand:SI 0 "register_operand" "r,r")
642
                       (match_operand:SI 1 "nonmemory_operand" "I,r")))]
643
  ""
644
  "@
645
   l.sfleui\t%0,%1
646
   l.sfleu \t%0,%1")
647
 
648
;; Single precision floating point evaluation instructions
649
(define_insn "*cmpsf_eq"
650 399 jeremybenn
  [(set (reg:CCEQ CC_REG)
651 282 jeremybenn
        (compare:CCEQ (match_operand:SF 0 "register_operand" "r,r")
652
                      (match_operand:SF 1 "register_operand" "r,r")))]
653
  "TARGET_HARD_FLOAT"
654
  "lf.sfeq.s\t%0,%1")
655
 
656
(define_insn "*cmpsf_ne"
657 399 jeremybenn
  [(set (reg:CCNE CC_REG)
658 282 jeremybenn
        (compare:CCNE (match_operand:SF 0 "register_operand" "r,r")
659
                      (match_operand:SF 1 "register_operand" "r,r")))]
660
  "TARGET_HARD_FLOAT"
661
  "lf.sfne.s\t%0,%1")
662
 
663
 
664
(define_insn "*cmpsf_gt"
665 399 jeremybenn
  [(set (reg:CCGT CC_REG)
666 282 jeremybenn
        (compare:CCGT (match_operand:SF 0 "register_operand" "r,r")
667
                      (match_operand:SF 1 "register_operand" "r,r")))]
668
  "TARGET_HARD_FLOAT"
669
  "lf.sfgt.s\t%0,%1")
670
 
671
(define_insn "*cmpsf_ge"
672 399 jeremybenn
  [(set (reg:CCGE CC_REG)
673 282 jeremybenn
        (compare:CCGE (match_operand:SF 0 "register_operand" "r,r")
674
                      (match_operand:SF 1 "register_operand" "r,r")))]
675
  "TARGET_HARD_FLOAT"
676
  "lf.sfge.s\t%0,%1")
677
 
678
 
679
(define_insn "*cmpsf_lt"
680 399 jeremybenn
  [(set (reg:CCLT CC_REG)
681 282 jeremybenn
        (compare:CCLT (match_operand:SF 0 "register_operand" "r,r")
682
                      (match_operand:SF 1 "register_operand" "r,r")))]
683
  "TARGET_HARD_FLOAT"
684
  "lf.sflt.s\t%0,%1")
685
 
686
(define_insn "*cmpsf_le"
687 399 jeremybenn
  [(set (reg:CCLE CC_REG)
688 282 jeremybenn
        (compare:CCLE (match_operand:SF 0 "register_operand" "r,r")
689
                      (match_operand:SF 1 "register_operand" "r,r")))]
690
  "TARGET_HARD_FLOAT"
691
  "lf.sfle.s\t%0,%1")
692
 
693
(define_insn "*bf"
694
  [(set (pc)
695
        (if_then_else (match_operator 1 "comparison_operator"
696
                                      [(match_operand 2
697
                                                      "cc_reg_operand" "")
698
                                       (const_int 0)])
699
                      (label_ref (match_operand 0 "" ""))
700
                      (pc)))]
701
  ""
702
  "*
703
   return or32_output_bf(operands);
704
  "
705
  [(set_attr "type" "branch")
706
   (set_attr "length" "1")])
707
 
708
;;
709
;;
710
;;
711
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
712
;;
713
;;
714 518 julius
(define_insn_and_split "movdi"
715 282 jeremybenn
  [(set (match_operand:DI 0 "nonimmediate_operand" "=r, r, m, r")
716 518 julius
       (match_operand:DI 1 "general_operand"      " r, m, r, n"))]
717 282 jeremybenn
  ""
718
  "*
719
    return or32_output_move_double (operands);
720
  "
721 518 julius
  "&& reload_completed && CONSTANT_P (operands[1])"
722
  [(set (match_dup 2) (match_dup 3)) (set (match_dup 4)  (match_dup 5))]
723
  "operands[2] = operand_subword (operands[0], 0, 0, DImode);
724
   operands[3] = operand_subword (operands[1], 0, 0, DImode);
725
   operands[4] = operand_subword (operands[0], 1, 0, DImode);
726
   operands[5] = operand_subword (operands[1], 1, 0, DImode);"
727 282 jeremybenn
  [(set_attr "length" "2,2,2,3")])
728
 
729
;; Moving double and single precision floating point values
730
 
731
(define_insn "movdf"
732
  [(set (match_operand:DF 0 "nonimmediate_operand" "=r, r, m, r")
733
        (match_operand:DF 1 "general_operand"      " r, m, r, i"))]
734
  ""
735
  "*
736
    return or32_output_move_double (operands);
737
  "
738
  [(set_attr "length" "2,2,2,3")])
739
 
740
 
741
(define_insn "movsf"
742
  [(set (match_operand:SF 0 "general_operand" "=r,r,m")
743
        (match_operand:SF 1 "general_operand"  "r,m,r"))]
744
  ""
745
  "@
746
   l.ori   \t%0,%1,0\t # movsf
747
   l.lwz   \t%0,%1\t # movsf
748
   l.sw    \t%0,%1\t # movsf"
749
  [(set_attr "type" "move,load,store")
750
   (set_attr "length" "1,1,1")])
751
 
752
 
753
;;
754
;; extendqisi2
755
;;
756
 
757
(define_expand "extendqisi2"
758
  [(use (match_operand:SI 0 "register_operand" ""))
759
   (use (match_operand:QI 1 "nonimmediate_operand" ""))]
760
  ""
761
  "
762
{
763
  if (TARGET_MASK_SEXT)
764
    emit_insn (gen_extendqisi2_sext(operands[0], operands[1]));
765
  else {
766
    if ( GET_CODE(operands[1]) == MEM ) {
767
      emit_insn (gen_extendqisi2_no_sext_mem(operands[0], operands[1]));
768
    }
769
    else {
770
      emit_insn (gen_extendqisi2_no_sext_reg(operands[0], operands[1]));
771
    }
772
 }
773
 DONE;
774
}")
775
 
776
(define_insn "extendqisi2_sext"
777
  [(set (match_operand:SI 0 "register_operand" "=r,r")
778
        (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "r,m")))]
779
  "TARGET_MASK_SEXT"
780
  "@
781
   l.extbs \t%0,%1\t # extendqisi2_has_signed_extend
782
   l.lbs   \t%0,%1\t # extendqisi2_has_signed_extend"
783
  [(set_attr "length" "1,1")
784
   (set_attr "type" "extend,load")])
785
 
786
(define_insn "extendqisi2_no_sext_mem"
787
  [(set (match_operand:SI 0 "register_operand" "=r")
788
        (sign_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
789
  "!TARGET_MASK_SEXT"
790
  "l.lbs   \t%0,%1\t # extendqisi2_no_sext_mem"
791
  [(set_attr "length" "1")
792
   (set_attr "type" "load")])
793
 
794
(define_expand "extendqisi2_no_sext_reg"
795
  [(set (match_dup 2)
796
        (ashift:SI (match_operand:QI 1 "register_operand" "")
797
                   (const_int 24)))
798
   (set (match_operand:SI 0 "register_operand" "")
799
        (ashiftrt:SI (match_dup 2)
800
                     (const_int 24)))]
801
  "!TARGET_MASK_SEXT"
802
  "
803
{
804
  operands[1] = gen_lowpart (SImode, operands[1]);
805
  operands[2] = gen_reg_rtx (SImode); }")
806
 
807
;;
808
;; extendhisi2
809
;;
810
 
811
(define_expand "extendhisi2"
812
  [(use (match_operand:SI 0 "register_operand" ""))
813
   (use (match_operand:HI 1 "nonimmediate_operand" ""))]
814
  ""
815
  "
816
{
817
  if (TARGET_MASK_SEXT)
818
    emit_insn (gen_extendhisi2_sext(operands[0], operands[1]));
819
  else {
820
    if ( GET_CODE(operands[1]) == MEM ) {
821
      emit_insn (gen_extendhisi2_no_sext_mem(operands[0], operands[1]));
822
    }
823
    else {
824
      emit_insn (gen_extendhisi2_no_sext_reg(operands[0], operands[1]));
825
    }
826
 }
827
 DONE;
828
}")
829
 
830
(define_insn "extendhisi2_sext"
831
  [(set (match_operand:SI 0 "register_operand" "=r,r")
832
        (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "r,m")))]
833
  "TARGET_MASK_SEXT"
834
  "@
835
   l.exths \t%0,%1\t # extendhisi2_has_signed_extend
836
   l.lhs   \t%0,%1\t # extendhisi2_has_signed_extend"
837
  [(set_attr "length" "1,1")
838
   (set_attr "type" "extend,load")])
839
 
840
(define_insn "extendhisi2_no_sext_mem"
841
  [(set (match_operand:SI 0 "register_operand" "=r")
842
        (sign_extend:SI (match_operand:HI 1 "memory_operand" "m")))]
843
  "!TARGET_MASK_SEXT"
844
  "l.lhs   \t%0,%1\t # extendhisi2_no_sext_mem"
845
  [(set_attr "length" "1")
846
   (set_attr "type" "load")])
847
 
848
(define_expand "extendhisi2_no_sext_reg"
849
  [(set (match_dup 2)
850
        (ashift:SI (match_operand:HI 1 "register_operand" "")
851
                   (const_int 16)))
852
   (set (match_operand:SI 0 "register_operand" "")
853
        (ashiftrt:SI (match_dup 2)
854
                     (const_int 16)))]
855
  "!TARGET_MASK_SEXT"
856
  "
857
{
858
  operands[1] = gen_lowpart (SImode, operands[1]);
859
  operands[2] = gen_reg_rtx (SImode); }")
860
 
861
 
862
;;
863
;; zero_extend2
864
;;
865
 
866
(define_insn "zero_extendqisi2"
867
  [(set (match_operand:SI 0 "register_operand" "=r,r")
868
        (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "r,m")))]
869
  ""
870
  "@
871
   l.andi  \t%0,%1,0xff\t # zero_extendqisi2
872
   l.lbz   \t%0,%1\t # zero_extendqisi2"
873
  [(set_attr "type" "logic,load")
874
   (set_attr "length" "1,1")])
875
 
876
 
877
(define_insn "zero_extendhisi2"
878
  [(set (match_operand:SI 0 "register_operand" "=r,r")
879
        (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "r,m")))]
880
  ""
881
  "@
882
   l.andi  \t%0,%1,0xffff\t # zero_extendqisi2
883
   l.lhz   \t%0,%1\t # zero_extendqisi2"
884
  [(set_attr "type" "logic,load")
885
   (set_attr "length" "1,1")])
886
 
887
;;
888
;; Shift/rotate operations
889
;;
890
 
891
(define_insn "ashlsi3"
892
  [(set (match_operand:SI 0 "register_operand" "=r,r")
893
        (ashift:SI (match_operand:SI 1 "register_operand" "r,r")
894
                   (match_operand:SI 2 "nonmemory_operand" "r,L")))]
895
  ""
896
  "@
897
   l.sll   \t%0,%1,%2
898
   l.slli  \t%0,%1,%2"
899
  [(set_attr "type" "shift,shift")
900
   (set_attr "length" "1,1")])
901
 
902
(define_insn "ashrsi3"
903
  [(set (match_operand:SI 0 "register_operand" "=r,r")
904
        (ashiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
905
                   (match_operand:SI 2 "nonmemory_operand" "r,L")))]
906
  ""
907
  "@
908
   l.sra   \t%0,%1,%2
909
   l.srai  \t%0,%1,%2"
910
  [(set_attr "type" "shift,shift")
911
   (set_attr "length" "1,1")])
912
 
913
(define_insn "lshrsi3"
914
  [(set (match_operand:SI 0 "register_operand" "=r,r")
915
        (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
916
                   (match_operand:SI 2 "nonmemory_operand" "r,L")))]
917
  ""
918
  "@
919
   l.srl   \t%0,%1,%2
920
   l.srli  \t%0,%1,%2"
921
  [(set_attr "type" "shift,shift")
922
   (set_attr "length" "1,1")])
923
 
924
(define_insn "rotrsi3"
925
  [(set (match_operand:SI 0 "register_operand" "=r,r")
926
        (rotatert:SI (match_operand:SI 1 "register_operand" "r,r")
927
                   (match_operand:SI 2 "nonmemory_operand" "r,L")))]
928
  "TARGET_MASK_ROR"
929
  "@
930
   l.ror   \t%0,%1,%2
931
   l.rori  \t%0,%1,%2"
932
  [(set_attr "type" "shift,shift")
933
   (set_attr "length" "1,1")])
934
 
935
;;
936
;; Logical bitwise operations
937
;;
938
 
939
(define_insn "andsi3"
940
  [(set (match_operand:SI 0 "register_operand" "=r,r")
941
        (and:SI (match_operand:SI 1 "register_operand" "%r,r")
942
                (match_operand:SI 2 "nonmemory_operand" "r,K")))]
943
  ""
944
  "@
945
   l.and   \t%0,%1,%2
946
   l.andi  \t%0,%1,%2"
947
  [(set_attr "type" "logic,logic")
948
   (set_attr "length" "1,1")])
949
 
950
(define_insn "iorsi3"
951
  [(set (match_operand:SI 0 "register_operand" "=r,r")
952
        (ior:SI (match_operand:SI 1 "register_operand" "%r,r")
953
                (match_operand:SI 2 "nonmemory_operand" "r,K")))]
954
  ""
955
  "@
956
   l.or    \t%0,%1,%2
957
   l.ori   \t%0,%1,%2"
958
  [(set_attr "type" "logic,logic")
959
   (set_attr "length" "1,1")])
960
 
961
(define_insn "xorsi3"
962
  [(set (match_operand:SI 0 "register_operand" "=r,r")
963
        (xor:SI (match_operand:SI 1 "register_operand" "%r,r")
964
                (match_operand:SI 2 "nonmemory_operand" "r,I")))]
965
  ""
966
  "@
967
   l.xor   \t%0,%1,%2
968
   l.xori  \t%0,%1,%2"
969
  [(set_attr "type" "logic,logic")
970
   (set_attr "length" "1,1")])
971
 
972
(define_insn "one_cmplqi2"
973
  [(set (match_operand:QI 0 "register_operand" "=r")
974
        (not:QI (match_operand:QI 1 "register_operand" "r")))]
975
  ""
976
  "l.xori  \t%0,%1,0x00ff"
977
  [(set_attr "type" "logic")
978
   (set_attr "length" "1")])
979
 
980
(define_insn "one_cmplsi2"
981
  [(set (match_operand:SI 0 "register_operand" "=r")
982
        (not:SI (match_operand:SI 1 "register_operand" "r")))]
983
  ""
984
  "l.xori  \t%0,%1,0xffff"
985
  [(set_attr "type" "logic")
986
   (set_attr "length" "1")])
987
 
988
;;
989
;; Arithmetic operations
990
;;
991
 
992
(define_insn "negsi2"
993
  [(set (match_operand:SI 0 "register_operand" "=r")
994
        (neg:SI (match_operand:SI 1 "register_operand" "r")))]
995
  ""
996
  "l.sub   \t%0,r0,%1"
997
  [(set_attr "type" "add")
998
   (set_attr "length" "1")])
999
 
1000
(define_insn "addsi3"
1001
  [(set (match_operand:SI 0 "register_operand" "=r,r")
1002
        (plus:SI (match_operand:SI 1 "register_operand" "%r,r")
1003
                 (match_operand:SI 2 "nonmemory_operand" "r,I")))]
1004
  ""
1005
  "@
1006
   l.add   \t%0,%1,%2
1007
   l.addi  \t%0,%1,%2"
1008
  [(set_attr "type" "add,add")
1009
   (set_attr "length" "1,1")])
1010
 
1011
(define_insn "subsi3"
1012
  [(set (match_operand:SI 0 "register_operand" "=r,r")
1013
        (minus:SI (match_operand:SI 1 "register_operand" "r,r")
1014
                  (match_operand:SI 2 "nonmemory_operand" "r,I")))]
1015
  ""
1016
  "@
1017
   l.sub   \t%0,%1,%2
1018
   l.addi  \t%0,%1,%n2"
1019
  [(set_attr "type" "add,add")]
1020
)
1021
 
1022
;;
1023
;; mul and div
1024
;;
1025
 
1026
(define_insn "mulsi3"
1027
  [(set (match_operand:SI 0 "register_operand" "=r")
1028
        (mult:SI (match_operand:SI 1 "register_operand" "r")
1029
                 (match_operand:SI 2 "register_operand" "r")))]
1030
  "TARGET_HARD_MUL"
1031
  "l.mul   \t%0,%1,%2"
1032
  [(set_attr "type" "mul")
1033
   (set_attr "length" "1")])
1034
 
1035
(define_insn "divsi3"
1036
  [(set (match_operand:SI 0 "register_operand" "=r")
1037
        (div:SI (match_operand:SI 1 "register_operand" "r")
1038
                 (match_operand:SI 2 "register_operand" "r")))]
1039
  "TARGET_HARD_DIV"
1040
  "l.div   \t%0,%1,%2"
1041
  [(set_attr "type" "mul")
1042
   (set_attr "length" "1")])
1043
 
1044
(define_insn "udivsi3"
1045
  [(set (match_operand:SI 0 "register_operand" "=r")
1046
        (udiv:SI (match_operand:SI 1 "register_operand" "r")
1047
                 (match_operand:SI 2 "register_operand" "r")))]
1048
  "TARGET_HARD_DIV"
1049
  "l.divu  \t%0,%1,%2"
1050
  [(set_attr "type" "mul")
1051
   (set_attr "length" "1")])
1052
 
1053
;;
1054
;; jumps
1055
;;
1056
 
1057
;; jump
1058
 
1059
(define_expand "jump"
1060
  [(set (pc)
1061
        (label_ref (match_operand 0 "" "")))]
1062
  ""
1063
  "
1064
{
1065 399 jeremybenn
  emit_jump_insn (gen_jump_internal (operands[0]));
1066 282 jeremybenn
  DONE;
1067
}")
1068
 
1069
(define_insn "jump_internal"
1070
  [(set (pc)
1071
        (label_ref (match_operand 0 "" "")))]
1072 399 jeremybenn
  ""
1073 282 jeremybenn
  "l.j     \t%l0%("
1074
  [(set_attr "type" "jump")
1075
   (set_attr "length" "1")])
1076
 
1077
;; indirect jump
1078
 
1079
(define_expand "indirect_jump"
1080
  [(set (pc) (match_operand:SI 0 "register_operand" "r"))]
1081
  ""
1082
  "
1083
{
1084 399 jeremybenn
  emit_jump_insn (gen_indirect_jump_internal (operands[0]));
1085 282 jeremybenn
  DONE;
1086
 
1087
}")
1088
 
1089
(define_insn "indirect_jump_internal"
1090
  [(set (pc) (match_operand:SI 0 "register_operand" "r"))]
1091 399 jeremybenn
  ""
1092 282 jeremybenn
  "l.jr    \t%0%("
1093
  [(set_attr "type" "jump")
1094
   (set_attr "length" "1")])
1095
 
1096
;;
1097
;; calls
1098
;;
1099
 
1100
;; call
1101
 
1102
(define_expand "call"
1103
  [(parallel [(call (match_operand:SI 0 "sym_ref_mem_operand" "")
1104
                    (match_operand 1 "" "i"))
1105
              (clobber (reg:SI 9))])]
1106
  ""
1107
  "
1108
{
1109 399 jeremybenn
  emit_call_insn (gen_call_internal (operands[0], operands[1]));
1110 282 jeremybenn
  DONE;
1111
}")
1112
 
1113
(define_insn "call_internal"
1114
[(parallel [(call (match_operand:SI 0 "sym_ref_mem_operand" "")
1115
                  (match_operand 1 "" "i"))
1116
            (clobber (reg:SI 9))])]
1117 399 jeremybenn
  ""
1118 282 jeremybenn
  "l.jal   \t%S0%("
1119
  [(set_attr "type" "jump")
1120
   (set_attr "length" "1")])
1121
 
1122
;; call value
1123
 
1124
(define_expand "call_value"
1125
  [(parallel [(set (match_operand 0 "register_operand" "=r")
1126
                   (call (match_operand:SI 1 "sym_ref_mem_operand" "")
1127
                         (match_operand 2 "" "i")))
1128
              (clobber (reg:SI 9))])]
1129
  ""
1130
  "
1131
{
1132 399 jeremybenn
  emit_call_insn (gen_call_value_internal (operands[0], operands[1], operands[2]));
1133 282 jeremybenn
  DONE;
1134
}")
1135
 
1136
(define_insn "call_value_internal"
1137
[(parallel [(set (match_operand 0 "register_operand" "=r")
1138
                  (call (match_operand:SI 1 "sym_ref_mem_operand" "")
1139
                        (match_operand 2 "" "i")))
1140
            (clobber (reg:SI 9))])]
1141 399 jeremybenn
  ""
1142 282 jeremybenn
  "l.jal   \t%S1%("
1143
  [(set_attr "type" "jump")
1144
   (set_attr "length" "1")])
1145
 
1146
;; indirect call value
1147
 
1148
(define_expand "call_value_indirect"
1149
  [(parallel [(set (match_operand 0 "register_operand" "=r")
1150
                   (call (mem:SI (match_operand:SI 1 "register_operand" "r"))
1151
                         (match_operand 2 "" "i")))
1152
              (clobber (reg:SI 9))])]
1153
  ""
1154
  "
1155
{
1156 399 jeremybenn
  emit_call_insn (gen_call_value_indirect_internal (operands[0], operands[1], operands[2]));
1157 282 jeremybenn
  DONE;
1158
}")
1159
 
1160
(define_insn "call_value_indirect_internal"
1161
  [(parallel [(set (match_operand 0 "register_operand" "=r")
1162
                   (call (mem:SI (match_operand:SI 1 "register_operand" "r"))
1163
                         (match_operand 2 "" "i")))
1164
              (clobber (reg:SI 9))])]
1165 399 jeremybenn
  ""
1166 282 jeremybenn
  "l.jalr  \t%1%("
1167
  [(set_attr "type" "jump")
1168
   (set_attr "length" "1")])
1169
 
1170
;; indirect call
1171
 
1172
(define_expand "call_indirect"
1173
  [(parallel [(call (mem:SI (match_operand:SI 0 "register_operand" "r"))
1174
                    (match_operand 1 "" "i"))
1175
              (clobber (reg:SI 9))])]
1176
  ""
1177
  "
1178
{
1179 399 jeremybenn
  emit_call_insn (gen_call_indirect_internal (operands[0], operands[1]));
1180 282 jeremybenn
  DONE;
1181
}")
1182
 
1183
(define_insn "call_indirect_internal"
1184
[(parallel [(call (mem:SI (match_operand:SI 0 "register_operand" "r"))
1185
                  (match_operand 1 "" "i"))
1186
              (clobber (reg:SI 9))])]
1187 399 jeremybenn
  ""
1188 282 jeremybenn
  "l.jalr  \t%0%("
1189
  [(set_attr "type" "jump")
1190
   (set_attr "length" "1")])
1191
 
1192
;; table jump
1193
 
1194
(define_expand "tablejump"
1195
  [(set (pc) (match_operand:SI 0 "register_operand" "r"))
1196
   (use (label_ref (match_operand 1 "" "")))]
1197
   ""
1198
  "
1199
{
1200 399 jeremybenn
  if (CASE_VECTOR_PC_RELATIVE || flag_pic)
1201
    operands[0]
1202
      = force_reg (Pmode,
1203
                   gen_rtx_PLUS (Pmode, operands[0],
1204
                                 gen_rtx_LABEL_REF (Pmode, operands[1])));
1205
  emit_jump_insn (gen_tablejump_internal (operands[0], operands[1]));
1206 282 jeremybenn
  DONE;
1207
}")
1208
 
1209
(define_insn "tablejump_internal"
1210
  [(set (pc) (match_operand:SI 0 "register_operand" "r"))
1211
   (use (label_ref (match_operand 1 "" "")))]
1212 399 jeremybenn
  ""
1213 282 jeremybenn
  "l.jr    \t%0%("
1214
  [(set_attr "type" "jump")
1215
   (set_attr "length" "1")])
1216
 
1217
 
1218
;; no-op
1219
 
1220
(define_insn "nop"
1221
  [(const_int 0)]
1222
  ""
1223
  "l.nop"
1224
  [(set_attr "type" "logic")
1225
   (set_attr "length" "1")])
1226
 
1227
;;
1228
;; floating point
1229
;;
1230
 
1231
;; floating point arithmetic
1232
 
1233
(define_insn "addsf3"
1234
  [(set (match_operand:SF 0 "register_operand" "=r")
1235
        (plus:SF (match_operand:SF 1 "register_operand" "r")
1236
                 (match_operand:SF 2 "register_operand" "r")))]
1237
  "TARGET_HARD_FLOAT"
1238
  "lf.add.s\t%0,%1,%2"
1239
  [(set_attr "type"     "fp")
1240
   (set_attr "length"   "1")])
1241
 
1242
(define_insn "adddf3"
1243
  [(set (match_operand:DF 0 "register_operand" "=r")
1244
        (plus:DF (match_operand:DF 1 "register_operand" "r")
1245
                 (match_operand:DF 2 "register_operand" "r")))]
1246
  "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
1247
  "lf.add.d\t%0,%1,%2"
1248
  [(set_attr "type"     "fp")
1249
   (set_attr "length"   "1")])
1250
 
1251
(define_insn "subsf3"
1252
  [(set (match_operand:SF 0 "register_operand" "=r")
1253
        (minus:SF (match_operand:SF 1 "register_operand" "r")
1254
                 (match_operand:SF 2 "register_operand" "r")))]
1255
  "TARGET_HARD_FLOAT"
1256
  "lf.sub.s\t%0,%1,%2"
1257
  [(set_attr "type"     "fp")
1258
   (set_attr "length"   "1")])
1259
 
1260
(define_insn "subdf3"
1261
  [(set (match_operand:DF 0 "register_operand" "=r")
1262
        (minus:DF (match_operand:DF 1 "register_operand" "r")
1263
                  (match_operand:DF 2 "register_operand" "r")))]
1264
  "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
1265
  "lf.sub.d\t%0,%1,%2"
1266
  [(set_attr "type"     "fp")
1267
   (set_attr "length"   "1")])
1268
 
1269
(define_insn "mulsf3"
1270
  [(set (match_operand:SF 0 "register_operand" "=r")
1271
        (mult:SF (match_operand:SF 1 "register_operand" "r")
1272
                 (match_operand:SF 2 "register_operand" "r")))]
1273
  "TARGET_HARD_FLOAT"
1274
  "lf.mul.s\t%0,%1,%2"
1275
  [(set_attr "type"     "fp")
1276
   (set_attr "length"   "1")])
1277
 
1278
(define_insn "muldf3"
1279
  [(set (match_operand:DF 0 "register_operand" "=r")
1280
        (mult:DF (match_operand:DF 1 "register_operand" "r")
1281
                 (match_operand:DF 2 "register_operand" "r")))]
1282
  "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
1283
  "lf.mul.d\t%0,%1,%2"
1284
  [(set_attr "type"     "fp")
1285
   (set_attr "length"   "1")])
1286
 
1287
(define_insn "divsf3"
1288
  [(set (match_operand:SF 0 "register_operand" "=r")
1289
        (div:SF (match_operand:SF 1 "register_operand" "r")
1290
                (match_operand:SF 2 "register_operand" "r")))]
1291
  "TARGET_HARD_FLOAT"
1292
  "lf.div.s\t%0,%1,%2"
1293
  [(set_attr "type"     "fp")
1294
   (set_attr "length"   "1")])
1295
 
1296
(define_insn "divdf3"
1297
  [(set (match_operand:DF 0 "register_operand" "=r")
1298
        (div:DF (match_operand:DF 1 "register_operand" "r")
1299
                (match_operand:DF 2 "register_operand" "r")))]
1300
  "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT"
1301
  "lf.div.d\t%0,%1,%2"
1302
  [(set_attr "type"     "fp")
1303
   (set_attr "length"   "1")])
1304
 
1305
;; Conversion between fixed point and floating point.
1306
 
1307
 
1308
(define_insn "floatsisf2"
1309
  [(set (match_operand:SF 0 "register_operand" "=r")
1310
        (float:SF (match_operand:SI 1 "register_operand" "r")))]
1311
  "TARGET_HARD_FLOAT"
1312
  "lf.itof.s\t%0, %1"
1313
  [(set_attr "type" "fp")
1314
   (set_attr "length" "1")])
1315
 
1316
;; not working
1317
(define_insn "fixunssfsi2"
1318
  [(set (match_operand:SI 0 "register_operand" "=r")
1319
        (fix:SI (match_operand:SF 1 "register_operand" "r")))]
1320
  "TARGET_HARD_FLOAT"
1321
  "lf.ftoi.s\t%0, %1"
1322
  [(set_attr "type" "fp")
1323
   (set_attr "length" "1")])
1324
 
1325
 
1326
;; Local variables:
1327
;; mode:emacs-lisp
1328
;; comment-start: ";; "
1329
;; eval: (set-syntax-table (copy-sequence (syntax-table)))
1330
;; eval: (modify-syntax-entry ?[ "(]")
1331
;; eval: (modify-syntax-entry ?] ")[")
1332
;; eval: (modify-syntax-entry ?{ "(}")
1333
;; eval: (modify-syntax-entry ?} "){")
1334
;; eval: (setq indent-tabs-mode t)
1335
;; End:

powered by: WebSVN 2.1.0

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