Debian Codegraph @

gcc/config/h8300/extensions.md

raw
1 ;; ----------------------------------------------------------------------
2 ;; EXTEND INSTRUCTIONS
3 ;; ----------------------------------------------------------------------
4
5 (define_expand "zero_extendqi<mode>2"
6 [(set (match_operand:HSI 0 "register_operand" "")
7 (zero_extend:HSI (match_operand:QI 1 "general_operand_src" "")))]
8 ""
9 {
10 if (TARGET_H8300SX)
11 operands[1] = force_reg (QImode, operands[1]);
12 })
13
14 (define_insn_and_split "*zero_extendqihi2"
15 [(set (match_operand:HI 0 "register_operand" "=r,r,r")
16 (zero_extend:HI (match_operand:QI 1 "general_operand_src" "0,r,g>")))]
17 ""
18 "#"
19 "&& reload_completed"
20 [(parallel [(set (match_dup 0) (zero_extend:HI (match_dup 1)))
21 (clobber (reg:CC CC_REG))])])
22
23 (define_insn "*zero_extendqihi2<cczn>"
24 [(set (match_operand:HI 0 "register_operand" "=r,r,r")
25 (zero_extend:HI (match_operand:QI 1 "general_operand_src" "0,r,g>")))
26 (clobber (reg:CC CC_REG))]
27 ""
28 "@
29 extu.w %T0
30 mov.b\t%X1,%R0\;extu.w\t%T0
31 #"
32 [(set_attr "length" "2,4,10")])
33
34 ;; Split the zero extension of a general operand (actually a memory
35 ;; operand) into a load of the operand and the actual zero extension
36 ;; so that 1) the length will be accurate, and 2) the zero extensions
37 ;; appearing at the end of basic blocks may be merged.
38
39 (define_split
40 [(set (match_operand:HI 0 "register_operand" "")
41 (zero_extend:HI (match_operand:QI 1 "general_operand_src" "")))
42 (clobber (reg:CC CC_REG))]
43 "reload_completed"
44 [(set (match_dup 2) (match_dup 1))
45 (parallel [(set (match_dup 0) (zero_extend:HI (match_dup 2)))
46 (clobber (reg:CC CC_REG))])]
47 {
48 operands[2] = gen_rtx_REG (QImode, REGNO (operands[0]));
49 })
50
51 ;; Similarly, but setting cczn.
52 (define_split
53 [(set (reg:CCZN CC_REG)
54 (compare:CCZN
55 (zero_extend:HI (match_operand:QI 1 "general_operand_src" ""))
56 (const_int 0)))
57 (set (match_operand:HI 0 "register_operand" "")
58 (zero_extend:HI (match_dup 1)))]
59 "!REG_P (operands[1]) && reload_completed"
60 [(parallel [(set (match_dup 2) (match_dup 1))
61 (clobber (reg:CC CC_REG))])
62 (parallel [(set (reg:CCZN CC_REG)
63 (compare:CCZN (zero_extend:HI (match_dup 2)) (const_int 0)))
64 (set (match_dup 0) (zero_extend:HI (match_dup 2)))])]
65 {
66 operands[2] = gen_rtx_REG (QImode, REGNO (operands[0]));
67 })
68
69 (define_insn "*zero_extendqisi2"
70 [(set (match_operand:SI 0 "register_operand" "=r,r")
71 (zero_extend:SI (match_operand:QI 1 "general_operand_src" "0,g>")))]
72 "!reload_completed && !TARGET_H8300SX"
73 "#")
74
75 ;; Two cases for the !H8/SX target. One where there is an overlap
76 ;; between the source and destination, one where there is no overlap
77 (define_split
78 [(set (match_operand:SI 0 "register_operand" "")
79 (zero_extend:SI (match_operand:QI 1 "general_operand_src" "")))]
80 "!TARGET_H8300SX
81 && reg_overlap_mentioned_p (operands[0], operands[1])
82 && reload_completed"
83 [(parallel [(set (match_dup 2) (match_dup 1))
84 (clobber (reg:CC CC_REG))])
85 (parallel [(set (match_dup 3) (zero_extend:HI (match_dup 2)))
86 (clobber (reg:CC CC_REG))])
87 (parallel [(set (match_dup 0) (zero_extend:SI (match_dup 3)))
88 (clobber (reg:CC CC_REG))])]
89 {
90 operands[2] = gen_lowpart (QImode, operands[0]);
91 operands[3] = gen_lowpart (HImode, operands[0]);
92 })
93
94 (define_split
95 [(set (match_operand:SI 0 "register_operand" "")
96 (zero_extend:SI (match_operand:QI 1 "general_operand_src" "")))]
97 "!TARGET_H8300SX
98 && !reg_overlap_mentioned_p (operands[0], operands[1])
99 && reload_completed"
100 [(parallel [(set (match_dup 0) (const_int 0))
101 (clobber (reg:CC CC_REG))])
102 (parallel [(set (strict_low_part (match_dup 2)) (match_dup 1))
103 (clobber (reg:CC CC_REG))])]
104 {
105 operands[2] = gen_rtx_REG (QImode, REGNO (operands[0]));
106 })
107
108 (define_insn_and_split "*zero_extendqisi2_h8sx"
109 [(set (match_operand:SI 0 "register_operand" "=r")
110 (zero_extend:SI (match_operand:QI 1 "register_operand" "0")))]
111 "TARGET_H8300SX"
112 "#"
113 "&& reload_completed"
114 [(parallel [(set (match_dup 0) (zero_extend:SI (match_dup 1)))
115 (clobber (reg:CC CC_REG))])])
116
117 (define_insn "*zero_extendqisi2_h8sx<cczn>"
118 [(set (match_operand:SI 0 "register_operand" "=r")
119 (zero_extend:SI (match_operand:QI 1 "register_operand" "0")))
120 (clobber (reg:CC CC_REG))]
121 "TARGET_H8300SX"
122 "extu.l\t#2,%0"
123 [(set_attr "length" "2")])
124
125 (define_expand "zero_extendhisi2"
126 [(set (match_operand:SI 0 "register_operand" "")
127 (zero_extend:SI (match_operand:HI 1 "register_operand" "")))]
128 ""
129 "")
130
131 (define_insn_and_split "*zero_extendhisi2"
132 [(set (match_operand:SI 0 "register_operand" "=r")
133 (zero_extend:SI (match_operand:HI 1 "register_operand" "0")))]
134 ""
135 "#"
136 "&& reload_completed"
137 [(parallel [(set (match_dup 0) (zero_extend:SI (match_dup 1)))
138 (clobber (reg:CC CC_REG))])])
139
140 (define_insn "*zero_extendhisi2<cczn>"
141 [(set (match_operand:SI 0 "register_operand" "=r")
142 (zero_extend:SI (match_operand:HI 1 "register_operand" "0")))
143 (clobber (reg:CC CC_REG))]
144 ""
145 "extu.l %S0"
146 [(set_attr "length" "2")])
147
148 (define_expand "extendqi<mode>2"
149 [(set (match_operand:HSI 0 "register_operand" "")
150 (sign_extend:HSI (match_operand:QI 1 "register_operand" "")))]
151 ""
152 "")
153
154 (define_insn_and_split "*extendqihi2"
155 [(set (match_operand:HI 0 "register_operand" "=r")
156 (sign_extend:HI (match_operand:QI 1 "register_operand" "0")))]
157 ""
158 "#"
159 "&& reload_completed"
160 [(parallel [(set (match_dup 0) (sign_extend:HI (match_dup 1)))
161 (clobber (reg:CC CC_REG))])])
162
163 (define_insn "*extendqihi2<cczn>"
164 [(set (match_operand:HI 0 "register_operand" "=r")
165 (sign_extend:HI (match_operand:QI 1 "register_operand" "0")))
166 (clobber (reg:CC CC_REG))]
167 ""
168 "exts.w %T0"
169 [(set_attr "length" "2")])
170
171 ;; The following pattern is needed because without the pattern, the
172 ;; combiner would split (sign_extend:SI (reg:QI)) into two 24-bit
173 ;; shifts, one ashift and one ashiftrt.
174
175 (define_insn_and_split "*extendqisi2"
176 [(set (match_operand:SI 0 "register_operand" "=r")
177 (sign_extend:SI (match_operand:QI 1 "register_operand" "0")))]
178 "!TARGET_H8300SX"
179 "#"
180 "&& reload_completed"
181 [(parallel [(set (match_dup 2) (sign_extend:HI (match_dup 1)))
182 (clobber (reg:CC CC_REG))])
183 (parallel [(set (match_dup 0) (sign_extend:SI (match_dup 2)))
184 (clobber (reg:CC CC_REG))])]
185 {
186 operands[2] = gen_rtx_REG (HImode, REGNO (operands[0]));
187 })
188
189 (define_insn_and_split "*extendqisi2_h8sx"
190 [(set (match_operand:SI 0 "register_operand" "=r")
191 (sign_extend:SI (match_operand:QI 1 "register_operand" "0")))]
192 "TARGET_H8300SX"
193 "#"
194 "&& reload_completed"
195 [(parallel [(set (match_dup 0) (sign_extend:SI (match_dup 1)))
196 (clobber (reg:CC CC_REG))])])
197
198 (define_insn "*extendqisi2_h8sx<cczn>"
199 [(set (match_operand:SI 0 "register_operand" "=r")
200 (sign_extend:SI (match_operand:QI 1 "register_operand" "0")))
201 (clobber (reg:CC CC_REG))]
202 "TARGET_H8300SX"
203 "exts.l\t#2,%0"
204 [(set_attr "length" "2")])
205
206 (define_expand "extendhisi2"
207 [(set (match_operand:SI 0 "register_operand" "")
208 (sign_extend:SI (match_operand:HI 1 "register_operand" "")))]
209 ""
210 "")
211
212 (define_insn_and_split "*extendhisi2"
213 [(set (match_operand:SI 0 "register_operand" "=r")
214 (sign_extend:SI (match_operand:HI 1 "register_operand" "0")))]
215 ""
216 "#"
217 "&& reload_completed"
218 [(parallel [(set (match_dup 0) (sign_extend:SI (match_dup 1)))
219 (clobber (reg:CC CC_REG))])])
220
221 (define_insn "*extendhisi2<cczn>"
222 [(set (match_operand:SI 0 "register_operand" "=r")
223 (sign_extend:SI (match_operand:HI 1 "register_operand" "0")))
224 (clobber (reg:CC CC_REG))]
225 ""
226 "exts.l %S0"
227 [(set_attr "length" "2")])