Mercurial > hg > CbC > CbC_gcc
comparison gcc/config/mn10300/mn10300.md @ 67:f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
author | nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 22 Mar 2011 17:18:12 +0900 |
parents | 77e2b8dfacca |
children | 04ced10e8804 |
comparison
equal
deleted
inserted
replaced
65:65488c3d617d | 67:f6334be47118 |
---|---|
1 ;; GCC machine description for Matsushita MN10300 | 1 ;; GCC machine description for Matsushita MN10300 |
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, | 2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
3 ;; 2007, 2008 Free Software Foundation, Inc. | 3 ;; 2005, 2006, 2007, 2008, 2009, 2010, 2011 |
4 ;; Free Software Foundation, Inc. | |
4 ;; Contributed by Jeff Law (law@cygnus.com). | 5 ;; Contributed by Jeff Law (law@cygnus.com). |
5 | 6 |
6 ;; This file is part of GCC. | 7 ;; This file is part of GCC. |
7 | 8 |
8 ;; GCC is free software; you can redistribute it and/or modify | 9 ;; GCC is free software; you can redistribute it and/or modify |
22 ;; The original PO technology requires these to be ordered by speed, | 23 ;; The original PO technology requires these to be ordered by speed, |
23 ;; so that assigner will pick the fastest. | 24 ;; so that assigner will pick the fastest. |
24 | 25 |
25 ;; See file "rtl.def" for documentation on define_insn, match_*, et. al. | 26 ;; See file "rtl.def" for documentation on define_insn, match_*, et. al. |
26 | 27 |
27 ;; Condition code settings. | |
28 ;; none - insn does not affect cc | |
29 ;; none_0hit - insn does not affect cc but it does modify operand 0 | |
30 ;; This attribute is used to keep track of when operand 0 changes. | |
31 ;; See the description of NOTICE_UPDATE_CC for more info. | |
32 ;; set_znv - insn sets z,n,v to usable values; c is unusable. | |
33 ;; set_zn - insn sets z,n to usable values; v,c are unusable. | |
34 ;; compare - compare instruction | |
35 ;; clobber - value of cc is unknown | |
36 (define_attr "cc" "none,none_0hit,set_znv,set_zn,compare,clobber" | |
37 (const_string "clobber")) | |
38 | |
39 (define_constants [ | 28 (define_constants [ |
40 (PIC_REG 6) | 29 (PIC_REG 6) |
41 (SP_REG 9) | 30 (SP_REG 9) |
42 | 31 (MDR_REG 50) |
43 (UNSPEC_INT_LABEL 0) | 32 (CC_REG 51) |
33 | |
44 (UNSPEC_PIC 1) | 34 (UNSPEC_PIC 1) |
45 (UNSPEC_GOT 2) | 35 (UNSPEC_GOT 2) |
46 (UNSPEC_GOTOFF 3) | 36 (UNSPEC_GOTOFF 3) |
47 (UNSPEC_PLT 4) | 37 (UNSPEC_PLT 4) |
48 (UNSPEC_GOTSYM_OFF 5) | 38 (UNSPEC_GOTSYM_OFF 5) |
39 | |
40 (UNSPEC_EXT 6) | |
41 (UNSPEC_BSCH 7) | |
42 | |
43 ;; This is used to encode LIW patterns. | |
44 (UNSPEC_LIW 8) | |
49 ]) | 45 ]) |
50 | 46 |
51 (include "predicates.md") | 47 (include "predicates.md") |
52 (include "constraints.md") | 48 (include "constraints.md") |
49 | |
50 ;; Processor type. This attribute must exactly match the processor_type | |
51 ;; enumeration in mn10300.h. | |
52 (define_attr "cpu" "mn10300,am33,am33_2,am34" | |
53 (const (symbol_ref "(enum attr_cpu) mn10300_tune_cpu"))) | |
54 | |
55 ;; Used to control the "enabled" attribute on a per-instruction basis. | |
56 (define_attr "isa" "base,am33,am33_2,am34" | |
57 (const_string "base")) | |
58 | |
59 (define_attr "enabled" "" | |
60 (cond [(eq_attr "isa" "base") | |
61 (const_int 1) | |
62 | |
63 (and (eq_attr "isa" "am33") | |
64 (ne (symbol_ref "TARGET_AM33") (const_int 0))) | |
65 (const_int 1) | |
66 | |
67 (and (eq_attr "isa" "am33_2") | |
68 (ne (symbol_ref "TARGET_AM33_2") (const_int 0))) | |
69 (const_int 1) | |
70 | |
71 (and (eq_attr "isa" "am34") | |
72 (ne (symbol_ref "TARGET_AM34") (const_int 0))) | |
73 (const_int 1) | |
74 ] | |
75 (const_int 0)) | |
76 ) | |
77 | |
78 (define_mode_iterator INT [QI HI SI]) | |
79 | |
53 | 80 |
81 ;; Bundling of smaller insns into a long instruction word (LIW) | |
82 (define_automaton "liw_bundling") | |
83 (automata_option "ndfa") | |
84 | |
85 (define_cpu_unit "liw_op1_u,liw_op2_u" "liw_bundling") | |
86 | |
87 (define_attr "liw" "op1,op2,both,either" | |
88 (const_string "both")) | |
89 ;; Note: this list must match the one defined for liw_op_names[]. | |
90 (define_attr "liw_op" "add,cmp,sub,mov,and,or,xor,asr,lsr,asl,none,max" | |
91 (const_string "none")) | |
92 | |
93 (define_insn_reservation "liw_op1" 1 | |
94 (and (ior (eq_attr "cpu" "am33") | |
95 (eq_attr "cpu" "am33_2") | |
96 (eq_attr "cpu" "am34")) | |
97 (eq_attr "liw" "op1")) | |
98 "liw_op1_u"); | |
99 (define_insn_reservation "liw_op2" 1 | |
100 (and (ior (eq_attr "cpu" "am33") | |
101 (eq_attr "cpu" "am33_2") | |
102 (eq_attr "cpu" "am34")) | |
103 (eq_attr "liw" "op2")) | |
104 "liw_op2_u"); | |
105 (define_insn_reservation "liw_both" 1 | |
106 (and (ior (eq_attr "cpu" "am33") | |
107 (eq_attr "cpu" "am33_2") | |
108 (eq_attr "cpu" "am34")) | |
109 (eq_attr "liw" "both")) | |
110 "liw_op1_u + liw_op2_u"); | |
111 (define_insn_reservation "liw_either" 1 | |
112 (and (ior (eq_attr "cpu" "am33") | |
113 (eq_attr "cpu" "am33_2") | |
114 (eq_attr "cpu" "am34")) | |
115 (eq_attr "liw" "either")) | |
116 "liw_op1_u | liw_op2_u"); | |
117 | |
118 ;; ---------------------------------------------------------------------- | |
119 ;; Pipeline description. | |
120 ;; ---------------------------------------------------------------------- | |
121 | |
122 ;; The AM33 only has a single pipeline. It has five stages (fetch, | |
123 ;; decode, execute, memory access, writeback) each of which normally | |
124 ;; takes a single CPU clock cycle. | |
125 | |
126 ;; The timings attribute consists of two numbers, the first is the | |
127 ;; throughput, which is the number of cycles the instruction takes | |
128 ;; to execute and generate a result. The second is the latency | |
129 ;; which is the effective number of cycles the instruction takes to | |
130 ;; execute if its result is used by the following instruction. The | |
131 ;; latency is always greater than or equal to the throughput. | |
132 ;; These values were taken from the Appendix of the "MN103E Series | |
133 ;; Instruction Manual" and the timings for the AM34. | |
134 | |
135 ;; Note - it would be nice to use strings rather than integers for | |
136 ;; the possible values of this attribute, so that we can have the | |
137 ;; gcc build mechanism check for values that are not supported by | |
138 ;; the reservations below. But this will not work because the code | |
139 ;; in mn10300_adjust_sched_cost() needs integers not strings. | |
140 | |
141 (define_attr "timings" "" (const_int 11)) | |
142 | |
143 (define_automaton "pipelining") | |
144 (define_cpu_unit "throughput" "pipelining") | |
145 | |
146 (define_insn_reservation "throughput__1_latency__1" 1 | |
147 (eq_attr "timings" "11") "throughput") | |
148 (define_insn_reservation "throughput__1_latency__2" 2 | |
149 (eq_attr "timings" "12") "throughput,nothing") | |
150 (define_insn_reservation "throughput__1_latency__3" 3 | |
151 (eq_attr "timings" "13") "throughput,nothing*2") | |
152 (define_insn_reservation "throughput__1_latency__4" 4 | |
153 (eq_attr "timings" "14") "throughput,nothing*3") | |
154 (define_insn_reservation "throughput__2_latency__2" 2 | |
155 (eq_attr "timings" "22") "throughput*2") | |
156 (define_insn_reservation "throughput__2_latency__3" 3 | |
157 (eq_attr "timings" "23") "throughput*2,nothing") | |
158 (define_insn_reservation "throughput__2_latency__4" 4 | |
159 (eq_attr "timings" "24") "throughput*2,nothing*2") | |
160 (define_insn_reservation "throughput__2_latency__5" 5 | |
161 (eq_attr "timings" "25") "throughput*2,nothing*3") | |
162 (define_insn_reservation "throughput__3_latency__3" 3 | |
163 (eq_attr "timings" "33") "throughput*3") | |
164 (define_insn_reservation "throughput__3_latency__7" 7 | |
165 (eq_attr "timings" "37") "throughput*3,nothing*4") | |
166 (define_insn_reservation "throughput__4_latency__4" 4 | |
167 (eq_attr "timings" "44") "throughput*4") | |
168 (define_insn_reservation "throughput__4_latency__7" 7 | |
169 (eq_attr "timings" "47") "throughput*4,nothing*3") | |
170 (define_insn_reservation "throughput__4_latency__8" 8 | |
171 (eq_attr "timings" "48") "throughput*4,nothing*4") | |
172 (define_insn_reservation "throughput__5_latency__5" 5 | |
173 (eq_attr "timings" "55") "throughput*5") | |
174 (define_insn_reservation "throughput__6_latency__6" 6 | |
175 (eq_attr "timings" "66") "throughput*6") | |
176 (define_insn_reservation "throughput__7_latency__7" 7 | |
177 (eq_attr "timings" "77") "throughput*7") | |
178 (define_insn_reservation "throughput__7_latency__8" 8 | |
179 (eq_attr "timings" "78") "throughput*7,nothing") | |
180 (define_insn_reservation "throughput__8_latency__8" 8 | |
181 (eq_attr "timings" "88") "throughput*8") | |
182 (define_insn_reservation "throughput__9_latency__9" 9 | |
183 (eq_attr "timings" "99") "throughput*9") | |
184 (define_insn_reservation "throughput__8_latency_14" 14 | |
185 (eq_attr "timings" "814") "throughput*8,nothing*6") | |
186 (define_insn_reservation "throughput__9_latency_10" 10 | |
187 (eq_attr "timings" "910") "throughput*9,nothing") | |
188 (define_insn_reservation "throughput_10_latency_10" 10 | |
189 (eq_attr "timings" "1010") "throughput*10") | |
190 (define_insn_reservation "throughput_12_latency_16" 16 | |
191 (eq_attr "timings" "1216") "throughput*12,nothing*4") | |
192 (define_insn_reservation "throughput_13_latency_13" 13 | |
193 (eq_attr "timings" "1313") "throughput*13") | |
194 (define_insn_reservation "throughput_14_latency_14" 14 | |
195 (eq_attr "timings" "1414") "throughput*14") | |
196 (define_insn_reservation "throughput_13_latency_17" 17 | |
197 (eq_attr "timings" "1317") "throughput*13,nothing*4") | |
198 (define_insn_reservation "throughput_23_latency_27" 27 | |
199 (eq_attr "timings" "2327") "throughput*23,nothing*4") | |
200 (define_insn_reservation "throughput_25_latency_31" 31 | |
201 (eq_attr "timings" "2531") "throughput*25,nothing*6") | |
202 (define_insn_reservation "throughput_38_latency_39" 39 | |
203 (eq_attr "timings" "3839") "throughput*38,nothing") | |
204 (define_insn_reservation "throughput_39_latency_40" 40 | |
205 (eq_attr "timings" "3940") "throughput*39,nothing") | |
206 (define_insn_reservation "throughput_40_latency_40" 40 | |
207 (eq_attr "timings" "4040") "throughput*40") | |
208 (define_insn_reservation "throughput_41_latency_42" 42 | |
209 (eq_attr "timings" "4142") "throughput*41,nothing") | |
210 (define_insn_reservation "throughput_42_latency_43" 44 | |
211 (eq_attr "timings" "4243") "throughput*42,nothing") | |
212 (define_insn_reservation "throughput_43_latency_44" 44 | |
213 (eq_attr "timings" "4344") "throughput*43,nothing") | |
214 (define_insn_reservation "throughput_45_latency_46" 46 | |
215 (eq_attr "timings" "4546") "throughput*45,nothing") | |
216 (define_insn_reservation "throughput_47_latency_53" 53 | |
217 (eq_attr "timings" "4753") "throughput*47,nothing*6") | |
218 | |
219 ;; Note - the conflict between memory load/store instructions | |
220 ;; and floating point instructions described in section 1-7-4 | |
221 ;; of Chapter 3 of the MN103E Series Instruction Manual is | |
222 ;; handled by the mn10300_adjust_sched_cost function. | |
223 | |
54 ;; ---------------------------------------------------------------------- | 224 ;; ---------------------------------------------------------------------- |
55 ;; MOVE INSTRUCTIONS | 225 ;; MOVE INSTRUCTIONS |
56 ;; ---------------------------------------------------------------------- | 226 ;; ---------------------------------------------------------------------- |
57 | 227 |
58 ;; movqi | 228 ;; movqi |
59 | 229 |
60 (define_expand "movqi" | 230 (define_expand "movqi" |
61 [(set (match_operand:QI 0 "general_operand" "") | 231 [(set (match_operand:QI 0 "nonimmediate_operand") |
62 (match_operand:QI 1 "general_operand" ""))] | 232 (match_operand:QI 1 "general_operand"))] |
63 "" | 233 "" |
64 " | 234 { |
65 { | 235 /* One of the ops has to be in a register. */ |
66 /* One of the ops has to be in a register */ | |
67 if (!register_operand (operand0, QImode) | 236 if (!register_operand (operand0, QImode) |
68 && !register_operand (operand1, QImode)) | 237 && !register_operand (operand1, QImode)) |
69 operands[1] = copy_to_mode_reg (QImode, operand1); | 238 operands[1] = force_reg (QImode, operand1); |
70 }") | 239 }) |
71 | 240 |
72 (define_insn "" | 241 (define_insn "*movqi_internal" |
73 [(set (match_operand:QI 0 "nonimmediate_operand" "=d*x*a*f,d*x,d*x*a,d*x*a,m,*f,d*x*a") | 242 [(set (match_operand:QI 0 "nonimmediate_operand" "=*r,D*r,D*r,D,m") |
74 (match_operand:QI 1 "general_operand" "0,I,d*xai,m,d*xa,d*xa*f,*f"))] | 243 (match_operand:QI 1 "general_operand" " 0,D*r, i,m,D"))] |
75 "TARGET_AM33 | 244 "(register_operand (operands[0], QImode) |
76 && (register_operand (operands[0], QImode) | 245 || register_operand (operands[1], QImode))" |
77 || register_operand (operands[1], QImode))" | |
78 "* | |
79 { | 246 { |
80 switch (which_alternative) | 247 switch (which_alternative) |
81 { | 248 { |
82 case 0: | 249 case 0: |
83 return \"nop\"; | 250 return ""; |
84 case 1: | 251 case 1: |
85 return \"clr %0\"; | |
86 case 2: | 252 case 2: |
87 if (GET_CODE (operands[1]) == CONST_DOUBLE) | 253 return "mov %1,%0"; |
88 { | |
89 rtx xoperands[2]; | |
90 xoperands[0] = operands[0]; | |
91 xoperands[1] = GEN_INT (CONST_DOUBLE_LOW (operands[1])); | |
92 output_asm_insn (\"mov %1,%0\", xoperands); | |
93 return \"\"; | |
94 } | |
95 | |
96 if (REGNO_REG_CLASS (true_regnum (operands[0])) == EXTENDED_REGS | |
97 && GET_CODE (operands[1]) == CONST_INT) | |
98 { | |
99 HOST_WIDE_INT val = INTVAL (operands[1]); | |
100 | |
101 if (((val & 0x80) && ! (val & 0xffffff00)) | |
102 || ((val & 0x800000) && ! (val & 0xff000000))) | |
103 return \"movu %1,%0\"; | |
104 } | |
105 return \"mov %1,%0\"; | |
106 case 3: | 254 case 3: |
107 case 4: | 255 case 4: |
108 return \"movbu %1,%0\"; | 256 return "movbu %1,%0"; |
109 case 5: | |
110 case 6: | |
111 return \"fmov %1,%0\"; | |
112 default: | 257 default: |
113 gcc_unreachable (); | 258 gcc_unreachable (); |
114 } | 259 } |
115 }" | 260 } |
116 [(set_attr "cc" "none,clobber,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit")]) | 261 [(set_attr_alternative "timings" |
117 | 262 [(const_int 11) |
118 (define_insn "" | 263 (const_int 11) |
119 [(set (match_operand:QI 0 "nonimmediate_operand" "=d*a,d,d,!*a,d*a,d,m") | 264 (const_int 11) |
120 (match_operand:QI 1 "general_operand" "0,I,i,i,da,m,d"))] | 265 (if_then_else (eq_attr "cpu" "am34") |
121 "register_operand (operands[0], QImode) | 266 (const_int 13) (const_int 24)) |
122 || register_operand (operands[1], QImode)" | 267 (if_then_else (eq_attr "cpu" "am34") |
123 "* | 268 (const_int 11) (const_int 22)) |
269 ])] | |
270 ) | |
271 | |
272 ;; movhi | |
273 | |
274 (define_expand "movhi" | |
275 [(set (match_operand:HI 0 "nonimmediate_operand") | |
276 (match_operand:HI 1 "general_operand"))] | |
277 "" | |
278 { | |
279 /* One of the ops has to be in a register. */ | |
280 if (!register_operand (operand1, HImode) | |
281 && !register_operand (operand0, HImode)) | |
282 operands[1] = force_reg (HImode, operand1); | |
283 }) | |
284 | |
285 (define_insn "*movhi_internal" | |
286 [(set (match_operand:HI 0 "nonimmediate_operand" "=*r,D*r,D*r,D,m") | |
287 (match_operand:HI 1 "general_operand" " 0, i,D*r,m,D"))] | |
288 "(register_operand (operands[0], HImode) | |
289 || register_operand (operands[1], HImode))" | |
124 { | 290 { |
125 switch (which_alternative) | 291 switch (which_alternative) |
126 { | 292 { |
127 case 0: | 293 case 0: |
128 return \"nop\"; | 294 return ""; |
129 case 1: | 295 case 1: |
130 return \"clr %0\"; | 296 /* Note that "MOV imm8,An" is already zero-extending, and is 2 bytes. |
297 We have "MOV imm16,Dn" at 3 bytes. The only win for the 4 byte | |
298 movu is for an 8-bit unsigned move into Rn. */ | |
299 if (TARGET_AM33 | |
300 && CONST_INT_P (operands[1]) | |
301 && IN_RANGE (INTVAL (operands[1]), 0x80, 0xff) | |
302 && REGNO_EXTENDED_P (REGNO (operands[0]), 1)) | |
303 return "movu %1,%0"; | |
304 /* FALLTHRU */ | |
131 case 2: | 305 case 2: |
306 return "mov %1,%0"; | |
132 case 3: | 307 case 3: |
133 case 4: | 308 case 4: |
134 if (GET_CODE (operands[1]) == CONST_DOUBLE) | 309 return "movhu %1,%0"; |
135 { | |
136 rtx xoperands[2]; | |
137 xoperands[0] = operands[0]; | |
138 xoperands[1] = GEN_INT (CONST_DOUBLE_LOW (operands[1])); | |
139 output_asm_insn (\"mov %1,%0\", xoperands); | |
140 return \"\"; | |
141 } | |
142 | |
143 return \"mov %1,%0\"; | |
144 case 5: | |
145 case 6: | |
146 return \"movbu %1,%0\"; | |
147 default: | 310 default: |
148 gcc_unreachable (); | 311 gcc_unreachable (); |
149 } | 312 } |
150 }" | 313 } |
151 [(set_attr "cc" "none,clobber,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit")]) | 314 [(set_attr_alternative "timings" |
152 | 315 [(const_int 11) |
153 ;; movhi | 316 (const_int 11) |
154 | 317 (if_then_else (eq_attr "cpu" "am34") |
155 (define_expand "movhi" | 318 (const_int 11) (const_int 22)) |
156 [(set (match_operand:HI 0 "general_operand" "") | 319 (if_then_else (eq_attr "cpu" "am34") |
157 (match_operand:HI 1 "general_operand" ""))] | 320 (const_int 13) (const_int 24)) |
158 "" | 321 (if_then_else (eq_attr "cpu" "am34") |
159 " | 322 (const_int 11) (const_int 22)) |
160 { | 323 ])] |
161 /* One of the ops has to be in a register */ | 324 ) |
162 if (!register_operand (operand1, HImode) | |
163 && !register_operand (operand0, HImode)) | |
164 operands[1] = copy_to_mode_reg (HImode, operand1); | |
165 }") | |
166 | |
167 (define_insn "" | |
168 [(set (match_operand:HI 0 "nonimmediate_operand" "=d*x*a*f,d*x,d*x*a,d*x*a,m,*f,d*x*a") | |
169 (match_operand:HI 1 "general_operand" "0,I,d*x*ai,m,d*x*a,d*x*a*f,*f"))] | |
170 "TARGET_AM33 | |
171 && (register_operand (operands[0], HImode) | |
172 || register_operand (operands[1], HImode))" | |
173 "* | |
174 { | |
175 switch (which_alternative) | |
176 { | |
177 case 0: | |
178 return \"nop\"; | |
179 case 1: | |
180 return \"clr %0\"; | |
181 case 2: | |
182 if (GET_CODE (operands[1]) == CONST_DOUBLE) | |
183 { | |
184 rtx xoperands[2]; | |
185 xoperands[0] = operands[0]; | |
186 xoperands[1] = GEN_INT (CONST_DOUBLE_LOW (operands[1])); | |
187 output_asm_insn (\"mov %1,%0\", xoperands); | |
188 return \"\"; | |
189 } | |
190 | |
191 if (REGNO_REG_CLASS (true_regnum (operands[0])) == EXTENDED_REGS | |
192 && GET_CODE (operands[1]) == CONST_INT) | |
193 { | |
194 HOST_WIDE_INT val = INTVAL (operands[1]); | |
195 | |
196 if (((val & 0x80) && ! (val & 0xffffff00)) | |
197 || ((val & 0x800000) && ! (val & 0xff000000))) | |
198 return \"movu %1,%0\"; | |
199 } | |
200 return \"mov %1,%0\"; | |
201 case 3: | |
202 case 4: | |
203 return \"movhu %1,%0\"; | |
204 case 5: | |
205 case 6: | |
206 return \"fmov %1,%0\"; | |
207 default: | |
208 gcc_unreachable (); | |
209 } | |
210 }" | |
211 [(set_attr "cc" "none,clobber,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit")]) | |
212 | |
213 (define_insn "" | |
214 [(set (match_operand:HI 0 "nonimmediate_operand" "=d*a,d,d,!*a,d*a,d,m") | |
215 (match_operand:HI 1 "general_operand" "0,I,i,i,da,m,d"))] | |
216 "register_operand (operands[0], HImode) | |
217 || register_operand (operands[1], HImode)" | |
218 "* | |
219 { | |
220 switch (which_alternative) | |
221 { | |
222 case 0: | |
223 return \"nop\"; | |
224 case 1: | |
225 return \"clr %0\"; | |
226 case 2: | |
227 case 3: | |
228 case 4: | |
229 if (GET_CODE (operands[1]) == CONST_DOUBLE) | |
230 { | |
231 rtx xoperands[2]; | |
232 xoperands[0] = operands[0]; | |
233 xoperands[1] = GEN_INT (CONST_DOUBLE_LOW (operands[1])); | |
234 output_asm_insn (\"mov %1,%0\", xoperands); | |
235 return \"\"; | |
236 } | |
237 return \"mov %1,%0\"; | |
238 case 5: | |
239 case 6: | |
240 return \"movhu %1,%0\"; | |
241 default: | |
242 gcc_unreachable (); | |
243 } | |
244 }" | |
245 [(set_attr "cc" "none,clobber,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit")]) | |
246 | 325 |
247 ;; movsi and helpers | 326 ;; movsi and helpers |
248 | 327 |
249 ;; We use this to handle addition of two values when one operand is the | 328 ;; We use this to handle addition of two values when one operand is the |
250 ;; stack pointer and the other is a memory reference of some kind. Reload | 329 ;; stack pointer and the other is a memory reference of some kind. Reload |
251 ;; does not handle them correctly without this expander. | 330 ;; does not handle them correctly without this expander. |
252 (define_expand "reload_insi" | 331 (define_expand "reload_plus_sp_const" |
253 [(set (match_operand:SI 0 "register_operand" "=a") | 332 [(set (match_operand:SI 0 "register_operand" "=r") |
254 (match_operand:SI 1 "impossible_plus_operand" "")) | 333 (match_operand:SI 1 "impossible_plus_operand" "")) |
255 (clobber (match_operand:SI 2 "register_operand" "=&r"))] | 334 (clobber (match_operand:SI 2 "register_operand" "=&A"))] |
256 "" | 335 "" |
257 " | 336 { |
258 { | 337 rtx dest, scratch, other; |
259 if (XEXP (operands[1], 0) == stack_pointer_rtx) | 338 |
260 { | 339 dest = operands[0]; |
261 if (GET_CODE (XEXP (operands[1], 1)) == SUBREG | 340 scratch = operands[2]; |
262 && (GET_MODE_SIZE (GET_MODE (XEXP (operands[1], 1))) | 341 |
263 > GET_MODE_SIZE (GET_MODE (SUBREG_REG (XEXP (operands[1], 1)))))) | 342 other = XEXP (operands[1], 1); |
264 emit_move_insn (operands[2], | 343 if (other == stack_pointer_rtx) |
265 gen_rtx_ZERO_EXTEND | 344 other = XEXP (operands[1], 0); |
266 (GET_MODE (XEXP (operands[1], 1)), | 345 |
267 SUBREG_REG (XEXP (operands[1], 1)))); | 346 if (true_regnum (other) == true_regnum (dest)) |
347 { | |
348 gcc_assert (true_regnum (scratch) != true_regnum (dest)); | |
349 emit_move_insn (scratch, stack_pointer_rtx); | |
350 emit_insn (gen_addsi3 (dest, dest, scratch)); | |
351 } | |
352 else if (TARGET_AM33 || REGNO_REG_CLASS (true_regnum (dest)) == ADDRESS_REGS) | |
353 { | |
354 emit_move_insn (dest, stack_pointer_rtx); | |
355 if (other == stack_pointer_rtx) | |
356 emit_insn (gen_addsi3 (dest, dest, dest)); | |
357 else if (other != const0_rtx) | |
358 emit_insn (gen_addsi3 (dest, dest, other)); | |
359 } | |
360 else | |
361 { | |
362 emit_move_insn (scratch, stack_pointer_rtx); | |
363 if (other == stack_pointer_rtx) | |
364 { | |
365 emit_move_insn (dest, scratch); | |
366 emit_insn (gen_addsi3 (dest, dest, dest)); | |
367 } | |
368 else if (other != const0_rtx) | |
369 { | |
370 emit_move_insn (dest, other); | |
371 emit_insn (gen_addsi3 (dest, dest, scratch)); | |
372 } | |
268 else | 373 else |
269 emit_move_insn (operands[2], XEXP (operands[1], 1)); | 374 emit_move_insn (dest, scratch); |
270 emit_move_insn (operands[0], XEXP (operands[1], 0)); | 375 } |
271 } | |
272 else | |
273 { | |
274 if (GET_CODE (XEXP (operands[1], 0)) == SUBREG | |
275 && (GET_MODE_SIZE (GET_MODE (XEXP (operands[1], 0))) | |
276 > GET_MODE_SIZE (GET_MODE (SUBREG_REG (XEXP (operands[1], 0)))))) | |
277 emit_move_insn (operands[2], | |
278 gen_rtx_ZERO_EXTEND | |
279 (GET_MODE (XEXP (operands[1], 0)), | |
280 SUBREG_REG (XEXP (operands[1], 0)))); | |
281 else | |
282 emit_move_insn (operands[2], XEXP (operands[1], 0)); | |
283 emit_move_insn (operands[0], XEXP (operands[1], 1)); | |
284 } | |
285 emit_insn (gen_addsi3 (operands[0], operands[0], operands[2])); | |
286 DONE; | 376 DONE; |
287 }") | 377 }) |
288 | |
289 (define_insn "pop_pic_reg" | |
290 [(set (reg:SI PIC_REG) | |
291 (mem:SI (post_inc:SI (reg:SI SP_REG))))] | |
292 "reload_completed" | |
293 "movm (sp),[a2]") | |
294 | 378 |
295 (define_expand "movsi" | 379 (define_expand "movsi" |
296 [(set (match_operand:SI 0 "general_operand" "") | 380 [(set (match_operand:SI 0 "nonimmediate_operand") |
297 (match_operand:SI 1 "general_operand" ""))] | 381 (match_operand:SI 1 "general_operand"))] |
298 "" | 382 "" |
299 " | 383 { |
300 { | 384 /* One of the ops has to be in a register. */ |
301 /* One of the ops has to be in a register */ | |
302 if (!register_operand (operand1, SImode) | 385 if (!register_operand (operand1, SImode) |
303 && !register_operand (operand0, SImode)) | 386 && !register_operand (operand0, SImode)) |
304 operands[1] = copy_to_mode_reg (SImode, operand1); | 387 operands[1] = force_reg (SImode, operand1); |
305 if (flag_pic) | 388 if (flag_pic) |
306 { | 389 { |
307 rtx temp; | 390 rtx temp; |
308 if (SYMBOLIC_CONST_P (operands[1])) | 391 if (SYMBOLIC_CONST_P (operands[1])) |
309 { | 392 { |
310 if (GET_CODE (operands[0]) == MEM) | 393 if (MEM_P (operands[0])) |
311 operands[1] = force_reg (Pmode, operands[1]); | 394 operands[1] = force_reg (Pmode, operands[1]); |
312 else | 395 else |
313 { | 396 { |
314 temp = (!can_create_pseudo_p () | 397 temp = (!can_create_pseudo_p () |
315 ? operands[0] | 398 ? operands[0] |
316 : gen_reg_rtx (Pmode)); | 399 : gen_reg_rtx (Pmode)); |
317 operands[1] = legitimize_pic_address (operands[1], temp); | 400 operands[1] = mn10300_legitimize_pic_address (operands[1], temp); |
318 } | 401 } |
319 } | 402 } |
320 else if (GET_CODE (operands[1]) == CONST | 403 else if (GET_CODE (operands[1]) == CONST |
321 && GET_CODE (XEXP (operands[1], 0)) == PLUS | 404 && GET_CODE (XEXP (operands[1], 0)) == PLUS |
322 && SYMBOLIC_CONST_P (XEXP (XEXP (operands[1], 0), 0))) | 405 && SYMBOLIC_CONST_P (XEXP (XEXP (operands[1], 0), 0))) |
323 { | 406 { |
324 temp = !can_create_pseudo_p () ? operands[0] : gen_reg_rtx (Pmode); | 407 temp = !can_create_pseudo_p () ? operands[0] : gen_reg_rtx (Pmode); |
325 temp = legitimize_pic_address (XEXP (XEXP (operands[1], 0), 0), | 408 temp = mn10300_legitimize_pic_address (XEXP (XEXP (operands[1], 0), 0), |
326 temp); | 409 temp); |
327 operands[1] = expand_binop (SImode, add_optab, temp, | 410 operands[1] = expand_binop (SImode, add_optab, temp, |
328 XEXP (XEXP (operands[1], 0), 1), | 411 XEXP (XEXP (operands[1], 0), 1), |
329 (!can_create_pseudo_p () | 412 (!can_create_pseudo_p () |
330 ? temp | 413 ? temp |
331 : gen_reg_rtx (Pmode)), | 414 : gen_reg_rtx (Pmode)), |
332 0, OPTAB_LIB_WIDEN); | 415 0, OPTAB_LIB_WIDEN); |
333 } | 416 } |
334 } | 417 } |
335 }") | 418 }) |
336 | 419 |
337 (define_insn "" | 420 (define_insn "*movsi_internal" |
338 [(set (match_operand:SI 0 "nonimmediate_operand" | 421 [(set (match_operand:SI 0 "nonimmediate_operand" |
339 "=dx,ax,dx,a,dxm,dxm,axm,axm,dx,dx,ax,ax,axR,!*y,*f,*f,dxaQ") | 422 "=r,r,r,r,m,r, A,*y,*y,*z,*d") |
340 (match_operand:SI 1 "general_operand" | 423 (match_operand:SI 1 "general_operand" |
341 "0,0,I,I,dx,ax,dx,ax,dixm,aixm,dixm,aixm,!*y,axR,0,dxaQi*f,*f"))] | 424 " 0,O,i,r,r,m,*y, A, i,*d,*z"))] |
342 "register_operand (operands[0], SImode) | 425 "register_operand (operands[0], SImode) |
343 || register_operand (operands[1], SImode)" | 426 || register_operand (operands[1], SImode)" |
344 "* | |
345 { | 427 { |
346 switch (which_alternative) | 428 switch (which_alternative) |
347 { | 429 { |
348 case 0: | 430 case 0: |
431 return ""; | |
432 case 1: /* imm-reg. */ | |
433 case 2: | |
434 /* See movhi for a discussion of sizes for 8-bit movu. Note that the | |
435 24-bit movu is 6 bytes, which is the same size as the full 32-bit | |
436 mov form for An and Dn. So again movu is only a win for Rn. */ | |
437 if (TARGET_AM33 | |
438 && CONST_INT_P (operands[1]) | |
439 && REGNO_EXTENDED_P (REGNO (operands[0]), 1)) | |
440 { | |
441 HOST_WIDE_INT val = INTVAL (operands[1]); | |
442 if (IN_RANGE (val, 0x80, 0xff) | |
443 || IN_RANGE (val, 0x800000, 0xffffff)) | |
444 return "movu %1,%0"; | |
445 } | |
446 /* FALLTHRU */ | |
447 case 3: /* reg-reg */ | |
448 case 4: /* reg-mem */ | |
449 case 5: /* mem-reg */ | |
450 case 6: /* sp-reg */ | |
451 case 7: /* reg-sp */ | |
452 case 8: /* imm-sp */ | |
453 case 9: /* reg-mdr */ | |
454 case 10: /* mdr-reg */ | |
455 return "mov %1,%0"; | |
456 default: | |
457 gcc_unreachable (); | |
458 } | |
459 } | |
460 [(set_attr "isa" "*,*,*,*,*,*,*,*,am33,*,*") | |
461 (set_attr "liw" "*,either,*,either,*,*,*,*,*,*,*") | |
462 (set_attr "liw_op" "mov") | |
463 (set_attr_alternative "timings" | |
464 [(const_int 11) | |
465 (const_int 22) | |
466 (const_int 22) | |
467 (const_int 11) | |
468 (if_then_else (eq_attr "cpu" "am34") | |
469 (const_int 11) (const_int 22)) | |
470 (if_then_else (eq_attr "cpu" "am34") | |
471 (const_int 13) (const_int 24)) | |
472 (if_then_else (eq_attr "cpu" "am34") | |
473 (const_int 11) (const_int 22)) | |
474 (if_then_else (eq_attr "cpu" "am34") | |
475 (const_int 13) (const_int 24)) | |
476 (const_int 11) | |
477 (const_int 11) | |
478 (const_int 11) | |
479 ])] | |
480 ) | |
481 | |
482 (define_expand "movsf" | |
483 [(set (match_operand:SF 0 "nonimmediate_operand") | |
484 (match_operand:SF 1 "general_operand"))] | |
485 "TARGET_AM33_2" | |
486 { | |
487 /* One of the ops has to be in a register. */ | |
488 if (!register_operand (operand1, SFmode) | |
489 && !register_operand (operand0, SFmode)) | |
490 operands[1] = force_reg (SFmode, operand1); | |
491 }) | |
492 | |
493 (define_insn "*movsf_internal" | |
494 [(set (match_operand:SF 0 "nonimmediate_operand" "=rf,r,f,r,f,r,f,r,m,f,Q") | |
495 (match_operand:SF 1 "general_operand" " 0,F,F,r,f,f,r,m,r,Q,f"))] | |
496 "TARGET_AM33_2 | |
497 && (register_operand (operands[0], SFmode) | |
498 || register_operand (operands[1], SFmode))" | |
499 { | |
500 switch (which_alternative) | |
501 { | |
502 case 0: | |
503 return ""; | |
349 case 1: | 504 case 1: |
350 return \"nop\"; | 505 case 3: |
506 case 7: | |
507 case 8: | |
508 return "mov %1,%0"; | |
351 case 2: | 509 case 2: |
352 return \"clr %0\"; | |
353 case 3: | |
354 case 4: | 510 case 4: |
355 case 5: | 511 case 5: |
356 case 6: | 512 case 6: |
357 case 7: | |
358 case 8: | |
359 case 9: | 513 case 9: |
360 case 10: | 514 case 10: |
361 case 11: | 515 return "fmov %1,%0"; |
362 case 12: | |
363 case 13: | |
364 if (GET_CODE (operands[1]) == CONST_DOUBLE) | |
365 { | |
366 rtx xoperands[2]; | |
367 xoperands[0] = operands[0]; | |
368 xoperands[1] = GEN_INT (CONST_DOUBLE_LOW (operands[1])); | |
369 output_asm_insn (\"mov %1,%0\", xoperands); | |
370 return \"\"; | |
371 } | |
372 | |
373 if (REGNO_REG_CLASS (true_regnum (operands[0])) == EXTENDED_REGS | |
374 && GET_CODE (operands[1]) == CONST_INT) | |
375 { | |
376 HOST_WIDE_INT val = INTVAL (operands[1]); | |
377 | |
378 if (((val & 0x80) && ! (val & 0xffffff00)) | |
379 || ((val & 0x800000) && ! (val & 0xff000000))) | |
380 return \"movu %1,%0\"; | |
381 } | |
382 return \"mov %1,%0\"; | |
383 case 14: | |
384 return \"nop\"; | |
385 case 15: | |
386 case 16: | |
387 return \"fmov %1,%0\"; | |
388 default: | 516 default: |
389 gcc_unreachable (); | 517 gcc_unreachable (); |
390 } | 518 } |
391 }" | 519 } |
392 [(set_attr "cc" "none,none,clobber,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none,none_0hit,none_0hit")]) | 520 [(set_attr_alternative "timings" |
393 | 521 [(const_int 11) |
394 (define_expand "movsf" | 522 (const_int 22) |
395 [(set (match_operand:SF 0 "general_operand" "") | 523 (if_then_else (eq_attr "cpu" "am34") |
396 (match_operand:SF 1 "general_operand" ""))] | 524 (const_int 47) (const_int 25)) |
397 "" | 525 (const_int 11) |
398 " | 526 (if_then_else (eq_attr "cpu" "am34") |
399 { | 527 (const_int 13) (const_int 14)) |
400 /* One of the ops has to be in a register */ | 528 (if_then_else (eq_attr "cpu" "am34") |
401 if (!register_operand (operand1, SFmode) | 529 (const_int 13) (const_int 12)) |
402 && !register_operand (operand0, SFmode)) | 530 (if_then_else (eq_attr "cpu" "am34") |
403 operands[1] = copy_to_mode_reg (SFmode, operand1); | 531 (const_int 13) (const_int 14)) |
404 }") | 532 (if_then_else (eq_attr "cpu" "am34") |
405 | 533 (const_int 13) (const_int 24)) |
406 (define_insn "" | 534 (if_then_else (eq_attr "cpu" "am34") |
407 [(set (match_operand:SF 0 "nonimmediate_operand" "=f,dx,ax,dx,a,f,dxaQ,daxm,dax") | 535 (const_int 13) (const_int 24)) |
408 (match_operand:SF 1 "general_operand" "0,0,0,G,G,fdxaQF,f,dax,daxFm"))] | 536 (if_then_else (eq_attr "cpu" "am34") |
409 "register_operand (operands[0], SFmode) | 537 (const_int 13) (const_int 24)) |
410 || register_operand (operands[1], SFmode)" | 538 (if_then_else (eq_attr "cpu" "am34") |
411 "* | 539 (const_int 13) (const_int 24)) |
412 { | 540 ])] |
413 switch (which_alternative) | 541 ) |
414 { | 542 |
415 case 0: | 543 ;; If the flags register is not live, generate CLR instead of MOV 0. |
416 case 1: | 544 ;; For MN103, this is only legal for DATA_REGS; for AM33 this is legal |
417 case 2: | 545 ;; but not a win for ADDRESS_REGS. |
418 return \"nop\"; | 546 (define_peephole2 |
419 case 3: | 547 [(set (match_operand:INT 0 "register_operand" "") (const_int 0))] |
420 return \"clr %0\"; | 548 "peep2_regno_dead_p (0, CC_REG) |
421 /* case 4: below */ | 549 && (REGNO_DATA_P (REGNO (operands[0]), 1) |
422 case 5: | 550 || REGNO_EXTENDED_P (REGNO (operands[0]), 1))" |
423 case 6: | 551 [(parallel [(set (match_dup 0) (const_int 0)) |
424 return \"fmov %1, %0\"; | 552 (clobber (reg:CC CC_REG))])] |
425 case 4: | 553 ) |
426 case 7: | 554 |
427 case 8: | 555 (define_insn "*mov<mode>_clr" |
428 if (REGNO_REG_CLASS (true_regnum (operands[0])) == EXTENDED_REGS | 556 [(set (match_operand:INT 0 "register_operand" "=D") |
429 && GET_CODE (operands[1]) == CONST_INT) | 557 (const_int 0)) |
558 (clobber (reg:CC CC_REG))] | |
559 "" | |
560 "clr %0" | |
561 ) | |
562 | |
563 ;; ---------------------------------------------------------------------- | |
564 ;; ADD INSTRUCTIONS | |
565 ;; ---------------------------------------------------------------------- | |
566 | |
567 (define_insn "addsi3" | |
568 [(set (match_operand:SI 0 "register_operand" "=r,r,r,!*y,!r") | |
569 (plus:SI (match_operand:SI 1 "register_operand" "%0,0,0, 0, r") | |
570 (match_operand:SI 2 "nonmemory_operand" "r,O,i, i, r"))) | |
571 (clobber (reg:CC CC_REG))] | |
572 "" | |
573 { return mn10300_output_add (operands, false); } | |
574 [(set_attr "timings" "11,11,11,11,22") | |
575 (set_attr "liw" "either,either,*,*,*") | |
576 (set_attr "liw_op" "add")] | |
577 ) | |
578 | |
579 ;; Note that ADD IMM,SP does not set the flags, so omit that here. | |
580 (define_insn "*addsi3_flags" | |
581 [(set (match_operand:SI 0 "register_operand" "=r,!r") | |
582 (plus:SI (match_operand:SI 1 "register_operand" "%0, r") | |
583 (match_operand:SI 2 "nonmemory_operand" "ri, r"))) | |
584 (set (reg CC_REG) | |
585 (compare (plus:SI (match_dup 1) (match_dup 2)) | |
586 (const_int 0)))] | |
587 "reload_completed && mn10300_match_ccmode (insn, CCZNCmode)" | |
588 { return mn10300_output_add (operands, true); } | |
589 [(set_attr "timings" "11,22")] | |
590 ) | |
591 | |
592 ;; A helper to expand the above, with the CC_MODE filled in. | |
593 (define_expand "addsi3_flags" | |
594 [(parallel [(set (match_operand:SI 0 "register_operand") | |
595 (plus:SI (match_operand:SI 1 "register_operand") | |
596 (match_operand:SI 2 "nonmemory_operand"))) | |
597 (set (reg:CCZNC CC_REG) | |
598 (compare:CCZNC (plus:SI (match_dup 1) (match_dup 2)) | |
599 (const_int 0)))])] | |
600 "" | |
601 ) | |
602 | |
603 (define_insn "addc_internal" | |
604 [(set (match_operand:SI 0 "register_operand" "=D,r,r") | |
605 (plus:SI | |
606 (plus:SI | |
607 (ltu:SI (reg:CC CC_REG) (const_int 0)) | |
608 (match_operand:SI 1 "register_operand" "%0,0,r")) | |
609 (match_operand:SI 2 "reg_or_am33_const_operand" " D,i,r"))) | |
610 (clobber (reg:CC CC_REG))] | |
611 "reload_completed" | |
612 "@ | |
613 addc %2,%0 | |
614 addc %2,%0 | |
615 addc %2,%1,%0" | |
616 [(set_attr "isa" "*,am33,am33")] | |
617 ) | |
618 | |
619 (define_expand "adddi3" | |
620 [(set (match_operand:DI 0 "register_operand" "") | |
621 (plus:DI (match_operand:DI 1 "register_operand" "") | |
622 (match_operand:DI 2 "nonmemory_operand" "")))] | |
623 "" | |
624 { | |
625 rtx op0l, op0h, op1l, op1h, op2l, op2h; | |
626 | |
627 op0l = gen_lowpart (SImode, operands[0]); | |
628 op1l = gen_lowpart (SImode, operands[1]); | |
629 op2l = gen_lowpart (SImode, operands[2]); | |
630 op0h = gen_highpart (SImode, operands[0]); | |
631 op1h = gen_highpart (SImode, operands[1]); | |
632 op2h = gen_highpart_mode (SImode, DImode, operands[2]); | |
633 | |
634 if (!reg_or_am33_const_operand (op2h, SImode)) | |
635 op2h = force_reg (SImode, op2h); | |
636 | |
637 emit_insn (gen_adddi3_internal (op0l, op0h, op1l, op2l, op1h, op2h)); | |
638 DONE; | |
639 }) | |
640 | |
641 ;; Note that reload only supports one commutative operand. Thus we cannot | |
642 ;; auto-swap both the high and low outputs with their matching constraints. | |
643 ;; For MN103, we're strapped for registers but thankfully the alternatives | |
644 ;; are few. For AM33, it becomes much easier to not represent the early | |
645 ;; clobber and 6 permutations of immediate and three-operand adds, but | |
646 ;; instead allocate a scratch register and do the expansion by hand. | |
647 | |
648 (define_insn_and_split "adddi3_internal" | |
649 [(set (match_operand:SI 0 "register_operand" "=r, r, r") | |
650 (plus:SI (match_operand:SI 2 "register_operand" "%0, 0, r") | |
651 (match_operand:SI 3 "nonmemory_operand" "ri,ri,ri"))) | |
652 (set (match_operand:SI 1 "register_operand" "=D, D, r") | |
653 (plus:SI | |
654 (plus:SI | |
655 (ltu:SI (plus:SI (match_dup 2) (match_dup 3)) (match_dup 2)) | |
656 (match_operand:SI 4 "register_operand" " 1, D, r")) | |
657 (match_operand:SI 5 "reg_or_am33_const_operand" " D, 1,ri"))) | |
658 (clobber (match_scratch:SI 6 "=X, X,&r")) | |
659 (clobber (reg:CC CC_REG))] | |
660 "" | |
661 "#" | |
662 "reload_completed" | |
663 [(const_int 0)] | |
664 { | |
665 rtx op0l = operands[0]; | |
666 rtx op0h = operands[1]; | |
667 rtx op1l = operands[2]; | |
668 rtx op2l = operands[3]; | |
669 rtx op1h = operands[4]; | |
670 rtx op2h = operands[5]; | |
671 rtx scratch = operands[6]; | |
672 rtx x; | |
673 | |
674 if (reg_overlap_mentioned_p (op0l, op1h)) | |
675 { | |
676 emit_move_insn (scratch, op0l); | |
677 op1h = scratch; | |
678 if (reg_overlap_mentioned_p (op0l, op2h)) | |
679 op2h = scratch; | |
680 } | |
681 else if (reg_overlap_mentioned_p (op0l, op2h)) | |
682 { | |
683 emit_move_insn (scratch, op0l); | |
684 op2h = scratch; | |
685 } | |
686 | |
687 if (rtx_equal_p (op0l, op1l)) | |
688 ; | |
689 else if (rtx_equal_p (op0l, op2l)) | |
690 x = op1l, op1l = op2l, op2l = x; | |
691 else | |
692 { | |
693 gcc_assert (TARGET_AM33); | |
694 if (!REG_P (op2l)) | |
430 { | 695 { |
431 HOST_WIDE_INT val = INTVAL (operands[1]); | 696 emit_move_insn (op0l, op2l); |
432 | 697 op2l = op1l; |
433 if (((val & 0x80) && ! (val & 0xffffff00)) | 698 op1l = op0l; |
434 || ((val & 0x800000) && ! (val & 0xff000000))) | |
435 return \"movu %1,%0\"; | |
436 } | 699 } |
437 return \"mov %1,%0\"; | 700 } |
438 default: | 701 emit_insn (gen_addsi3_flags (op0l, op1l, op2l)); |
439 gcc_unreachable (); | 702 |
440 } | 703 if (rtx_equal_p (op0h, op1h)) |
441 }" | 704 ; |
442 [(set_attr "cc" "none,none,none,clobber,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit")]) | 705 else if (rtx_equal_p (op0h, op2h)) |
443 | 706 x = op1h, op1h = op2h, op2h = x; |
444 (define_expand "movdi" | 707 else |
445 [(set (match_operand:DI 0 "general_operand" "") | 708 { |
446 (match_operand:DI 1 "general_operand" ""))] | 709 gcc_assert (TARGET_AM33); |
447 "" | 710 if (!REG_P (op2h)) |
448 " | 711 { |
449 { | 712 emit_move_insn (op0h, op2h); |
450 /* One of the ops has to be in a register */ | 713 op2h = op1h; |
451 if (!register_operand (operand1, DImode) | 714 op1h = op0h; |
452 && !register_operand (operand0, DImode)) | 715 } |
453 operands[1] = copy_to_mode_reg (DImode, operand1); | 716 } |
454 }") | 717 emit_insn (gen_addc_internal (op0h, op1h, op2h)); |
455 | 718 DONE; |
456 (define_insn "" | 719 } |
457 [(set (match_operand:DI 0 "nonimmediate_operand" | 720 [(set_attr "isa" "*,*,am33")] |
458 "=dx,ax,dx,a,dxm,dxm,axm,axm,dx,dx,ax,ax,*f,*f,*f,dxa,*f,Q") | 721 ) |
459 (match_operand:DI 1 "general_operand" | 722 |
460 "0,0,I,I,dx,ax,dx,ax,dxim,axim,dxim,axim,0,*f,dxai,*f,Q,*f"))] | 723 ;; The following pattern is generated by combine when it proves that one |
461 "register_operand (operands[0], DImode) | 724 ;; of the inputs to the low-part of the double-word add is zero, and thus |
462 || register_operand (operands[1], DImode)" | 725 ;; no carry is generated into the high-part. |
463 "* | 726 |
464 { | 727 (define_insn_and_split "*adddi3_degenerate" |
465 long val[2]; | 728 [(set (match_operand:SI 0 "register_operand" "=&r,&r") |
466 REAL_VALUE_TYPE rv; | 729 (match_operand:SI 2 "nonmemory_operand" " 0, 0")) |
467 | 730 (set (match_operand:SI 1 "register_operand" "=r , r") |
468 switch (which_alternative) | 731 (plus:SI (match_operand:SI 3 "register_operand" "%1 , r") |
469 { | 732 (match_operand:SI 4 "nonmemory_operand" "ri, r"))) |
470 case 0: | 733 (clobber (reg:CC CC_REG))] |
471 case 1: | 734 "" |
472 return \"nop\"; | 735 "#" |
473 | 736 "" |
474 case 2: | 737 [(const_int 0)] |
475 return \"clr %L0\;clr %H0\"; | 738 { |
476 | 739 rtx scratch = NULL_RTX; |
477 case 3: | 740 if (!rtx_equal_p (operands[0], operands[2])) |
478 if (rtx_equal_p (operands[0], operands[1])) | 741 { |
479 return \"sub %L1,%L0\;mov %L0,%H0\"; | 742 gcc_assert (!reg_overlap_mentioned_p (operands[0], operands[1])); |
480 else | 743 if (reg_overlap_mentioned_p (operands[0], operands[3]) |
481 return \"mov %1,%L0\;mov %L0,%H0\"; | 744 || reg_overlap_mentioned_p (operands[0], operands[4])) |
482 case 4: | 745 { |
483 case 5: | 746 scratch = gen_reg_rtx (SImode); |
484 case 6: | 747 emit_move_insn (scratch, operands[2]); |
485 case 7: | 748 } |
486 case 8: | 749 else |
487 case 9: | 750 emit_move_insn (operands[0], operands[2]); |
488 case 10: | 751 } |
489 case 11: | 752 emit_insn (gen_addsi3 (operands[1], operands[3], operands[4])); |
490 if (GET_CODE (operands[1]) == CONST_INT) | 753 if (scratch) |
491 { | 754 emit_move_insn (operands[0], scratch); |
492 rtx low, high; | 755 DONE; |
493 split_double (operands[1], &low, &high); | 756 }) |
494 val[0] = INTVAL (low); | 757 |
495 val[1] = INTVAL (high); | 758 ;; ---------------------------------------------------------------------- |
496 } | 759 ;; SUBTRACT INSTRUCTIONS |
497 if (GET_CODE (operands[1]) == CONST_DOUBLE) | 760 ;; ---------------------------------------------------------------------- |
498 { | 761 |
499 if (GET_MODE (operands[1]) == DFmode) | 762 (define_insn "subsi3" |
500 { | 763 [(set (match_operand:SI 0 "register_operand" "=r,r,r,r") |
501 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]); | 764 (minus:SI (match_operand:SI 1 "register_operand" "0,0,0,r") |
502 REAL_VALUE_TO_TARGET_DOUBLE (rv, val); | 765 (match_operand:SI 2 "nonmemory_operand" "r,O,i,r"))) |
503 } | 766 (clobber (reg:CC CC_REG))] |
504 else if (GET_MODE (operands[1]) == VOIDmode | 767 "" |
505 || GET_MODE (operands[1]) == DImode) | 768 "@ |
506 { | 769 sub %2,%0 |
507 val[0] = CONST_DOUBLE_LOW (operands[1]); | 770 sub %2,%0 |
508 val[1] = CONST_DOUBLE_HIGH (operands[1]); | 771 sub %2,%0 |
509 } | 772 sub %2,%1,%0" |
510 } | 773 [(set_attr "isa" "*,*,*,am33") |
511 | 774 (set_attr "liw" "either,either,*,*") |
512 if (GET_CODE (operands[1]) == MEM | 775 (set_attr "liw_op" "sub") |
513 && reg_overlap_mentioned_p (operands[0], XEXP (operands[1], 0))) | 776 (set_attr "timings" "11,11,11,22")] |
514 { | 777 ) |
515 rtx temp = operands[0]; | 778 |
516 | 779 (define_insn "*subsi3_flags" |
517 while (GET_CODE (temp) == SUBREG) | 780 [(set (match_operand:SI 0 "register_operand" "=r, r") |
518 temp = SUBREG_REG (temp); | 781 (minus:SI (match_operand:SI 1 "register_operand" "0, r") |
519 | 782 (match_operand:SI 2 "nonmemory_operand" "ri,r"))) |
520 gcc_assert (GET_CODE (temp) == REG); | 783 (set (reg CC_REG) |
521 | 784 (compare (minus:SI (match_dup 1) (match_dup 2)) |
522 if (reg_overlap_mentioned_p (gen_rtx_REG (SImode, REGNO (temp)), | 785 (const_int 0)))] |
523 XEXP (operands[1], 0))) | 786 "reload_completed && mn10300_match_ccmode (insn, CCZNCmode)" |
524 return \"mov %H1,%H0\;mov %L1,%L0\"; | 787 "@ |
525 else | 788 sub %2,%0 |
526 return \"mov %L1,%L0\;mov %H1,%H0\"; | 789 sub %2,%1,%0" |
527 | 790 [(set_attr "isa" "*,am33") |
528 } | 791 (set_attr "timings" "11,22")] |
529 else if (GET_CODE (operands[1]) == MEM | 792 ) |
530 && CONSTANT_ADDRESS_P (XEXP (operands[1], 0)) | 793 |
531 && REGNO_REG_CLASS (REGNO (operands[0])) == ADDRESS_REGS) | 794 ;; A helper to expand the above, with the CC_MODE filled in. |
532 { | 795 (define_expand "subsi3_flags" |
533 rtx xoperands[2]; | 796 [(parallel [(set (match_operand:SI 0 "register_operand") |
534 | 797 (minus:SI (match_operand:SI 1 "register_operand") |
535 xoperands[0] = operands[0]; | 798 (match_operand:SI 2 "nonmemory_operand"))) |
536 xoperands[1] = XEXP (operands[1], 0); | 799 (set (reg:CCZNC CC_REG) |
537 | 800 (compare:CCZNC (minus:SI (match_dup 1) (match_dup 2)) |
538 output_asm_insn (\"mov %1,%L0\;mov (4,%L0),%H0\;mov (%L0),%L0\", | 801 (const_int 0)))])] |
539 xoperands); | 802 "" |
540 return \"\"; | 803 ) |
541 } | 804 |
542 else | 805 (define_insn "subc_internal" |
543 { | 806 [(set (match_operand:SI 0 "register_operand" "=D,r,r") |
544 if ((GET_CODE (operands[1]) == CONST_INT | 807 (minus:SI |
545 || GET_CODE (operands[1]) == CONST_DOUBLE) | 808 (minus:SI (match_operand:SI 1 "register_operand" " 0,0,r") |
546 && val[0] == 0) | 809 (match_operand:SI 2 "reg_or_am33_const_operand" " D,i,r")) |
547 { | 810 (geu:SI (reg:CC CC_REG) (const_int 0)))) |
548 if (REGNO_REG_CLASS (REGNO (operands[0])) == DATA_REGS) | 811 (clobber (reg:CC CC_REG))] |
549 output_asm_insn (\"clr %L0\", operands); | 812 "reload_completed" |
550 else | 813 "@ |
551 output_asm_insn (\"mov %L1,%L0\", operands); | 814 subc %2,%0 |
552 } | 815 subc %2,%0 |
553 else if ((GET_CODE (operands[1]) == CONST_INT | 816 subc %2,%1,%0" |
554 || GET_CODE (operands[1]) == CONST_DOUBLE) | 817 [(set_attr "isa" "*,am33,am33")] |
555 && (REGNO_REG_CLASS (true_regnum (operands[0])) | 818 ) |
556 == EXTENDED_REGS) | 819 |
557 && (((val[0] & 0x80) && ! (val[0] & 0xffffff00)) | 820 (define_expand "subdi3" |
558 || ((val[0] & 0x800000) && ! (val[0] & 0xff000000)))) | 821 [(set (match_operand:DI 0 "register_operand" "") |
559 output_asm_insn (\"movu %L1,%L0\", operands); | 822 (minus:DI (match_operand:DI 1 "register_operand" "") |
560 else | 823 (match_operand:DI 2 "nonmemory_operand" "")))] |
561 output_asm_insn (\"mov %L1,%L0\", operands); | 824 "" |
562 | 825 { |
563 if ((GET_CODE (operands[1]) == CONST_INT | 826 rtx op0l, op0h, op1l, op1h, op2l, op2h; |
564 || GET_CODE (operands[1]) == CONST_DOUBLE) | 827 |
565 && val[1] == 0) | 828 op0l = gen_lowpart (SImode, operands[0]); |
566 { | 829 op1l = gen_lowpart (SImode, operands[1]); |
567 if (REGNO_REG_CLASS (REGNO (operands[0])) == DATA_REGS) | 830 op2l = gen_lowpart (SImode, operands[2]); |
568 output_asm_insn (\"clr %H0\", operands); | 831 op0h = gen_highpart (SImode, operands[0]); |
569 else | 832 op1h = gen_highpart (SImode, operands[1]); |
570 output_asm_insn (\"mov %H1,%H0\", operands); | 833 op2h = gen_highpart_mode (SImode, DImode, operands[2]); |
571 } | 834 |
572 else if ((GET_CODE (operands[1]) == CONST_INT | 835 if (!reg_or_am33_const_operand (op2h, SImode)) |
573 || GET_CODE (operands[1]) == CONST_DOUBLE) | 836 op2h = force_reg (SImode, op2h); |
574 && val[0] == val[1]) | 837 |
575 output_asm_insn (\"mov %L0,%H0\", operands); | 838 emit_insn (gen_subdi3_internal (op0l, op0h, op1l, op1h, op2l, op2h)); |
576 else if ((GET_CODE (operands[1]) == CONST_INT | 839 DONE; |
577 || GET_CODE (operands[1]) == CONST_DOUBLE) | 840 }) |
578 && (REGNO_REG_CLASS (true_regnum (operands[0])) | 841 |
579 == EXTENDED_REGS) | 842 ;; As with adddi3, the use of the scratch register helps reduce the |
580 && (((val[1] & 0x80) && ! (val[1] & 0xffffff00)) | 843 ;; number of permutations for AM33. |
581 || ((val[1] & 0x800000) && ! (val[1] & 0xff000000)))) | 844 ;; ??? The early clobber on op0 avoids a reload bug wherein both output |
582 output_asm_insn (\"movu %H1,%H0\", operands); | 845 ;; registers are set the same. Consider negate, where both op2 and op3 |
583 else | 846 ;; are 0, are csed to the same input register, and reload fails to undo |
584 output_asm_insn (\"mov %H1,%H0\", operands); | 847 ;; the cse when satisfying the matching constraints. |
585 return \"\"; | 848 |
586 } | 849 (define_insn_and_split "subdi3_internal" |
587 case 12: | 850 [(set (match_operand:SI 0 "register_operand" "=&r, r") |
588 return \"nop\"; | 851 (minus:SI |
589 case 13: | 852 (match_operand:SI 2 "register_operand" " 0, r") |
590 case 14: | 853 (match_operand:SI 4 "nonmemory_operand" " ri,ri"))) |
591 case 15: | 854 (set (match_operand:SI 1 "register_operand" "=D , r") |
592 return \"fmov %L1, %L0\;fmov %H1, %H0\"; | 855 (minus:SI |
593 case 16: | 856 (minus:SI |
594 if (GET_CODE (operands[1]) == MEM | 857 (match_operand:SI 3 "register_operand" " 1, r") |
595 && GET_CODE (XEXP (operands[1], 0)) == CONST_INT | 858 (match_operand:SI 5 "reg_or_am33_const_operand" " D,ri")) |
596 && (INTVAL (XEXP (operands[1], 0)) & 7) == 0) | 859 (ltu:SI (match_dup 2) (match_dup 4)))) |
597 return \"fmov %D1, %D0\"; | 860 (clobber (match_scratch:SI 6 "=X ,&r")) |
598 else | 861 (clobber (reg:CC CC_REG))] |
599 return \"fmov %L1, %L0\;fmov %H1, %H0\"; | 862 "" |
600 case 17: | 863 "#" |
601 if (GET_CODE (operands[0]) == MEM | 864 "reload_completed" |
602 && GET_CODE (XEXP (operands[0], 0)) == CONST_INT | 865 [(const_int 0)] |
603 && (INTVAL (XEXP (operands[0], 0)) & 7) == 0) | 866 { |
604 return \"fmov %D1, %D0\"; | 867 rtx op0l = operands[0]; |
605 else | 868 rtx op0h = operands[1]; |
606 return \"fmov %L1, %L0\;fmov %H1, %H0\"; | 869 rtx op1l = operands[2]; |
607 default: | 870 rtx op1h = operands[3]; |
608 gcc_unreachable (); | 871 rtx op2l = operands[4]; |
609 } | 872 rtx op2h = operands[5]; |
610 }" | 873 rtx scratch = operands[6]; |
611 [(set (attr "cc") | 874 |
612 (cond | 875 if (reg_overlap_mentioned_p (op0l, op1h)) |
613 [ | 876 { |
614 (ior (lt (symbol_ref "which_alternative") (const_int 2)) | 877 emit_move_insn (scratch, op0l); |
615 (eq (symbol_ref "which_alternative") (const_int 12)) | 878 op1h = scratch; |
616 ) (const_string "none") | 879 if (reg_overlap_mentioned_p (op0l, op2h)) |
617 (eq (symbol_ref "which_alternative") (const_int 2) | 880 op2h = scratch; |
618 ) (const_string "clobber") | 881 } |
619 (eq (symbol_ref "which_alternative") (const_int 3) | 882 else if (reg_overlap_mentioned_p (op0l, op2h)) |
620 ) (if_then_else | 883 { |
621 (ne (symbol_ref "rtx_equal_p (operands[0], operands[1])") | 884 emit_move_insn (scratch, op0l); |
622 (const_int 0)) (const_string "clobber") | 885 op2h = scratch; |
623 (const_string "none_0hit")) | 886 } |
624 (ior (eq (symbol_ref "which_alternative") (const_int 8)) | 887 |
625 (eq (symbol_ref "which_alternative") (const_int 9)) | 888 if (!rtx_equal_p (op0l, op1l)) |
626 ) (if_then_else | 889 { |
627 (ne (symbol_ref "mn10300_wide_const_load_uses_clr | 890 gcc_assert (TARGET_AM33); |
628 (operands)") | 891 if (!REG_P (op2l)) |
629 (const_int 0)) (const_string "clobber") | 892 { |
630 (const_string "none_0hit")) | 893 emit_move_insn (op0l, op1l); |
631 ] (const_string "none_0hit")))]) | 894 op1l = op0l; |
632 | 895 } |
633 (define_expand "movdf" | 896 } |
634 [(set (match_operand:DF 0 "general_operand" "") | 897 emit_insn (gen_subsi3_flags (op0l, op1l, op2l)); |
635 (match_operand:DF 1 "general_operand" ""))] | 898 |
636 "" | 899 if (!rtx_equal_p (op0h, op1h)) |
637 " | 900 { |
638 { | 901 gcc_assert (TARGET_AM33); |
639 /* One of the ops has to be in a register */ | 902 if (!REG_P (op2h)) |
640 if (!register_operand (operand1, DFmode) | 903 { |
641 && !register_operand (operand0, DFmode)) | 904 emit_move_insn (op0h, op1h); |
642 operands[1] = copy_to_mode_reg (DFmode, operand1); | 905 op1h = op0h; |
643 }") | 906 } |
644 | 907 } |
645 (define_insn "" | 908 emit_insn (gen_subc_internal (op0h, op1h, op2h)); |
646 [(set (match_operand:DF 0 "nonimmediate_operand" | 909 DONE; |
647 "=f,dx,ax,dx,f,f,dxa,f,Q,a,dxm,dxm,axm,axm,dx,dx,ax,ax") | 910 } |
648 (match_operand:DF 1 "general_operand" | 911 [(set_attr "isa" "*,am33")] |
649 "0,0,0,G,f,dxaF,f,Q,f,G,dx,ax,dx,ax,dxFm,axFm,dxFm,axFm"))] | 912 ) |
650 "register_operand (operands[0], DFmode) | 913 |
651 || register_operand (operands[1], DFmode)" | 914 ;; The following pattern is generated by combine when it proves that one |
652 "* | 915 ;; of the inputs to the low-part of the double-word sub is zero, and thus |
653 { | 916 ;; no carry is generated into the high-part. |
654 long val[2]; | 917 |
655 REAL_VALUE_TYPE rv; | 918 (define_insn_and_split "*subdi3_degenerate" |
656 | 919 [(set (match_operand:SI 0 "register_operand" "=&r,&r") |
657 switch (which_alternative) | 920 (match_operand:SI 2 "nonmemory_operand" " 0, 0")) |
658 { | 921 (set (match_operand:SI 1 "register_operand" "=r , r") |
659 case 0: | 922 (minus:SI (match_operand:SI 3 "register_operand" " 1, r") |
660 case 1: | 923 (match_operand:SI 4 "nonmemory_operand" " ri, r"))) |
661 case 2: | 924 (clobber (reg:CC CC_REG))] |
662 return \"nop\"; | 925 "" |
663 | 926 "#" |
664 case 3: | 927 "" |
665 return \"clr %L0\;clr %H0\"; | 928 [(const_int 0)] |
666 | 929 { |
667 case 4: | 930 rtx scratch = NULL_RTX; |
668 case 5: | 931 if (!rtx_equal_p (operands[0], operands[2])) |
669 case 6: | 932 { |
670 return \"fmov %L1, %L0\;fmov %H1, %H0\"; | 933 gcc_assert (!reg_overlap_mentioned_p (operands[0], operands[1])); |
671 | 934 if (reg_overlap_mentioned_p (operands[0], operands[3]) |
672 case 7: | 935 || reg_overlap_mentioned_p (operands[0], operands[4])) |
673 if (GET_CODE (operands[1]) == MEM | 936 { |
674 && GET_CODE (XEXP (operands[1], 0)) == CONST_INT | 937 scratch = gen_reg_rtx (SImode); |
675 && (INTVAL (XEXP (operands[1], 0)) & 7) == 0) | 938 emit_move_insn (scratch, operands[2]); |
676 return \"fmov %D1, %D0\"; | 939 } |
677 else | 940 else |
678 return \"fmov %L1, %L0\;fmov %H1, %H0\"; | 941 emit_move_insn (operands[0], operands[2]); |
679 | 942 } |
680 case 8: | 943 emit_insn (gen_subsi3 (operands[1], operands[3], operands[4])); |
681 if (GET_CODE (operands[0]) == MEM | 944 if (scratch) |
682 && GET_CODE (XEXP (operands[0], 0)) == CONST_INT | 945 emit_move_insn (operands[0], scratch); |
683 && (INTVAL (XEXP (operands[0], 0)) & 7) == 0) | 946 DONE; |
684 return \"fmov %D1, %D0\"; | 947 }) |
685 else | 948 |
686 return \"fmov %L1, %L0\;fmov %H1, %H0\"; | 949 (define_insn_and_split "negsi2" |
687 | 950 [(set (match_operand:SI 0 "register_operand" "=D,&r") |
688 case 9: | 951 (neg:SI (match_operand:SI 1 "register_operand" " 0, r"))) |
689 if (rtx_equal_p (operands[0], operands[1])) | 952 (clobber (reg:CC CC_REG))] |
690 return \"sub %L1,%L0\;mov %L0,%H0\"; | 953 "" |
691 else | 954 "#" |
692 return \"mov %1,%L0\;mov %L0,%H0\"; | 955 "&& reload_completed" |
693 case 10: | 956 [(const_int 0)] |
694 case 11: | 957 { |
695 case 12: | 958 /* Recall that twos-compliment is ones-compliment plus one. When |
696 case 13: | 959 allocated in DATA_REGS this is 2+1 bytes; otherwise (for am33) |
697 case 14: | 960 this is 3+3 bytes. |
698 case 15: | 961 |
699 case 16: | 962 For AM33, it would have been possible to load zero and use the |
700 case 17: | 963 three-address subtract to have a total size of 3+4*N bytes for |
701 if (GET_CODE (operands[1]) == CONST_INT) | 964 multiple negations, plus increased throughput. Not attempted here. */ |
702 { | 965 |
703 rtx low, high; | 966 if (true_regnum (operands[0]) == true_regnum (operands[1])) |
704 split_double (operands[1], &low, &high); | 967 { |
705 val[0] = INTVAL (low); | 968 emit_insn (gen_one_cmplsi2 (operands[0], operands[0])); |
706 val[1] = INTVAL (high); | 969 emit_insn (gen_addsi3 (operands[0], operands[0], const1_rtx)); |
707 } | 970 } |
708 if (GET_CODE (operands[1]) == CONST_DOUBLE) | 971 else |
709 { | 972 { |
710 if (GET_MODE (operands[1]) == DFmode) | 973 emit_move_insn (operands[0], const0_rtx); |
711 { | 974 emit_insn (gen_subsi3 (operands[0], operands[0], operands[1])); |
712 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]); | 975 } |
713 REAL_VALUE_TO_TARGET_DOUBLE (rv, val); | 976 DONE; |
714 } | 977 }) |
715 else if (GET_MODE (operands[1]) == VOIDmode | 978 |
716 || GET_MODE (operands[1]) == DImode) | 979 ;; ---------------------------------------------------------------------- |
717 { | 980 ;; MULTIPLY INSTRUCTIONS |
718 val[0] = CONST_DOUBLE_LOW (operands[1]); | 981 ;; ---------------------------------------------------------------------- |
719 val[1] = CONST_DOUBLE_HIGH (operands[1]); | 982 |
720 } | 983 ;; ??? Note that AM33 has a third multiply variant that puts the high part |
721 } | 984 ;; into the MDRQ register, however this variant also constrains the inputs |
722 | 985 ;; to be in DATA_REGS and thus isn't as helpful as it might be considering |
723 if (GET_CODE (operands[1]) == MEM | 986 ;; the existance of the 4-operand multiply. Nor is there a set of divide |
724 && reg_overlap_mentioned_p (operands[0], XEXP (operands[1], 0))) | 987 ;; insns that use MDRQ. Given that there is an IMM->MDRQ insn, this would |
725 { | 988 ;; have been very handy for starting udivmodsi4... |
726 rtx temp = operands[0]; | 989 |
727 | 990 (define_expand "mulsidi3" |
728 while (GET_CODE (temp) == SUBREG) | 991 [(set (match_operand:DI 0 "register_operand" "") |
729 temp = SUBREG_REG (temp); | 992 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "")) |
730 | 993 (sign_extend:DI (match_operand:SI 2 "register_operand" ""))))] |
731 gcc_assert (GET_CODE (temp) == REG); | 994 "" |
732 | 995 { |
733 if (reg_overlap_mentioned_p (gen_rtx_REG (SImode, REGNO (temp)), | 996 emit_insn (gen_mulsidi3_internal (gen_lowpart (SImode, operands[0]), |
734 XEXP (operands[1], 0))) | 997 gen_highpart (SImode, operands[0]), |
735 return \"mov %H1,%H0\;mov %L1,%L0\"; | 998 operands[1], operands[2])); |
736 else | 999 DONE; |
737 return \"mov %L1,%L0\;mov %H1,%H0\"; | 1000 }) |
738 | 1001 |
739 } | 1002 (define_insn "mulsidi3_internal" |
740 else if (GET_CODE (operands[1]) == MEM | 1003 [(set (match_operand:SI 0 "register_operand" "=D,r") |
741 && CONSTANT_ADDRESS_P (XEXP (operands[1], 0)) | 1004 (mult:SI (match_operand:SI 2 "register_operand" "%0,r") |
742 && REGNO_REG_CLASS (REGNO (operands[0])) == ADDRESS_REGS) | 1005 (match_operand:SI 3 "register_operand" " D,r"))) |
743 { | 1006 (set (match_operand:SI 1 "register_operand" "=z,r") |
744 rtx xoperands[2]; | 1007 (truncate:SI |
745 | 1008 (ashiftrt:DI |
746 xoperands[0] = operands[0]; | 1009 (mult:DI (sign_extend:DI (match_dup 2)) |
747 xoperands[1] = XEXP (operands[1], 0); | 1010 (sign_extend:DI (match_dup 3))) |
748 | 1011 (const_int 32)))) |
749 output_asm_insn (\"mov %1,%L0\;mov (4,%L0),%H0\;mov (%L0),%L0\", | 1012 (clobber (reg:CC CC_REG))] |
750 xoperands); | 1013 "" |
751 return \"\"; | 1014 { |
752 } | 1015 if (which_alternative == 1) |
753 else | 1016 return "mul %2,%3,%1,%0"; |
754 { | 1017 else if (TARGET_MULT_BUG) |
755 if ((GET_CODE (operands[1]) == CONST_INT | 1018 return "nop\;nop\;mul %3,%0"; |
756 || GET_CODE (operands[1]) == CONST_DOUBLE) | 1019 else |
757 && val[0] == 0) | 1020 return "mul %3,%0"; |
758 { | 1021 } |
759 if (REGNO_REG_CLASS (REGNO (operands[0])) == DATA_REGS) | 1022 [(set_attr "isa" "*,am33") |
760 output_asm_insn (\"clr %L0\", operands); | 1023 (set (attr "timings") |
761 else | 1024 (if_then_else (eq_attr "cpu" "am34") (const_int 24) (const_int 23)))] |
762 output_asm_insn (\"mov %L1,%L0\", operands); | 1025 ) |
763 } | 1026 |
764 else if ((GET_CODE (operands[1]) == CONST_INT | 1027 (define_expand "umulsidi3" |
765 || GET_CODE (operands[1]) == CONST_DOUBLE) | 1028 [(set (match_operand:DI 0 "register_operand" "") |
766 && (REGNO_REG_CLASS (true_regnum (operands[0])) | 1029 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "")) |
767 == EXTENDED_REGS) | 1030 (zero_extend:DI (match_operand:SI 2 "register_operand" "")))) |
768 && (((val[0] & 0x80) && ! (val[0] & 0xffffff00)) | 1031 (clobber (reg:CC CC_REG))] |
769 || ((val[0] & 0x800000) && ! (val[0] & 0xff000000)))) | 1032 "" |
770 output_asm_insn (\"movu %L1,%L0\", operands); | 1033 { |
771 else | 1034 emit_insn (gen_umulsidi3_internal (gen_lowpart (SImode, operands[0]), |
772 output_asm_insn (\"mov %L1,%L0\", operands); | 1035 gen_highpart (SImode, operands[0]), |
773 | 1036 operands[1], operands[2])); |
774 if ((GET_CODE (operands[1]) == CONST_INT | 1037 DONE; |
775 || GET_CODE (operands[1]) == CONST_DOUBLE) | 1038 }) |
776 && val[1] == 0) | 1039 |
777 { | 1040 (define_insn "umulsidi3_internal" |
778 if (REGNO_REG_CLASS (REGNO (operands[0])) == DATA_REGS) | 1041 [(set (match_operand:SI 0 "register_operand" "=D,r") |
779 output_asm_insn (\"clr %H0\", operands); | 1042 (mult:SI (match_operand:SI 2 "register_operand" "%0,r") |
780 else | 1043 (match_operand:SI 3 "register_operand" " D,r"))) |
781 output_asm_insn (\"mov %H1,%H0\", operands); | 1044 (set (match_operand:SI 1 "register_operand" "=z,r") |
782 } | 1045 (truncate:SI |
783 else if ((GET_CODE (operands[1]) == CONST_INT | 1046 (lshiftrt:DI |
784 || GET_CODE (operands[1]) == CONST_DOUBLE) | 1047 (mult:DI (zero_extend:DI (match_dup 2)) |
785 && val[0] == val[1]) | 1048 (zero_extend:DI (match_dup 3))) |
786 output_asm_insn (\"mov %L0,%H0\", operands); | 1049 (const_int 32)))) |
787 else if ((GET_CODE (operands[1]) == CONST_INT | 1050 (clobber (reg:CC CC_REG))] |
788 || GET_CODE (operands[1]) == CONST_DOUBLE) | 1051 "" |
789 && (REGNO_REG_CLASS (true_regnum (operands[0])) | 1052 { |
790 == EXTENDED_REGS) | 1053 if (which_alternative == 1) |
791 && (((val[1] & 0x80) && ! (val[1] & 0xffffff00)) | 1054 return "mulu %2,%3,%1,%0"; |
792 || ((val[1] & 0x800000) && ! (val[1] & 0xff000000)))) | 1055 else if (TARGET_MULT_BUG) |
793 output_asm_insn (\"movu %H1,%H0\", operands); | 1056 return "nop\;nop\;mulu %3,%0"; |
794 else | 1057 else |
795 output_asm_insn (\"mov %H1,%H0\", operands); | 1058 return "mulu %3,%0"; |
796 return \"\"; | 1059 } |
797 } | 1060 [(set_attr "isa" "*,am33") |
798 default: | 1061 (set (attr "timings") |
799 gcc_unreachable (); | 1062 (if_then_else (eq_attr "cpu" "am34") (const_int 24) (const_int 23)))] |
800 } | 1063 ) |
801 }" | 1064 |
802 [(set (attr "cc") | 1065 (define_expand "mulsi3" |
803 (cond | 1066 [(parallel [(set (match_operand:SI 0 "register_operand") |
804 [ | 1067 (mult:SI (match_operand:SI 1 "register_operand") |
805 (lt (symbol_ref "which_alternative") (const_int 3) | 1068 (match_operand:SI 2 "reg_or_am33_const_operand"))) |
806 ) (const_string "none") | 1069 (clobber (match_scratch:SI 3)) |
807 (eq (symbol_ref "which_alternative") (const_int 3) | 1070 (clobber (reg:CC CC_REG))])] |
808 ) (const_string "clobber") | 1071 "" |
809 (eq (symbol_ref "which_alternative") (const_int 9) | 1072 ) |
810 ) (if_then_else | 1073 |
811 (ne (symbol_ref "rtx_equal_p (operands[0], operands[1])") | 1074 (define_insn "*mulsi3" |
812 (const_int 0)) (const_string "clobber") | 1075 [(set (match_operand:SI 0 "register_operand" "=D, r,r") |
813 (const_string "none_0hit")) | 1076 (mult:SI (match_operand:SI 2 "register_operand" "%0, 0,r") |
814 (ior (eq (symbol_ref "which_alternative") (const_int 14)) | 1077 (match_operand:SI 3 "reg_or_am33_const_operand" " D,ri,r"))) |
815 (eq (symbol_ref "which_alternative") (const_int 15)) | 1078 (clobber (match_scratch:SI 1 "=z, z,r")) |
816 ) (if_then_else | 1079 (clobber (reg:CC CC_REG))] |
817 (ne (symbol_ref "mn10300_wide_const_load_uses_clr | 1080 "" |
818 (operands)") | 1081 { |
819 (const_int 0)) (const_string "clobber") | 1082 if (which_alternative == 2) |
820 (const_string "none_0hit")) | 1083 return "mul %2,%3,%1,%0"; |
821 ] (const_string "none_0hit")))]) | 1084 else if (TARGET_MULT_BUG) |
822 | 1085 return "nop\;nop\;mul %3,%0"; |
1086 else | |
1087 return "mul %3,%0"; | |
1088 } | |
1089 [(set_attr "isa" "*,am33,am33") | |
1090 (set (attr "timings") | |
1091 (if_then_else (eq_attr "cpu" "am34") (const_int 24) (const_int 23)))] | |
1092 ) | |
1093 | |
1094 (define_expand "udivmodsi4" | |
1095 [(parallel [(set (match_operand:SI 0 "register_operand") | |
1096 (udiv:SI (match_operand:SI 1 "register_operand") | |
1097 (match_operand:SI 2 "register_operand"))) | |
1098 (set (match_operand:SI 3 "register_operand") | |
1099 (umod:SI (match_dup 1) (match_dup 2))) | |
1100 (use (const_int 0)) | |
1101 (clobber (reg:CC CC_REG))])] | |
1102 "" | |
1103 ) | |
1104 | |
1105 ;; Note the trick to get reload to put the zero into the MDR register, | |
1106 ;; rather than exposing the load early and letting CSE or someone try | |
1107 ;; to share the zeros between division insns. Which tends to result | |
1108 ;; in sequences like 0->r0->d0->mdr. | |
1109 | |
1110 (define_insn "*udivmodsi4" | |
1111 [(set (match_operand:SI 0 "register_operand" "=D") | |
1112 (udiv:SI (match_operand:SI 2 "register_operand" " 0") | |
1113 (match_operand:SI 3 "register_operand" " D"))) | |
1114 (set (match_operand:SI 1 "register_operand" "=z") | |
1115 (umod:SI (match_dup 2) (match_dup 3))) | |
1116 (use (match_operand:SI 4 "nonmemory_operand" " 1")) | |
1117 (clobber (reg:CC CC_REG))] | |
1118 "" | |
1119 "divu %3,%0" | |
1120 [(set (attr "timings") (if_then_else (eq_attr "cpu" "am34") | |
1121 (const_int 3839) (const_int 4243)))] | |
1122 ) | |
1123 | |
1124 (define_expand "divmodsi4" | |
1125 [(parallel [(set (match_operand:SI 0 "register_operand" "") | |
1126 (div:SI (match_operand:SI 1 "register_operand" "") | |
1127 (match_operand:SI 2 "register_operand" ""))) | |
1128 (set (match_operand:SI 3 "register_operand" "") | |
1129 (mod:SI (match_dup 1) (match_dup 2))) | |
1130 (use (match_dup 4)) | |
1131 (clobber (reg:CC CC_REG))])] | |
1132 "" | |
1133 { | |
1134 operands[4] = gen_reg_rtx (SImode); | |
1135 emit_insn (gen_ext_internal (operands[4], operands[1])); | |
1136 }) | |
1137 | |
1138 ;; ??? Ideally we'd represent this via shift, but it seems like adding a | |
1139 ;; special-case pattern for (ashiftrt x 31) is just as likely to result | |
1140 ;; in poor register allocation choices. | |
1141 (define_insn "ext_internal" | |
1142 [(set (match_operand:SI 0 "register_operand" "=z") | |
1143 (unspec:SI [(match_operand:SI 1 "register_operand" "D")] UNSPEC_EXT))] | |
1144 "" | |
1145 "ext %1" | |
1146 ) | |
1147 | |
1148 (define_insn "*divmodsi4" | |
1149 [(set (match_operand:SI 0 "register_operand" "=D") | |
1150 (div:SI (match_operand:SI 2 "register_operand" " 0") | |
1151 (match_operand:SI 3 "register_operand" " D"))) | |
1152 (set (match_operand:SI 1 "register_operand" "=z") | |
1153 (mod:SI (match_dup 2) (match_dup 3))) | |
1154 (use (match_operand:SI 4 "register_operand" " 1")) | |
1155 (clobber (reg:CC CC_REG))] | |
1156 "" | |
1157 "div %3,%0"; | |
1158 [(set (attr "timings") (if_then_else (eq_attr "cpu" "am34") | |
1159 (const_int 3839) (const_int 4243)))] | |
1160 ) | |
823 | 1161 |
824 | 1162 |
825 ;; ---------------------------------------------------------------------- | 1163 ;; ---------------------------------------------------------------------- |
826 ;; TEST INSTRUCTIONS | 1164 ;; AND INSTRUCTIONS |
827 ;; ---------------------------------------------------------------------- | 1165 ;; ---------------------------------------------------------------------- |
828 | 1166 |
829 (define_insn "*tst_extqisi_am33" | 1167 (define_insn "andsi3" |
830 [(set (cc0) (compare | 1168 [(set (match_operand:SI 0 "register_operand" "=D,D,r") |
831 (zero_extend:SI (match_operand:QI 0 "memory_operand" "dx,!a")) | 1169 (and:SI (match_operand:SI 1 "register_operand" "%0,0,r") |
832 (const_int 0)))] | 1170 (match_operand:SI 2 "nonmemory_operand" " i,D,r"))) |
833 "TARGET_AM33" | 1171 (clobber (reg:CC CC_REG))] |
834 "* return output_tst (operands[0], insn);" | 1172 "" |
835 [(set_attr "cc" "set_znv")]) | 1173 "@ |
836 | 1174 and %2,%0 |
837 (define_insn "*tst_extqisi" | 1175 and %2,%0 |
838 [(set (cc0) (compare | 1176 and %2,%1,%0" |
839 (zero_extend:SI (match_operand:QI 0 "memory_operand" "dx")) | 1177 [(set_attr "isa" "*,*,am33") |
840 (const_int 0)))] | 1178 (set_attr "liw" "*,op1,*") |
841 "" | 1179 (set_attr "liw_op" "and") |
842 "* return output_tst (operands[0], insn);" | 1180 (set_attr "timings" "22,11,11")] |
843 [(set_attr "cc" "set_znv")]) | 1181 ) |
844 | 1182 |
845 (define_insn "*tst_exthisi_am33" | 1183 (define_insn "*andsi3_flags" |
846 [(set (cc0) (compare | 1184 [(set (match_operand:SI 0 "register_operand" "=D,D,r") |
847 (zero_extend:SI (match_operand:HI 0 "memory_operand" "dx,!a")) | 1185 (and:SI (match_operand:SI 1 "register_operand" "%0,0,r") |
848 (const_int 0)))] | 1186 (match_operand:SI 2 "nonmemory_operand" " i,D,r"))) |
849 "TARGET_AM33" | 1187 (set (reg CC_REG) |
850 "* return output_tst (operands[0], insn);" | 1188 (compare (and:SI (match_dup 1) (match_dup 2)) |
851 [(set_attr "cc" "set_znv")]) | 1189 (const_int 0)))] |
852 | 1190 "reload_completed && mn10300_match_ccmode (insn, CCZNmode)" |
853 (define_insn "*tst_exthisi" | 1191 "@ |
854 [(set (cc0) (compare | 1192 and %2,%0 |
855 (zero_extend:SI (match_operand:HI 0 "memory_operand" "dx")) | 1193 and %2,%0 |
856 (const_int 0)))] | 1194 and %2,%1,%0" |
857 "" | 1195 [(set_attr "isa" "*,*,am33") |
858 "* return output_tst (operands[0], insn);" | 1196 (set_attr "timings" "22,11,11")] |
859 [(set_attr "cc" "set_znv")]) | 1197 ) |
860 | 1198 |
861 ;; Ordinarily, the cmp instruction will set the Z bit of cc0 to 1 if | 1199 ;; Make sure we generate extensions instead of ANDs. |
862 ;; its operands hold equal values, but the operands of a cmp | 1200 |
863 ;; instruction must be distinct registers. In the case where we'd | 1201 (define_split |
864 ;; like to compare a register to itself, we can achieve this effect | 1202 [(parallel [(set (match_operand:SI 0 "register_operand" "") |
865 ;; with a btst 0,d0 instead. (This will not alter the contents of d0 | 1203 (and:SI (match_operand:SI 1 "register_operand" "") |
866 ;; but will have the proper effect on cc0. Using d0 is arbitrary; any | 1204 (const_int 255))) |
867 ;; data register would work.) | 1205 (clobber (reg:CC CC_REG))])] |
868 | 1206 "" |
869 ;; Even though the first alternative would be preferable if it can | 1207 [(set (match_dup 0) (zero_extend:SI (match_dup 1)))] |
870 ;; possibly match, reload must not be given the opportunity to attempt | 1208 { operands[1] = gen_lowpart (QImode, operands[1]); } |
871 ;; to use it. It assumes that such matches can only occur when one of | 1209 ) |
872 ;; the operands is used for input and the other for output. Since | 1210 |
873 ;; this is not the case, it abort()s. Indeed, such a reload cannot be | 1211 (define_split |
874 ;; possibly satisfied, so just mark the alternative with a `!', so | 1212 [(parallel [(set (match_operand:SI 0 "register_operand" "") |
875 ;; that it is not considered by reload. | 1213 (and:SI (match_operand:SI 1 "register_operand" "") |
1214 (const_int 65535))) | |
1215 (clobber (reg:CC CC_REG))])] | |
1216 "" | |
1217 [(set (match_dup 0) (zero_extend:SI (match_dup 1)))] | |
1218 { operands[1] = gen_lowpart (HImode, operands[1]); } | |
1219 ) | |
1220 | |
1221 ;; Split AND by an appropriate constant into two shifts. Recall that | |
1222 ;; operations with a full 32-bit immediate require an extra cycle, so | |
1223 ;; this is a size optimization with no speed penalty. This only applies | |
1224 ;; do DATA_REGS; the shift insns that AM33 adds are too large for a win. | |
1225 | |
1226 (define_split | |
1227 [(parallel [(set (match_operand:SI 0 "register_operand" "") | |
1228 (and:SI (match_dup 0) | |
1229 (match_operand:SI 1 "const_int_operand" ""))) | |
1230 (clobber (reg:CC CC_REG))])] | |
1231 "reload_completed | |
1232 && REGNO_DATA_P (true_regnum (operands[0]), 1) | |
1233 && mn10300_split_and_operand_count (operands[1]) != 0" | |
1234 [(const_int 0)] | |
1235 { | |
1236 int count = mn10300_split_and_operand_count (operands[1]); | |
1237 if (count > 0) | |
1238 { | |
1239 emit_insn (gen_lshrsi3 (operands[0], operands[0], GEN_INT (count))); | |
1240 emit_insn (gen_ashlsi3 (operands[0], operands[0], GEN_INT (count))); | |
1241 } | |
1242 else | |
1243 { | |
1244 emit_insn (gen_ashlsi3 (operands[0], operands[0], GEN_INT (-count))); | |
1245 emit_insn (gen_lshrsi3 (operands[0], operands[0], GEN_INT (-count))); | |
1246 } | |
1247 DONE; | |
1248 }) | |
1249 | |
1250 ;; ---------------------------------------------------------------------- | |
1251 ;; OR INSTRUCTIONS | |
1252 ;; ---------------------------------------------------------------------- | |
1253 | |
1254 (define_insn "iorsi3" | |
1255 [(set (match_operand:SI 0 "register_operand" "=D,D,r") | |
1256 (ior:SI (match_operand:SI 1 "register_operand" "%0,0,r") | |
1257 (match_operand:SI 2 "nonmemory_operand" " i,D,r"))) | |
1258 (clobber (reg:CC CC_REG))] | |
1259 "" | |
1260 "@ | |
1261 or %2,%0 | |
1262 or %2,%0 | |
1263 or %2,%1,%0" | |
1264 [(set_attr "isa" "*,*,am33") | |
1265 (set_attr "liw" "*,op1,*") | |
1266 (set_attr "liw_op" "or") | |
1267 (set_attr "timings" "22,11,11")] | |
1268 ) | |
1269 | |
1270 (define_insn "*iorsi3_flags" | |
1271 [(set (match_operand:SI 0 "register_operand" "=D,D,r") | |
1272 (ior:SI (match_operand:SI 1 "register_operand" "%0,0,r") | |
1273 (match_operand:SI 2 "nonmemory_operand" " i,D,r"))) | |
1274 (set (reg CC_REG) | |
1275 (compare (ior:SI (match_dup 1) (match_dup 2)) | |
1276 (const_int 0)))] | |
1277 "reload_completed && mn10300_match_ccmode (insn, CCZNmode)" | |
1278 "@ | |
1279 or %2,%0 | |
1280 or %2,%0 | |
1281 or %2,%1,%0" | |
1282 [(set_attr "isa" "*,*,am33") | |
1283 (set_attr "timings" "22,11,11")] | |
1284 ) | |
1285 | |
1286 ;; ---------------------------------------------------------------------- | |
1287 ;; XOR INSTRUCTIONS | |
1288 ;; ---------------------------------------------------------------------- | |
1289 | |
1290 (define_insn "xorsi3" | |
1291 [(set (match_operand:SI 0 "register_operand" "=D,D,r") | |
1292 (xor:SI (match_operand:SI 1 "register_operand" "%0,0,r") | |
1293 (match_operand:SI 2 "nonmemory_operand" " i,D,r"))) | |
1294 (clobber (reg:CC CC_REG))] | |
1295 "" | |
1296 "@ | |
1297 xor %2,%0 | |
1298 xor %2,%0 | |
1299 xor %2,%1,%0" | |
1300 [(set_attr "isa" "*,*,am33") | |
1301 (set_attr "liw" "*,op1,*") | |
1302 (set_attr "liw_op" "xor") | |
1303 (set_attr "timings" "22,11,11")] | |
1304 ) | |
1305 | |
1306 (define_insn "*xorsi3_flags" | |
1307 [(set (match_operand:SI 0 "register_operand" "=D,D,r") | |
1308 (xor:SI (match_operand:SI 1 "register_operand" "%0,0,r") | |
1309 (match_operand:SI 2 "nonmemory_operand" " i,D,r"))) | |
1310 (set (reg CC_REG) | |
1311 (compare (xor:SI (match_dup 1) (match_dup 2)) | |
1312 (const_int 0)))] | |
1313 "reload_completed && mn10300_match_ccmode (insn, CCZNmode)" | |
1314 "@ | |
1315 xor %2,%0 | |
1316 xor %2,%0 | |
1317 xor %2,%1,%0" | |
1318 [(set_attr "isa" "*,*,am33") | |
1319 (set_attr "timings" "22,11,11")] | |
1320 ) | |
1321 | |
1322 ;; ---------------------------------------------------------------------- | |
1323 ;; NOT INSTRUCTIONS | |
1324 ;; ---------------------------------------------------------------------- | |
1325 | |
1326 (define_insn "one_cmplsi2" | |
1327 [(set (match_operand:SI 0 "register_operand" "=D") | |
1328 (not:SI (match_operand:SI 1 "register_operand" " 0"))) | |
1329 (clobber (reg:CC CC_REG))] | |
1330 "" | |
1331 "not %0" | |
1332 ) | |
1333 | |
1334 (define_insn "*one_cmplsi2_flags" | |
1335 [(set (match_operand:SI 0 "register_operand" "=D") | |
1336 (not:SI (match_operand:SI 1 "register_operand" " 0"))) | |
1337 (set (reg CC_REG) | |
1338 (compare (not:SI (match_dup 1)) | |
1339 (const_int 0)))] | |
1340 "reload_completed && mn10300_match_ccmode (insn, CCZNmode)" | |
1341 "not %0" | |
1342 ) | |
1343 | |
1344 ;; ---------------------------------------------------------------------- | |
1345 ;; COMPARE AND BRANCH INSTRUCTIONS | |
1346 ;; ---------------------------------------------------------------------- | |
1347 | |
1348 ;; We expand the comparison into a single insn so that it will not be split | |
1349 ;; up by reload. | |
1350 (define_expand "cbranchsi4" | |
1351 [(set (pc) | |
1352 (if_then_else | |
1353 (match_operator 0 "ordered_comparison_operator" | |
1354 [(match_operand:SI 1 "register_operand") | |
1355 (match_operand:SI 2 "nonmemory_operand")]) | |
1356 (label_ref (match_operand 3 "")) | |
1357 (pc)))] | |
1358 "" | |
1359 "" | |
1360 ) | |
1361 | |
1362 (define_insn_and_split "*cbranchsi4_cmp" | |
1363 [(set (pc) | |
1364 (if_then_else (match_operator 3 "ordered_comparison_operator" | |
1365 [(match_operand:SI 0 "register_operand" "r") | |
1366 (match_operand:SI 1 "nonmemory_operand" "ri")]) | |
1367 (match_operand 2 "label_ref_operand" "") | |
1368 (pc)))] | |
1369 "" | |
1370 "#" | |
1371 "reload_completed" | |
1372 [(const_int 0)] | |
1373 { | |
1374 mn10300_split_cbranch (CCmode, operands[3], operands[2]); | |
1375 DONE; | |
1376 }) | |
876 | 1377 |
877 (define_insn "*cmpsi" | 1378 (define_insn "*cmpsi" |
878 [(set (cc0) | 1379 [(set (reg CC_REG) |
879 (compare (match_operand:SI 0 "register_operand" "!*d*a*x,dax,dax") | 1380 (compare (match_operand:SI 0 "register_operand" "r,r,r") |
880 (match_operand:SI 1 "nonmemory_operand" "*0,I,daxi")))] | 1381 (match_operand:SI 1 "nonmemory_operand" "r,O,i")))] |
881 "" | 1382 "reload_completed" |
882 "* | 1383 { |
883 { | 1384 /* The operands of CMP must be distinct registers. In the case where |
884 if (which_alternative == 0) | 1385 we've failed to optimize the comparison of a register to itself, we |
885 return \"btst 0,d0\"; | 1386 must use another method to set the Z flag. We can achieve this |
886 if (which_alternative == 1) | 1387 effect with a BTST 0,D0. This will not alter the contents of D0; |
887 return output_tst (operands[0], insn); | 1388 the use of d0 is arbitrary; any data register would work. */ |
888 return \"cmp %1,%0\"; | 1389 if (rtx_equal_p (operands[0], operands[1])) |
889 }" | 1390 return "btst 0,d0"; |
890 [(set_attr "cc" "compare,set_znv,compare")]) | 1391 else |
891 | 1392 return "cmp %1,%0"; |
892 (define_insn "*cmpsf" | 1393 } |
893 [(set (cc0) | 1394 [(set_attr_alternative "timings" |
894 (compare (match_operand:SF 0 "register_operand" "f,f") | 1395 [(if_then_else (eq_attr "cpu" "am34") (const_int 11) (const_int 22)) |
895 (match_operand:SF 1 "nonmemory_operand" "f,F")))] | 1396 (if_then_else (eq_attr "cpu" "am34") (const_int 11) (const_int 22)) |
1397 (if_then_else (eq_attr "cpu" "am34") (const_int 11) (const_int 22))]) | |
1398 (set_attr "liw" "either,either,*") | |
1399 (set_attr "liw_op" "cmp")] | |
1400 ) | |
1401 | |
1402 (define_insn "*integer_conditional_branch" | |
1403 [(set (pc) | |
1404 (if_then_else (match_operator 0 "comparison_operator" | |
1405 [(match_operand 2 "int_mode_flags" "") | |
1406 (const_int 0)]) | |
1407 (label_ref (match_operand 1 "" "")) | |
1408 (pc)))] | |
1409 "reload_completed" | |
1410 "b%b0 %1" | |
1411 ) | |
1412 | |
1413 (define_insn_and_split "*cbranchsi4_btst" | |
1414 [(set (pc) | |
1415 (if_then_else | |
1416 (match_operator 3 "CCZN_comparison_operator" | |
1417 [(and:SI (match_operand:SI 0 "register_operand" "D") | |
1418 (match_operand:SI 1 "immediate_operand" "i")) | |
1419 (const_int 0)]) | |
1420 (match_operand 2 "label_ref_operand" "") | |
1421 (pc)))] | |
1422 "" | |
1423 "#" | |
1424 "reload_completed" | |
1425 [(const_int 0)] | |
1426 { | |
1427 mn10300_split_cbranch (CCZNmode, operands[3], operands[2]); | |
1428 DONE; | |
1429 }) | |
1430 | |
1431 (define_insn "*btstsi" | |
1432 [(set (reg:CCZN CC_REG) | |
1433 (compare:CCZN | |
1434 (and:SI (match_operand:SI 0 "register_operand" "D") | |
1435 (match_operand:SI 1 "immediate_operand" "i")) | |
1436 (const_int 0)))] | |
1437 "reload_completed" | |
1438 "btst %1,%0" | |
1439 ) | |
1440 | |
1441 (define_expand "cbranchsf4" | |
1442 [(set (pc) | |
1443 (if_then_else | |
1444 (match_operator 0 "ordered_comparison_operator" | |
1445 [(match_operand:SF 1 "register_operand") | |
1446 (match_operand:SF 2 "nonmemory_operand")]) | |
1447 (label_ref (match_operand 3 "")) | |
1448 (pc)))] | |
896 "TARGET_AM33_2" | 1449 "TARGET_AM33_2" |
897 "fcmp %1,%0" | 1450 "" |
898 [(set_attr "cc" "compare,compare")]) | 1451 ) |
899 | 1452 |
900 ;; ---------------------------------------------------------------------- | 1453 (define_insn_and_split "*cbranchsf4_cmp" |
901 ;; ADD INSTRUCTIONS | 1454 [(set (pc) |
902 ;; ---------------------------------------------------------------------- | 1455 (if_then_else (match_operator 3 "ordered_comparison_operator" |
903 | 1456 [(match_operand:SF 0 "register_operand" "f") |
904 (define_expand "addsi3" | 1457 (match_operand:SF 1 "nonmemory_operand" "fF")]) |
905 [(set (match_operand:SI 0 "register_operand" "") | 1458 (match_operand 2 "label_ref_operand" "") |
906 (plus:SI (match_operand:SI 1 "register_operand" "") | 1459 (pc))) |
907 (match_operand:SI 2 "nonmemory_operand" "")))] | 1460 ] |
908 "" | 1461 "TARGET_AM33_2" |
909 "") | 1462 "#" |
910 | 1463 "&& reload_completed" |
911 (define_insn "" | 1464 [(const_int 0)] |
912 [(set (match_operand:SI 0 "register_operand" "=dx,a,x,a,dax,!*y,!dax") | 1465 { |
913 (plus:SI (match_operand:SI 1 "register_operand" "%0,0,0,0,0,0,dax") | 1466 mn10300_split_cbranch (CC_FLOATmode, operands[3], operands[2]); |
914 (match_operand:SI 2 "nonmemory_operand" "J,J,L,L,daxi,i,dax")))] | |
915 "TARGET_AM33" | |
916 "* | |
917 { | |
918 switch (which_alternative) | |
919 { | |
920 case 0: | |
921 case 1: | |
922 return \"inc %0\"; | |
923 case 2: | |
924 case 3: | |
925 return \"inc4 %0\"; | |
926 case 4: | |
927 case 5: | |
928 return \"add %2,%0\"; | |
929 case 6: | |
930 { | |
931 enum reg_class src1_class, src2_class, dst_class; | |
932 | |
933 src1_class = REGNO_REG_CLASS (true_regnum (operands[1])); | |
934 src2_class = REGNO_REG_CLASS (true_regnum (operands[2])); | |
935 dst_class = REGNO_REG_CLASS (true_regnum (operands[0])); | |
936 | |
937 /* I'm not sure if this can happen or not. Might as well be prepared | |
938 and generate the best possible code if it does happen. */ | |
939 if (true_regnum (operands[0]) == true_regnum (operands[1])) | |
940 return \"add %2,%0\"; | |
941 if (true_regnum (operands[0]) == true_regnum (operands[2])) | |
942 return \"add %1,%0\"; | |
943 | |
944 /* Catch cases where no extended register was used. These should be | |
945 handled just like the mn10300. */ | |
946 if (src1_class != EXTENDED_REGS | |
947 && src2_class != EXTENDED_REGS | |
948 && dst_class != EXTENDED_REGS) | |
949 { | |
950 /* We have to copy one of the sources into the destination, then | |
951 add the other source to the destination. | |
952 | |
953 Carefully select which source to copy to the destination; a naive | |
954 implementation will waste a byte when the source classes are | |
955 different and the destination is an address register. Selecting | |
956 the lowest cost register copy will optimize this sequence. */ | |
957 if (REGNO_REG_CLASS (true_regnum (operands[1])) | |
958 == REGNO_REG_CLASS (true_regnum (operands[0]))) | |
959 return \"mov %1,%0\;add %2,%0\"; | |
960 return \"mov %2,%0\;add %1,%0\"; | |
961 } | |
962 | |
963 /* At least one register is an extended register. */ | |
964 | |
965 /* The three operand add instruction on the am33 is a win iff the | |
966 output register is an extended register, or if both source | |
967 registers are extended registers. */ | |
968 if (dst_class == EXTENDED_REGS | |
969 || src1_class == src2_class) | |
970 return \"add %2,%1,%0\"; | |
971 | |
972 /* It is better to copy one of the sources to the destination, then | |
973 perform a 2 address add. The destination in this case must be | |
974 an address or data register and one of the sources must be an | |
975 extended register and the remaining source must not be an extended | |
976 register. | |
977 | |
978 The best code for this case is to copy the extended reg to the | |
979 destination, then emit a two address add. */ | |
980 if (src1_class == EXTENDED_REGS) | |
981 return \"mov %1,%0\;add %2,%0\"; | |
982 return \"mov %2,%0\;add %1,%0\"; | |
983 } | |
984 default: | |
985 gcc_unreachable (); | |
986 } | |
987 }" | |
988 [(set_attr "cc" "set_zn,none_0hit,set_zn,none_0hit,set_zn,none_0hit,set_zn")]) | |
989 | |
990 (define_insn "" | |
991 [(set (match_operand:SI 0 "register_operand" "=dx,a,a,dax,!*y,!dax") | |
992 (plus:SI (match_operand:SI 1 "register_operand" "%0,0,0,0,0,dax") | |
993 (match_operand:SI 2 "nonmemory_operand" "J,J,L,daxi,i,dax")))] | |
994 "" | |
995 "* | |
996 { | |
997 switch (which_alternative) | |
998 { | |
999 case 0: | |
1000 case 1: | |
1001 return \"inc %0\"; | |
1002 case 2: | |
1003 return \"inc4 %0\"; | |
1004 case 3: | |
1005 case 4: | |
1006 return \"add %2,%0\"; | |
1007 case 5: | |
1008 /* I'm not sure if this can happen or not. Might as well be prepared | |
1009 and generate the best possible code if it does happen. */ | |
1010 if (true_regnum (operands[0]) == true_regnum (operands[1])) | |
1011 return \"add %2,%0\"; | |
1012 if (true_regnum (operands[0]) == true_regnum (operands[2])) | |
1013 return \"add %1,%0\"; | |
1014 | |
1015 /* We have to copy one of the sources into the destination, then add | |
1016 the other source to the destination. | |
1017 | |
1018 Carefully select which source to copy to the destination; a naive | |
1019 implementation will waste a byte when the source classes are different | |
1020 and the destination is an address register. Selecting the lowest | |
1021 cost register copy will optimize this sequence. */ | |
1022 if (REGNO_REG_CLASS (true_regnum (operands[1])) | |
1023 == REGNO_REG_CLASS (true_regnum (operands[0]))) | |
1024 return \"mov %1,%0\;add %2,%0\"; | |
1025 return \"mov %2,%0\;add %1,%0\"; | |
1026 default: | |
1027 gcc_unreachable (); | |
1028 } | |
1029 }" | |
1030 [(set_attr "cc" "set_zn,none_0hit,none_0hit,set_zn,none_0hit,set_zn")]) | |
1031 | |
1032 ;; ---------------------------------------------------------------------- | |
1033 ;; SUBTRACT INSTRUCTIONS | |
1034 ;; ---------------------------------------------------------------------- | |
1035 | |
1036 (define_expand "subsi3" | |
1037 [(set (match_operand:SI 0 "register_operand" "") | |
1038 (minus:SI (match_operand:SI 1 "register_operand" "") | |
1039 (match_operand:SI 2 "nonmemory_operand" "")))] | |
1040 "" | |
1041 "") | |
1042 | |
1043 (define_insn "" | |
1044 [(set (match_operand:SI 0 "register_operand" "=dax,!dax") | |
1045 (minus:SI (match_operand:SI 1 "register_operand" "0,dax") | |
1046 (match_operand:SI 2 "nonmemory_operand" "daxi,dax")))] | |
1047 "TARGET_AM33" | |
1048 "* | |
1049 { | |
1050 if (true_regnum (operands[0]) == true_regnum (operands[1])) | |
1051 return \"sub %2,%0\"; | |
1052 else | |
1053 { | |
1054 enum reg_class src1_class, src2_class, dst_class; | |
1055 | |
1056 src1_class = REGNO_REG_CLASS (true_regnum (operands[1])); | |
1057 src2_class = REGNO_REG_CLASS (true_regnum (operands[2])); | |
1058 dst_class = REGNO_REG_CLASS (true_regnum (operands[0])); | |
1059 | |
1060 /* If no extended registers are used, then the best way to handle | |
1061 this is to copy the first source operand into the destination | |
1062 and emit a two address subtraction. */ | |
1063 if (src1_class != EXTENDED_REGS | |
1064 && src2_class != EXTENDED_REGS | |
1065 && dst_class != EXTENDED_REGS | |
1066 && true_regnum (operands[0]) != true_regnum (operands[2])) | |
1067 return \"mov %1,%0\;sub %2,%0\"; | |
1068 return \"sub %2,%1,%0\"; | |
1069 } | |
1070 }" | |
1071 [(set_attr "cc" "set_zn")]) | |
1072 | |
1073 (define_insn "" | |
1074 [(set (match_operand:SI 0 "register_operand" "=dax") | |
1075 (minus:SI (match_operand:SI 1 "register_operand" "0") | |
1076 (match_operand:SI 2 "nonmemory_operand" "daxi")))] | |
1077 "" | |
1078 "sub %2,%0" | |
1079 [(set_attr "cc" "set_zn")]) | |
1080 | |
1081 (define_expand "negsi2" | |
1082 [(set (match_operand:SI 0 "register_operand" "") | |
1083 (neg:SI (match_operand:SI 1 "register_operand" "")))] | |
1084 "" | |
1085 " | |
1086 { | |
1087 rtx target = gen_reg_rtx (SImode); | |
1088 | |
1089 emit_move_insn (target, const0_rtx); | |
1090 emit_insn (gen_subsi3 (target, target, operands[1])); | |
1091 emit_move_insn (operands[0], target); | |
1092 DONE; | 1467 DONE; |
1093 }") | 1468 }) |
1094 | 1469 |
1095 ;; ---------------------------------------------------------------------- | 1470 (define_insn "*am33_cmpsf" |
1096 ;; MULTIPLY INSTRUCTIONS | 1471 [(set (reg:CC_FLOAT CC_REG) |
1097 ;; ---------------------------------------------------------------------- | 1472 (compare:CC_FLOAT (match_operand:SF 0 "register_operand" "f") |
1098 | 1473 (match_operand:SF 1 "nonmemory_operand" "fF")))] |
1099 (define_insn "mulsidi3" | 1474 "TARGET_AM33_2 && reload_completed" |
1100 [(set (match_operand:DI 0 "register_operand" "=dax") | 1475 "fcmp %1, %0" |
1101 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "dax")) | 1476 [(set (attr "timings") (if_then_else (eq_attr "cpu" "am34") |
1102 (sign_extend:DI (match_operand:SI 2 "register_operand" "dax"))))] | 1477 (const_int 17) (const_int 25)))] |
1103 "TARGET_AM33" | 1478 ) |
1104 "mul %1,%2,%H0,%L0" | 1479 |
1105 [(set_attr "cc" "set_zn")]) | 1480 (define_insn "*float_conditional_branch" |
1106 | |
1107 (define_insn "umulsidi3" | |
1108 [(set (match_operand:DI 0 "register_operand" "=dax") | |
1109 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "dax")) | |
1110 (zero_extend:DI (match_operand:SI 2 "register_operand" "dax"))))] | |
1111 "TARGET_AM33" | |
1112 "mulu %1,%2,%H0,%L0" | |
1113 [(set_attr "cc" "set_zn")]) | |
1114 | |
1115 (define_expand "mulsi3" | |
1116 [(set (match_operand:SI 0 "register_operand" "") | |
1117 (mult:SI (match_operand:SI 1 "register_operand" "") | |
1118 (match_operand:SI 2 "register_operand" "")))] | |
1119 "" | |
1120 "") | |
1121 | |
1122 (define_insn "" | |
1123 [(set (match_operand:SI 0 "register_operand" "=dx,!dax") | |
1124 (mult:SI (match_operand:SI 1 "register_operand" "%0,0") | |
1125 (match_operand:SI 2 "nonmemory_operand" "dx,daxi")))] | |
1126 "TARGET_AM33" | |
1127 "* | |
1128 { | |
1129 if (TARGET_MULT_BUG) | |
1130 return \"nop\;nop\;mul %2,%0\"; | |
1131 else | |
1132 return \"mul %2,%0\"; | |
1133 }" | |
1134 [(set_attr "cc" "set_zn")]) | |
1135 | |
1136 (define_insn "" | |
1137 [(set (match_operand:SI 0 "register_operand" "=dx") | |
1138 (mult:SI (match_operand:SI 1 "register_operand" "%0") | |
1139 (match_operand:SI 2 "register_operand" "dx")))] | |
1140 "" | |
1141 "* | |
1142 { | |
1143 if (TARGET_MULT_BUG) | |
1144 return \"nop\;nop\;mul %2,%0\"; | |
1145 else | |
1146 return \"mul %2,%0\"; | |
1147 }" | |
1148 [(set_attr "cc" "set_zn")]) | |
1149 | |
1150 (define_insn "udivmodsi4" | |
1151 [(set (match_operand:SI 0 "nonimmediate_operand" "=dx") | |
1152 (udiv:SI (match_operand:SI 1 "general_operand" "0") | |
1153 (match_operand:SI 2 "general_operand" "dx"))) | |
1154 (set (match_operand:SI 3 "nonimmediate_operand" "=&d") | |
1155 (umod:SI (match_dup 1) (match_dup 2)))] | |
1156 "" | |
1157 "* | |
1158 { | |
1159 output_asm_insn (\"sub %3,%3\;mov %3,mdr\", operands); | |
1160 | |
1161 if (find_reg_note (insn, REG_UNUSED, operands[3])) | |
1162 return \"divu %2,%0\"; | |
1163 else | |
1164 return \"divu %2,%0\;mov mdr,%3\"; | |
1165 }" | |
1166 [(set_attr "cc" "set_zn")]) | |
1167 | |
1168 (define_insn "divmodsi4" | |
1169 [(set (match_operand:SI 0 "nonimmediate_operand" "=dx") | |
1170 (div:SI (match_operand:SI 1 "general_operand" "0") | |
1171 (match_operand:SI 2 "general_operand" "dx"))) | |
1172 (set (match_operand:SI 3 "nonimmediate_operand" "=d") | |
1173 (mod:SI (match_dup 1) (match_dup 2)))] | |
1174 "" | |
1175 "* | |
1176 { | |
1177 if (find_reg_note (insn, REG_UNUSED, operands[3])) | |
1178 return \"ext %0\;div %2,%0\"; | |
1179 else | |
1180 return \"ext %0\;div %2,%0\;mov mdr,%3\"; | |
1181 }" | |
1182 [(set_attr "cc" "set_zn")]) | |
1183 | |
1184 | |
1185 ;; ---------------------------------------------------------------------- | |
1186 ;; AND INSTRUCTIONS | |
1187 ;; ---------------------------------------------------------------------- | |
1188 | |
1189 (define_expand "andsi3" | |
1190 [(set (match_operand:SI 0 "register_operand" "") | |
1191 (and:SI (match_operand:SI 1 "register_operand" "") | |
1192 (match_operand:SI 2 "nonmemory_operand" "")))] | |
1193 "" | |
1194 "") | |
1195 | |
1196 (define_insn "" | |
1197 [(set (match_operand:SI 0 "register_operand" "=dx,dx,!dax") | |
1198 (and:SI (match_operand:SI 1 "register_operand" "%0,0,dax") | |
1199 (match_operand:SI 2 "nonmemory_operand" "N,dxi,dax")))] | |
1200 "TARGET_AM33" | |
1201 "* | |
1202 { | |
1203 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0xff) | |
1204 return \"extbu %0\"; | |
1205 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0xffff) | |
1206 return \"exthu %0\"; | |
1207 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0x7fffffff) | |
1208 return \"add %0,%0\;lsr 1,%0\"; | |
1209 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0x3fffffff) | |
1210 return \"asl2 %0\;lsr 2,%0\"; | |
1211 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0x1fffffff) | |
1212 return \"add %0,%0\;asl2 %0\;lsr 3,%0\"; | |
1213 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0x0fffffff) | |
1214 return \"asl2 %0\;asl2 %0\;lsr 4,%0\"; | |
1215 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0xfffffffe) | |
1216 return \"lsr 1,%0\;add %0,%0\"; | |
1217 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0xfffffffc) | |
1218 return \"lsr 2,%0\;asl2 %0\"; | |
1219 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0xfffffff8) | |
1220 return \"lsr 3,%0\;add %0,%0\;asl2 %0\"; | |
1221 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0xfffffff0) | |
1222 return \"lsr 4,%0\;asl2 %0\;asl2 %0\"; | |
1223 if (REG_P (operands[2]) && REG_P (operands[1]) | |
1224 && true_regnum (operands[0]) != true_regnum (operands[1]) | |
1225 && true_regnum (operands[0]) != true_regnum (operands[2]) | |
1226 && REGNO_REG_CLASS (true_regnum (operands[0])) == DATA_REGS | |
1227 && REGNO_REG_CLASS (true_regnum (operands[1])) == DATA_REGS | |
1228 && REGNO_REG_CLASS (true_regnum (operands[2])) == DATA_REGS) | |
1229 return \"mov %1,%0\;and %2,%0\"; | |
1230 if (REG_P (operands[2]) && REG_P (operands[1]) | |
1231 && true_regnum (operands[0]) != true_regnum (operands[1]) | |
1232 && true_regnum (operands[0]) != true_regnum (operands[2])) | |
1233 return \"and %1,%2,%0\"; | |
1234 if (REG_P (operands[2]) && REG_P (operands[0]) | |
1235 && true_regnum (operands[2]) == true_regnum (operands[0])) | |
1236 return \"and %1,%0\"; | |
1237 return \"and %2,%0\"; | |
1238 }" | |
1239 [(set (attr "cc") | |
1240 (cond | |
1241 [ | |
1242 (eq (symbol_ref "which_alternative") (const_int 0) | |
1243 ) (const_string "none_0hit") | |
1244 (ne (symbol_ref "GET_CODE (operands[2]) == CONST_INT | |
1245 && (INTVAL (operands[2]) == 0x7fffffff | |
1246 || INTVAL (operands[2]) == 0x3fffffff | |
1247 || INTVAL (operands[2]) == 0x1fffffff | |
1248 || INTVAL (operands[2]) == 0x0fffffff | |
1249 || INTVAL (operands[2]) == 0xfffffffe | |
1250 || INTVAL (operands[2]) == 0xfffffffc | |
1251 || INTVAL (operands[2]) == 0xfffffff8 | |
1252 || INTVAL (operands[2]) == 0xfffffff0)") | |
1253 (const_int 0)) (const_string "set_zn") | |
1254 ] (const_string "set_znv")))]) | |
1255 | |
1256 (define_insn "" | |
1257 [(set (match_operand:SI 0 "register_operand" "=dx,dx") | |
1258 (and:SI (match_operand:SI 1 "register_operand" "%0,0") | |
1259 (match_operand:SI 2 "nonmemory_operand" "N,dxi")))] | |
1260 "" | |
1261 "* | |
1262 { | |
1263 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0xff) | |
1264 return \"extbu %0\"; | |
1265 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0xffff) | |
1266 return \"exthu %0\"; | |
1267 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0x7fffffff) | |
1268 return \"add %0,%0\;lsr 1,%0\"; | |
1269 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0x3fffffff) | |
1270 return \"asl2 %0\;lsr 2,%0\"; | |
1271 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0x1fffffff) | |
1272 return \"add %0,%0\;asl2 %0\;lsr 3,%0\"; | |
1273 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0x0fffffff) | |
1274 return \"asl2 %0\;asl2 %0\;lsr 4,%0\"; | |
1275 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0xfffffffe) | |
1276 return \"lsr 1,%0\;add %0,%0\"; | |
1277 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0xfffffffc) | |
1278 return \"lsr 2,%0\;asl2 %0\"; | |
1279 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0xfffffff8) | |
1280 return \"lsr 3,%0\;add %0,%0\;asl2 %0\"; | |
1281 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0xfffffff0) | |
1282 return \"lsr 4,%0\;asl2 %0\;asl2 %0\"; | |
1283 return \"and %2,%0\"; | |
1284 }" | |
1285 [(set (attr "cc") | |
1286 (cond | |
1287 [ | |
1288 (eq (symbol_ref "which_alternative") (const_int 0) | |
1289 ) (const_string "none_0hit") | |
1290 ;; Shifts don't set the V flag, but bitwise operations clear | |
1291 ;; it (which correctly reflects the absence of overflow in a | |
1292 ;; compare-with-zero that might follow). As for the | |
1293 ;; 0xfffffffe case, the add may overflow, so we can't use the | |
1294 ;; V flag. | |
1295 (ne (symbol_ref "GET_CODE (operands[2]) == CONST_INT | |
1296 && (INTVAL (operands[2]) == 0x7fffffff | |
1297 || INTVAL (operands[2]) == 0x3fffffff | |
1298 || INTVAL (operands[2]) == 0x1fffffff | |
1299 || INTVAL (operands[2]) == 0x0fffffff | |
1300 || INTVAL (operands[2]) == 0xfffffffe | |
1301 || INTVAL (operands[2]) == 0xfffffffc | |
1302 || INTVAL (operands[2]) == 0xfffffff8 | |
1303 || INTVAL (operands[2]) == 0xfffffff0)") | |
1304 (const_int 0)) (const_string "set_zn") | |
1305 ] (const_string "set_znv")))]) | |
1306 | |
1307 ;; ---------------------------------------------------------------------- | |
1308 ;; OR INSTRUCTIONS | |
1309 ;; ---------------------------------------------------------------------- | |
1310 | |
1311 (define_expand "iorsi3" | |
1312 [(set (match_operand:SI 0 "register_operand" "") | |
1313 (ior:SI (match_operand:SI 1 "register_operand" "") | |
1314 (match_operand:SI 2 "nonmemory_operand" "")))] | |
1315 "" | |
1316 "") | |
1317 | |
1318 (define_insn "" | |
1319 [(set (match_operand:SI 0 "register_operand" "=dx,!dax") | |
1320 (ior:SI (match_operand:SI 1 "register_operand" "%0,dax") | |
1321 (match_operand:SI 2 "nonmemory_operand" "dxi,dax")))] | |
1322 "TARGET_AM33" | |
1323 "* | |
1324 { | |
1325 if (REG_P (operands[2]) && REG_P (operands[1]) | |
1326 && true_regnum (operands[0]) != true_regnum (operands[1]) | |
1327 && true_regnum (operands[0]) != true_regnum (operands[2]) | |
1328 && REGNO_REG_CLASS (true_regnum (operands[0])) == DATA_REGS | |
1329 && REGNO_REG_CLASS (true_regnum (operands[1])) == DATA_REGS | |
1330 && REGNO_REG_CLASS (true_regnum (operands[2])) == DATA_REGS) | |
1331 return \"mov %1,%0\;or %2,%0\"; | |
1332 if (REG_P (operands[2]) && REG_P (operands[1]) | |
1333 && true_regnum (operands[0]) != true_regnum (operands[1]) | |
1334 && true_regnum (operands[0]) != true_regnum (operands[2])) | |
1335 return \"or %1,%2,%0\"; | |
1336 if (REG_P (operands[2]) && REG_P (operands[0]) | |
1337 && true_regnum (operands[2]) == true_regnum (operands[0])) | |
1338 return \"or %1,%0\"; | |
1339 return \"or %2,%0\"; | |
1340 }" | |
1341 [(set_attr "cc" "set_znv")]) | |
1342 | |
1343 (define_insn "" | |
1344 [(set (match_operand:SI 0 "register_operand" "=dx") | |
1345 (ior:SI (match_operand:SI 1 "register_operand" "%0") | |
1346 (match_operand:SI 2 "nonmemory_operand" "dxi")))] | |
1347 "" | |
1348 "or %2,%0" | |
1349 [(set_attr "cc" "set_znv")]) | |
1350 | |
1351 ;; ---------------------------------------------------------------------- | |
1352 ;; XOR INSTRUCTIONS | |
1353 ;; ---------------------------------------------------------------------- | |
1354 | |
1355 (define_expand "xorsi3" | |
1356 [(set (match_operand:SI 0 "register_operand" "") | |
1357 (xor:SI (match_operand:SI 1 "register_operand" "") | |
1358 (match_operand:SI 2 "nonmemory_operand" "")))] | |
1359 "" | |
1360 "") | |
1361 | |
1362 (define_insn "" | |
1363 [(set (match_operand:SI 0 "register_operand" "=dx,!dax") | |
1364 (xor:SI (match_operand:SI 1 "register_operand" "%0,dax") | |
1365 (match_operand:SI 2 "nonmemory_operand" "dxi,dax")))] | |
1366 "TARGET_AM33" | |
1367 "* | |
1368 { | |
1369 if (REG_P (operands[2]) && REG_P (operands[1]) | |
1370 && true_regnum (operands[0]) != true_regnum (operands[1]) | |
1371 && true_regnum (operands[0]) != true_regnum (operands[2]) | |
1372 && REGNO_REG_CLASS (true_regnum (operands[0])) == DATA_REGS | |
1373 && REGNO_REG_CLASS (true_regnum (operands[1])) == DATA_REGS | |
1374 && REGNO_REG_CLASS (true_regnum (operands[2])) == DATA_REGS) | |
1375 return \"mov %1,%0\;xor %2,%0\"; | |
1376 if (REG_P (operands[2]) && REG_P (operands[1]) | |
1377 && true_regnum (operands[0]) != true_regnum (operands[1]) | |
1378 && true_regnum (operands[0]) != true_regnum (operands[2])) | |
1379 return \"xor %1,%2,%0\"; | |
1380 if (REG_P (operands[2]) && REG_P (operands[0]) | |
1381 && true_regnum (operands[2]) == true_regnum (operands[0])) | |
1382 return \"xor %1,%0\"; | |
1383 return \"xor %2,%0\"; | |
1384 }" | |
1385 [(set_attr "cc" "set_znv")]) | |
1386 | |
1387 (define_insn "" | |
1388 [(set (match_operand:SI 0 "register_operand" "=dx") | |
1389 (xor:SI (match_operand:SI 1 "register_operand" "%0") | |
1390 (match_operand:SI 2 "nonmemory_operand" "dxi")))] | |
1391 "" | |
1392 "xor %2,%0" | |
1393 [(set_attr "cc" "set_znv")]) | |
1394 | |
1395 ;; ---------------------------------------------------------------------- | |
1396 ;; NOT INSTRUCTIONS | |
1397 ;; ---------------------------------------------------------------------- | |
1398 | |
1399 (define_expand "one_cmplsi2" | |
1400 [(set (match_operand:SI 0 "register_operand" "") | |
1401 (not:SI (match_operand:SI 1 "register_operand" "")))] | |
1402 "" | |
1403 "") | |
1404 | |
1405 (define_insn "" | |
1406 [(set (match_operand:SI 0 "register_operand" "=dx,!dax") | |
1407 (not:SI (match_operand:SI 1 "register_operand" "0,0")))] | |
1408 "TARGET_AM33" | |
1409 "not %0" | |
1410 [(set_attr "cc" "set_znv")]) | |
1411 | |
1412 (define_insn "" | |
1413 [(set (match_operand:SI 0 "register_operand" "=dx") | |
1414 (not:SI (match_operand:SI 1 "register_operand" "0")))] | |
1415 "" | |
1416 "not %0" | |
1417 [(set_attr "cc" "set_znv")]) | |
1418 | |
1419 ;; ----------------------------------------------------------------- | |
1420 ;; BIT FIELDS | |
1421 ;; ----------------------------------------------------------------- | |
1422 | |
1423 | |
1424 ;; These set/clear memory in byte sized chunks. | |
1425 ;; | |
1426 ;; They are no smaller/faster than loading the value into a register | |
1427 ;; and storing the register, but they don't need a scratch register | |
1428 ;; which may allow for better code generation. | |
1429 (define_insn "" | |
1430 [(set (match_operand:QI 0 "nonimmediate_operand" "=R,d") (const_int 0))] | |
1431 "" | |
1432 "@ | |
1433 bclr 255,%A0 | |
1434 clr %0" | |
1435 [(set_attr "cc" "clobber")]) | |
1436 | |
1437 (define_insn "" | |
1438 [(set (match_operand:QI 0 "nonimmediate_operand" "=R,d") (const_int -1))] | |
1439 "" | |
1440 "@ | |
1441 bset 255,%A0 | |
1442 mov -1,%0" | |
1443 [(set_attr "cc" "clobber,none_0hit")]) | |
1444 | |
1445 (define_insn "" | |
1446 [(set (match_operand:QI 0 "nonimmediate_operand" "+R,d") | |
1447 (subreg:QI | |
1448 (and:SI (subreg:SI (match_dup 0) 0) | |
1449 (match_operand:SI 1 "const_int_operand" "i,i")) 0))] | |
1450 "" | |
1451 "@ | |
1452 bclr %N1,%A0 | |
1453 and %1,%0" | |
1454 [(set_attr "cc" "clobber,set_znv")]) | |
1455 | |
1456 (define_insn "" | |
1457 [(set (match_operand:QI 0 "memory_operand" "=R,T") | |
1458 (and:QI | |
1459 (match_dup 0) | |
1460 (not:QI (match_operand:QI 1 "nonmemory_operand" "i,d"))))] | |
1461 "" | |
1462 "@ | |
1463 bclr %U1,%A0 | |
1464 bclr %1,%0" | |
1465 [(set_attr "cc" "clobber,clobber")]) | |
1466 | |
1467 (define_insn "" | |
1468 [(set (match_operand:QI 0 "nonimmediate_operand" "+R,d") | |
1469 (subreg:QI | |
1470 (ior:SI (subreg:SI (match_dup 0) 0) | |
1471 (match_operand:SI 1 "const_int_operand" "i,i")) 0))] | |
1472 "" | |
1473 "@ | |
1474 bset %U1,%A0 | |
1475 or %1,%0" | |
1476 [(set_attr "cc" "clobber,set_znv")]) | |
1477 | |
1478 (define_expand "iorqi3" | |
1479 [(set (match_operand:QI 0 "nonimmediate_operand" "") | |
1480 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "") | |
1481 (match_operand:QI 2 "nonmemory_operand" "")))] | |
1482 "" | |
1483 "") | |
1484 | |
1485 (define_insn "" | |
1486 [(set (match_operand:QI 0 "nonimmediate_operand" "=R,T,r") | |
1487 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0") | |
1488 ;; This constraint should really be nonmemory_operand, | |
1489 ;; but making it general_operand, along with the | |
1490 ;; condition that not both input operands are MEMs, it | |
1491 ;; here helps combine do a better job. | |
1492 (match_operand:QI 2 "general_operand" "i,d,ir")))] | |
1493 "TARGET_AM33 && | |
1494 (GET_CODE (operands[2]) != MEM || GET_CODE (operands[1]) != MEM)" | |
1495 "@ | |
1496 bset %U2,%A0 | |
1497 bset %2,%0 | |
1498 or %2,%0" | |
1499 [(set_attr "cc" "clobber,clobber,set_znv")]) | |
1500 | |
1501 (define_insn "" | |
1502 [(set (match_operand:QI 0 "nonimmediate_operand" "=R,T,d") | |
1503 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0") | |
1504 ;; This constraint should really be nonmemory_operand, | |
1505 ;; but making it general_operand, along with the | |
1506 ;; condition that not both input operands are MEMs, it | |
1507 ;; here helps combine do a better job. | |
1508 (match_operand:QI 2 "general_operand" "i,d,id")))] | |
1509 "GET_CODE (operands[2]) != MEM || GET_CODE (operands[1]) != MEM" | |
1510 "@ | |
1511 bset %U2,%A0 | |
1512 bset %2,%0 | |
1513 or %2,%0" | |
1514 [(set_attr "cc" "clobber,clobber,set_znv")]) | |
1515 | |
1516 (define_insn "" | |
1517 [(set (cc0) | |
1518 (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "dx") | |
1519 (match_operand 1 "const_int_operand" "") | |
1520 (match_operand 2 "const_int_operand" "")) | |
1521 (const_int 0)))] | |
1522 "" | |
1523 "* | |
1524 { | |
1525 int len = INTVAL (operands[1]); | |
1526 int bit = INTVAL (operands[2]); | |
1527 int mask = 0; | |
1528 rtx xoperands[2]; | |
1529 | |
1530 while (len > 0) | |
1531 { | |
1532 mask |= (1 << bit); | |
1533 bit++; | |
1534 len--; | |
1535 } | |
1536 | |
1537 xoperands[0] = operands[0]; | |
1538 xoperands[1] = GEN_INT (trunc_int_for_mode (mask, SImode)); | |
1539 output_asm_insn (\"btst %1,%0\", xoperands); | |
1540 return \"\"; | |
1541 }" | |
1542 [(set_attr "cc" "clobber")]) | |
1543 | |
1544 (define_insn "" | |
1545 [(set (cc0) | |
1546 (compare (zero_extract:SI (match_operand:QI 0 "general_operand" "R,dx") | |
1547 (match_operand 1 "const_int_operand" "") | |
1548 (match_operand 2 "const_int_operand" "")) | |
1549 (const_int 0)))] | |
1550 "mask_ok_for_mem_btst (INTVAL (operands[1]), INTVAL (operands[2]))" | |
1551 "* | |
1552 { | |
1553 int len = INTVAL (operands[1]); | |
1554 int bit = INTVAL (operands[2]); | |
1555 int mask = 0; | |
1556 rtx xoperands[2]; | |
1557 | |
1558 while (len > 0) | |
1559 { | |
1560 mask |= (1 << bit); | |
1561 bit++; | |
1562 len--; | |
1563 } | |
1564 | |
1565 /* If the source operand is not a reg (i.e. it is memory), then extract the | |
1566 bits from mask that we actually want to test. Note that the mask will | |
1567 never cross a byte boundary. */ | |
1568 if (!REG_P (operands[0])) | |
1569 { | |
1570 if (mask & 0xff) | |
1571 mask = mask & 0xff; | |
1572 else if (mask & 0xff00) | |
1573 mask = (mask >> 8) & 0xff; | |
1574 else if (mask & 0xff0000) | |
1575 mask = (mask >> 16) & 0xff; | |
1576 else if (mask & 0xff000000) | |
1577 mask = (mask >> 24) & 0xff; | |
1578 } | |
1579 | |
1580 xoperands[0] = operands[0]; | |
1581 xoperands[1] = GEN_INT (trunc_int_for_mode (mask, SImode)); | |
1582 if (GET_CODE (operands[0]) == REG) | |
1583 output_asm_insn (\"btst %1,%0\", xoperands); | |
1584 else | |
1585 output_asm_insn (\"btst %U1,%A0\", xoperands); | |
1586 return \"\"; | |
1587 }" | |
1588 [(set_attr "cc" "clobber")]) | |
1589 | |
1590 (define_insn "" | |
1591 [(set (cc0) (compare (and:SI (match_operand:SI 0 "register_operand" "dx") | |
1592 (match_operand:SI 1 "const_int_operand" "")) | |
1593 (const_int 0)))] | |
1594 "" | |
1595 "btst %1,%0" | |
1596 [(set_attr "cc" "clobber")]) | |
1597 | |
1598 (define_insn "" | |
1599 [(set (cc0) | |
1600 (compare (and:SI | |
1601 (subreg:SI (match_operand:QI 0 "general_operand" "R,dx") 0) | |
1602 (match_operand:SI 1 "const_8bit_operand" "")) | |
1603 (const_int 0)))] | |
1604 "" | |
1605 "@ | |
1606 btst %U1,%A0 | |
1607 btst %1,%0" | |
1608 [(set_attr "cc" "clobber")]) | |
1609 | |
1610 | |
1611 ;; ---------------------------------------------------------------------- | |
1612 ;; JUMP INSTRUCTIONS | |
1613 ;; ---------------------------------------------------------------------- | |
1614 | |
1615 (define_expand "cbranchsi4" | |
1616 [(set (cc0) | |
1617 (compare (match_operand:SI 1 "register_operand" "") | |
1618 (match_operand:SI 2 "nonmemory_operand" ""))) | |
1619 (set (pc) | |
1620 (if_then_else | |
1621 (match_operator 0 "ordered_comparison_operator" [(cc0) | |
1622 (const_int 0)]) | |
1623 (label_ref (match_operand 3 "" "")) | |
1624 (pc)))] | |
1625 "" | |
1626 "") | |
1627 | |
1628 (define_expand "cbranchsf4" | |
1629 [(set (cc0) | |
1630 (compare (match_operand:SF 1 "register_operand" "") | |
1631 (match_operand:SF 2 "nonmemory_operand" ""))) | |
1632 (set (pc) | |
1633 (if_then_else | |
1634 (match_operator 0 "ordered_comparison_operator" [(cc0) | |
1635 (const_int 0)]) | |
1636 (label_ref (match_operand 3 "" "")) | |
1637 (pc)))] | |
1638 "TARGET_AM33_2" | |
1639 "") | |
1640 | |
1641 | |
1642 ;; Conditional jump instructions | |
1643 | |
1644 (define_insn "" | |
1645 [(set (pc) | 1481 [(set (pc) |
1646 (if_then_else (match_operator 1 "comparison_operator" | 1482 (if_then_else (match_operator 0 "comparison_operator" |
1647 [(cc0) (const_int 0)]) | 1483 [(reg:CC_FLOAT CC_REG) (const_int 0)]) |
1648 (label_ref (match_operand 0 "" "")) | 1484 (label_ref (match_operand 1 "" "")) |
1649 (pc)))] | 1485 (pc)))] |
1650 "" | 1486 "TARGET_AM33_2 && reload_completed" |
1651 "* | 1487 "fb%b0 %1" |
1652 { | 1488 [(set (attr "timings") (if_then_else (eq_attr "cpu" "am34") |
1653 if (cc_status.mdep.fpCC) | 1489 (const_int 44) (const_int 33)))] |
1654 return \"fb%b1 %0\"; | 1490 ) |
1655 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0 | |
1656 && (GET_CODE (operands[1]) == GT | |
1657 || GET_CODE (operands[1]) == GE | |
1658 || GET_CODE (operands[1]) == LE | |
1659 || GET_CODE (operands[1]) == LT)) | |
1660 return 0; | |
1661 return \"b%b1 %0\"; | |
1662 }" | |
1663 [(set_attr "cc" "none")]) | |
1664 | |
1665 (define_insn "" | |
1666 [(set (pc) | |
1667 (if_then_else (match_operator 1 "comparison_operator" | |
1668 [(cc0) (const_int 0)]) | |
1669 (pc) | |
1670 (label_ref (match_operand 0 "" ""))))] | |
1671 "" | |
1672 "* | |
1673 { | |
1674 if (cc_status.mdep.fpCC) | |
1675 return \"fb%B1 %0\"; | |
1676 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0 | |
1677 && (GET_CODE (operands[1]) == GT | |
1678 || GET_CODE (operands[1]) == GE | |
1679 || GET_CODE (operands[1]) == LE | |
1680 || GET_CODE (operands[1]) == LT)) | |
1681 return 0; | |
1682 return \"b%B1 %0\"; | |
1683 }" | |
1684 [(set_attr "cc" "none")]) | |
1685 | 1491 |
1686 ;; Unconditional and other jump instructions. | 1492 ;; Unconditional and other jump instructions. |
1687 | 1493 |
1688 (define_insn "jump" | 1494 (define_insn "jump" |
1689 [(set (pc) | 1495 [(set (pc) |
1690 (label_ref (match_operand 0 "" "")))] | 1496 (label_ref (match_operand 0 "" "")))] |
1691 "" | 1497 "" |
1692 "jmp %l0" | 1498 "jmp %l0" |
1693 [(set_attr "cc" "none")]) | 1499 [(set (attr "timings") (if_then_else (eq_attr "cpu" "am34") |
1500 (const_int 11) (const_int 44)))] | |
1501 ) | |
1694 | 1502 |
1695 (define_insn "indirect_jump" | 1503 (define_insn "indirect_jump" |
1696 [(set (pc) (match_operand:SI 0 "register_operand" "a"))] | 1504 [(set (pc) (match_operand:SI 0 "register_operand" "a"))] |
1697 "" | 1505 "" |
1698 "jmp (%0)" | 1506 "jmp (%0)" |
1699 [(set_attr "cc" "none")]) | 1507 [(set (attr "timings") (if_then_else (eq_attr "cpu" "am34") |
1508 (const_int 11) (const_int 33)))] | |
1509 ) | |
1700 | 1510 |
1701 (define_expand "builtin_setjmp_receiver" | 1511 (define_expand "builtin_setjmp_receiver" |
1702 [(match_operand 0 "" "")] | 1512 [(match_operand 0 "" "")] |
1703 "flag_pic" | 1513 "flag_pic" |
1704 " | 1514 { |
1705 { | 1515 emit_insn (gen_load_pic ()); |
1706 if (flag_pic) | |
1707 emit_insn (gen_GOTaddr2picreg ()); | |
1708 | |
1709 DONE; | 1516 DONE; |
1710 }") | 1517 }) |
1711 | 1518 |
1712 (define_expand "casesi" | 1519 (define_expand "casesi" |
1713 [(match_operand:SI 0 "register_operand" "") | 1520 [(match_operand:SI 0 "register_operand") |
1714 (match_operand:SI 1 "immediate_operand" "") | 1521 (match_operand:SI 1 "immediate_operand") |
1715 (match_operand:SI 2 "immediate_operand" "") | 1522 (match_operand:SI 2 "immediate_operand") |
1716 (match_operand 3 "" "") (match_operand 4 "" "")] | 1523 (match_operand 3 "" "") (match_operand 4 "")] |
1717 "" | 1524 "" |
1718 " | |
1719 { | 1525 { |
1720 rtx table = gen_reg_rtx (SImode); | 1526 rtx table = gen_reg_rtx (SImode); |
1721 rtx index = gen_reg_rtx (SImode); | 1527 rtx index = gen_reg_rtx (SImode); |
1722 rtx addr = gen_reg_rtx (Pmode); | 1528 rtx addr = gen_reg_rtx (Pmode); |
1723 rtx test; | 1529 rtx test; |
1724 | 1530 |
1725 emit_move_insn (table, gen_rtx_LABEL_REF (VOIDmode, operands[3])); | 1531 emit_move_insn (table, gen_rtx_LABEL_REF (VOIDmode, operands[3])); |
1726 emit_move_insn (index, plus_constant (operands[0], - INTVAL (operands[1]))); | 1532 emit_insn (gen_addsi3 (index, operands[0], GEN_INT (- INTVAL (operands[1])))); |
1727 test = gen_rtx_fmt_ee (GTU, VOIDmode, index, operands[2]); | 1533 test = gen_rtx_fmt_ee (GTU, VOIDmode, index, operands[2]); |
1728 emit_jump_insn (gen_cbranchsi4 (test, index, operands[2], operands[4])); | 1534 emit_jump_insn (gen_cbranchsi4 (test, index, operands[2], operands[4])); |
1729 | 1535 |
1730 emit_move_insn (index, gen_rtx_ASHIFT (SImode, index, const2_rtx)); | 1536 emit_insn (gen_ashlsi3 (index, index, const2_rtx)); |
1731 emit_move_insn (addr, gen_rtx_MEM (SImode, | 1537 emit_move_insn (addr, gen_rtx_MEM (SImode, |
1732 gen_rtx_PLUS (SImode, table, index))); | 1538 gen_rtx_PLUS (SImode, table, index))); |
1733 if (flag_pic) | 1539 if (flag_pic) |
1734 emit_move_insn (addr, gen_rtx_PLUS (SImode, addr, table)); | 1540 emit_insn (gen_addsi3 (addr, addr, table)); |
1735 | 1541 |
1736 emit_jump_insn (gen_tablejump (addr, operands[3])); | 1542 emit_jump_insn (gen_tablejump (addr, operands[3])); |
1737 DONE; | 1543 DONE; |
1738 }") | 1544 }) |
1739 | 1545 |
1740 (define_insn "tablejump" | 1546 (define_insn "tablejump" |
1741 [(set (pc) (match_operand:SI 0 "register_operand" "a")) | 1547 [(set (pc) (match_operand:SI 0 "register_operand" "a")) |
1742 (use (label_ref (match_operand 1 "" "")))] | 1548 (use (label_ref (match_operand 1 "" "")))] |
1743 "" | 1549 "" |
1744 "jmp (%0)" | 1550 "jmp (%0)" |
1745 [(set_attr "cc" "none")]) | 1551 [(set (attr "timings") (if_then_else (eq_attr "cpu" "am34") |
1552 (const_int 11) (const_int 33)))] | |
1553 ) | |
1746 | 1554 |
1747 ;; Call subroutine with no return value. | 1555 ;; Call subroutine with no return value. |
1748 | 1556 |
1749 (define_expand "call" | 1557 (define_expand "call" |
1750 [(call (match_operand:QI 0 "general_operand" "") | 1558 [(call (match_operand:QI 0 "general_operand") |
1751 (match_operand:SI 1 "general_operand" ""))] | 1559 (match_operand:SI 1 "general_operand"))] |
1752 "" | 1560 "" |
1753 " | 1561 { |
1754 { | 1562 rtx fn = XEXP (operands[0], 0); |
1755 if (flag_pic && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF) | 1563 |
1756 { | 1564 if (flag_pic && GET_CODE (fn) == SYMBOL_REF) |
1757 if (MN10300_GLOBAL_P (XEXP (operands[0], 0))) | 1565 { |
1566 if (MN10300_GLOBAL_P (fn)) | |
1758 { | 1567 { |
1759 /* The PLT code won't run on AM30, but then, there's no | 1568 /* The PLT code won't run on AM30, but then, there's no |
1760 shared library support for AM30 either, so we just assume | 1569 shared library support for AM30 either, so we just assume |
1761 the linker is going to adjust all @PLT relocs to the | 1570 the linker is going to adjust all @PLT relocs to the |
1762 actual symbols. */ | 1571 actual symbols. */ |
1763 emit_use (pic_offset_table_rtx); | 1572 emit_use (pic_offset_table_rtx); |
1764 XEXP (operands[0], 0) = gen_sym2PLT (XEXP (operands[0], 0)); | 1573 fn = gen_rtx_UNSPEC (SImode, gen_rtvec (1, fn), UNSPEC_PLT); |
1765 } | 1574 } |
1766 else | 1575 else |
1767 XEXP (operands[0], 0) = gen_sym2PIC (XEXP (operands[0], 0)); | 1576 fn = gen_rtx_UNSPEC (SImode, gen_rtvec (1, fn), UNSPEC_PIC); |
1768 } | 1577 } |
1769 if (! call_address_operand (XEXP (operands[0], 0), VOIDmode)) | 1578 if (! call_address_operand (fn, VOIDmode)) |
1770 XEXP (operands[0], 0) = force_reg (SImode, XEXP (operands[0], 0)); | 1579 fn = force_reg (SImode, fn); |
1771 emit_call_insn (gen_call_internal (XEXP (operands[0], 0), operands[1])); | 1580 |
1772 DONE; | 1581 XEXP (operands[0], 0) = fn; |
1773 }") | 1582 }) |
1774 | 1583 |
1775 ;; NB: Mode on match_operand 0 deliberately omitted in | 1584 (define_insn "*call_internal" |
1776 ;; order to be able to match UNSPECs in PIC mode. | 1585 [(call (mem:QI (match_operand:SI 0 "call_address_operand" "a,S")) |
1777 (define_insn "call_internal" | 1586 (match_operand:SI 1 "" ""))] |
1778 [(call (mem:QI (match_operand 0 "call_address_operand" "aS")) | 1587 "" |
1779 (match_operand:SI 1 "general_operand" "g"))] | 1588 "@ |
1780 "" | 1589 calls %C0 |
1781 "* | 1590 call %C0,[],0" |
1782 { | 1591 [(set_attr_alternative "timings" |
1783 if (REG_P (operands[0])) | 1592 [(if_then_else (eq_attr "cpu" "am34") |
1784 return \"calls %C0\"; | 1593 (const_int 33) (const_int 44)) |
1785 else | 1594 (if_then_else (eq_attr "cpu" "am34") |
1786 return \"call %C0,[],0\"; | 1595 (const_int 55) (const_int 33)) |
1787 }" | 1596 ]) |
1788 [(set_attr "cc" "clobber")]) | 1597 ] |
1598 ) | |
1789 | 1599 |
1790 ;; Call subroutine, returning value in operand 0 | 1600 ;; Call subroutine, returning value in operand 0 |
1791 ;; (which must be a hard register). | 1601 ;; (which must be a hard register). |
1792 | 1602 |
1793 (define_expand "call_value" | 1603 (define_expand "call_value" |
1794 [(set (match_operand 0 "" "") | 1604 [(set (match_operand 0 "") |
1795 (call (match_operand:QI 1 "general_operand" "") | 1605 (call (match_operand:QI 1 "general_operand") |
1796 (match_operand:SI 2 "general_operand" "")))] | 1606 (match_operand:SI 2 "general_operand")))] |
1797 "" | 1607 "" |
1798 " | 1608 { |
1799 { | 1609 rtx fn = XEXP (operands[1], 0); |
1800 if (flag_pic && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF) | 1610 |
1801 { | 1611 if (flag_pic && GET_CODE (fn) == SYMBOL_REF) |
1802 if (MN10300_GLOBAL_P (XEXP (operands[1], 0))) | 1612 { |
1613 if (MN10300_GLOBAL_P (fn)) | |
1803 { | 1614 { |
1804 /* The PLT code won't run on AM30, but then, there's no | 1615 /* The PLT code won't run on AM30, but then, there's no |
1805 shared library support for AM30 either, so we just assume | 1616 shared library support for AM30 either, so we just assume |
1806 the linker is going to adjust all @PLT relocs to the | 1617 the linker is going to adjust all @PLT relocs to the |
1807 actual symbols. */ | 1618 actual symbols. */ |
1808 emit_use (pic_offset_table_rtx); | 1619 emit_use (pic_offset_table_rtx); |
1809 XEXP (operands[1], 0) = gen_sym2PLT (XEXP (operands[1], 0)); | 1620 fn = gen_rtx_UNSPEC (SImode, gen_rtvec (1, fn), UNSPEC_PLT); |
1810 } | 1621 } |
1811 else | 1622 else |
1812 XEXP (operands[1], 0) = gen_sym2PIC (XEXP (operands[1], 0)); | 1623 fn = gen_rtx_UNSPEC (SImode, gen_rtvec (1, fn), UNSPEC_PIC); |
1813 } | 1624 } |
1814 if (! call_address_operand (XEXP (operands[1], 0), VOIDmode)) | 1625 if (! call_address_operand (fn, VOIDmode)) |
1815 XEXP (operands[1], 0) = force_reg (SImode, XEXP (operands[1], 0)); | 1626 fn = force_reg (SImode, fn); |
1816 emit_call_insn (gen_call_value_internal (operands[0], | 1627 |
1817 XEXP (operands[1], 0), | 1628 XEXP (operands[1], 0) = fn; |
1818 operands[2])); | 1629 }) |
1819 DONE; | 1630 |
1820 }") | |
1821 | |
1822 ;; NB: Mode on match_operands 0 and 1 deliberately omitted | |
1823 ;; in order to be able to match UNSPECs in PIC mode. | |
1824 (define_insn "call_value_internal" | 1631 (define_insn "call_value_internal" |
1825 [(set (match_operand 0 "register_operand" "=dax") | 1632 [(set (match_operand 0 "" "") |
1826 (call (mem:QI (match_operand 1 "call_address_operand" "aS")) | 1633 (call (mem:QI (match_operand:SI 1 "call_address_operand" "a,S")) |
1827 (match_operand:SI 2 "general_operand" "g")))] | 1634 (match_operand:SI 2 "" "")))] |
1828 "" | 1635 "" |
1829 "* | 1636 "@ |
1830 { | 1637 calls %C1 |
1831 if (REG_P (operands[1])) | 1638 call %C1,[],0" |
1832 return \"calls %C1\"; | 1639 [(set_attr_alternative "timings" |
1833 else | 1640 [(if_then_else (eq_attr "cpu" "am34") |
1834 return \"call %C1,[],0\"; | 1641 (const_int 33) (const_int 44)) |
1835 }" | 1642 (if_then_else (eq_attr "cpu" "am34") |
1836 [(set_attr "cc" "clobber")]) | 1643 (const_int 55) (const_int 33)) |
1644 ]) | |
1645 ] | |
1646 ) | |
1837 | 1647 |
1838 (define_expand "untyped_call" | 1648 (define_expand "untyped_call" |
1839 [(parallel [(call (match_operand 0 "" "") | 1649 [(parallel [(call (match_operand 0 "") |
1840 (const_int 0)) | 1650 (const_int 0)) |
1841 (match_operand 1 "" "") | 1651 (match_operand 1 "") |
1842 (match_operand 2 "" "")])] | 1652 (match_operand 2 "")])] |
1843 "" | 1653 "" |
1844 " | |
1845 { | 1654 { |
1846 int i; | 1655 int i; |
1847 | 1656 |
1848 emit_call_insn (gen_call (operands[0], const0_rtx)); | 1657 emit_call_insn (gen_call (operands[0], const0_rtx)); |
1849 | 1658 |
1851 { | 1660 { |
1852 rtx set = XVECEXP (operands[2], 0, i); | 1661 rtx set = XVECEXP (operands[2], 0, i); |
1853 emit_move_insn (SET_DEST (set), SET_SRC (set)); | 1662 emit_move_insn (SET_DEST (set), SET_SRC (set)); |
1854 } | 1663 } |
1855 DONE; | 1664 DONE; |
1856 }") | 1665 }) |
1857 | 1666 |
1858 (define_insn "nop" | 1667 (define_insn "nop" |
1859 [(const_int 0)] | 1668 [(const_int 0)] |
1860 "" | 1669 "" |
1861 "nop" | 1670 "nop" |
1862 [(set_attr "cc" "none")]) | 1671 ) |
1863 | 1672 |
1864 ;; ---------------------------------------------------------------------- | 1673 ;; ---------------------------------------------------------------------- |
1865 ;; EXTEND INSTRUCTIONS | 1674 ;; EXTEND INSTRUCTIONS |
1866 ;; ---------------------------------------------------------------------- | 1675 ;; ---------------------------------------------------------------------- |
1867 | 1676 |
1868 (define_expand "zero_extendqisi2" | 1677 (define_insn "zero_extendqisi2" |
1869 [(set (match_operand:SI 0 "general_operand" "") | 1678 [(set (match_operand:SI 0 "register_operand" "=D,D,r") |
1870 (zero_extend:SI | 1679 (zero_extend:SI |
1871 (match_operand:QI 1 "general_operand" "")))] | 1680 (match_operand:QI 1 "nonimmediate_operand" " 0,m,r")))] |
1872 "" | 1681 "" |
1873 "") | 1682 "@ |
1874 | 1683 extbu %0 |
1875 (define_insn "" | 1684 movbu %1,%0 |
1876 [(set (match_operand:SI 0 "nonimmediate_operand" "=dx,dx,dx,!dax,!dax,!dax") | 1685 extbu %1,%0" |
1686 [(set_attr "isa" "*,*,am33") | |
1687 (set_attr_alternative "timings" | |
1688 [(const_int 11) | |
1689 (if_then_else (eq_attr "cpu" "am34") | |
1690 (const_int 13) (const_int 24)) | |
1691 (const_int 11) | |
1692 ])] | |
1693 ) | |
1694 | |
1695 (define_insn "zero_extendhisi2" | |
1696 [(set (match_operand:SI 0 "register_operand" "=D,D,r") | |
1877 (zero_extend:SI | 1697 (zero_extend:SI |
1878 (match_operand:QI 1 "general_operand" "0,dax,m,0,dax,m")))] | 1698 (match_operand:HI 1 "nonimmediate_operand" " 0,m,r")))] |
1699 "" | |
1700 "@ | |
1701 exthu %0 | |
1702 movhu %1,%0 | |
1703 exthu %1,%0" | |
1704 [(set_attr "isa" "*,*,am33") | |
1705 (set_attr_alternative "timings" | |
1706 [(const_int 11) | |
1707 (if_then_else (eq_attr "cpu" "am34") | |
1708 (const_int 13) (const_int 24)) | |
1709 (const_int 11)])] | |
1710 ) | |
1711 | |
1712 (define_insn "extendqisi2" | |
1713 [(set (match_operand:SI 0 "register_operand" "=D,r") | |
1714 (sign_extend:SI | |
1715 (match_operand:QI 1 "register_operand" "0,r")))] | |
1716 "" | |
1717 "@ | |
1718 extb %0 | |
1719 extb %1,%0" | |
1720 [(set_attr "isa" "*,am33")] | |
1721 ) | |
1722 | |
1723 (define_insn "extendhisi2" | |
1724 [(set (match_operand:SI 0 "register_operand" "=D,r") | |
1725 (sign_extend:SI | |
1726 (match_operand:HI 1 "register_operand" "0,r")))] | |
1727 "" | |
1728 "@ | |
1729 exth %0 | |
1730 exth %1,%0" | |
1731 [(set_attr "isa" "*,am33")] | |
1732 ) | |
1733 | |
1734 ;; ---------------------------------------------------------------------- | |
1735 ;; SHIFTS | |
1736 ;; ---------------------------------------------------------------------- | |
1737 | |
1738 (define_insn "ashlsi3" | |
1739 [(set (match_operand:SI 0 "register_operand" "=r,D,d,d,D,D,D,r") | |
1740 (ashift:SI | |
1741 (match_operand:SI 1 "register_operand" " 0,0,0,0,0,0,0,r") | |
1742 (match_operand:QI 2 "nonmemory_operand" " J,K,M,L,D,O,i,r"))) | |
1743 (clobber (reg:CC CC_REG))] | |
1744 "" | |
1745 "@ | |
1746 add %0,%0 | |
1747 asl2 %0 | |
1748 asl2 %0\;add %0,%0 | |
1749 asl2 %0\;asl2 %0 | |
1750 asl %S2,%0 | |
1751 asl %S2,%0 | |
1752 asl %S2,%0 | |
1753 asl %2,%1,%0" | |
1754 [(set_attr "isa" "*,*,*,*,*,*,*,am33") | |
1755 (set_attr "liw" "op2,op2,op2,op2,op2,op2,*,*") | |
1756 (set_attr "liw_op" "asl") | |
1757 (set_attr "timings" "11,11,22,22,11,11,11,11")] | |
1758 ) | |
1759 | |
1760 (define_insn "lshrsi3" | |
1761 [(set (match_operand:SI 0 "register_operand" "=D,D,D,r") | |
1762 (lshiftrt:SI | |
1763 (match_operand:SI 1 "register_operand" "0,0,0,r") | |
1764 (match_operand:QI 2 "nonmemory_operand" "D,O,i,r"))) | |
1765 (clobber (reg:CC CC_REG))] | |
1766 "" | |
1767 "@ | |
1768 lsr %S2,%0 | |
1769 lsr %S2,%0 | |
1770 lsr %S2,%0 | |
1771 lsr %2,%1,%0" | |
1772 [(set_attr "isa" "*,*,*,am33") | |
1773 (set_attr "liw" "op2,op2,*,*") | |
1774 (set_attr "liw_op" "lsr")] | |
1775 ) | |
1776 | |
1777 (define_insn "ashrsi3" | |
1778 [(set (match_operand:SI 0 "register_operand" "=D,D,D,r") | |
1779 (ashiftrt:SI | |
1780 (match_operand:SI 1 "register_operand" "0,0,0,r") | |
1781 (match_operand:QI 2 "nonmemory_operand" "D,O,i,r"))) | |
1782 (clobber (reg:CC CC_REG))] | |
1783 "" | |
1784 "@ | |
1785 asr %S2,%0 | |
1786 asr %S2,%0 | |
1787 asr %S2,%0 | |
1788 asr %2,%1,%0" | |
1789 [(set_attr "isa" "*,*,*,am33") | |
1790 (set_attr "liw" "op2,op2,*,*") | |
1791 (set_attr "liw_op" "asr")] | |
1792 ) | |
1793 | |
1794 ;; ---------------------------------------------------------------------- | |
1795 ;; MISCELANEOUS | |
1796 ;; ---------------------------------------------------------------------- | |
1797 | |
1798 (define_expand "clzsi2" | |
1799 [(parallel [(set (match_operand:SI 0 "register_operand" "") | |
1800 (unspec:SI [(match_operand:SI 1 "register_operand" "") | |
1801 (const_int 0)] UNSPEC_BSCH)) | |
1802 (clobber (reg:CC CC_REG))])] | |
1879 "TARGET_AM33" | 1803 "TARGET_AM33" |
1880 "@ | 1804 ) |
1881 extbu %0 | 1805 |
1882 mov %1,%0\;extbu %0 | 1806 (define_insn "*bsch" |
1883 movbu %1,%0 | 1807 [(set (match_operand:SI 0 "register_operand" "=r") |
1884 extbu %0 | 1808 (unspec:SI [(match_operand:SI 1 "register_operand" "r") |
1885 mov %1,%0\;extbu %0 | 1809 (match_operand:SI 2 "nonmemory_operand" "0")] |
1886 movbu %1,%0" | 1810 UNSPEC_BSCH)) |
1887 [(set_attr "cc" "none_0hit")]) | 1811 (clobber (reg:CC CC_REG))] |
1888 | |
1889 (define_insn "" | |
1890 [(set (match_operand:SI 0 "nonimmediate_operand" "=dx,dx,dx") | |
1891 (zero_extend:SI | |
1892 (match_operand:QI 1 "general_operand" "0,d,m")))] | |
1893 "" | |
1894 "@ | |
1895 extbu %0 | |
1896 mov %1,%0\;extbu %0 | |
1897 movbu %1,%0" | |
1898 [(set_attr "cc" "none_0hit")]) | |
1899 | |
1900 (define_expand "zero_extendhisi2" | |
1901 [(set (match_operand:SI 0 "general_operand" "") | |
1902 (zero_extend:SI | |
1903 (match_operand:HI 1 "general_operand" "")))] | |
1904 "" | |
1905 "") | |
1906 | |
1907 (define_insn "" | |
1908 [(set (match_operand:SI 0 "nonimmediate_operand" "=dx,dx,dx,!dax,!dax,!dax") | |
1909 (zero_extend:SI | |
1910 (match_operand:HI 1 "general_operand" "0,dax,m,0,dax,m")))] | |
1911 "TARGET_AM33" | 1812 "TARGET_AM33" |
1912 "@ | 1813 "bsch %1,%0" |
1913 exthu %0 | 1814 ) |
1914 mov %1,%0\;exthu %0 | |
1915 movhu %1,%0 | |
1916 exthu %0 | |
1917 mov %1,%0\;exthu %0 | |
1918 movhu %1,%0" | |
1919 [(set_attr "cc" "none_0hit")]) | |
1920 | |
1921 (define_insn "" | |
1922 [(set (match_operand:SI 0 "nonimmediate_operand" "=dx,dx,dx") | |
1923 (zero_extend:SI | |
1924 (match_operand:HI 1 "general_operand" "0,dx,m")))] | |
1925 "" | |
1926 "@ | |
1927 exthu %0 | |
1928 mov %1,%0\;exthu %0 | |
1929 movhu %1,%0" | |
1930 [(set_attr "cc" "none_0hit")]) | |
1931 | |
1932 ;;- sign extension instructions | |
1933 | |
1934 (define_expand "extendqisi2" | |
1935 [(set (match_operand:SI 0 "general_operand" "") | |
1936 (sign_extend:SI | |
1937 (match_operand:QI 1 "general_operand" "")))] | |
1938 "" | |
1939 "") | |
1940 | |
1941 (define_insn "" | |
1942 [(set (match_operand:SI 0 "nonimmediate_operand" "=dx,dx,!dax,!dax") | |
1943 (sign_extend:SI | |
1944 (match_operand:QI 1 "general_operand" "0,dx,0,dax")))] | |
1945 "TARGET_AM33" | |
1946 "@ | |
1947 extb %0 | |
1948 mov %1,%0\;extb %0 | |
1949 extb %0 | |
1950 mov %1,%0\;extb %0" | |
1951 [(set_attr "cc" "none_0hit")]) | |
1952 | |
1953 (define_insn "" | |
1954 [(set (match_operand:SI 0 "nonimmediate_operand" "=dx,dx") | |
1955 (sign_extend:SI | |
1956 (match_operand:QI 1 "general_operand" "0,dx")))] | |
1957 "" | |
1958 "@ | |
1959 extb %0 | |
1960 mov %1,%0\;extb %0" | |
1961 [(set_attr "cc" "none_0hit")]) | |
1962 | |
1963 (define_expand "extendhisi2" | |
1964 [(set (match_operand:SI 0 "general_operand" "") | |
1965 (sign_extend:SI | |
1966 (match_operand:HI 1 "general_operand" "")))] | |
1967 "" | |
1968 "") | |
1969 | |
1970 (define_insn "" | |
1971 [(set (match_operand:SI 0 "nonimmediate_operand" "=dx,dx,!dax,!dax") | |
1972 (sign_extend:SI | |
1973 (match_operand:HI 1 "general_operand" "0,dax,0,dax")))] | |
1974 "TARGET_AM33" | |
1975 "@ | |
1976 exth %0 | |
1977 mov %1,%0\;exth %0 | |
1978 exth %0 | |
1979 mov %1,%0\;exth %0" | |
1980 [(set_attr "cc" "none_0hit")]) | |
1981 | |
1982 (define_insn "" | |
1983 [(set (match_operand:SI 0 "nonimmediate_operand" "=dx,dx") | |
1984 (sign_extend:SI | |
1985 (match_operand:HI 1 "general_operand" "0,dx")))] | |
1986 "" | |
1987 "@ | |
1988 exth %0 | |
1989 mov %1,%0\;exth %0" | |
1990 [(set_attr "cc" "none_0hit")]) | |
1991 | |
1992 ;; ---------------------------------------------------------------------- | |
1993 ;; SHIFTS | |
1994 ;; ---------------------------------------------------------------------- | |
1995 | |
1996 (define_expand "ashlsi3" | |
1997 [(set (match_operand:SI 0 "register_operand" "") | |
1998 (ashift:SI | |
1999 (match_operand:SI 1 "register_operand" "") | |
2000 (match_operand:QI 2 "nonmemory_operand" "")))] | |
2001 "" | |
2002 "") | |
2003 | |
2004 (define_insn "" | |
2005 [(set (match_operand:SI 0 "register_operand" "=dax,dx,!dax") | |
2006 (ashift:SI | |
2007 (match_operand:SI 1 "register_operand" "0,0,dax") | |
2008 (match_operand:QI 2 "nonmemory_operand" "J,dxi,dax")))] | |
2009 "TARGET_AM33" | |
2010 "* | |
2011 { | |
2012 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 1) | |
2013 return \"add %0,%0\"; | |
2014 | |
2015 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 2) | |
2016 return \"asl2 %0\"; | |
2017 | |
2018 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 3 | |
2019 && REGNO_REG_CLASS (true_regnum (operands[0])) == DATA_REGS) | |
2020 return \"asl2 %0\;add %0,%0\"; | |
2021 | |
2022 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 4 | |
2023 && REGNO_REG_CLASS (true_regnum (operands[0])) == DATA_REGS) | |
2024 return \"asl2 %0\;asl2 %0\"; | |
2025 | |
2026 if (true_regnum (operands[1]) == true_regnum (operands[0])) | |
2027 return \"asl %S2,%0\"; | |
2028 | |
2029 if (REGNO_REG_CLASS (true_regnum (operands[0])) == DATA_REGS | |
2030 && REGNO_REG_CLASS (true_regnum (operands[1])) == DATA_REGS | |
2031 && true_regnum (operands[0]) != true_regnum (operands[2])) | |
2032 return \"mov %1,%0\;asl %S2,%0\"; | |
2033 return \"asl %2,%1,%0\"; | |
2034 }" | |
2035 [(set_attr "cc" "set_zn")]) | |
2036 | |
2037 (define_insn "" | |
2038 [(set (match_operand:SI 0 "register_operand" "=dax,dx,dx,dx,dx") | |
2039 (ashift:SI | |
2040 (match_operand:SI 1 "register_operand" "0,0,0,0,0") | |
2041 (match_operand:QI 2 "nonmemory_operand" "J,K,M,L,dxi")))] | |
2042 "" | |
2043 "@ | |
2044 add %0,%0 | |
2045 asl2 %0 | |
2046 asl2 %0\;add %0,%0 | |
2047 asl2 %0\;asl2 %0 | |
2048 asl %S2,%0" | |
2049 [(set_attr "cc" "set_zn")]) | |
2050 | |
2051 (define_expand "lshrsi3" | |
2052 [(set (match_operand:SI 0 "register_operand" "") | |
2053 (lshiftrt:SI | |
2054 (match_operand:SI 1 "register_operand" "") | |
2055 (match_operand:QI 2 "nonmemory_operand" "")))] | |
2056 "" | |
2057 "") | |
2058 | |
2059 (define_insn "" | |
2060 [(set (match_operand:SI 0 "register_operand" "=dx,!dax") | |
2061 (lshiftrt:SI | |
2062 (match_operand:SI 1 "register_operand" "0,dax") | |
2063 (match_operand:QI 2 "nonmemory_operand" "dxi,dax")))] | |
2064 "TARGET_AM33" | |
2065 "* | |
2066 { | |
2067 if (true_regnum (operands[1]) == true_regnum (operands[0])) | |
2068 return \"lsr %S2,%0\"; | |
2069 | |
2070 if (REGNO_REG_CLASS (true_regnum (operands[0])) == DATA_REGS | |
2071 && REGNO_REG_CLASS (true_regnum (operands[1])) == DATA_REGS | |
2072 && true_regnum (operands[0]) != true_regnum (operands[2])) | |
2073 return \"mov %1,%0\;lsr %S2,%0\"; | |
2074 return \"lsr %2,%1,%0\"; | |
2075 }" | |
2076 [(set_attr "cc" "set_zn")]) | |
2077 | |
2078 (define_insn "" | |
2079 [(set (match_operand:SI 0 "register_operand" "=dx") | |
2080 (lshiftrt:SI | |
2081 (match_operand:SI 1 "register_operand" "0") | |
2082 (match_operand:QI 2 "nonmemory_operand" "dxi")))] | |
2083 "" | |
2084 "lsr %S2,%0" | |
2085 [(set_attr "cc" "set_zn")]) | |
2086 | |
2087 (define_expand "ashrsi3" | |
2088 [(set (match_operand:SI 0 "register_operand" "") | |
2089 (ashiftrt:SI | |
2090 (match_operand:SI 1 "register_operand" "") | |
2091 (match_operand:QI 2 "nonmemory_operand" "")))] | |
2092 "" | |
2093 "") | |
2094 | |
2095 (define_insn "" | |
2096 [(set (match_operand:SI 0 "register_operand" "=dx,!dax") | |
2097 (ashiftrt:SI | |
2098 (match_operand:SI 1 "register_operand" "0,dax") | |
2099 (match_operand:QI 2 "nonmemory_operand" "dxi,dax")))] | |
2100 "TARGET_AM33" | |
2101 "* | |
2102 { | |
2103 if (true_regnum (operands[1]) == true_regnum (operands[0])) | |
2104 return \"asr %S2,%0\"; | |
2105 | |
2106 if (REGNO_REG_CLASS (true_regnum (operands[0])) == DATA_REGS | |
2107 && REGNO_REG_CLASS (true_regnum (operands[1])) == DATA_REGS | |
2108 && true_regnum (operands[0]) != true_regnum (operands[2])) | |
2109 return \"mov %1,%0\;asr %S2,%0\"; | |
2110 return \"asr %2,%1,%0\"; | |
2111 }" | |
2112 [(set_attr "cc" "set_zn")]) | |
2113 | |
2114 (define_insn "" | |
2115 [(set (match_operand:SI 0 "register_operand" "=dx") | |
2116 (ashiftrt:SI | |
2117 (match_operand:SI 1 "register_operand" "0") | |
2118 (match_operand:QI 2 "nonmemory_operand" "dxi")))] | |
2119 "" | |
2120 "asr %S2,%0" | |
2121 [(set_attr "cc" "set_zn")]) | |
2122 | 1815 |
2123 ;; ---------------------------------------------------------------------- | 1816 ;; ---------------------------------------------------------------------- |
2124 ;; FP INSTRUCTIONS | 1817 ;; FP INSTRUCTIONS |
2125 ;; ---------------------------------------------------------------------- | 1818 ;; ---------------------------------------------------------------------- |
2126 ;; | 1819 |
2127 ;; The mn103 series does not have floating point instructions, but since | 1820 (define_insn "abssf2" |
2128 ;; FP values are held in integer regs, we can clear the high bit easily | 1821 [(set (match_operand:SF 0 "register_operand" "=f,f") |
2129 ;; which gives us an efficient inline floating point absolute value. | |
2130 ;; | |
2131 ;; Similarly for negation of a FP value. | |
2132 ;; | |
2133 | |
2134 (define_expand "absdf2" | |
2135 [(set (match_operand:DF 0 "register_operand" "") | |
2136 (abs:DF (match_operand:DF 1 "register_operand" "")))] | |
2137 "" | |
2138 " | |
2139 { | |
2140 rtx target, result, insns; | |
2141 | |
2142 start_sequence (); | |
2143 target = operand_subword (operands[0], 1, 1, DFmode); | |
2144 result = expand_binop (SImode, and_optab, | |
2145 operand_subword_force (operands[1], 1, DFmode), | |
2146 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN); | |
2147 | |
2148 gcc_assert (result); | |
2149 | |
2150 if (result != target) | |
2151 emit_move_insn (result, target); | |
2152 | |
2153 emit_move_insn (operand_subword (operands[0], 0, 1, DFmode), | |
2154 operand_subword_force (operands[1], 0, DFmode)); | |
2155 | |
2156 insns = get_insns (); | |
2157 end_sequence (); | |
2158 | |
2159 emit_insn (insns); | |
2160 DONE; | |
2161 }") | |
2162 | |
2163 (define_expand "abssf2" | |
2164 [(set (match_operand:SF 0 "register_operand" "") | |
2165 (abs:SF (match_operand:SF 1 "register_operand" "")))] | |
2166 "" | |
2167 " | |
2168 { | |
2169 rtx result; | |
2170 rtx target; | |
2171 | |
2172 if (TARGET_AM33_2) | |
2173 { | |
2174 emit_insn (gen_abssf2_am33_2 (operands[0], operands[1])); | |
2175 DONE; | |
2176 } | |
2177 | |
2178 target = operand_subword_force (operands[0], 0, SFmode); | |
2179 result = expand_binop (SImode, and_optab, | |
2180 operand_subword_force (operands[1], 0, SFmode), | |
2181 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN); | |
2182 gcc_assert (result); | |
2183 | |
2184 if (result != target) | |
2185 emit_move_insn (result, target); | |
2186 | |
2187 /* Make a place for REG_EQUAL. */ | |
2188 emit_move_insn (operands[0], operands[0]); | |
2189 DONE; | |
2190 }") | |
2191 | |
2192 | |
2193 (define_insn "abssf2_am33_2" | |
2194 [(set (match_operand:SF 0 "register_operand" "=f,f") | |
2195 (abs:SF (match_operand:SF 1 "register_operand" "0,?f")))] | 1822 (abs:SF (match_operand:SF 1 "register_operand" "0,?f")))] |
2196 "TARGET_AM33_2" | 1823 "TARGET_AM33_2" |
2197 "@ | 1824 "@ |
2198 fabs %0 | 1825 fabs %0 |
2199 fabs %1, %0" | 1826 fabs %1, %0" |
2200 [(set_attr "cc" "none_0hit")]) | 1827 [(set (attr "timings") (if_then_else (eq_attr "cpu" "am34") |
2201 | 1828 (const_int 17) (const_int 14)))] |
2202 (define_expand "negdf2" | 1829 ) |
2203 [(set (match_operand:DF 0 "register_operand" "") | 1830 |
2204 (neg:DF (match_operand:DF 1 "register_operand" "")))] | 1831 (define_insn "negsf2" |
2205 "" | 1832 [(set (match_operand:SF 0 "register_operand" "=f,f") |
2206 " | |
2207 { | |
2208 rtx target, result, insns; | |
2209 | |
2210 start_sequence (); | |
2211 target = operand_subword (operands[0], 1, 1, DFmode); | |
2212 result = expand_binop (SImode, xor_optab, | |
2213 operand_subword_force (operands[1], 1, DFmode), | |
2214 GEN_INT (trunc_int_for_mode (0x80000000, SImode)), | |
2215 target, 0, OPTAB_WIDEN); | |
2216 | |
2217 gcc_assert (result); | |
2218 | |
2219 if (result != target) | |
2220 emit_move_insn (result, target); | |
2221 | |
2222 emit_move_insn (operand_subword (operands[0], 0, 1, DFmode), | |
2223 operand_subword_force (operands[1], 0, DFmode)); | |
2224 | |
2225 insns = get_insns (); | |
2226 end_sequence (); | |
2227 | |
2228 emit_insn (insns); | |
2229 DONE; | |
2230 }") | |
2231 | |
2232 (define_expand "negsf2" | |
2233 [(set (match_operand:SF 0 "register_operand" "") | |
2234 (neg:SF (match_operand:SF 1 "register_operand" "")))] | |
2235 "" | |
2236 " | |
2237 { | |
2238 rtx result; | |
2239 rtx target; | |
2240 | |
2241 if (TARGET_AM33_2) | |
2242 { | |
2243 emit_insn (gen_negsf2_am33_2 (operands[0], operands[1])); | |
2244 DONE; | |
2245 } | |
2246 | |
2247 target = operand_subword_force (operands[0], 0, SFmode); | |
2248 result = expand_binop (SImode, xor_optab, | |
2249 operand_subword_force (operands[1], 0, SFmode), | |
2250 GEN_INT (trunc_int_for_mode (0x80000000, SImode)), | |
2251 target, 0, OPTAB_WIDEN); | |
2252 gcc_assert (result); | |
2253 | |
2254 if (result != target) | |
2255 emit_move_insn (result, target); | |
2256 | |
2257 /* Make a place for REG_EQUAL. */ | |
2258 emit_move_insn (operands[0], operands[0]); | |
2259 DONE; | |
2260 }") | |
2261 | |
2262 (define_insn "negsf2_am33_2" | |
2263 [(set (match_operand:SF 0 "register_operand" "=f,f") | |
2264 (neg:SF (match_operand:SF 1 "register_operand" "0,?f")))] | 1833 (neg:SF (match_operand:SF 1 "register_operand" "0,?f")))] |
2265 "TARGET_AM33_2" | 1834 "TARGET_AM33_2" |
2266 "@ | 1835 "@ |
2267 fneg %0 | 1836 fneg %0 |
2268 fneg %1, %0" | 1837 fneg %1, %0" |
2269 [(set_attr "cc" "none_0hit")]) | 1838 [(set (attr "timings") (if_then_else (eq_attr "cpu" "am34") |
1839 (const_int 17) (const_int 14)))] | |
1840 ) | |
2270 | 1841 |
2271 (define_expand "sqrtsf2" | 1842 (define_expand "sqrtsf2" |
2272 [(set (match_operand:SF 0 "register_operand" "") | 1843 [(set (match_operand:SF 0 "register_operand" "") |
2273 (sqrt:SF (match_operand:SF 1 "register_operand" "")))] | 1844 (sqrt:SF (match_operand:SF 1 "register_operand" "")))] |
2274 "TARGET_AM33_2 && flag_unsafe_math_optimizations" | 1845 "TARGET_AM33_2 && flag_unsafe_math_optimizations" |
2275 " | |
2276 { | 1846 { |
2277 rtx scratch = gen_reg_rtx (SFmode); | 1847 rtx scratch = gen_reg_rtx (SFmode); |
2278 emit_insn (gen_rsqrtsf2 (scratch, operands[1], CONST1_RTX (SFmode))); | 1848 emit_insn (gen_rsqrtsf2 (scratch, operands[1], CONST1_RTX (SFmode))); |
2279 emit_insn (gen_divsf3 (operands[0], force_reg (SFmode, CONST1_RTX (SFmode)), | 1849 emit_insn (gen_divsf3 (operands[0], force_reg (SFmode, CONST1_RTX (SFmode)), |
2280 scratch)); | 1850 scratch)); |
2281 DONE; | 1851 DONE; |
2282 }") | 1852 }) |
2283 | 1853 |
2284 (define_insn "rsqrtsf2" | 1854 (define_insn "rsqrtsf2" |
2285 [(set (match_operand:SF 0 "register_operand" "=f,f") | 1855 [(set (match_operand:SF 0 "register_operand" "=f,f") |
2286 (div:SF (match_operand:SF 2 "const_1f_operand" "F,F") | 1856 (div:SF (match_operand:SF 2 "const_1f_operand" "F,F") |
2287 (sqrt:SF (match_operand:SF 1 "register_operand" "0,?f"))))] | 1857 (sqrt:SF (match_operand:SF 1 "register_operand" "0,?f")))) |
1858 (clobber (reg:CC_FLOAT CC_REG))] | |
2288 "TARGET_AM33_2" | 1859 "TARGET_AM33_2" |
2289 "@ | 1860 "@ |
2290 frsqrt %0 | 1861 frsqrt %0 |
2291 frsqrt %1, %0" | 1862 frsqrt %1, %0" |
2292 [(set_attr "cc" "none_0hit")]) | 1863 [(set (attr "timings") (if_then_else (eq_attr "cpu" "am34") |
1864 (const_int 4753) (const_int 2327)))] | |
1865 ) | |
2293 | 1866 |
2294 (define_insn "addsf3" | 1867 (define_insn "addsf3" |
2295 [(set (match_operand:SF 0 "register_operand" "=f,f") | 1868 [(set (match_operand:SF 0 "register_operand" "=f,f") |
2296 (plus:SF (match_operand:SF 1 "register_operand" "%0,f") | 1869 (plus:SF (match_operand:SF 1 "register_operand" "%0,f") |
2297 (match_operand:SF 2 "general_operand" "f,?fF")))] | 1870 (match_operand:SF 2 "nonmemory_operand" "f,?fF"))) |
1871 (clobber (reg:CC_FLOAT CC_REG))] | |
2298 "TARGET_AM33_2" | 1872 "TARGET_AM33_2" |
2299 "@ | 1873 "@ |
2300 fadd %2, %0 | 1874 fadd %2, %0 |
2301 fadd %2, %1, %0" | 1875 fadd %2, %1, %0" |
2302 [(set_attr "cc" "none_0hit")]) | 1876 [(set_attr_alternative "timings" |
1877 [(if_then_else (eq_attr "cpu" "am34") | |
1878 (const_int 17) (const_int 14)) | |
1879 (if_then_else (eq_attr "cpu" "am34") | |
1880 (const_int 17) (const_int 25)) | |
1881 ])] | |
1882 ) | |
2303 | 1883 |
2304 (define_insn "subsf3" | 1884 (define_insn "subsf3" |
2305 [(set (match_operand:SF 0 "register_operand" "=f,f") | 1885 [(set (match_operand:SF 0 "register_operand" "=f,f") |
2306 (minus:SF (match_operand:SF 1 "register_operand" "0,f") | 1886 (minus:SF (match_operand:SF 1 "register_operand" "0,f") |
2307 (match_operand:SF 2 "general_operand" "f,?fF")))] | 1887 (match_operand:SF 2 "nonmemory_operand" "f,?fF"))) |
1888 (clobber (reg:CC_FLOAT CC_REG))] | |
2308 "TARGET_AM33_2" | 1889 "TARGET_AM33_2" |
2309 "@ | 1890 "@ |
2310 fsub %2, %0 | 1891 fsub %2, %0 |
2311 fsub %2, %1, %0" | 1892 fsub %2, %1, %0" |
2312 [(set_attr "cc" "none_0hit")]) | 1893 [(set_attr_alternative "timings" |
1894 [(if_then_else (eq_attr "cpu" "am34") | |
1895 (const_int 17) (const_int 14)) | |
1896 (if_then_else (eq_attr "cpu" "am34") | |
1897 (const_int 17) (const_int 25)) | |
1898 ])] | |
1899 ) | |
2313 | 1900 |
2314 (define_insn "mulsf3" | 1901 (define_insn "mulsf3" |
2315 [(set (match_operand:SF 0 "register_operand" "=f,f") | 1902 [(set (match_operand:SF 0 "register_operand" "=f,f") |
2316 (mult:SF (match_operand:SF 1 "register_operand" "%0,f") | 1903 (mult:SF (match_operand:SF 1 "register_operand" "%0,f") |
2317 (match_operand:SF 2 "general_operand" "f,?fF")))] | 1904 (match_operand:SF 2 "nonmemory_operand" "f,?fF"))) |
1905 (clobber (reg:CC_FLOAT CC_REG)) | |
1906 ] | |
2318 "TARGET_AM33_2" | 1907 "TARGET_AM33_2" |
2319 "@ | 1908 "@ |
2320 fmul %2, %0 | 1909 fmul %2, %0 |
2321 fmul %2, %1, %0" | 1910 fmul %2, %1, %0" |
2322 [(set_attr "cc" "none_0hit")]) | 1911 [(set_attr_alternative "timings" |
1912 [(if_then_else (eq_attr "cpu" "am34") | |
1913 (const_int 17) (const_int 14)) | |
1914 (if_then_else (eq_attr "cpu" "am34") | |
1915 (const_int 17) (const_int 25)) | |
1916 ])] | |
1917 ) | |
2323 | 1918 |
2324 (define_insn "divsf3" | 1919 (define_insn "divsf3" |
2325 [(set (match_operand:SF 0 "register_operand" "=f,f") | 1920 [(set (match_operand:SF 0 "register_operand" "=f,f") |
2326 (div:SF (match_operand:SF 1 "register_operand" "0,f") | 1921 (div:SF (match_operand:SF 1 "register_operand" "0,f") |
2327 (match_operand:SF 2 "general_operand" "f,?fF")))] | 1922 (match_operand:SF 2 "nonmemory_operand" "f,?fF"))) |
1923 (clobber (reg:CC_FLOAT CC_REG))] | |
2328 "TARGET_AM33_2" | 1924 "TARGET_AM33_2" |
2329 "@ | 1925 "@ |
2330 fdiv %2, %0 | 1926 fdiv %2, %0 |
2331 fdiv %2, %1, %0" | 1927 fdiv %2, %1, %0" |
2332 [(set_attr "cc" "none_0hit")]) | 1928 [(set_attr_alternative "timings" |
2333 | 1929 [(if_then_else (eq_attr "cpu" "am34") |
2334 (define_insn "fmaddsf4" | 1930 (const_int 2531) (const_int 1216)) |
2335 [(set (match_operand:SF 0 "register_operand" "=A") | 1931 (if_then_else (eq_attr "cpu" "am34") |
2336 (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "%f") | 1932 (const_int 2531) (const_int 1317)) |
2337 (match_operand:SF 2 "register_operand" "f")) | 1933 ])] |
2338 (match_operand:SF 3 "register_operand" "f")))] | 1934 ) |
1935 | |
1936 (define_insn "fmasf4" | |
1937 [(set (match_operand:SF 0 "register_operand" "=c") | |
1938 (fma:SF (match_operand:SF 1 "register_operand" "f") | |
1939 (match_operand:SF 2 "register_operand" "f") | |
1940 (match_operand:SF 3 "register_operand" "f"))) | |
1941 (clobber (reg:CC_FLOAT CC_REG)) | |
1942 ] | |
2339 "TARGET_AM33_2" | 1943 "TARGET_AM33_2" |
2340 "fmadd %1, %2, %3, %0" | 1944 "fmadd %1, %2, %3, %0" |
2341 [(set_attr "cc" "none_0hit")]) | 1945 [(set (attr "timings") (if_then_else (eq_attr "cpu" "am34") |
2342 | 1946 (const_int 17) (const_int 24)))] |
2343 (define_insn "fmsubsf4" | 1947 ) |
2344 [(set (match_operand:SF 0 "register_operand" "=A") | 1948 |
2345 (minus:SF (mult:SF (match_operand:SF 1 "register_operand" "%f") | 1949 (define_insn "fmssf4" |
2346 (match_operand:SF 2 "register_operand" "f")) | 1950 [(set (match_operand:SF 0 "register_operand" "=c") |
2347 (match_operand:SF 3 "register_operand" "f")))] | 1951 (fma:SF (match_operand:SF 1 "register_operand" "f") |
1952 (match_operand:SF 2 "register_operand" "f") | |
1953 (neg:SF (match_operand:SF 3 "register_operand" "f")))) | |
1954 (clobber (reg:CC_FLOAT CC_REG)) | |
1955 ] | |
2348 "TARGET_AM33_2" | 1956 "TARGET_AM33_2" |
2349 "fmsub %1, %2, %3, %0" | 1957 "fmsub %1, %2, %3, %0" |
2350 [(set_attr "cc" "none_0hit")]) | 1958 [(set (attr "timings") (if_then_else (eq_attr "cpu" "am34") |
2351 | 1959 (const_int 17) (const_int 24)))] |
2352 (define_insn "fnmaddsf4" | 1960 ) |
2353 [(set (match_operand:SF 0 "register_operand" "=A") | 1961 |
2354 (minus:SF (match_operand:SF 3 "register_operand" "f") | 1962 (define_insn "fnmasf4" |
2355 (mult:SF (match_operand:SF 1 "register_operand" "%f") | 1963 [(set (match_operand:SF 0 "register_operand" "=c") |
2356 (match_operand:SF 2 "register_operand" "f"))))] | 1964 (fma:SF (neg:SF (match_operand:SF 1 "register_operand" "f")) |
1965 (match_operand:SF 2 "register_operand" "f") | |
1966 (match_operand:SF 3 "register_operand" "f"))) | |
1967 (clobber (reg:CC_FLOAT CC_REG)) | |
1968 ] | |
2357 "TARGET_AM33_2" | 1969 "TARGET_AM33_2" |
2358 "fnmadd %1, %2, %3, %0" | 1970 "fnmadd %1, %2, %3, %0" |
2359 [(set_attr "cc" "none_0hit")]) | 1971 [(set (attr "timings") (if_then_else (eq_attr "cpu" "am34") |
2360 | 1972 (const_int 17) (const_int 24)))] |
2361 (define_insn "fnmsubsf4" | 1973 ) |
2362 [(set (match_operand:SF 0 "register_operand" "=A") | 1974 |
2363 (minus:SF (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "%f") | 1975 (define_insn "fnmssf4" |
2364 (match_operand:SF 2 "register_operand" "f"))) | 1976 [(set (match_operand:SF 0 "register_operand" "=c") |
2365 (match_operand:SF 3 "register_operand" "f")))] | 1977 (fma:SF (neg:SF (match_operand:SF 1 "register_operand" "f")) |
1978 (match_operand:SF 2 "register_operand" "f") | |
1979 (neg:SF (match_operand:SF 3 "register_operand" "f")))) | |
1980 (clobber (reg:CC_FLOAT CC_REG)) | |
1981 ] | |
2366 "TARGET_AM33_2" | 1982 "TARGET_AM33_2" |
2367 "fnmsub %1, %2, %3, %0" | 1983 "fnmsub %1, %2, %3, %0" |
2368 [(set_attr "cc" "none_0hit")]) | 1984 [(set (attr "timings") (if_then_else (eq_attr "cpu" "am34") |
2369 | 1985 (const_int 17) (const_int 24)))] |
1986 ) | |
2370 | 1987 |
2371 ;; ---------------------------------------------------------------------- | 1988 ;; ---------------------------------------------------------------------- |
2372 ;; PROLOGUE/EPILOGUE | 1989 ;; PROLOGUE/EPILOGUE |
2373 ;; ---------------------------------------------------------------------- | 1990 ;; ---------------------------------------------------------------------- |
2374 (define_expand "prologue" | 1991 (define_expand "prologue" |
2375 [(const_int 0)] | 1992 [(const_int 0)] |
2376 "" | 1993 "" |
2377 "expand_prologue (); DONE;") | 1994 { mn10300_expand_prologue (); DONE; } |
1995 ) | |
2378 | 1996 |
2379 (define_expand "epilogue" | 1997 (define_expand "epilogue" |
2380 [(return)] | 1998 [(return)] |
2381 "" | 1999 "" |
2382 " | 2000 { mn10300_expand_epilogue (); DONE; } |
2383 { | 2001 ) |
2384 expand_epilogue (); | 2002 |
2385 DONE; | 2003 (define_insn "return" |
2386 }") | 2004 [(return)] |
2387 | 2005 "mn10300_can_use_rets_insn ()" |
2388 (define_insn "return_internal" | 2006 { |
2389 [(const_int 2) | 2007 /* The RETF insn is 4 cycles faster than RETS, though 1 byte larger. */ |
2390 (return)] | 2008 if (optimize_insn_for_speed_p () && mn10300_can_use_retf_insn ()) |
2391 "" | 2009 return "retf [],0"; |
2392 "rets" | 2010 else |
2393 [(set_attr "cc" "clobber")]) | 2011 return "rets"; |
2394 | 2012 }) |
2395 ;; This insn restores the callee saved registers and does a return, it | 2013 |
2396 ;; can also deallocate stack space. | 2014 (define_insn "return_ret" |
2397 (define_insn "return_internal_regs" | 2015 [(return) |
2398 [(const_int 0) | 2016 (use (match_operand:SI 0 "const_int_operand" ""))] |
2399 (match_operand:SI 0 "const_int_operand" "i") | 2017 "" |
2400 (return)] | 2018 { |
2401 "" | 2019 /* The RETF insn is up to 3 cycles faster than RET. */ |
2402 "* | 2020 fputs ((mn10300_can_use_retf_insn () ? "\tretf " : "\tret "), asm_out_file); |
2403 { | |
2404 fputs (\"\\tret \", asm_out_file); | |
2405 mn10300_print_reg_list (asm_out_file, mn10300_get_live_callee_saved_regs ()); | 2021 mn10300_print_reg_list (asm_out_file, mn10300_get_live_callee_saved_regs ()); |
2406 fprintf (asm_out_file, \",%d\\n\", (int) INTVAL (operands[0])); | 2022 fprintf (asm_out_file, ",%d\n", (int) INTVAL (operands[0])); |
2407 return \"\"; | 2023 return ""; |
2408 }" | 2024 }) |
2409 [(set_attr "cc" "clobber")]) | |
2410 | 2025 |
2411 ;; This instruction matches one generated by mn10300_gen_multiple_store() | 2026 ;; This instruction matches one generated by mn10300_gen_multiple_store() |
2412 (define_insn "store_movm" | 2027 (define_insn "store_movm" |
2413 [(match_parallel 0 "store_multiple_operation" | 2028 [(match_parallel 0 "mn10300_store_multiple_operation" |
2414 [(set (reg:SI 9) (plus:SI (reg:SI 9) (match_operand 1 "" "")))])] | 2029 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (match_operand 1 "" "")))])] |
2415 "" | 2030 "" |
2416 "* | 2031 { |
2417 { | 2032 fputs ("\tmovm ", asm_out_file); |
2418 fputs (\"\\tmovm \", asm_out_file); | |
2419 mn10300_print_reg_list (asm_out_file, | 2033 mn10300_print_reg_list (asm_out_file, |
2420 store_multiple_operation (operands[0], VOIDmode)); | 2034 mn10300_store_multiple_operation (operands[0], |
2421 fprintf (asm_out_file, \",(sp)\\n\"); | 2035 VOIDmode)); |
2422 return \"\"; | 2036 fprintf (asm_out_file, ",(sp)\n"); |
2423 }" | 2037 return ""; |
2424 [(set_attr "cc" "clobber")]) | 2038 } |
2425 | 2039 ;; Assume that no more than 8 registers will be pushed. |
2426 (define_insn "return" | 2040 [(set (attr "timings") (if_then_else (eq_attr "cpu" "am34") |
2427 [(return)] | 2041 (const_int 99) (const_int 88)))] |
2428 "can_use_return_insn ()" | 2042 ) |
2429 "* | 2043 |
2430 { | 2044 (define_expand "load_pic" |
2431 rtx next = next_active_insn (insn); | 2045 [(const_int 0)] |
2432 | 2046 "flag_pic" |
2433 if (next | 2047 { |
2434 && GET_CODE (next) == JUMP_INSN | 2048 if (TARGET_AM33) |
2435 && GET_CODE (PATTERN (next)) == RETURN) | 2049 emit_insn (gen_am33_load_pic (pic_offset_table_rtx)); |
2436 return \"\"; | 2050 else if (mn10300_frame_size () == 0) |
2051 emit_insn (gen_mn10300_load_pic0 (pic_offset_table_rtx)); | |
2437 else | 2052 else |
2438 return \"rets\"; | 2053 emit_insn (gen_mn10300_load_pic1 (pic_offset_table_rtx)); |
2439 }" | |
2440 [(set_attr "cc" "clobber")]) | |
2441 | |
2442 ;; Try to combine consecutive updates of the stack pointer (or any | |
2443 ;; other register for that matter). | |
2444 (define_peephole | |
2445 [(set (match_operand:SI 0 "register_operand" "=dxay") | |
2446 (plus:SI (match_dup 0) | |
2447 (match_operand 1 "const_int_operand" ""))) | |
2448 (set (match_dup 0) | |
2449 (plus:SI (match_dup 0) | |
2450 (match_operand 2 "const_int_operand" "")))] | |
2451 "" | |
2452 "* | |
2453 { | |
2454 operands[1] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[1])); | |
2455 return \"add %1,%0\"; | |
2456 }" | |
2457 [(set_attr "cc" "clobber")]) | |
2458 | |
2459 ;; | |
2460 ;; We had patterns to check eq/ne, but the they don't work because | |
2461 ;; 0x80000000 + 0x80000000 = 0x0 with a carry out. | |
2462 ;; | |
2463 ;; The Z flag and C flag would be set, and we have no way to | |
2464 ;; check for the Z flag set and C flag clear. | |
2465 ;; | |
2466 ;; This will work on the mn10200 because we can check the ZX flag | |
2467 ;; if the comparison is in HImode. | |
2468 (define_peephole | |
2469 [(set (cc0) (compare (match_operand:SI 0 "register_operand" "dx") | |
2470 (const_int 0))) | |
2471 (set (pc) (if_then_else (ge (cc0) (const_int 0)) | |
2472 (match_operand 1 "" "") | |
2473 (pc)))] | |
2474 "dead_or_set_p (ins1, operands[0]) && REG_OK_FOR_INDEX_P (operands[0])" | |
2475 "add %0,%0\;bcc %1" | |
2476 [(set_attr "cc" "clobber")]) | |
2477 | |
2478 (define_peephole | |
2479 [(set (cc0) (compare (match_operand:SI 0 "register_operand" "dx") | |
2480 (const_int 0))) | |
2481 (set (pc) (if_then_else (lt (cc0) (const_int 0)) | |
2482 (match_operand 1 "" "") | |
2483 (pc)))] | |
2484 "dead_or_set_p (ins1, operands[0]) && REG_OK_FOR_INDEX_P (operands[0])" | |
2485 "add %0,%0\;bcs %1" | |
2486 [(set_attr "cc" "clobber")]) | |
2487 | |
2488 (define_peephole | |
2489 [(set (cc0) (compare (match_operand:SI 0 "register_operand" "dx") | |
2490 (const_int 0))) | |
2491 (set (pc) (if_then_else (ge (cc0) (const_int 0)) | |
2492 (pc) | |
2493 (match_operand 1 "" "")))] | |
2494 "dead_or_set_p (ins1, operands[0]) && REG_OK_FOR_INDEX_P (operands[0])" | |
2495 "add %0,%0\;bcs %1" | |
2496 [(set_attr "cc" "clobber")]) | |
2497 | |
2498 (define_peephole | |
2499 [(set (cc0) (compare (match_operand:SI 0 "register_operand" "dx") | |
2500 (const_int 0))) | |
2501 (set (pc) (if_then_else (lt (cc0) (const_int 0)) | |
2502 (pc) | |
2503 (match_operand 1 "" "")))] | |
2504 "dead_or_set_p (ins1, operands[0]) && REG_OK_FOR_INDEX_P (operands[0])" | |
2505 "add %0,%0\;bcc %1" | |
2506 [(set_attr "cc" "clobber")]) | |
2507 | |
2508 (define_expand "int_label" | |
2509 [(unspec [(match_operand:SI 0 "" "")] UNSPEC_INT_LABEL)] | |
2510 "" "") | |
2511 | |
2512 (define_expand "GOTaddr2picreg" | |
2513 [(match_dup 0)] | |
2514 "" " | |
2515 { | |
2516 /* It would be nice to be able to have int_label keep track of the | |
2517 counter and all, but if we add C code to it, we'll get an insn | |
2518 back, and we just want the pattern. */ | |
2519 operands[0] = gen_int_label (GEN_INT (mn10300_unspec_int_label_counter++)); | |
2520 if (TARGET_AM33) | |
2521 emit_insn (gen_am33_loadPC (operands[0])); | |
2522 else | |
2523 emit_insn (gen_mn10300_loadPC (operands[0])); | |
2524 emit_insn (gen_add_GOT_to_pic_reg (copy_rtx (operands[0]))); | |
2525 DONE; | 2054 DONE; |
2055 }) | |
2056 | |
2057 (define_insn "am33_load_pic" | |
2058 [(set (match_operand:SI 0 "register_operand" "=a") | |
2059 (unspec:SI [(const_int 0)] UNSPEC_GOT)) | |
2060 (clobber (reg:CC CC_REG))] | |
2061 "TARGET_AM33" | |
2062 { | |
2063 operands[1] = gen_rtx_SYMBOL_REF (VOIDmode, GOT_SYMBOL_NAME); | |
2064 return ".LPIC%=:\;mov pc,%0\;add %1-(.LPIC%=-.),%0"; | |
2526 } | 2065 } |
2527 ") | 2066 [(set_attr "timings" "33")] |
2528 | 2067 ) |
2529 (define_insn "am33_loadPC" | 2068 |
2530 [(parallel | 2069 ;; Load pic register with push/pop of stack. |
2531 [(set (reg:SI PIC_REG) (pc)) | 2070 (define_insn "mn10300_load_pic0" |
2532 (use (match_operand 0 "" ""))])] | 2071 [(set (match_operand:SI 0 "register_operand" "=a") |
2533 "TARGET_AM33" | 2072 (unspec:SI [(const_int 0)] UNSPEC_GOT)) |
2534 "%0:\;mov pc,a2") | 2073 (clobber (reg:SI MDR_REG)) |
2535 | 2074 (clobber (reg:CC CC_REG))] |
2536 | 2075 "" |
2537 (define_insn_and_split "mn10300_loadPC" | 2076 { |
2538 [(parallel | 2077 operands[1] = gen_rtx_SYMBOL_REF (VOIDmode, GOT_SYMBOL_NAME); |
2539 [(set (reg:SI PIC_REG) (pc)) | 2078 return ("add -4,sp\;" |
2540 (use (match_operand 0 "" ""))])] | 2079 "calls .LPIC%=\n" |
2541 "" | 2080 ".LPIC%=:\;" |
2542 "#" | 2081 "movm (sp),[%0]\;" |
2543 "reload_completed" | 2082 "add %1-(.LPIC%=-.),%0"); |
2544 [(match_operand 0 "" "")] | 2083 } |
2545 " | 2084 [(set_attr "timings" "88")] |
2546 { | 2085 ) |
2547 rtx sp_reg = gen_rtx_REG (SImode, SP_REG); | 2086 |
2548 int need_stack_space = (get_frame_size () == 0 | 2087 ;; Load pic register re-using existing stack space. |
2549 && crtl->outgoing_args_size == 0); | 2088 (define_insn "mn10300_load_pic1" |
2550 | 2089 [(set (match_operand:SI 0 "register_operand" "=a") |
2551 if (need_stack_space) | 2090 (unspec:SI [(const_int 0)] UNSPEC_GOT)) |
2552 emit_move_insn (sp_reg, plus_constant (sp_reg, -4)); | 2091 (clobber (mem:SI (reg:SI SP_REG))) |
2553 | 2092 (clobber (reg:SI MDR_REG)) |
2554 emit_insn (gen_call_next_insn (operands[0])); | 2093 (clobber (reg:CC CC_REG))] |
2555 | 2094 "" |
2556 if (need_stack_space) | 2095 { |
2557 emit_insn (gen_pop_pic_reg ()); | 2096 operands[1] = gen_rtx_SYMBOL_REF (VOIDmode, GOT_SYMBOL_NAME); |
2558 else | 2097 return ("calls .LPIC%=\n" |
2559 emit_move_insn (pic_offset_table_rtx, gen_rtx_MEM (SImode, sp_reg)); | 2098 ".LPIC%=:\;" |
2560 | 2099 "mov (sp),%0\;" |
2561 DONE; | 2100 "add %1-(.LPIC%=-.),%0"); |
2562 }") | 2101 } |
2563 | 2102 [(set_attr "timings" "66")] |
2564 (define_insn "call_next_insn" | 2103 ) |
2565 [(parallel | 2104 |
2566 [(set (mem:SI (reg:SI SP_REG)) (pc)) | 2105 ;; The mode on operand 3 has been deliberately omitted because it |
2567 (use (match_operand 0 "" ""))])] | 2106 ;; can be either SI (for arithmetic operations) or QI (for shifts). |
2568 "reload_completed" | 2107 (define_insn "liw" |
2569 "calls %0\;%0:") | 2108 [(set (match_operand:SI 0 "register_operand" "=r") |
2570 | 2109 (unspec:SI [(match_dup 0) |
2571 (define_expand "add_GOT_to_pic_reg" | 2110 (match_operand 2 "liw_operand" "rO") |
2572 [(set (reg:SI PIC_REG) | 2111 (match_operand:SI 4 "const_int_operand" "")] |
2573 (plus:SI | 2112 UNSPEC_LIW)) |
2574 (reg:SI PIC_REG) | 2113 (set (match_operand:SI 1 "register_operand" "=r") |
2575 (const:SI | 2114 (unspec:SI [(match_dup 1) |
2576 (unspec:SI [(match_operand:SI 0 "" "")] UNSPEC_GOTSYM_OFF))))] | 2115 (match_operand 3 "liw_operand" "rO") |
2577 "") | 2116 (match_operand:SI 5 "const_int_operand" "")] |
2578 | 2117 UNSPEC_LIW))] |
2579 (define_expand "symGOT2reg" | 2118 "TARGET_ALLOW_LIW" |
2580 [(match_operand:SI 0 "" "") | 2119 "%W4_%W5 %2, %0, %3, %1" |
2581 (match_operand:SI 1 "" "")] | 2120 [(set (attr "timings") (if_then_else (eq_attr "cpu" "am34") |
2582 "" | 2121 (const_int 13) (const_int 12)))] |
2583 " | 2122 ) |
2584 { | 2123 |
2585 rtx insn = emit_insn (gen_symGOT2reg_i (operands[0], operands[1])); | 2124 ;; The mode on operand 1 has been deliberately omitted because it |
2586 | 2125 ;; can be either SI (for arithmetic operations) or QI (for shifts). |
2587 MEM_READONLY_P (SET_SRC (PATTERN (insn))) = 1; | 2126 (define_insn "cmp_liw" |
2588 | 2127 [(set (reg:CC CC_REG) |
2589 set_unique_reg_note (insn, REG_EQUAL, operands[1]); | 2128 (compare:CC (match_operand:SI 2 "register_operand" "r") |
2590 | 2129 (match_operand 3 "liw_operand" "rO"))) |
2591 DONE; | 2130 (set (match_operand:SI 0 "register_operand" "=r") |
2592 }") | 2131 (unspec:SI [(match_dup 0) |
2593 | 2132 (match_operand 1 "liw_operand" "rO") |
2594 (define_expand "symGOT2reg_i" | 2133 (match_operand:SI 4 "const_int_operand" "")] |
2595 [(set (match_operand:SI 0 "" "") | 2134 UNSPEC_LIW))] |
2596 (mem:SI (plus:SI (reg:SI PIC_REG) | 2135 "TARGET_ALLOW_LIW" |
2597 (const (unspec [(match_operand:SI 1 "" "")] | 2136 "cmp_%W4 %3, %2, %1, %0" |
2598 UNSPEC_GOT)))))] | 2137 [(set (attr "timings") (if_then_else (eq_attr "cpu" "am34") |
2599 "" | 2138 (const_int 13) (const_int 12)))] |
2600 "") | 2139 ) |
2601 | 2140 |
2602 (define_expand "symGOTOFF2reg" | 2141 (define_insn "liw_cmp" |
2603 [(match_operand:SI 0 "" "") (match_operand:SI 1 "" "")] | 2142 [(set (match_operand:SI 0 "register_operand" "=r") |
2604 "" | 2143 (unspec:SI [(match_dup 0) |
2605 " | 2144 (match_operand 1 "liw_operand" "rO") |
2606 { | 2145 (match_operand:SI 4 "const_int_operand" "")] |
2607 rtx insn = emit_insn (gen_symGOTOFF2reg_i (operands[0], operands[1])); | 2146 UNSPEC_LIW)) |
2608 | 2147 (set (reg:CC CC_REG) |
2609 set_unique_reg_note (insn, REG_EQUAL, operands[1]); | 2148 (compare:CC (match_operand:SI 2 "register_operand" "r") |
2610 | 2149 (match_operand 3 "liw_operand" "rO")))] |
2611 DONE; | 2150 "TARGET_ALLOW_LIW" |
2612 }") | 2151 "%W4_cmp %1, %0, %3, %2" |
2613 | 2152 [(set (attr "timings") (if_then_else (eq_attr "cpu" "am34") |
2614 (define_expand "symGOTOFF2reg_i" | 2153 (const_int 13) (const_int 12)))] |
2615 [(set (match_operand:SI 0 "" "") | 2154 ) |
2616 (const (unspec [(match_operand:SI 1 "" "")] UNSPEC_GOTOFF))) | |
2617 (set (match_dup 0) (plus:SI (match_dup 0) (reg:SI PIC_REG)))] | |
2618 "" | |
2619 "") | |
2620 | |
2621 (define_expand "sym2PIC" | |
2622 [(unspec [(match_operand:SI 0 "" "")] UNSPEC_PIC)] | |
2623 "" "") | |
2624 | |
2625 (define_expand "sym2PLT" | |
2626 [(unspec [(match_operand:SI 0 "" "")] UNSPEC_PLT)] | |
2627 "" "") |