Handle implicit zext in a better way. Shamelessly stolen from x86 backend.
[oota-llvm.git] / lib / Target / MSP430 / MSP430InstrInfo.td
1 //===- MSP430InstrInfo.td - MSP430 Instruction defs -----------*- tblgen-*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source 
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file describes the MSP430 instructions in TableGen format.
11 //
12 //===----------------------------------------------------------------------===//
13
14 include "MSP430InstrFormats.td"
15
16 //===----------------------------------------------------------------------===//
17 // Type Constraints.
18 //===----------------------------------------------------------------------===//
19 class SDTCisI8<int OpNum> : SDTCisVT<OpNum, i8>;
20 class SDTCisI16<int OpNum> : SDTCisVT<OpNum, i16>;
21
22 //===----------------------------------------------------------------------===//
23 // Type Profiles.
24 //===----------------------------------------------------------------------===//
25 def SDT_MSP430Call         : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
26 def SDT_MSP430CallSeqStart : SDCallSeqStart<[SDTCisVT<0, i16>]>;
27 def SDT_MSP430CallSeqEnd   : SDCallSeqEnd<[SDTCisVT<0, i16>, SDTCisVT<1, i16>]>;
28 def SDT_MSP430Wrapper      : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
29 def SDT_MSP430Cmp          : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
30 def SDT_MSP430BrCC         : SDTypeProfile<0, 2, [SDTCisVT<0, OtherVT>,
31                                                   SDTCisVT<1, i8>]>;
32 def SDT_MSP430SelectCC     : SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, 
33                                                   SDTCisVT<3, i8>]>;
34
35 //===----------------------------------------------------------------------===//
36 // MSP430 Specific Node Definitions.
37 //===----------------------------------------------------------------------===//
38 def MSP430retflag : SDNode<"MSP430ISD::RET_FLAG", SDTNone,
39                      [SDNPHasChain, SDNPOptInFlag]>;
40
41 def MSP430rra     : SDNode<"MSP430ISD::RRA", SDTIntUnaryOp, []>;
42 def MSP430rla     : SDNode<"MSP430ISD::RLA", SDTIntUnaryOp, []>;
43 def MSP430rrc     : SDNode<"MSP430ISD::RRC", SDTIntUnaryOp, []>;
44
45 def MSP430call    : SDNode<"MSP430ISD::CALL", SDT_MSP430Call,
46                      [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
47 def MSP430callseq_start :
48                  SDNode<"ISD::CALLSEQ_START", SDT_MSP430CallSeqStart,
49                         [SDNPHasChain, SDNPOutFlag]>;
50 def MSP430callseq_end :
51                  SDNode<"ISD::CALLSEQ_END",   SDT_MSP430CallSeqEnd,
52                         [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
53 def MSP430Wrapper : SDNode<"MSP430ISD::Wrapper", SDT_MSP430Wrapper>;
54 def MSP430cmp     : SDNode<"MSP430ISD::CMP", SDT_MSP430Cmp, [SDNPOutFlag]>;
55 def MSP430brcc    : SDNode<"MSP430ISD::BR_CC", SDT_MSP430BrCC, [SDNPHasChain, SDNPInFlag]>;
56 def MSP430selectcc: SDNode<"MSP430ISD::SELECT_CC", SDT_MSP430SelectCC, [SDNPInFlag]>;
57
58 //===----------------------------------------------------------------------===//
59 // MSP430 Operand Definitions.
60 //===----------------------------------------------------------------------===//
61
62 // Address operands
63 def memsrc : Operand<i16> {
64   let PrintMethod = "printSrcMemOperand";
65   let MIOperandInfo = (ops GR16, i16imm);
66 }
67
68 def memdst : Operand<i16> {
69   let PrintMethod = "printSrcMemOperand";
70   let MIOperandInfo = (ops GR16, i16imm);
71 }
72
73 // Branch targets have OtherVT type.
74 def brtarget : Operand<OtherVT>;
75
76 // Operand for printing out a condition code.
77 def cc : Operand<i8> {
78   let PrintMethod = "printCCOperand";
79 }
80
81 //===----------------------------------------------------------------------===//
82 // MSP430 Complex Pattern Definitions.
83 //===----------------------------------------------------------------------===//
84
85 def addr : ComplexPattern<iPTR, 2, "SelectAddr", [], []>;
86
87 //===----------------------------------------------------------------------===//
88 // Pattern Fragments
89 def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
90 def  extloadi16i8 : PatFrag<(ops node:$ptr), (i16 ( extloadi8 node:$ptr))>;
91
92 //===----------------------------------------------------------------------===//
93 // Instruction list..
94
95 // ADJCALLSTACKDOWN/UP implicitly use/def SP because they may be expanded into
96 // a stack adjustment and the codegen must know that they may modify the stack
97 // pointer before prolog-epilog rewriting occurs.
98 // Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
99 // sub / add which can clobber SRW.
100 let Defs = [SPW, SRW], Uses = [SPW] in {
101 def ADJCALLSTACKDOWN : Pseudo<(outs), (ins i16imm:$amt),
102                               "#ADJCALLSTACKDOWN",
103                               [(MSP430callseq_start timm:$amt)]>;
104 def ADJCALLSTACKUP   : Pseudo<(outs), (ins i16imm:$amt1, i16imm:$amt2),
105                               "#ADJCALLSTACKUP",
106                               [(MSP430callseq_end timm:$amt1, timm:$amt2)]>;
107 }
108
109 let usesCustomDAGSchedInserter = 1 in {
110   def Select16 : Pseudo<(outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$cc),
111                         "# Select16 PSEUDO",
112                         [(set GR16:$dst,
113                           (MSP430selectcc GR16:$src1, GR16:$src2, imm:$cc))]>;
114 }
115
116 let neverHasSideEffects = 1 in
117 def NOP : Pseudo<(outs), (ins), "nop", []>;
118
119 //===----------------------------------------------------------------------===//
120 //  Control Flow Instructions...
121 //
122
123 // FIXME: Provide proper encoding!
124 let isReturn = 1, isTerminator = 1 in {
125   def RET : Pseudo<(outs), (ins), "ret", [(MSP430retflag)]>;
126 }
127
128 let isBranch = 1, isTerminator = 1 in {
129
130 // Direct branch
131 let isBarrier = 1 in
132   def JMP : Pseudo<(outs), (ins brtarget:$dst),
133                    "jmp\t$dst",
134                    [(br bb:$dst)]>;
135
136 // Conditional branches
137 let Uses = [SRW] in
138   def JCC : Pseudo<(outs), (ins brtarget:$dst, cc:$cc),
139                             "j$cc $dst",
140                             [(MSP430brcc bb:$dst, imm:$cc)]>;
141 } // isBranch, isTerminator
142
143 //===----------------------------------------------------------------------===//
144 //  Call Instructions...
145 //
146 let isCall = 1 in
147   // All calls clobber the non-callee saved registers. SPW is marked as
148   // a use to prevent stack-pointer assignments that appear immediately
149   // before calls from potentially appearing dead. Uses for argument
150   // registers are added manually.
151   let Defs = [R12W, R13W, R14W, R15W, SRW],
152       Uses = [SPW] in {
153     def CALLi     : Pseudo<(outs), (ins i16imm:$dst, variable_ops),
154                            "call\t${dst:call}", [(MSP430call imm:$dst)]>;
155     def CALLr     : Pseudo<(outs), (ins GR16:$dst, variable_ops),
156                            "call\t$dst", [(MSP430call GR16:$dst)]>;
157     def CALLm     : Pseudo<(outs), (ins memsrc:$dst, variable_ops),
158                            "call\t${dst:mem}", [(MSP430call (load addr:$dst))]>;
159   }
160
161
162 //===----------------------------------------------------------------------===//
163 //  Miscellaneous Instructions...
164 //
165 let Defs = [SPW], Uses = [SPW], neverHasSideEffects=1 in {
166 let mayLoad = 1 in
167 def POP16r   : Pseudo<(outs GR16:$reg), (ins), "pop.w\t$reg", []>;
168
169 let mayStore = 1 in
170 def PUSH16r  : Pseudo<(outs), (ins GR16:$reg), "push.w\t$reg",[]>;
171 }
172
173 //===----------------------------------------------------------------------===//
174 // Move Instructions
175
176 // FIXME: Provide proper encoding!
177 let neverHasSideEffects = 1 in {
178 def MOV8rr  : Pseudo<(outs GR8:$dst), (ins GR8:$src),
179                      "mov.b\t{$src, $dst}",
180                      []>;
181 def MOV16rr : Pseudo<(outs GR16:$dst), (ins GR16:$src),
182                      "mov.w\t{$src, $dst}",
183                      []>;
184 }
185
186 // FIXME: Provide proper encoding!
187 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
188 def MOV8ri  : Pseudo<(outs GR8:$dst), (ins i8imm:$src),
189                      "mov.b\t{$src, $dst}",
190                      [(set GR8:$dst, imm:$src)]>;
191 def MOV16ri : Pseudo<(outs GR16:$dst), (ins i16imm:$src),
192                      "mov.w\t{$src, $dst}",
193                      [(set GR16:$dst, imm:$src)]>;
194 }
195
196 let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
197 def MOV8rm  : Pseudo<(outs GR8:$dst), (ins memsrc:$src),
198                 "mov.b\t{$src, $dst}",
199                 [(set GR8:$dst, (load addr:$src))]>;
200 def MOV16rm : Pseudo<(outs GR16:$dst), (ins memsrc:$src),
201                 "mov.w\t{$src, $dst}",
202                 [(set GR16:$dst, (load addr:$src))]>;
203 }
204
205 def MOVZX16rr8 : Pseudo<(outs GR16:$dst), (ins GR8:$src),
206                 "mov.b\t{$src, $dst}",
207                 [(set GR16:$dst, (zext GR8:$src))]>;
208 def MOVZX16rm8 : Pseudo<(outs GR16:$dst), (ins memsrc:$src),
209                 "mov.b\t{$src, $dst}",
210                 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>;
211
212 // Any instruction that defines a 8-bit result leaves the high half of the
213 // register. Truncate can be lowered to EXTRACT_SUBREG, and CopyFromReg may
214 // be copying from a truncate, but any other 8-bit operation will zero-extend
215 // up to 16 bits.
216 def def8 : PatLeaf<(i8 GR8:$src), [{
217   return N->getOpcode() != ISD::TRUNCATE &&
218          N->getOpcode() != TargetInstrInfo::EXTRACT_SUBREG &&
219          N->getOpcode() != ISD::CopyFromReg;
220 }]>;
221
222 // In the case of a 8-bit def that is known to implicitly zero-extend,
223 // we can use a SUBREG_TO_REG.
224 def : Pat<(i16 (zext def8:$src)),
225           (SUBREG_TO_REG (i16 0), GR8:$src, subreg_8bit)>;
226
227
228 def MOV8mi  : Pseudo<(outs), (ins memdst:$dst, i8imm:$src),
229                 "mov.b\t{$src, $dst}",
230                 [(store (i8 imm:$src), addr:$dst)]>;
231 def MOV16mi : Pseudo<(outs), (ins memdst:$dst, i16imm:$src),
232                 "mov.w\t{$src, $dst}",
233                 [(store (i16 imm:$src), addr:$dst)]>;
234
235 def MOV8mr  : Pseudo<(outs), (ins memdst:$dst, GR8:$src),
236                 "mov.b\t{$src, $dst}",
237                 [(store GR8:$src, addr:$dst)]>;
238 def MOV16mr : Pseudo<(outs), (ins memdst:$dst, GR16:$src),
239                 "mov.w\t{$src, $dst}",
240                 [(store GR16:$src, addr:$dst)]>;
241
242 //===----------------------------------------------------------------------===//
243 // Arithmetic Instructions
244
245 let isTwoAddress = 1 in {
246
247 let Defs = [SRW] in {
248
249 let isCommutable = 1 in { // X = ADD Y, Z  == X = ADD Z, Y
250 // FIXME: Provide proper encoding!
251 def ADD8rr  : Pseudo<(outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
252                      "add.b\t{$src2, $dst}",
253                      [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
254                       (implicit SRW)]>;
255 def ADD16rr : Pseudo<(outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
256                      "add.w\t{$src2, $dst}",
257                      [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
258                       (implicit SRW)]>;
259 }
260
261 def ADD8rm  : Pseudo<(outs GR8:$dst), (ins GR8:$src1, memsrc:$src2),
262                      "add.b\t{$src2, $dst}",
263                      [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
264                       (implicit SRW)]>;
265 def ADD16rm : Pseudo<(outs GR16:$dst), (ins GR16:$src1, memsrc:$src2),
266                      "add.w\t{$src2, $dst}",
267                      [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
268                       (implicit SRW)]>;
269
270 def ADD8ri  : Pseudo<(outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
271                      "add.b\t{$src2, $dst}",
272                      [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
273                       (implicit SRW)]>;
274 def ADD16ri : Pseudo<(outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
275                      "add.w\t{$src2, $dst}",
276                      [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
277                       (implicit SRW)]>;
278
279 let isTwoAddress = 0 in {
280 def ADD8mr  : Pseudo<(outs), (ins memdst:$dst, GR8:$src),
281                 "add.b\t{$src, $dst}",
282                 [(store (add (load addr:$dst), GR8:$src), addr:$dst),
283                  (implicit SRW)]>;
284 def ADD16mr : Pseudo<(outs), (ins memdst:$dst, GR16:$src),
285                 "add.w\t{$src, $dst}",
286                 [(store (add (load addr:$dst), GR16:$src), addr:$dst),
287                  (implicit SRW)]>;
288
289 def ADD8mi  : Pseudo<(outs), (ins memdst:$dst, i8imm:$src),
290                 "add.b\t{$src, $dst}",
291                 [(store (add (load addr:$dst), (i8 imm:$src)), addr:$dst),
292                  (implicit SRW)]>;
293 def ADD16mi : Pseudo<(outs), (ins memdst:$dst, i16imm:$src),
294                 "add.w\t{$src, $dst}",
295                 [(store (add (load addr:$dst), (i16 imm:$src)), addr:$dst),
296                  (implicit SRW)]>;
297
298 def ADD8mm  : Pseudo<(outs), (ins memdst:$dst, memsrc:$src),
299                 "add.b\t{$src, $dst}",
300                 [(store (add (load addr:$dst), (i8 (load addr:$src))), addr:$dst),
301                  (implicit SRW)]>;
302 def ADD16mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src),
303                 "add.w\t{$src, $dst}",
304                 [(store (add (load addr:$dst), (i16 (load addr:$src))), addr:$dst),
305                  (implicit SRW)]>;
306 }
307
308 let Uses = [SRW] in {
309
310 let isCommutable = 1 in { // X = ADDC Y, Z  == X = ADDC Z, Y
311 def ADC8rr  : Pseudo<(outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
312                      "addc.b\t{$src2, $dst}",
313                      [(set GR8:$dst, (adde GR8:$src1, GR8:$src2)),
314                       (implicit SRW)]>;
315 def ADC16rr : Pseudo<(outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
316                      "addc.w\t{$src2, $dst}",
317                      [(set GR16:$dst, (adde GR16:$src1, GR16:$src2)),
318                       (implicit SRW)]>;
319 } // isCommutable
320
321 def ADC8ri  : Pseudo<(outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
322                      "addc.b\t{$src2, $dst}",
323                      [(set GR8:$dst, (adde GR8:$src1, imm:$src2)),
324                       (implicit SRW)]>;
325 def ADC16ri : Pseudo<(outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
326                      "addc.w\t{$src2, $dst}",
327                      [(set GR16:$dst, (adde GR16:$src1, imm:$src2)),
328                       (implicit SRW)]>;
329
330 def ADC8rm  : Pseudo<(outs GR8:$dst), (ins GR8:$src1, memsrc:$src2),
331                      "addc.b\t{$src2, $dst}",
332                      [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2))),
333                       (implicit SRW)]>;
334 def ADC16rm : Pseudo<(outs GR16:$dst), (ins GR16:$src1, memsrc:$src2),
335                      "addc.w\t{$src2, $dst}",
336                      [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2))),
337                       (implicit SRW)]>;
338
339 let isTwoAddress = 0 in {
340 def ADC8mr  : Pseudo<(outs), (ins memdst:$dst, GR8:$src),
341                 "addc.b\t{$src, $dst}",
342                 [(store (adde (load addr:$dst), GR8:$src), addr:$dst),
343                  (implicit SRW)]>;
344 def ADC16mr : Pseudo<(outs), (ins memdst:$dst, GR16:$src),
345                 "addc.w\t{$src, $dst}",
346                 [(store (adde (load addr:$dst), GR16:$src), addr:$dst),
347                  (implicit SRW)]>;
348
349 def ADC8mi  : Pseudo<(outs), (ins memdst:$dst, i8imm:$src),
350                 "addc.b\t{$src, $dst}",
351                 [(store (adde (load addr:$dst), (i8 imm:$src)), addr:$dst),
352                  (implicit SRW)]>;
353 def ADC16mi : Pseudo<(outs), (ins memdst:$dst, i16imm:$src),
354                 "addc.w\t{$src, $dst}",
355                 [(store (adde (load addr:$dst), (i16 imm:$src)), addr:$dst),
356                  (implicit SRW)]>;
357
358 def ADC8mm  : Pseudo<(outs), (ins memdst:$dst, memsrc:$src),
359                 "addc.b\t{$src, $dst}",
360                 [(store (adde (load addr:$dst), (i8 (load addr:$src))), addr:$dst),
361                  (implicit SRW)]>;
362 def ADC16mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src),
363                 "addc.w\t{$src, $dst}",
364                 [(store (adde (load addr:$dst), (i16 (load addr:$src))), addr:$dst),
365                  (implicit SRW)]>;
366 }
367
368 } // Uses = [SRW]
369
370 let isCommutable = 1 in { // X = AND Y, Z  == X = AND Z, Y
371 def AND8rr  : Pseudo<(outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
372                      "and.b\t{$src2, $dst}",
373                      [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
374                       (implicit SRW)]>;
375 def AND16rr : Pseudo<(outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
376                      "and.w\t{$src2, $dst}",
377                      [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
378                       (implicit SRW)]>;
379 }
380
381 def AND8ri  : Pseudo<(outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
382                      "and.b\t{$src2, $dst}",
383                      [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
384                       (implicit SRW)]>;
385 def AND16ri : Pseudo<(outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
386                      "and.w\t{$src2, $dst}",
387                      [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
388                       (implicit SRW)]>;
389
390 def AND8rm  : Pseudo<(outs GR8:$dst), (ins GR8:$src1, memsrc:$src2),
391                      "and.b\t{$src2, $dst}",
392                      [(set GR8:$dst, (and GR8:$src1, (load addr:$src2))),
393                       (implicit SRW)]>;
394 def AND16rm : Pseudo<(outs GR16:$dst), (ins GR16:$src1, memsrc:$src2),
395                      "and.w\t{$src2, $dst}",
396                      [(set GR16:$dst, (and GR16:$src1, (load addr:$src2))),
397                       (implicit SRW)]>;
398
399 let isTwoAddress = 0 in {
400 def AND8mr  : Pseudo<(outs), (ins memdst:$dst, GR8:$src),
401                 "and.b\t{$src, $dst}",
402                 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
403                  (implicit SRW)]>;
404 def AND16mr : Pseudo<(outs), (ins memdst:$dst, GR16:$src),
405                 "and.w\t{$src, $dst}",
406                 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
407                  (implicit SRW)]>;
408
409 def AND8mi  : Pseudo<(outs), (ins memdst:$dst, i8imm:$src),
410                 "and.b\t{$src, $dst}",
411                 [(store (and (load addr:$dst), (i8 imm:$src)), addr:$dst),
412                  (implicit SRW)]>;
413 def AND16mi : Pseudo<(outs), (ins memdst:$dst, i16imm:$src),
414                 "and.w\t{$src, $dst}",
415                 [(store (and (load addr:$dst), (i16 imm:$src)), addr:$dst),
416                  (implicit SRW)]>;
417
418 def AND8mm  : Pseudo<(outs), (ins memdst:$dst, memsrc:$src),
419                 "and.b\t{$src, $dst}",
420                 [(store (and (load addr:$dst), (i8 (load addr:$src))), addr:$dst),
421                  (implicit SRW)]>;
422 def AND16mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src),
423                 "and.w\t{$src, $dst}",
424                 [(store (and (load addr:$dst), (i16 (load addr:$src))), addr:$dst),
425                  (implicit SRW)]>;
426 }
427
428
429 let isCommutable = 1 in { // X = XOR Y, Z  == X = XOR Z, Y
430 def XOR8rr  : Pseudo<(outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
431                      "xor.b\t{$src2, $dst}",
432                      [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
433                       (implicit SRW)]>;
434 def XOR16rr : Pseudo<(outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
435                      "xor.w\t{$src2, $dst}",
436                      [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
437                       (implicit SRW)]>;
438 }
439
440 def XOR8ri  : Pseudo<(outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
441                      "xor.b\t{$src2, $dst}",
442                      [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
443                       (implicit SRW)]>;
444 def XOR16ri : Pseudo<(outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
445                      "xor.w\t{$src2, $dst}",
446                      [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
447                       (implicit SRW)]>;
448
449 def XOR8rm  : Pseudo<(outs GR8:$dst), (ins GR8:$src1, memsrc:$src2),
450                      "xor.b\t{$src2, $dst}",
451                      [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
452                       (implicit SRW)]>;
453 def XOR16rm : Pseudo<(outs GR16:$dst), (ins GR16:$src1, memsrc:$src2),
454                      "xor.w\t{$src2, $dst}",
455                      [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
456                       (implicit SRW)]>;
457
458 let isTwoAddress = 0 in {
459 def XOR8mr  : Pseudo<(outs), (ins memdst:$dst, GR8:$src),
460                 "xor.b\t{$src, $dst}",
461                 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
462                  (implicit SRW)]>;
463 def XOR16mr : Pseudo<(outs), (ins memdst:$dst, GR16:$src),
464                 "xor.w\t{$src, $dst}",
465                 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
466                  (implicit SRW)]>;
467
468 def XOR8mi  : Pseudo<(outs), (ins memdst:$dst, i8imm:$src),
469                 "xor.b\t{$src, $dst}",
470                 [(store (xor (load addr:$dst), (i8 imm:$src)), addr:$dst),
471                  (implicit SRW)]>;
472 def XOR16mi : Pseudo<(outs), (ins memdst:$dst, i16imm:$src),
473                 "xor.w\t{$src, $dst}",
474                 [(store (xor (load addr:$dst), (i16 imm:$src)), addr:$dst),
475                  (implicit SRW)]>;
476
477 def XOR8mm  : Pseudo<(outs), (ins memdst:$dst, memsrc:$src),
478                 "xor.b\t{$src, $dst}",
479                 [(store (xor (load addr:$dst), (i8 (load addr:$src))), addr:$dst),
480                  (implicit SRW)]>;
481 def XOR16mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src),
482                 "xor.w\t{$src, $dst}",
483                 [(store (xor (load addr:$dst), (i16 (load addr:$src))), addr:$dst),
484                  (implicit SRW)]>;
485 }
486
487
488 def SUB8rr  : Pseudo<(outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
489                      "sub.b\t{$src2, $dst}",
490                      [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
491                       (implicit SRW)]>;
492 def SUB16rr : Pseudo<(outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
493                      "sub.w\t{$src2, $dst}",
494                      [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
495                       (implicit SRW)]>;
496
497 def SUB8ri  : Pseudo<(outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
498                      "sub.b\t{$src2, $dst}",
499                      [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
500                       (implicit SRW)]>;
501 def SUB16ri : Pseudo<(outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
502                      "sub.w\t{$src2, $dst}",
503                      [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
504                       (implicit SRW)]>;
505
506 def SUB8rm  : Pseudo<(outs GR8:$dst), (ins GR8:$src1, memsrc:$src2),
507                      "sub.b\t{$src2, $dst}",
508                      [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
509                       (implicit SRW)]>;
510 def SUB16rm : Pseudo<(outs GR16:$dst), (ins GR16:$src1, memsrc:$src2),
511                      "sub.w\t{$src2, $dst}",
512                      [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
513                       (implicit SRW)]>;
514
515 let isTwoAddress = 0 in {
516 def SUB8mr  : Pseudo<(outs), (ins memdst:$dst, GR8:$src),
517                 "sub.b\t{$src, $dst}",
518                 [(store (sub (load addr:$dst), GR8:$src), addr:$dst),
519                  (implicit SRW)]>;
520 def SUB16mr : Pseudo<(outs), (ins memdst:$dst, GR16:$src),
521                 "sub.w\t{$src, $dst}",
522                 [(store (sub (load addr:$dst), GR16:$src), addr:$dst),
523                  (implicit SRW)]>;
524
525 def SUB8mi  : Pseudo<(outs), (ins memdst:$dst, i8imm:$src),
526                 "sub.b\t{$src, $dst}",
527                 [(store (sub (load addr:$dst), (i8 imm:$src)), addr:$dst),
528                  (implicit SRW)]>;
529 def SUB16mi : Pseudo<(outs), (ins memdst:$dst, i16imm:$src),
530                 "sub.w\t{$src, $dst}",
531                 [(store (sub (load addr:$dst), (i16 imm:$src)), addr:$dst),
532                  (implicit SRW)]>;
533
534 def SUB8mm  : Pseudo<(outs), (ins memdst:$dst, memsrc:$src),
535                 "sub.b\t{$src, $dst}",
536                 [(store (sub (load addr:$dst), (i8 (load addr:$src))), addr:$dst),
537                  (implicit SRW)]>;
538 def SUB16mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src),
539                 "sub.w\t{$src, $dst}",
540                 [(store (sub (load addr:$dst), (i16 (load addr:$src))), addr:$dst),
541                  (implicit SRW)]>;
542 }
543
544 let Uses = [SRW] in {
545 def SBC8rr  : Pseudo<(outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
546                      "subc.b\t{$src2, $dst}",
547                      [(set GR8:$dst, (sube GR8:$src1, GR8:$src2)),
548                       (implicit SRW)]>;
549 def SBC16rr : Pseudo<(outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
550                      "subc.w\t{$src2, $dst}",
551                      [(set GR16:$dst, (sube GR16:$src1, GR16:$src2)),
552                       (implicit SRW)]>;
553
554 def SBC8ri  : Pseudo<(outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
555                      "subc.b\t{$src2, $dst}",
556                      [(set GR8:$dst, (sube GR8:$src1, imm:$src2)),
557                       (implicit SRW)]>;
558 def SBC16ri : Pseudo<(outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
559                      "subc.w\t{$src2, $dst}",
560                      [(set GR16:$dst, (sube GR16:$src1, imm:$src2)),
561                       (implicit SRW)]>;
562
563 def SBC8rm  : Pseudo<(outs GR8:$dst), (ins GR8:$src1, memsrc:$src2),
564                      "subc.b\t{$src2, $dst}",
565                      [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2))),
566                       (implicit SRW)]>;
567 def SBC16rm : Pseudo<(outs GR16:$dst), (ins GR16:$src1, memsrc:$src2),
568                      "subc.w\t{$src2, $dst}",
569                      [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2))),
570                       (implicit SRW)]>;
571
572 let isTwoAddress = 0 in {
573 def SBC8mr  : Pseudo<(outs), (ins memdst:$dst, GR8:$src),
574                 "subc.b\t{$src, $dst}",
575                 [(store (sube (load addr:$dst), GR8:$src), addr:$dst),
576                  (implicit SRW)]>;
577 def SBC16mr : Pseudo<(outs), (ins memdst:$dst, GR16:$src),
578                 "subc.w\t{$src, $dst}",
579                 [(store (sube (load addr:$dst), GR16:$src), addr:$dst),
580                  (implicit SRW)]>;
581
582 def SBC8mi  : Pseudo<(outs), (ins memdst:$dst, i8imm:$src),
583                 "subc.b\t{$src, $dst}",
584                 [(store (sube (load addr:$dst), (i8 imm:$src)), addr:$dst),
585                  (implicit SRW)]>;
586 def SBC16mi : Pseudo<(outs), (ins memdst:$dst, i16imm:$src),
587                 "subc.w\t{$src, $dst}",
588                 [(store (sube (load addr:$dst), (i16 imm:$src)), addr:$dst),
589                  (implicit SRW)]>;
590
591 def SBC8mm  : Pseudo<(outs), (ins memdst:$dst, memsrc:$src),
592                 "subc.b\t{$src, $dst}",
593                 [(store (sube (load addr:$dst), (i8 (load addr:$src))), addr:$dst),
594                  (implicit SRW)]>;
595 def SBC16mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src),
596                 "subc.w\t{$src, $dst}",
597                 [(store (sube (load addr:$dst), (i16 (load addr:$src))), addr:$dst),
598                  (implicit SRW)]>;
599 }
600
601 } // Uses = [SRW]
602
603 // FIXME: Provide proper encoding!
604 def SAR8r1  : Pseudo<(outs GR8:$dst), (ins GR8:$src),
605                      "rra.b\t$dst",
606                      [(set GR8:$dst, (MSP430rra GR8:$src)),
607                       (implicit SRW)]>;
608 def SAR16r1 : Pseudo<(outs GR16:$dst), (ins GR16:$src),
609                      "rra.w\t$dst",
610                      [(set GR16:$dst, (MSP430rra GR16:$src)),
611                       (implicit SRW)]>;
612
613 def SHL8r1  : Pseudo<(outs GR8:$dst), (ins GR8:$src),
614                      "rla.b\t$dst",
615                      [(set GR8:$dst, (MSP430rla GR8:$src)),
616                       (implicit SRW)]>;
617 def SHL16r1 : Pseudo<(outs GR16:$dst), (ins GR16:$src),
618                      "rla.w\t$dst",
619                      [(set GR16:$dst, (MSP430rla GR16:$src)),
620                       (implicit SRW)]>;
621
622 def SAR8r1c  : Pseudo<(outs GR8:$dst), (ins GR8:$src),
623                       "clrc\n"
624                       "rrc.b\t$dst",
625                       [(set GR8:$dst, (MSP430rrc GR8:$src)),
626                        (implicit SRW)]>;
627 def SAR16r1c : Pseudo<(outs GR16:$dst), (ins GR16:$src),
628                       "clrc\n"
629                       "rrc.w\t$dst",
630                       [(set GR16:$dst, (MSP430rrc GR16:$src)),
631                        (implicit SRW)]>;
632
633 def SEXT16r : Pseudo<(outs GR16:$dst), (ins GR16:$src),
634                      "sxt\t$dst",
635                      [(set GR16:$dst, (sext_inreg GR16:$src, i8)),
636                       (implicit SRW)]>;
637
638 } // Defs = [SRW]
639
640 def SWPB16r : Pseudo<(outs GR16:$dst), (ins GR16:$src),
641                      "swpb\t$dst",
642                      [(set GR16:$dst, (bswap GR16:$src))]>;
643
644 let isCommutable = 1 in { // X = OR Y, Z  == X = OR Z, Y
645 def OR8rr  : Pseudo<(outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
646                     "bis.b\t{$src2, $dst}",
647                     [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
648 def OR16rr : Pseudo<(outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
649                     "bis.w\t{$src2, $dst}",
650                     [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>;
651 }
652
653 def OR8ri  : Pseudo<(outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
654                     "bis.b\t{$src2, $dst}",
655                     [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
656 def OR16ri : Pseudo<(outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
657                     "bis.w\t{$src2, $dst}",
658                     [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>;
659
660 def OR8rm  : Pseudo<(outs GR8:$dst), (ins GR8:$src1, memsrc:$src2),
661                     "bis.b\t{$src2, $dst}",
662                     [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
663 def OR16rm : Pseudo<(outs GR16:$dst), (ins GR16:$src1, memsrc:$src2),
664                     "bis.w\t{$src2, $dst}",
665                     [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>;
666
667 let isTwoAddress = 0 in {
668 def OR8mr  : Pseudo<(outs), (ins memdst:$dst, GR8:$src),
669                 "bis.b\t{$src, $dst}",
670                 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
671                  (implicit SRW)]>;
672 def OR16mr : Pseudo<(outs), (ins memdst:$dst, GR16:$src),
673                 "bis.w\t{$src, $dst}",
674                 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
675                  (implicit SRW)]>;
676
677 def OR8mi  : Pseudo<(outs), (ins memdst:$dst, i8imm:$src),
678                 "bis.b\t{$src, $dst}",
679                 [(store (or (load addr:$dst), (i8 imm:$src)), addr:$dst),
680                  (implicit SRW)]>;
681 def OR16mi : Pseudo<(outs), (ins memdst:$dst, i16imm:$src),
682                 "bis.w\t{$src, $dst}",
683                 [(store (or (load addr:$dst), (i16 imm:$src)), addr:$dst),
684                  (implicit SRW)]>;
685
686 def OR8mm  : Pseudo<(outs), (ins memdst:$dst, memsrc:$src),
687                 "bis.b\t{$src, $dst}",
688                 [(store (or (load addr:$dst), (i8 (load addr:$src))), addr:$dst),
689                  (implicit SRW)]>;
690 def OR16mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src),
691                 "bis.w\t{$src, $dst}",
692                 [(store (or (load addr:$dst), (i16 (load addr:$src))), addr:$dst),
693                  (implicit SRW)]>;
694 }
695
696 } // isTwoAddress = 1
697
698 // Integer comparisons
699 let Defs = [SRW] in {
700 def CMP8rr  : Pseudo<(outs), (ins GR8:$src1, GR8:$src2),
701                      "cmp.b\t{$src1, $src2}",
702                      [(MSP430cmp GR8:$src1, GR8:$src2), (implicit SRW)]>;
703 def CMP16rr : Pseudo<(outs), (ins GR16:$src1, GR16:$src2),
704                      "cmp.w\t{$src1, $src2}",
705                      [(MSP430cmp GR16:$src1, GR16:$src2), (implicit SRW)]>;
706
707 // FIXME: imm is allowed only on src operand, not on dst.
708
709 //def CMP8ri  : Pseudo<(outs), (ins GR8:$src1, i8imm:$src2),
710 //                   "cmp.b\t{$src1, $src2}",
711 //                   [(MSP430cmp GR8:$src1, imm:$src2), (implicit SRW)]>;
712 //def CMP16ri : Pseudo<(outs), (ins GR16:$src1, i16imm:$src2),
713 //                     "cmp.w\t{$src1, $src2}",
714 //                     [(MSP430cmp GR16:$src1, imm:$src2), (implicit SRW)]>;
715
716 //def CMP8mi  : Pseudo<(outs), (ins memsrc:$src1, i8imm:$src2),
717 //                "cmp.b\t{$src1, $src2}",
718 //                [(MSP430cmp (load addr:$src1), (i8 imm:$src2)), (implicit SRW)]>;
719 //def CMP16mi : Pseudo<(outs), (ins memsrc:$src1, i16imm:$src2),
720 //                "cmp.w\t{$src1, $src2}",
721 //                [(MSP430cmp (load addr:$src1), (i16 imm:$src2)), (implicit SRW)]>;
722
723
724 // Imm 0, +1, +2, +4, +8 are encoded via constant generator registers.
725 // That's why we can use them as dest operands. 
726 // We don't define new class for them, since they would need special encoding
727 // in the future.
728
729 def CMP8ri0 : Pseudo<(outs), (ins GR8:$src1),
730                      "cmp.b\t{$src1, #0}",
731                      [(MSP430cmp GR8:$src1, 0), (implicit SRW)]>;
732 def CMP16ri0: Pseudo<(outs), (ins GR16:$src1),
733                      "cmp.w\t{$src1, #0}",
734                      [(MSP430cmp GR16:$src1, 0), (implicit SRW)]>;
735 def CMP8ri1 : Pseudo<(outs), (ins GR8:$src1),
736                      "cmp.b\t{$src1, #1}",
737                      [(MSP430cmp GR8:$src1, 1), (implicit SRW)]>;
738 def CMP16ri1: Pseudo<(outs), (ins GR16:$src1),
739                      "cmp.w\t{$src1, #1}",
740                      [(MSP430cmp GR16:$src1, 1), (implicit SRW)]>;
741 def CMP8ri2 : Pseudo<(outs), (ins GR8:$src1),
742                      "cmp.b\t{$src1, #2}",
743                      [(MSP430cmp GR8:$src1, 2), (implicit SRW)]>;
744 def CMP16ri2: Pseudo<(outs), (ins GR16:$src1),
745                      "cmp.w\t{$src1, #2}",
746                      [(MSP430cmp GR16:$src1, 2), (implicit SRW)]>;
747 def CMP8ri4 : Pseudo<(outs), (ins GR8:$src1),
748                      "cmp.b\t{$src1, #4}",
749                      [(MSP430cmp GR8:$src1, 4), (implicit SRW)]>;
750 def CMP16ri4: Pseudo<(outs), (ins GR16:$src1),
751                      "cmp.w\t{$src1, #4}",
752                      [(MSP430cmp GR16:$src1, 4), (implicit SRW)]>;
753 def CMP8ri8 : Pseudo<(outs), (ins GR8:$src1),
754                      "cmp.b\t{$src1, #8}",
755                      [(MSP430cmp GR8:$src1, 8), (implicit SRW)]>;
756 def CMP16ri8: Pseudo<(outs), (ins GR16:$src1),
757                      "cmp.w\t{$src1, #8}",
758                      [(MSP430cmp GR16:$src1, 8), (implicit SRW)]>;
759
760 def CMP8rm  : Pseudo<(outs), (ins GR8:$src1, memsrc:$src2),
761                      "cmp.b\t{$src1, $src2}",
762                      [(MSP430cmp GR8:$src1, (load addr:$src2)), (implicit SRW)]>;
763 def CMP16rm : Pseudo<(outs), (ins GR16:$src1, memsrc:$src2),
764                      "cmp.w\t{$src1, $src2}",
765                      [(MSP430cmp GR16:$src1, (load addr:$src2)), (implicit SRW)]>;
766
767 def CMP8mr  : Pseudo<(outs), (ins memsrc:$src1, GR8:$src2),
768                 "cmp.b\t{$src1, $src2}",
769                 [(MSP430cmp (load addr:$src1), GR8:$src2), (implicit SRW)]>;
770 def CMP16mr : Pseudo<(outs), (ins memsrc:$src1, GR16:$src2),
771                 "cmp.w\t{$src1, $src2}",
772                 [(MSP430cmp (load addr:$src1), GR16:$src2), (implicit SRW)]>;
773
774 def CMP8mi0 : Pseudo<(outs), (ins memsrc:$src1),
775                 "cmp.b\t{$src1, #0}",
776                 [(MSP430cmp (load addr:$src1), (i8 0)), (implicit SRW)]>;
777 def CMP16mi0: Pseudo<(outs), (ins memsrc:$src1),
778                 "cmp.w\t{$src1, #0}",
779                 [(MSP430cmp (load addr:$src1), (i16 0)), (implicit SRW)]>;
780 def CMP8mi1 : Pseudo<(outs), (ins memsrc:$src1),
781                 "cmp.b\t{$src1, #1}",
782                 [(MSP430cmp (load addr:$src1), (i8 1)), (implicit SRW)]>;
783 def CMP16mi1: Pseudo<(outs), (ins memsrc:$src1),
784                 "cmp.w\t{$src1, #1}",
785                 [(MSP430cmp (load addr:$src1), (i16 1)), (implicit SRW)]>;
786 def CMP8mi2 : Pseudo<(outs), (ins memsrc:$src1),
787                 "cmp.b\t{$src1, #2}",
788                 [(MSP430cmp (load addr:$src1), (i8 2)), (implicit SRW)]>;
789 def CMP16mi2: Pseudo<(outs), (ins memsrc:$src1),
790                 "cmp.w\t{$src1, #2}",
791                 [(MSP430cmp (load addr:$src1), (i16 2)), (implicit SRW)]>;
792 def CMP8mi4 : Pseudo<(outs), (ins memsrc:$src1),
793                 "cmp.b\t{$src1, #4}",
794                 [(MSP430cmp (load addr:$src1), (i8 4)), (implicit SRW)]>;
795 def CMP16mi4: Pseudo<(outs), (ins memsrc:$src1),
796                 "cmp.w\t{$src1, #4}",
797                 [(MSP430cmp (load addr:$src1), (i16 4)), (implicit SRW)]>;
798 def CMP8mi8 : Pseudo<(outs), (ins memsrc:$src1),
799                 "cmp.b\t{$src1, #8}",
800                 [(MSP430cmp (load addr:$src1), (i8 8)), (implicit SRW)]>;
801 def CMP16mi8: Pseudo<(outs), (ins memsrc:$src1),
802                 "cmp.w\t{$src1, #8}",
803                 [(MSP430cmp (load addr:$src1), (i16 8)), (implicit SRW)]>;
804
805 } // Defs = [SRW]
806
807 //===----------------------------------------------------------------------===//
808 // Non-Instruction Patterns
809
810 // extload
811 def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
812
813 // anyext
814 def : Pat<(anyext addr:$src), (MOVZX16rr8 GR8:$src)>;
815
816 // truncs
817 def : Pat<(i8 (trunc GR16:$src)),
818           (EXTRACT_SUBREG GR16:$src, subreg_8bit)>;
819
820 // GlobalAddress, ExternalSymbol
821 def : Pat<(i16 (MSP430Wrapper tglobaladdr:$dst)), (MOV16ri tglobaladdr:$dst)>;
822 def : Pat<(i16 (MSP430Wrapper texternalsym:$dst)), (MOV16ri texternalsym:$dst)>;
823
824 def : Pat<(add GR16:$src1, (MSP430Wrapper tglobaladdr :$src2)),
825           (ADD16ri GR16:$src1, tglobaladdr:$src2)>;
826 def : Pat<(add GR16:$src1, (MSP430Wrapper texternalsym:$src2)),
827           (ADD16ri GR16:$src1, texternalsym:$src2)>;
828
829 def : Pat<(store (i16 (MSP430Wrapper tglobaladdr:$src)), addr:$dst),
830           (MOV16mi addr:$dst, tglobaladdr:$src)>;
831 def : Pat<(store (i16 (MSP430Wrapper texternalsym:$src)), addr:$dst),
832           (MOV16mi addr:$dst, texternalsym:$src)>;
833
834 // calls
835 def : Pat<(MSP430call (i16 tglobaladdr:$dst)),
836           (CALLi tglobaladdr:$dst)>;
837 def : Pat<(MSP430call (i16 texternalsym:$dst)),
838           (CALLi texternalsym:$dst)>;
839
840 // add and sub always produce carry
841 def : Pat<(addc GR16:$src1, GR16:$src2),
842           (ADD16rr GR16:$src1, GR16:$src2)>;
843 def : Pat<(addc GR16:$src1, (load addr:$src2)),
844           (ADD16rm GR16:$src1, addr:$src2)>;
845 def : Pat<(addc GR16:$src1, imm:$src2),
846           (ADD16ri GR16:$src1, imm:$src2)>;
847 def : Pat<(store (addc (load addr:$dst), GR16:$src), addr:$dst),
848           (ADD16mr addr:$dst, GR16:$src)>;
849 def : Pat<(store (addc (load addr:$dst), (i16 (load addr:$src))), addr:$dst),
850           (ADD16mm addr:$dst, addr:$src)>;
851
852 def : Pat<(addc GR8:$src1, GR8:$src2),
853           (ADD8rr GR8:$src1, GR8:$src2)>;
854 def : Pat<(addc GR8:$src1, (load addr:$src2)),
855           (ADD8rm GR8:$src1, addr:$src2)>;
856 def : Pat<(addc GR8:$src1, imm:$src2),
857           (ADD8ri GR8:$src1, imm:$src2)>;
858 def : Pat<(store (addc (load addr:$dst), GR8:$src), addr:$dst),
859           (ADD8mr addr:$dst, GR8:$src)>;
860 def : Pat<(store (addc (load addr:$dst), (i8 (load addr:$src))), addr:$dst),
861           (ADD8mm addr:$dst, addr:$src)>;
862
863 def : Pat<(subc GR16:$src1, GR16:$src2),
864           (SUB16rr GR16:$src1, GR16:$src2)>;
865 def : Pat<(subc GR16:$src1, (load addr:$src2)),
866           (SUB16rm GR16:$src1, addr:$src2)>;
867 def : Pat<(subc GR16:$src1, imm:$src2),
868           (SUB16ri GR16:$src1, imm:$src2)>;
869 def : Pat<(store (subc (load addr:$dst), GR16:$src), addr:$dst),
870           (SUB16mr addr:$dst, GR16:$src)>;
871 def : Pat<(store (subc (load addr:$dst), (i16 (load addr:$src))), addr:$dst),
872           (SUB16mm addr:$dst, addr:$src)>;
873
874 def : Pat<(subc GR8:$src1, GR8:$src2),
875           (SUB8rr GR8:$src1, GR8:$src2)>;
876 def : Pat<(subc GR8:$src1, (load addr:$src2)),
877           (SUB8rm GR8:$src1, addr:$src2)>;
878 def : Pat<(subc GR8:$src1, imm:$src2),
879           (SUB8ri GR8:$src1, imm:$src2)>;
880 def : Pat<(store (subc (load addr:$dst), GR8:$src), addr:$dst),
881           (SUB8mr addr:$dst, GR8:$src)>;
882 def : Pat<(store (subc (load addr:$dst), (i8 (load addr:$src))), addr:$dst),
883           (SUB8mm addr:$dst, addr:$src)>;