xref: /netbsd-src/external/gpl3/gcc.old/dist/gcc/config/vax/builtins.md (revision b7b7574d3bf8eeb51a1fa3977b59142ec6434a55)
1;; builtin definitions for DEC VAX.
2;; Copyright (C) 2007, 2009 Free Software Foundation, Inc.
3;;
4;; This file is part of GCC.
5;;
6;; GCC is free software; you can redistribute it and/or modify it under
7;; the terms of the GNU General Public License as published by the Free
8;; Software Foundation; either version 3, or (at your option) any later
9;; version.
10;;
11;; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12;; WARRANTY; without even the implied warranty of MERCHANTABILITY or
13;; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14;; for more details.
15;;
16;; You should have received a copy of the GNU General Public License
17;; along with GCC; see the file COPYING3.  If not see
18;; <http://www.gnu.org/licenses/>.
19
20(define_constants
21  [
22    (VUNSPEC_LOCK 100)		; sync lock and test
23    (VUNSPEC_UNLOCK 101)	; sync lock release
24  ]
25)
26
27(define_expand "condjump"
28  [(set (pc)
29	(if_then_else (match_operand 0)
30		      (label_ref (match_operand 1))
31		      (pc)))])
32
33(define_expand "ffssi2"
34  [(set (match_operand:SI 0 "nonimmediate_operand" "")
35	(ffs:SI (match_operand:SI 1 "general_operand" "")))]
36  ""
37  "
38{
39  rtx label = gen_label_rtx ();
40  emit_insn (gen_ffssi2_internal (operands[0], operands[1]));
41  emit_jump_insn (gen_condjump (gen_rtx_NE(VOIDmode, cc0_rtx, const0_rtx), label));
42  emit_insn (gen_negsi2 (operands[0], const1_rtx));
43  emit_label (label);
44  emit_insn (gen_addsi3 (operands[0], operands[0], const1_rtx));
45  DONE;
46}")
47
48(define_insn "ffssi2_internal"
49  [(set (match_operand:SI 0 "nonimmediate_operand" "=rQ")
50	(ffs:SI (match_operand:SI 1 "general_operand" "nrmT")))
51   (set (cc0) (match_dup 0))]
52  ""
53  "ffs $0,$32,%1,%0")
54
55(define_expand "sync_lock_test_and_set<mode>"
56  [(set (match_operand:VAXint 0 "nonimmediate_operand" "=&g")
57	(unspec:VAXint [(match_operand:VAXint 1 "memory_operand" "+m")
58		    (match_operand:VAXint 2 "const_int_operand" "n")
59		   ] VUNSPEC_LOCK))]
60  ""
61  "
62{
63  rtx label;
64
65  if (operands[2] != const1_rtx)
66    FAIL;
67
68  label = gen_label_rtx ();
69  emit_move_insn (operands[0], const1_rtx);
70  emit_jump_insn (gen_jbbssi<mode> (operands[1], const0_rtx, label, operands[1]));
71  emit_move_insn (operands[0], const0_rtx);
72  emit_label (label);
73  DONE;
74}")
75
76(define_insn "jbbssiqi"
77  [(parallel
78    [(set (pc)
79	  (if_then_else
80	    (ne (zero_extract:SI (match_operand:QI 0 "memory_operand" "g")
81				 (const_int 1)
82				 (match_operand:SI 1 "general_operand" "nrm"))
83		(const_int 0))
84	    (label_ref (match_operand 2 "" ""))
85	    (pc)))
86     (set (zero_extract:SI (match_operand:QI 3 "memory_operand" "+0")
87			   (const_int 1)
88			   (match_dup 1))
89	  (const_int 1))])]
90  ""
91  "jbssi %1,%0,%l2")
92
93(define_insn "jbbssihi"
94  [(parallel
95    [(set (pc)
96	  (if_then_else
97	    (ne (zero_extract:SI (match_operand:HI 0 "memory_operand" "Q")
98				 (const_int 1)
99				 (match_operand:SI 1 "general_operand" "nrm"))
100		(const_int 0))
101	    (label_ref (match_operand 2 "" ""))
102	    (pc)))
103     (set (zero_extract:SI (match_operand:HI 3 "memory_operand" "+0")
104			   (const_int 1)
105			   (match_dup 1))
106	  (const_int 1))])]
107  ""
108  "jbssi %1,%0,%l2")
109
110(define_insn "jbbssisi"
111  [(parallel
112    [(set (pc)
113	  (if_then_else
114	    (ne (zero_extract:SI (match_operand:SI 0 "memory_operand" "Q")
115				 (const_int 1)
116				 (match_operand:SI 1 "general_operand" "nrm"))
117		(const_int 0))
118	    (label_ref (match_operand 2 "" ""))
119	    (pc)))
120     (set (zero_extract:SI (match_operand:SI 3 "memory_operand" "+0")
121			   (const_int 1)
122			   (match_dup 1))
123	  (const_int 1))])]
124  ""
125  "jbssi %1,%0,%l2")
126
127
128(define_expand "sync_lock_release<mode>"
129  [(set (match_operand:VAXint 0 "memory_operand" "+m")
130	(unspec:VAXint [(match_operand:VAXint 1 "const_int_operand" "n")
131		   ] VUNSPEC_UNLOCK))]
132  ""
133  "
134{
135  rtx label;
136  if (operands[1] != const0_rtx)
137    FAIL;
138#if 1
139  label = gen_label_rtx ();
140  emit_jump_insn (gen_jbbcci<mode> (operands[0], const0_rtx, label, operands[0]));
141  emit_label (label);
142#else
143  emit_move_insn (operands[0], const0_rtx);
144#endif
145  DONE;
146}")
147
148(define_insn "jbbcciqi"
149  [(parallel
150    [(set (pc)
151	  (if_then_else
152	    (eq (zero_extract:SI (match_operand:QI 0 "memory_operand" "g")
153				 (const_int 1)
154				 (match_operand:SI 1 "general_operand" "nrm"))
155		(const_int 0))
156	    (label_ref (match_operand 2 "" ""))
157	    (pc)))
158     (set (zero_extract:SI (match_operand:QI 3 "memory_operand" "+0")
159			   (const_int 1)
160			   (match_dup 1))
161	  (const_int 0))])]
162  ""
163  "jbcci %1,%0,%l2")
164
165(define_insn "jbbccihi"
166  [(parallel
167    [(set (pc)
168	  (if_then_else
169	    (eq (zero_extract:SI (match_operand:HI 0 "memory_operand" "Q")
170				 (const_int 1)
171				 (match_operand:SI 1 "general_operand" "nrm"))
172		(const_int 0))
173	    (label_ref (match_operand 2 "" ""))
174	    (pc)))
175     (set (zero_extract:SI (match_operand:HI 3 "memory_operand" "+0")
176			   (const_int 1)
177			   (match_dup 1))
178	  (const_int 0))])]
179  ""
180  "jbcci %1,%0,%l2")
181
182(define_insn "jbbccisi"
183  [(parallel
184    [(set (pc)
185	  (if_then_else
186	    (eq (zero_extract:SI (match_operand:SI 0 "memory_operand" "Q")
187				 (const_int 1)
188				 (match_operand:SI 1 "general_operand" "nrm"))
189		(const_int 0))
190	    (label_ref (match_operand 2 "" ""))
191	    (pc)))
192     (set (zero_extract:SI (match_operand:SI 3 "memory_operand" "+0")
193			   (const_int 1)
194			   (match_dup 1))
195	  (const_int 0))])]
196  ""
197  "jbcci %1,%0,%l2")
198