OSDN Git Service

Change FSF address.
[pf3gnuchains/gcc-fork.git] / gcc / config / 1750a / 1750a.md
1 ;;- Machine description for GNU compiler
2 ;;- MIL-STD-1750A version.
3 ;; Copyright (C) 1994 Free Software Foundation, Inc.
4 ;; Contributed by O.M.Kellogg, DASA (okellogg@salyko.cube.net).
5
6 ;; This file is part of GNU CC.
7
8 ;; GNU CC is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 1, or (at your option)
11 ;; any later version.
12
13 ;; GNU CC is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 ;; GNU General Public License for more details.
17
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GNU CC; see the file COPYING.  If not, write to
20 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
21 ;; Boston, MA 02111-1307, USA.
22
23
24 ;;- instruction definitions
25
26 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
27
28 ;;- When naming insn's (operand 0 of define_insn) be careful about using
29 ;;- names from other targets machine descriptions.
30
31 ;; MIL-STD-1750 specific remarks:
32 ;;
33 ;; 1) BITS_PER_UNIT = 16
34 ;;
35 ;; 2) GCC   to    MIL-STD-1750       data type mappings:
36 ;;    QImode => single integer (16 bits or 1 reg).
37 ;;    HImode => double integer (32 bits or 2 regs).
38 ;;    HFmode => single precision float (32 bits or 2 regs).
39 ;;    TQFmode => extended precision float (48 bits or 3 regs).
40 ;; 
41 ;; 3) Immediate integer operands Constraints:
42 ;;    'I'  1 .. 16
43 ;;    'J' -1 ..-16
44 ;;    'K'  0 .. 15
45 ;;    'L'  0 .. 255
46 ;;    'M' -32768 .. 32767
47 ;;    'O' => 0  (for optimizations and GCC quirks)
48 ;;
49 ;; Further notes:
50 ;;-  Assembly output ending in ".M" are macros in file M1750.INC
51
52
53 ;; stackpush
54 (define_insn ""
55   [(set (match_operand:QI 0 "push_operand" "=<")
56         (match_operand:QI 1 "general_operand" "r"))]
57   ""
58   "pshm r%1,r%1")
59
60 (define_insn ""
61   [(set (match_operand:HI 0 "push_operand" "=<")
62         (match_operand:HI 1 "general_operand" "r"))]
63   ""
64   "*
65    { 
66         rtx new_operands[2];
67         new_operands[0] = operands[1];
68         new_operands[1] = gen_rtx(CONST_INT,VOIDmode,REGNO(operands[1])+1);
69    } ")
70
71 (define_insn ""
72   [(set (match_operand:HF 0 "push_operand" "=<")
73         (match_operand:HF 1 "general_operand" "r"))]
74   ""
75   "*
76   { 
77         rtx new_operands[2];
78         new_operands[0] = operands[1];
79         new_operands[1] = gen_rtx(CONST_INT,VOIDmode,REGNO(operands[1])+1);
80         output_asm_insn(\"pshm r%0,r%1\",new_operands);
81         return \"\;\";
82    } ")
83
84 (define_insn ""
85   [(set (match_operand:TQF 0 "push_operand" "=<")
86         (match_operand:TQF 1 "general_operand" "r"))]
87   ""
88   "*
89    { 
90         rtx new_operands[2];
91         new_operands[0] = operands[1];
92         new_operands[1] = gen_rtx(CONST_INT,VOIDmode,REGNO(operands[1])+2);
93         output_asm_insn(\"pshm r%0,r%1\",new_operands);
94         return \"\;\";
95    } ")
96
97 ;; stackpop
98 (define_insn ""
99   [(set (match_operand:QI 0 "general_operand" "=r")
100         (match_operand:QI 1 "push_operand" ">"))]
101   ""
102   "popm r%1,r%1")
103
104 (define_insn ""
105   [(set (match_operand:HI 0 "general_operand" "=r")
106         (match_operand:HI 1 "push_operand" ">"))]
107   ""
108   "*
109    { 
110         rtx new_operands[2];
111         new_operands[0] = operands[0];
112         new_operands[1] = gen_rtx(CONST_INT,VOIDmode,REGNO(operands[0])+1);
113         output_asm_insn(\"popm r%0,r%1\",new_operands);
114         return \"\;\";
115    } ")
116
117 (define_insn ""
118   [(set (match_operand:HF 0 "general_operand" "=r")
119         (match_operand:HF 1 "push_operand" ">"))]
120   ""
121   "*
122    { 
123         rtx new_operands[2];
124         new_operands[0] = operands[0];
125         new_operands[1] = gen_rtx(CONST_INT,VOIDmode,REGNO(operands[0])+1);
126         output_asm_insn(\"popm r%0,r%1\",new_operands);
127         return \"\;\";
128    } ")
129
130 (define_insn ""
131   [(set (match_operand:TQF 0 "general_operand" "=r")
132         (match_operand:TQF 1 "push_operand" ">"))]
133   ""
134   "*
135    { 
136         rtx new_operands[2];
137         new_operands[0] = operands[0];
138         new_operands[1] = gen_rtx(CONST_INT,VOIDmode,REGNO(operands[0])+2);
139         output_asm_insn(\"popm r%0,r%1\",new_operands);
140         return \"\;\";
141    } ")
142
143 ;; Test operations. These shouldn't really occur for 1750:
144 ;; all important instructions set the cc's (see NOTICE_UPDATE_CC)
145
146 (define_insn "tstqi"
147   [(set (cc0)
148         (match_operand:QI 0 "register_operand" "r"))]
149   ""
150   "lr r%0,r%0   ; from tstqi")
151
152 (define_insn "tsthi"
153   [(set (cc0)
154         (match_operand:HI 0 "register_operand" "r"))]
155   ""
156   "dlr r%0,r%0   ; from tsthi")
157
158 (define_insn "tsthf"
159   [(set (cc0)
160         (match_operand:HF 0 "register_operand" "r"))]
161   ""
162   "dlr r%0,r%0   ; from tsthf")
163
164 ;; This one is happy with "roughly zero" :-)  (should be improved)
165 (define_insn "tsttqf"
166   [(set (cc0)
167         (match_operand:TQF 0 "register_operand" "r"))]
168   ""
169   "dlr r%0,r%0   ; from tsttqf")
170
171
172 ;; block move.
173
174 ; there is a problem with this insn in gcc-2.2.3
175 ; (clobber (match_dup 2)) does not prevent use of this operand later
176 ;
177 (define_insn "movstrqi"
178   [(set (mem:BLK (match_operand:QI 0 "register_operand" "r"))
179         (mem:BLK (match_operand:QI 1 "register_operand" "r")))
180    (use (match_operand:QI 2 "register_operand" "r"))
181    (use (match_operand:QI 3 "immediate_operand" ""))
182    (clobber (match_dup 0))
183    (clobber (match_dup 1))
184    (clobber (match_dup 2))]
185   ""
186   "* return (char *)movcnt_regno_adjust(operands); ")
187
188
189 ;; compare instructions.
190
191 (define_insn "cmpqi"
192   [(set (cc0)
193         (compare (match_operand:QI 0 "register_operand" "r,r,r,r,r")
194                  (match_operand:QI 1 "general_operand"  "I,J,i,r,m")))]
195   ""
196   "@
197      cisp r%0,%1
198      cisn r%0,%J1
199      cim  r%0,%1
200      cr   r%0,r%1
201      c    r%0,%1 ")
202
203 (define_insn "cmphi"
204   [(set (cc0)
205         (compare (match_operand:HI 0 "general_operand" "r,r")
206                  (match_operand:HI 1 "general_operand" "r,m")))]
207   ""
208   "@
209     dcr r%0,r%1
210     dc  r%0,%1 ")
211
212 (define_insn "cmphf"
213  [(set (cc0)
214        (compare (match_operand:HF 0 "general_operand" "r,r")
215                 (match_operand:HF 1 "general_operand" "r,m")))]
216  ""
217  "@
218    fcr r%0,r%1
219    fc  r%0,%1 ")
220
221 (define_insn "cmptqf"
222   [(set (cc0)
223         (compare (match_operand:TQF 0 "general_operand" "r,r")
224                  (match_operand:TQF 1 "general_operand" "r,m")))]
225   ""
226   "@
227     efcr r%0,r%1
228     efc  r%0,%1 ")
229
230
231 ;; truncation instructions
232 ;;- 1750: any needed?
233
234 (define_insn "trunchiqi2"
235   [(set (match_operand:QI 0 "register_operand" "=r")
236         (truncate:QI
237          (match_operand:HI 1 "register_operand" "r")))]
238   ""
239   "*
240      {
241         REGNO(operands[1]) += 1;
242         return \"lr r%0,r%1  ;trunchiqi2\";
243      } ")
244
245 ;; zero extension instructions
246
247 (define_insn "zero_extendqihi2"
248   [(set (match_operand:HI 0 "register_operand" "=r,r,r")
249         (zero_extend:HI (match_operand:QI 1 "general_operand" "r,m,i")))]
250   ""
251   "*
252       {
253         output_asm_insn(\"xorr r%0,r%0   ;zero_extendqihi2\",operands);
254         REGNO(operands[0]) += 1;
255         switch (which_alternative)
256           {
257             case 0:
258               return \"lr  r%0,r%1\";
259             case 1:
260               return \"l   r%0,%1\";
261             case 2:
262               return \"lim r%0,%1\";
263           }
264       } ")
265
266 ;; sign extension instructions
267
268 (define_insn "extendqihi2"
269   [(set (match_operand:HI 0 "register_operand" "=r,r,r")
270         (sign_extend:HI (match_operand:QI 1 "general_operand" "r,m,i")) )]
271   ""
272   "@
273     lr  r%0,r%1 ;extendqihi2\;dsra r%0,16
274     l   r%0,%1  ;extendqihi2\;dsra r%0,16
275     lim r%0,%1  ;extendqihi2\;dsra r%0,16 ")
276
277
278 ;; Conversions between float and double.
279
280 ; 1750 HF-to-TQF extend: just append 16 bits (least signif.) with all bits zero
281 (define_insn "extendhftqf2"
282   [(set (match_operand:TQF 0 "register_operand" "=r,r")
283         (float_extend:TQF
284          (match_operand:HF 1 "general_operand" "r,m")))]
285   ""
286   "*
287       {
288         REGNO(operands[0]) += 2;
289         output_asm_insn(\"xorr r%0,r%0   ;extendhftqf2\",operands);
290         REGNO(operands[0]) -= 2;
291         if (which_alternative == 0)
292           return \"dlr r%0,r%1\";
293         else
294           return \"dl  r%0,%1\";
295       } ")
296
297 ; 1750 TQF-to-HF truncate is a no-op: just leave away the least signif. 16 bits
298 (define_insn "trunctqfhf2"
299   [(set (match_operand:HF 0 "register_operand" "=r,r")
300         (float_truncate:HF
301           (match_operand:TQF 1 "general_operand" "r,m")))]
302   ""
303   "@
304      dlr r%0,r%1  ;trunctqfhf2
305      dl  r%0,%1   ;trunctqfhf2 ")
306
307
308 ;; Conversion between fixed point and floating point.
309
310 (define_insn "floatqihf2"
311   [(set           (match_operand:HF 0 "register_operand" "=r")
312         (float:HF (match_operand:QI 1 "register_operand" "r")))]
313   ""
314   "flt r%0,r%1")
315
316 (define_insn "floathitqf2"
317   [(set           (match_operand:TQF 0 "register_operand" "=r")
318         (float:TQF (match_operand:HI 1 "register_operand" "r")))]
319   ""
320   "eflt r%0,r%1")
321
322
323 ;; Convert floats to ints
324
325 (define_insn "fix_trunchfqi2"
326   [(set                 (match_operand:QI 0 "register_operand" "=r")
327         (fix:QI (fix:HF (match_operand:HF 1 "register_operand" "r"))))]
328   ""
329   "fix r%0,r%1")
330
331 (define_insn "fix_trunctqfhi2"
332   [(set                 (match_operand:HI 0 "register_operand" "=r")
333         (fix:HI (fix:TQF (match_operand:TQF 1 "register_operand" "r"))))]
334   ""
335   "efix r%0,r%1")
336
337
338 ;; Move instructions
339
340 ;; We can't deal with normal byte-size characters, only with WIDE characters!
341 ;; This may appear as a serious restriction, but it also opens the doors
342 ;; for ISO 10646  :-)
343
344 ;; 16-bit moves
345
346 (define_insn "movqi"
347   [(set (match_operand:QI 0 "general_operand" "=r,r,r,r,r,r,r,m,m")
348         (match_operand:QI 1 "general_operand"  "O,I,J,M,i,r,m,r,K"))]
349   ""
350   "@
351      xorr r%0,r%0
352      lisp r%0,%1
353      lisn r%0,%J1
354      lim  r%0,%1  ; 'M' constraint
355      lim  r%0,%1  ; 'i' constraint
356      lr   r%0,r%1
357      l    r%0,%1
358      st   r%1,%0
359      stc  %1,%0   ")
360
361 ;; 32-bit moves
362
363 ;; Set HIreg to constant
364 (define_insn ""
365   [(set (match_operand:HI 0 "register_operand" "=r")
366         (match_operand    1 "immediate_operand" "i"))]
367   ""
368   "*
369     if (GET_CODE(operands[1]) == CONST_INT)
370       {
371         int val = INTVAL(operands[1]);
372         if (val >= 0)
373           {
374             if (val <= 65535)
375               {
376                 output_asm_insn(\"xorr   r%0,r%0 ;movhi cst->reg\",operands);
377                 operands[0] = gen_rtx(REG,QImode,REGNO(operands[0]) + 1);
378                 if (val == 0)
379                   return \"xorr r%0,r%0\";
380                 else if (val <= 16)
381                   return \"lisp r%0,%1\";
382                 else
383                   return \"lim  r%0,%1\";
384               }
385           }
386         else if (val >= -16)
387           return \"lisn r%0,%J1\;dsra r%0,16 ;movhi cst\";
388         INTVAL(operands[1]) >>= 16;
389         output_asm_insn(\"lim r%0,%1 ;movhi cst->reg\",operands);
390         REGNO(operands[0]) += 1;
391         INTVAL(operands[1]) = val & 0xFFFF;
392         return \"lim r%0,%1\";
393       }
394     return \"lim r%0,%1\;dsra r%0,16 ;movhi cst\";
395   ")
396
397 (define_insn "movhi"
398   [(set (match_operand:HI 0 "general_operand" "=r,r,m")
399         (match_operand:HI 1 "general_operand"  "r,m,r"))]
400   ""
401   "@
402     dlr r%0,r%1
403     dl  r%0,%1
404     dst r%1,%0 ")
405
406
407 ;; Single-Float moves are *same* as HImode moves:
408
409 ;(define_insn "movhf"
410 ;  [(set (match_operand:HF 0 "general_operand" "=r,r,r,m")
411 ;        (match_operand:HF 1 "general_operand"  "F,r,m,r"))]
412 ;  ""
413 ;  "@
414 ;    %D1\;dl r%0,%F1
415 ;    dlr r%0,r%1
416 ;    dl  r%0,%1
417 ;    dst r%1,%0 ")
418
419 (define_insn "movhf"
420   [(set (match_operand:HF 0 "general_operand" "=r,r,m")
421         (match_operand:HF 1 "general_operand"  "r,m,r"))]
422   ""
423   "@
424     dlr r%0,r%1
425     dl  r%0,%1
426     dst r%1,%0 ")
427
428
429 ;; Longfloat moves
430
431 ;(define_insn "movtqf"
432 ;  [(set (match_operand:TQF 0 "general_operand" "=r,r,r,m")
433 ;        (match_operand:TQF 1 "general_operand"  "F,r,m,r"))]
434 ;  ""
435 ;  "@
436 ;    %E1\;efl r%0,%G1
437 ;    eflr.m %0,%1
438 ;    efl  r%0,%1
439 ;    efst r%1,%0 ")
440
441 (define_insn "movtqf"
442   [(set (match_operand:TQF 0 "general_operand" "=r,r,m")
443         (match_operand:TQF 1 "general_operand"  "r,m,r"))]
444   ""
445   "@
446     eflr.m %0,%1
447     efl  r%0,%1
448     efst r%1,%0 ")
449
450
451 ;; add instructions 
452
453 ;; single integer
454
455 ;; Use "LIM Ra,sym,Rb" for adding a symbol value to a register and
456 ;; transferring the result to a different register.
457 ;(define_insn ""
458 ;  [(set (match_operand:QI 0 "register_operand" "=r")
459 ;        (plus:QI (match_operand:QI 1 "register_operand" "b")
460 ;                 (match_operand:QI 2 "immediate_operand"  "i")))]
461 ;   "REGNO(operands[0]) != REGNO(operands[1])"
462 ;   "lim r%0,%2,r%1 ;md special addqi")
463
464 (define_insn "addqi3"
465   [(set (match_operand:QI 0 "general_operand" "=r,r,r,r,r,m,m")
466         (plus:QI (match_operand:QI 1 "general_operand" "%0,0,0,0,0,0,0")
467                  (match_operand:QI 2 "general_operand"  "I,J,i,r,m,I,J")))]
468   ""
469   "*
470     switch (which_alternative)
471       {
472         case 0:
473           return \"aisp r%0,%2\";
474         case 1:
475           return \"sisp r%0,%J2\";
476         case 2:
477           if (INTVAL(operands[2]) < 0)
478             return \"sim r%0,%J2\";
479           else
480             return \"aim r%0,%2\";
481         case 3:
482           return \"ar r%0,r%2\";
483         case 4:
484           return \"a r%0,%2\";
485         case 5:
486           return \"incm %2,%0\";
487         case 6:
488           return \"decm %J2,%0\";
489       } ")
490
491 ;; double integer
492 (define_insn "addhi3"
493   [(set (match_operand:HI 0 "register_operand" "=r,r")
494         (plus:HI (match_operand:HI 1 "register_operand" "%0,0")
495                  (match_operand:HI 2 "general_operand" "r,m")))]
496   ""
497   "@
498     dar r%0,r%2
499     da  r%0,%2 ")
500
501 (define_insn "addhf3"
502   [(set (match_operand:HF 0 "register_operand" "=r,r")
503         (plus:HF (match_operand:HF 1 "register_operand" "%0,0")
504                  (match_operand:HF 2 "general_operand" "m,r")))]
505   ""
506   "@
507     fa  r%0,%2
508     far r%0,r%2 ")
509
510 (define_insn "addtqf3"
511   [(set (match_operand:TQF 0 "register_operand" "=r,r")
512         (plus:TQF (match_operand:TQF 1 "register_operand" "%0,0")
513                  (match_operand:TQF 2 "general_operand" "m,r")))]
514   ""
515   "@
516     efa  r%0,%2
517     efar r%0,r%2 ")
518
519
520 ;; subtract instructions
521
522 ;; single integer
523 (define_insn "subqi3"
524   [(set (match_operand:QI 0 "general_operand" "=r,r,r,r,m")
525         (minus:QI (match_operand:QI 1 "general_operand" "0,0,0,0,0")
526                   (match_operand:QI 2 "general_operand"  "I,i,r,m,I")))]
527   ""
528   "@
529     sisp r%0,%2
530     sim  r%0,%2
531     sr   r%0,r%2
532     s    r%0,%2
533     decm %2,%0 ")
534
535 ;; double integer
536 (define_insn "subhi3"
537   [(set (match_operand:HI 0 "register_operand" "=r,r")
538         (minus:HI (match_operand:HI 1 "register_operand" "0,0")
539                   (match_operand:HI 2 "general_operand" "r,m")))]
540   ""
541   "@
542     dsr r%0,r%2
543     ds  r%0,%2 ")
544
545 (define_insn "subhf3"
546   [(set (match_operand:HF 0 "register_operand" "=r,r")
547         (minus:HF (match_operand:HF 1 "register_operand" "0,0")
548                   (match_operand:HF 2 "general_operand" "r,m")))]
549   ""
550   "@
551     fsr r%0,r%2
552     fs  r%0,%2 ")
553
554 (define_insn "subtqf3"
555   [(set (match_operand:TQF 0 "register_operand" "=r,r")
556         (minus:TQF (match_operand:TQF 1 "register_operand" "0,0")
557                   (match_operand:TQF 2 "general_operand" "r,m")))]
558   ""
559   "@
560     efsr r%0,r%2
561     efs  r%0,%2 ")
562
563
564 ;; multiply instructions
565
566 (define_insn "mulqi3"
567   [(set (match_operand:QI 0 "register_operand" "=r,r,r,r,r")
568         (mult:QI (match_operand:QI 1 "register_operand" "%0,0,0,0,0")
569                  (match_operand:QI 2 "general_operand"  "I,J,M,r,m")))]
570   ""
571   "@
572      misp r%0,%2
573      misn r%0,%J2
574      msim r%0,%2
575      msr  r%0,r%2
576      ms   r%0,%2  ")
577
578
579 ; 32-bit product
580 (define_insn "mulqihi3"
581   [(set (match_operand:HI 0 "register_operand" "=r,r,r")
582         (mult:HI (match_operand:QI 1 "register_operand" "%0,0,0")
583                  (match_operand:QI 2 "general_operand" "M,r,m")))]
584   ""
585   "@
586     mim r%0,%1
587     mr  r%0,r%2
588     m   r%0,%2 ")
589
590 (define_insn "mulhi3"
591   [(set (match_operand:HI 0 "register_operand" "=r,r")
592         (mult:HI (match_operand:HI 1 "register_operand" "%0,0")
593                  (match_operand:HI 2 "general_operand" "r,m")))]
594   ""
595   "@
596     dmr r%0,r%2
597     dm  r%0,%2 ")
598
599 ; not available on 1750: "umulhi3","umulhisi3","umulsi3" (unsigned multiply's)
600
601 (define_insn "mulhf3"
602   [(set (match_operand:HF 0 "register_operand" "=r,r")
603         (mult:HF (match_operand:HF 1 "register_operand" "%0,0")
604                  (match_operand:HF 2 "general_operand" "r,m")))]
605   ""
606   "@
607     fmr r%0,r%2
608     fm  r%0,%2 ")
609
610 (define_insn "multqf3"
611   [(set (match_operand:TQF 0 "register_operand" "=r,r")
612         (mult:TQF (match_operand:TQF 1 "register_operand" "%0,0")
613                  (match_operand:TQF 2 "general_operand" "r,m")))]
614   ""
615   "@
616     efmr r%0,r%2
617     efm  r%0,%2 ")
618
619
620 ;; divide instructions
621 ;; The 1750 16bit integer division instructions deliver a 16-bit
622 ;; quotient and a 16-bit remainder, where the remainder is in the next higher
623 ;; register number above the quotient. For now, we haven't found a way
624 ;; to give the reload pass knowledge of this property. So we make do with
625 ;; whatever registers the allocator wants, and willy-nilly output a pair of
626 ;; register-copy ops when needed. (See mod_regno_adjust() in file aux-output.c)
627 ;; A comment in the description of `divmodM4' suggests that one leave the divM3
628 ;; undefined when there is a divmodM4 available.
629
630 (define_insn "divmodqi4"
631   [(set (match_operand:QI 0 "register_operand" "=r,r,r,r,r")
632         (div:QI (match_operand:QI 1 "register_operand" "0,0,0,0,0")
633                 (match_operand:QI 2 "general_operand"  "I,J,M,r,m")))
634    (set (match_operand:QI 3 "register_operand" "=r,r,r,r,r")
635         (mod:QI (match_dup 1) (match_dup 2)))]
636   ""
637   "*
638    {
639      char *istr;
640      switch(which_alternative)
641        {
642        case 0:
643          istr = \"disp\";
644          break;
645        case 1:
646          INTVAL(operands[2]) = - INTVAL(operands[2]); /* to be corrected */
647          istr = \"disn\";
648          break;
649        case 2:
650          istr = \"dvim\";
651          break;
652        case 3:
653          istr = \"dvr \";
654          break;
655        case 4:
656          istr = \"dv  \";
657          break;
658       }
659       return (char *)mod_regno_adjust(istr,operands);
660      }")
661
662 ;; Division for other types is straightforward.
663
664 (define_insn "divhi3"
665   [(set (match_operand:HI 0 "register_operand" "=r,r")
666         (div:HI (match_operand:HI 1 "register_operand" "0,0")
667                 (match_operand:HI 2 "general_operand" "r,m")))]
668   ""
669   "@
670     ddr r%0,r%2
671     dd  r%0,%2 ")
672
673 (define_insn "divhf3"
674   [(set (match_operand:HF 0 "register_operand" "=r,r")
675         (div:HF (match_operand:HF 1 "register_operand" "0,0")
676                 (match_operand:HF 2 "general_operand" "r,m")))]
677   ""
678   "@
679     fdr r%0,r%2
680     fd  r%0,%2 ")
681
682 (define_insn "divtqf3"
683   [(set (match_operand:TQF 0 "register_operand" "=r,r")
684         (div:TQF (match_operand:TQF 1 "register_operand" "0,0")
685                 (match_operand:TQF 2 "general_operand" "r,m")))]
686   ""
687   "@
688     efdr r%0,r%2
689     efd  r%0,%2 ")
690
691
692 ;; Other arithmetic instructions:
693
694 ;; Absolute value
695
696 (define_insn "absqi2"
697   [(set (match_operand:QI 0 "register_operand" "=r")
698         (abs:QI (match_operand:QI 1 "register_operand" "r")))]
699   ""
700   "abs r%0,r%1")
701
702 (define_insn "abshi2"
703   [(set (match_operand:HI 0 "register_operand" "=r")
704         (abs:HI (match_operand:HI 1 "register_operand" "r")))]
705   ""
706   "dabs r%0,r%1")
707
708 (define_insn "abshf2"
709   [(set (match_operand:HF 0 "register_operand" "=r")
710         (abs:HF (match_operand:HF 1 "register_operand" "r")))]
711   ""
712   "fabs r%0,r%1")
713
714
715 ;; Negation
716
717 (define_insn "negqi2"
718   [(set (match_operand:QI 0 "register_operand" "=r")
719         (neg:QI (match_operand:QI 1 "register_operand" "r")))]
720   ""
721   "neg r%0,r%1")
722
723 (define_insn "neghi2"
724   [(set (match_operand:HI 0 "register_operand" "=r")
725         (neg:HI (match_operand:HI 1 "register_operand" "r")))]
726   ""
727   "dneg r%0,r%1")
728
729 (define_insn "neghf2"
730   [(set (match_operand:HF 0 "register_operand" "=r")
731         (neg:HF (match_operand:HF 1 "register_operand" "r")))]
732   ""
733   "fneg r%0,r%1")
734
735 ; The 1750A does not have an extended float negate instruction, so simulate.
736 (define_expand "negtqf2"
737   [(set (match_operand:TQF 0 "register_operand" "=&r")
738         (neg:TQF (match_operand:TQF 1 "register_operand" "r")))]
739   ""
740   "
741    emit_insn(gen_rtx(SET,VOIDmode,operands[0],CONST0_RTX(TQFmode)));
742    emit_insn(gen_rtx(SET,VOIDmode,operands[0],
743              gen_rtx(MINUS,TQFmode,operands[0],operands[1])));
744    DONE;
745   ")
746
747
748 ;; bit-logical instructions
749
750 ;; AND
751
752 (define_insn "andqi3"
753   [(set (match_operand:QI 0 "general_operand" "=r,r,r")
754         (and:QI (match_operand:QI 1 "general_operand" "%0,0,0")
755                 (match_operand:QI 2 "general_operand" "M,r,m")))]
756   ""
757   "@
758     andm r%0,%2
759     andr r%0,r%2
760     and  r%0,%2 ")
761
762 ; This sets incorrect condition codes. See notice_update_cc()
763 (define_insn "andhi3"
764   [(set (match_operand:HI 0 "register_operand" "=r")
765         (and:HI (match_operand:HI 1 "register_operand" "%0")
766                 (match_operand:HI 2 "register_operand" "r")))]
767   ""
768   "danr.m %0,%2")
769
770 ;; OR
771
772 (define_insn "iorqi3"
773   [(set (match_operand:QI 0 "general_operand" "=r,r,r")
774         (ior:QI  (match_operand:QI 1 "general_operand" "%0,0,0")
775                 (match_operand:QI 2 "general_operand" "M,r,m")))]
776   ""
777   "@
778     orim r%0,%2
779     orr  r%0,r%2
780     or   r%0,%2 ")
781
782 ; This sets incorrect condition codes. See notice_update_cc()
783 (define_insn "iorhi3"
784   [(set (match_operand:HI 0 "register_operand" "=r")
785         (ior:HI (match_operand:HI 1 "register_operand" "%0")
786                 (match_operand:HI 2 "register_operand" "r")))]
787   ""
788   "dorr.m %0,%2")
789
790 ;; XOR
791
792 (define_insn "xorqi3"
793   [(set (match_operand:QI 0 "register_operand" "=r,r,r")
794         (xor:QI (match_operand:QI 1 "register_operand" "%0,0,0")
795                 (match_operand:QI 2 "general_operand"  "M,r,m")))]
796   ""
797   "@
798     xorm r%0,%2
799     xorr r%0,r%2
800     xor  r%0,%2 ")
801
802 ; This sets incorrect condition codes. See notice_update_cc()
803 (define_insn "xorhi3"
804   [(set (match_operand:HI 0 "register_operand" "=r")
805         (xor:HI (match_operand:HI 1 "register_operand" "%0")
806                 (match_operand:HI 2 "register_operand" "r")))]
807   ""
808   "dxrr.m %0,%2")
809
810 ;; NAND
811
812 (define_insn ""
813   [(set (match_operand:QI 0 "register_operand" "=r,r,r")
814         (ior:QI (not:QI (match_operand:QI 1 "register_operand" "%0,0,0"))
815                 (not:QI (match_operand:QI 2 "general_operand" "M,r,m"))))]
816   ""
817   "@
818     nim r%0,%2
819     nr  r%0,r%2
820     n   r%0,%2 ")
821
822 ; This sets incorrect condition codes. See notice_update_cc()
823 (define_insn ""
824   [(set (match_operand:HI 0 "register_operand" "=r")
825         (ior:HI (not:HI (match_operand:HI 1 "register_operand" "%0"))
826                 (not:HI (match_operand:HI 2 "register_operand" "r"))))]
827   ""
828   "dnr.m %0,%2")
829
830 ;; NOT
831
832 (define_insn "one_cmplqi2"
833   [(set (match_operand:QI 0 "register_operand" "=r")
834         (not:QI (match_operand:QI 1 "register_operand" "0")))]
835   ""
836   "nr r%0,r%0")
837
838 ; This sets incorrect condition codes. See notice_update_cc()
839 (define_insn "one_cmplhi2"
840   [(set (match_operand:HI 0 "register_operand" "=r")
841         (not:HI (match_operand:HI 1 "register_operand" "0")))]
842   ""
843   "dnr.m %0,%0")
844
845
846 ;; Shift instructions
847
848 ; (What to the 1750 is logical-shift-left, GCC likes to call "arithmetic")
849 (define_insn "ashlqi3"
850   [(set (match_operand:QI 0 "register_operand" "=r,r,r")
851         (ashift:QI (match_operand:QI 1 "register_operand" "0,0,0")
852                    (match_operand:QI 2 "general_operand" "O,I,r")))]
853   ""
854   "@
855     ; optimized away an SLL r%0,0
856     sll r%0,%2
857     slr r%0,r%2 ")
858
859 (define_insn "ashlhi3"
860   [(set (match_operand:HI 0 "register_operand" "=r,r")
861         (ashift:HI (match_operand:HI 1 "register_operand" "0,0")
862                    (match_operand:QI 2 "general_operand" "L,r")))]
863   ""                        ; the 'L' constraint is a slight imprecise...
864   "@
865      dsll r%0,%2
866      dslr r%0,r%2 ")
867
868 (define_insn "lshrqi3"
869   [(set (match_operand:QI 0 "register_operand" "=r,r")
870         (lshiftrt:QI (match_operand:QI 1 "register_operand" "0,0")
871                      (match_operand:QI 2 "general_operand" "I,r")))]
872   ""
873   "@
874     srl r%0,%2
875     neg r%2,r%2\;slr    r%0,r%2 ")
876
877 (define_insn "lshrhi3"
878   [(set (match_operand:HI 0 "register_operand" "=r,r")
879         (lshiftrt:HI (match_operand:HI 1 "register_operand" "0,0")
880                      (match_operand:QI 2 "general_operand" "L,r")))]
881   ""                        ; the 'L' constraint is a slight imprecise...
882   "@
883     dsrl r%0,%2
884     neg  r%2,r%2\;dslr   r%0,r%2 ")
885
886 (define_insn "ashrqi3"
887   [(set (match_operand:QI 0 "register_operand" "=r,r")
888         (ashiftrt:QI (match_operand:QI 1 "register_operand" "0,0")
889                      (match_operand:QI 2 "general_operand" "I,r")))]
890   ""
891   "@
892      sra r%0,%2
893      neg r%2,r%2\;sar    r%0,r%2 ")
894
895 (define_insn "ashrhi3"
896   [(set (match_operand:HI 0 "register_operand" "=r,r")
897         (ashiftrt:HI (match_operand:HI 1 "register_operand" "0,0")
898                      (match_operand:QI 2 "general_operand" "I,r")))]
899   ""
900   "@
901      dsra r%0,%2
902      neg  r%2,r%2\;dsar   r%0,r%2 ")
903
904
905 ;; rotate instructions
906
907 (define_insn "rotlqi3"
908   [(set (match_operand:QI 0 "register_operand" "=r,r")
909         (rotate:QI (match_operand:QI 1 "register_operand" "0,0")
910                    (match_operand:QI 2 "general_operand" "I,r")))]
911   ""
912   "@
913     slc r%0,%2
914     scr r%0,r%2 ")
915
916 (define_insn "rotlhi3"
917   [(set (match_operand:HI 0 "register_operand" "=r,r")
918         (rotate:HI (match_operand:HI 1 "register_operand" "0,0")
919                    (match_operand:QI 2 "general_operand" "I,r")))]
920   ""
921   "@
922     dslc r%0,%2
923     dscr r%0,r%2 ")
924
925 (define_insn "rotrqi3"
926   [(set (match_operand:QI 0 "register_operand" "=r,r")
927         (rotatert:QI (match_operand:QI 1 "register_operand" "0,0")
928                      (match_operand:QI 2 "general_operand" "I,r")))]
929   ""
930   "@
931     slc r%0,%2
932     neg r%2,r%2\;scr    r%0,r%2 ")
933
934 (define_insn "rotrhi3"
935   [(set (match_operand:HI 0 "register_operand" "=r,r")
936         (rotatert:HI (match_operand:HI 1 "register_operand" "0,0")
937                      (match_operand:QI 2 "general_operand" "I,r")))]
938   ""
939   "@
940     dslc r%0,%2
941     neg  r%2,r%2\;dscr   r%0,r%2 ")
942
943
944
945 ;; Special cases of bit-field insns which we should
946 ;; recognize in preference to the general case.
947 ;; These handle aligned 8-bit and 16-bit fields,
948 ;; which can usually be done with move instructions.
949 ;    1750: t.b.d.
950 ;********************
951
952 ;; Bit field instructions, general cases.
953 ;; "o,d" constraint causes a nonoffsettable memref to match the "o"
954 ;; so that its address is reloaded.
955
956 ;; (define_insn "extv" ...
957
958 ;; (define_insn "extzv" ...
959
960 ;; (define_insn "insv" ...
961
962 ;; Now recognize bit field insns that operate on registers
963 ;; (or at least were intended to do so).
964 ;[unnamed only]
965
966 ;; Special patterns for optimizing bit-field instructions.
967 ;**************************************
968
969 ; cc status test ops n.a. on 1750 ......... e.g. "sleu" on 68k:
970 ;  [(set (match_operand:QI 0 "general_operand" "=d")
971 ;        (leu (cc0) (const_int 0)))]
972 ;  ""
973 ;  "* cc_status = cc_prev_status;
974 ;     return \"sls %0\"; ")
975
976
977 ;; Basic conditional jump instructions.
978
979 (define_insn "beq"
980   [(set (pc)
981         (if_then_else (eq (cc0)
982                           (const_int 0))
983                       (label_ref (match_operand 0 "" ""))
984                       (pc)))]
985   ""
986   "* return (char *)branch_or_jump(\"ez\",CODE_LABEL_NUMBER(operands[0]));
987   ")
988
989 (define_insn "bne"
990   [(set (pc)
991         (if_then_else (ne (cc0)
992                           (const_int 0))
993                       (label_ref (match_operand 0 "" ""))
994                       (pc)))]
995   ""
996   "* return (char *)branch_or_jump(\"nz\",CODE_LABEL_NUMBER(operands[0]));
997   ")
998
999 (define_insn "bgt"
1000   [(set (pc)
1001         (if_then_else (gt (cc0)
1002                           (const_int 0))
1003                       (label_ref (match_operand 0 "" ""))
1004                       (pc)))]
1005   ""
1006   "* return (char *)branch_or_jump(\"gt\",CODE_LABEL_NUMBER(operands[0]));
1007   ")
1008
1009 (define_insn "blt"
1010   [(set (pc)
1011         (if_then_else (lt (cc0)
1012                           (const_int 0))
1013                       (label_ref (match_operand 0 "" ""))
1014                       (pc)))]
1015   ""
1016   "* return (char *)branch_or_jump(\"lt\",CODE_LABEL_NUMBER(operands[0]));
1017   ")
1018
1019 (define_insn "bge"
1020   [(set (pc)
1021         (if_then_else (ge (cc0)
1022                           (const_int 0))
1023                       (label_ref (match_operand 0 "" ""))
1024                       (pc)))]
1025   ""
1026   "* return (char *)branch_or_jump(\"ge\",CODE_LABEL_NUMBER(operands[0]));
1027   ")
1028
1029 (define_insn "ble"
1030   [(set (pc)
1031         (if_then_else (le (cc0)
1032                           (const_int 0))
1033                       (label_ref (match_operand 0 "" ""))
1034                       (pc)))]
1035   ""
1036   "* return (char *)branch_or_jump(\"le\",CODE_LABEL_NUMBER(operands[0]));
1037   ")
1038
1039
1040 ; no unsigned branches available on 1750. But GCC still needs them, so faking:
1041
1042 (define_insn "bgtu"
1043   [(set (pc)
1044         (if_then_else (gtu (cc0)
1045                           (const_int 0))
1046                       (label_ref (match_operand 0 "" ""))
1047                       (pc)))]
1048   ""
1049   "jc gt,%l0 ; Warning: this should be an *unsigned* test!")
1050
1051 (define_insn "bltu"
1052   [(set (pc)
1053         (if_then_else (ltu (cc0)
1054                           (const_int 0))
1055                       (label_ref (match_operand 0 "" ""))
1056                       (pc)))]
1057   ""
1058   "jc lt,%l0 ; Warning: this should be an *unsigned* test!")
1059
1060 (define_insn "bgeu"
1061   [(set (pc)
1062         (if_then_else (geu (cc0)
1063                           (const_int 0))
1064                       (label_ref (match_operand 0 "" ""))
1065                       (pc)))]
1066   ""
1067   "jc ge,%l0 ; Warning: this should be an *unsigned* test!")
1068
1069 (define_insn "bleu"
1070   [(set (pc)
1071         (if_then_else (leu (cc0)
1072                           (const_int 0))
1073                       (label_ref (match_operand 0 "" ""))
1074                       (pc)))]
1075   ""
1076   "jc le,%l0 ; Warning: this should be an *unsigned* test!")
1077
1078
1079 ;; Negated conditional jump instructions.
1080
1081 (define_insn ""
1082   [(set (pc)
1083         (if_then_else (eq (cc0)
1084                           (const_int 0))
1085                       (pc)
1086                       (label_ref (match_operand 0 "" ""))))]
1087   ""
1088   "* return (char *)branch_or_jump(\"nz\",CODE_LABEL_NUMBER(operands[0]));
1089   ")
1090
1091 (define_insn ""
1092   [(set (pc)
1093         (if_then_else (ne (cc0)
1094                           (const_int 0))
1095                       (pc)
1096                       (label_ref (match_operand 0 "" ""))))]
1097   ""
1098   "* return (char *)branch_or_jump(\"ez\",CODE_LABEL_NUMBER(operands[0]));
1099   ")
1100
1101 (define_insn ""
1102   [(set (pc)
1103         (if_then_else (gt (cc0)
1104                           (const_int 0))
1105                       (pc)
1106                       (label_ref (match_operand 0 "" ""))))]
1107   ""
1108   "* return (char *)branch_or_jump(\"le\",CODE_LABEL_NUMBER(operands[0]));
1109   ")
1110
1111 (define_insn ""
1112   [(set (pc)
1113         (if_then_else (lt (cc0)
1114                           (const_int 0))
1115                       (pc)
1116                       (label_ref (match_operand 0 "" ""))))]
1117   ""
1118   "* return (char *)branch_or_jump(\"ge\",CODE_LABEL_NUMBER(operands[0]));
1119   ")
1120
1121 (define_insn ""
1122   [(set (pc)
1123         (if_then_else (ge (cc0)
1124                           (const_int 0))
1125                       (pc)
1126                       (label_ref (match_operand 0 "" ""))))]
1127   ""
1128   "* return (char *)branch_or_jump(\"lt\",CODE_LABEL_NUMBER(operands[0]));
1129   ")
1130
1131 (define_insn ""
1132   [(set (pc)
1133         (if_then_else (le (cc0)
1134                           (const_int 0))
1135                       (pc)
1136                       (label_ref (match_operand 0 "" ""))))]
1137   ""
1138   "* return (char *)branch_or_jump(\"gt\",CODE_LABEL_NUMBER(operands[0]));
1139   ")
1140
1141
1142 ;; Negated unsigned conditional jump instructions (faked for 1750).
1143
1144 (define_insn ""
1145   [(set (pc)
1146         (if_then_else (gtu (cc0)
1147                           (const_int 0))
1148                       (pc)
1149                       (label_ref (match_operand 0 "" ""))))]
1150   ""
1151   "jc le,%l0 ;inv.cond. ;Warning: this should be an *unsigned* test!")
1152
1153 (define_insn ""
1154   [(set (pc)
1155         (if_then_else (ltu (cc0)
1156                           (const_int 0))
1157                       (pc)
1158                       (label_ref (match_operand 0 "" ""))))]
1159   ""
1160   "jc ge,%l0 ;inv.cond. ;Warning: this should be an *unsigned* test!")
1161
1162 (define_insn ""
1163   [(set (pc)
1164         (if_then_else (geu (cc0)
1165                           (const_int 0))
1166                       (pc)
1167                       (label_ref (match_operand 0 "" ""))))]
1168   ""
1169   "jc lt,%l0 ;inv.cond. ;Warning: this should be an *unsigned* test!")
1170
1171 (define_insn ""
1172   [(set (pc)
1173         (if_then_else (leu (cc0)
1174                           (const_int 0))
1175                       (pc)
1176                       (label_ref (match_operand 0 "" ""))))]
1177   ""
1178   "jc gt,%l0 ;inv.cond. ;Warning: this should be an *unsigned* test!")
1179
1180 ;; Tablejump 
1181 ;; 1750 note: CASE_VECTOR_PC_RELATIVE is not defined
1182 (define_insn "tablejump"
1183   [(set (pc)
1184         (match_operand:QI 0 "register_operand" "b"))
1185    (use (label_ref (match_operand 1 "" "")))]
1186   ""
1187   "jc 15,0,r%0   ; tablejump label_ref=%1")
1188
1189
1190 ;; Unconditional jump
1191 (define_insn "jump"
1192   [(set (pc)
1193         (label_ref (match_operand 0 "" "")))]
1194   ""
1195   "jc uc,%0")
1196
1197 ;; Call subroutine, returning value in operand 0
1198 ;; (which must be a hard register).
1199 (define_insn "call_value"
1200   [(set (match_operand 0 "register_operand" "r")
1201         (call (match_operand:QI 1 "memory_operand" "m")
1202               (match_operand:QI 2 "general_operand" "g")))]
1203   ;; Operand 2 not really used for 1750.
1204   ""
1205   "sjs r15,%1   ; return value in R0")
1206
1207 ;; Call subroutine with no return value.
1208
1209 ;;  Operand 1 not really used in MIL-STD-1750.
1210 (define_insn ""
1211   [(call (match_operand:QI 0 "memory_operand" "mp")
1212          (match_operand:QI 1 "general_operand" ""))]
1213   ""
1214   "sjs r15,%0   ; no return value")
1215
1216 ;;;;;;;;;;;; 1750: NOT READY YET.
1217 (define_insn "call"
1218   [(call (match_operand:QI 0 "" "")
1219          (match_operand:QI 1 "" ""))]
1220   ""
1221   "ANYCALL %0")
1222
1223
1224 ; (define_insn "return"
1225 ;   [(return)]
1226 ;   ""
1227 ;   "*
1228 ;    { 
1229 ;         rtx oprnd = gen_rtx(CONST_INT,VOIDmode,get_frame_size());
1230 ;         output_asm_insn(\"ret.m  %0\",&oprnd);
1231 ;         return \"\;\";
1232 ;    } ")
1233
1234 (define_insn "indirect_jump"
1235   [(set (pc) (match_operand:QI 0 "address_operand" "p"))]
1236   ""
1237   "jci 15,%0")
1238
1239 (define_insn "nop"
1240   [(const_int 0)]
1241   ""
1242   "nop")
1243
1244
1245 ;; Subtract One and Jump (if non-zero)
1246 (define_peephole 
1247   [(set (match_operand:QI 0 "register_operand" "=r")
1248         (plus:QI (match_operand:QI 1 "register_operand" "%0")
1249                  (match_operand:QI 2 "immediate_operand" "J")))
1250    (set (cc0) (match_dup 0))
1251    (set (pc)
1252         (if_then_else (ne (cc0) (const_int 0))
1253          (label_ref (match_operand 3 "" ""))
1254          (pc)))
1255    ]
1256   "INTVAL(operands[2]) == -1"
1257   "soj r%0,%3")
1258
1259 ;;;End.
1260