1 //===- MSP430InstrInfo.td - MSP430 Instruction defs -----------*- tblgen-*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the MSP430 instructions in TableGen format.
12 //===----------------------------------------------------------------------===//
14 include "MSP430InstrFormats.td"
16 //===----------------------------------------------------------------------===//
18 //===----------------------------------------------------------------------===//
19 class SDTCisI8<int OpNum> : SDTCisVT<OpNum, i8>;
20 class SDTCisI16<int OpNum> : SDTCisVT<OpNum, i16>;
22 //===----------------------------------------------------------------------===//
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>]>;
30 //===----------------------------------------------------------------------===//
31 // MSP430 Specific Node Definitions.
32 //===----------------------------------------------------------------------===//
33 def MSP430retflag : SDNode<"MSP430ISD::RET_FLAG", SDTNone,
34 [SDNPHasChain, SDNPOptInFlag]>;
36 def MSP430rra : SDNode<"MSP430ISD::RRA", SDTIntUnaryOp, []>;
38 def MSP430call : SDNode<"MSP430ISD::CALL", SDT_MSP430Call,
39 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
40 def MSP430callseq_start :
41 SDNode<"ISD::CALLSEQ_START", SDT_MSP430CallSeqStart,
42 [SDNPHasChain, SDNPOutFlag]>;
43 def MSP430callseq_end :
44 SDNode<"ISD::CALLSEQ_END", SDT_MSP430CallSeqEnd,
45 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
46 def MSP430Wrapper : SDNode<"MSP430ISD::Wrapper", SDT_MSP430Wrapper>;
48 //===----------------------------------------------------------------------===//
49 // MSP430 Operand Definitions.
50 //===----------------------------------------------------------------------===//
53 def memsrc : Operand<i16> {
54 let PrintMethod = "printSrcMemOperand";
55 let MIOperandInfo = (ops GR16, i16imm);
58 def memdst : Operand<i16> {
59 let PrintMethod = "printSrcMemOperand";
60 let MIOperandInfo = (ops GR16, i16imm);
63 //===----------------------------------------------------------------------===//
64 // MSP430 Complex Pattern Definitions.
65 //===----------------------------------------------------------------------===//
67 def addr : ComplexPattern<iPTR, 2, "SelectAddr", [], []>;
69 //===----------------------------------------------------------------------===//
71 def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
72 def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 ( extloadi8 node:$ptr))>;
74 //===----------------------------------------------------------------------===//
77 // ADJCALLSTACKDOWN/UP implicitly use/def SP because they may be expanded into
78 // a stack adjustment and the codegen must know that they may modify the stack
79 // pointer before prolog-epilog rewriting occurs.
80 // Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
81 // sub / add which can clobber SRW.
82 let Defs = [SPW, SRW], Uses = [SPW] in {
83 def ADJCALLSTACKDOWN : Pseudo<(outs), (ins i16imm:$amt),
85 [(MSP430callseq_start timm:$amt)]>;
86 def ADJCALLSTACKUP : Pseudo<(outs), (ins i16imm:$amt1, i16imm:$amt2),
88 [(MSP430callseq_end timm:$amt1, timm:$amt2)]>;
92 let neverHasSideEffects = 1 in
93 def NOP : Pseudo<(outs), (ins), "nop", []>;
95 // FIXME: Provide proper encoding!
96 let isReturn = 1, isTerminator = 1 in {
97 def RET : Pseudo<(outs), (ins), "ret", [(MSP430retflag)]>;
100 //===----------------------------------------------------------------------===//
101 // Call Instructions...
104 // All calls clobber the non-callee saved registers. SPW is marked as
105 // a use to prevent stack-pointer assignments that appear immediately
106 // before calls from potentially appearing dead. Uses for argument
107 // registers are added manually.
108 let Defs = [R12W, R13W, R14W, R15W, SRW],
110 def CALLi : Pseudo<(outs), (ins i16imm:$dst, variable_ops),
111 "call\t${dst:call}", [(MSP430call imm:$dst)]>;
112 def CALLr : Pseudo<(outs), (ins GR16:$dst, variable_ops),
113 "call\t$dst", [(MSP430call GR16:$dst)]>;
114 def CALLm : Pseudo<(outs), (ins memsrc:$dst, variable_ops),
115 "call\t${dst:mem}", [(MSP430call (load addr:$dst))]>;
119 //===----------------------------------------------------------------------===//
122 // FIXME: Provide proper encoding!
123 let neverHasSideEffects = 1 in {
124 def MOV8rr : Pseudo<(outs GR8:$dst), (ins GR8:$src),
125 "mov.b\t{$src, $dst|$dst, $src}",
127 def MOV16rr : Pseudo<(outs GR16:$dst), (ins GR16:$src),
128 "mov.w\t{$src, $dst|$dst, $src}",
132 // FIXME: Provide proper encoding!
133 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
134 def MOV8ri : Pseudo<(outs GR8:$dst), (ins i8imm:$src),
135 "mov.b\t{$src, $dst|$dst, $src}",
136 [(set GR8:$dst, imm:$src)]>;
137 def MOV16ri : Pseudo<(outs GR16:$dst), (ins i16imm:$src),
138 "mov.w\t{$src, $dst|$dst, $src}",
139 [(set GR16:$dst, imm:$src)]>;
142 let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
143 def MOV8rm : Pseudo<(outs GR8:$dst), (ins memsrc:$src),
144 "mov.b\t{$src, $dst|$dst, $src}",
145 [(set GR8:$dst, (load addr:$src))]>;
146 def MOV16rm : Pseudo<(outs GR16:$dst), (ins memsrc:$src),
147 "mov.w\t{$src, $dst|$dst, $src}",
148 [(set GR16:$dst, (load addr:$src))]>;
151 def MOVZX16rr8 : Pseudo<(outs GR16:$dst), (ins GR8:$src),
152 "mov.b\t{$src, $dst|$dst, $src}",
153 [(set GR16:$dst, (zext GR8:$src))]>;
154 def MOVZX16rm8 : Pseudo<(outs GR16:$dst), (ins memsrc:$src),
155 "mov.b\t{$src, $dst|$dst, $src}",
156 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>;
158 def MOV8mi : Pseudo<(outs), (ins memdst:$dst, i8imm:$src),
159 "mov.b\t{$src, $dst|$dst, $src}",
160 [(store (i8 imm:$src), addr:$dst)]>;
161 def MOV16mi : Pseudo<(outs), (ins memdst:$dst, i16imm:$src),
162 "mov.w\t{$src, $dst|$dst, $src}",
163 [(store (i16 imm:$src), addr:$dst)]>;
165 def MOV8mr : Pseudo<(outs), (ins memdst:$dst, GR8:$src),
166 "mov.b\t{$src, $dst|$dst, $src}",
167 [(store GR8:$src, addr:$dst)]>;
168 def MOV16mr : Pseudo<(outs), (ins memdst:$dst, GR16:$src),
169 "mov.w\t{$src, $dst|$dst, $src}",
170 [(store GR16:$src, addr:$dst)]>;
172 //===----------------------------------------------------------------------===//
173 // Arithmetic Instructions
175 let isTwoAddress = 1 in {
177 let Defs = [SRW] in {
179 let isCommutable = 1 in { // X = ADD Y, Z == X = ADD Z, Y
180 // FIXME: Provide proper encoding!
181 def ADD8rr : Pseudo<(outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
182 "add.b\t{$src2, $dst|$dst, $src2}",
183 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
185 def ADD16rr : Pseudo<(outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
186 "add.w\t{$src2, $dst|$dst, $src2}",
187 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
191 def ADD8rm : Pseudo<(outs GR8:$dst), (ins GR8:$src1, memsrc:$src2),
192 "add.b\t{$src2, $dst|$dst, $src2}",
193 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
195 def ADD16rm : Pseudo<(outs GR16:$dst), (ins GR16:$src1, memsrc:$src2),
196 "add.w\t{$src2, $dst|$dst, $src2}",
197 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
200 def ADD8ri : Pseudo<(outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
201 "add.b\t{$src2, $dst|$dst, $src2}",
202 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
204 def ADD16ri : Pseudo<(outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
205 "add.w\t{$src2, $dst|$dst, $src2}",
206 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
209 let isTwoAddress = 0 in {
210 def ADD8mr : Pseudo<(outs), (ins memdst:$dst, GR8:$src),
211 "add.b\t{$src, $dst|$dst, $src}",
212 [(store (add (load addr:$dst), GR8:$src), addr:$dst),
214 def ADD16mr : Pseudo<(outs), (ins memdst:$dst, GR16:$src),
215 "add.w\t{$src, $dst|$dst, $src}",
216 [(store (add (load addr:$dst), GR16:$src), addr:$dst),
219 def ADD8mi : Pseudo<(outs), (ins memdst:$dst, i8imm:$src),
220 "add.b\t{$src, $dst|$dst, $src}",
221 [(store (add (load addr:$dst), (i8 imm:$src)), addr:$dst),
223 def ADD16mi : Pseudo<(outs), (ins memdst:$dst, i16imm:$src),
224 "add.w\t{$src, $dst|$dst, $src}",
225 [(store (add (load addr:$dst), (i16 imm:$src)), addr:$dst),
228 def ADD8mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src),
229 "add.b\t{$src, $dst|$dst, $src}",
230 [(store (add (load addr:$dst), (i8 (load addr:$src))), addr:$dst),
232 def ADD16mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src),
233 "add.w\t{$src, $dst|$dst, $src}",
234 [(store (add (load addr:$dst), (i16 (load addr:$src))), addr:$dst),
238 let Uses = [SRW] in {
240 let isCommutable = 1 in { // X = ADDC Y, Z == X = ADDC Z, Y
241 def ADC8rr : Pseudo<(outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
242 "addc.b\t{$src2, $dst|$dst, $src2}",
243 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2)),
245 def ADC16rr : Pseudo<(outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
246 "addc.w\t{$src2, $dst|$dst, $src2}",
247 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2)),
251 def ADC8ri : Pseudo<(outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
252 "addc.b\t{$src2, $dst|$dst, $src2}",
253 [(set GR8:$dst, (adde GR8:$src1, imm:$src2)),
255 def ADC16ri : Pseudo<(outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
256 "addc.w\t{$src2, $dst|$dst, $src2}",
257 [(set GR16:$dst, (adde GR16:$src1, imm:$src2)),
260 def ADC8rm : Pseudo<(outs GR8:$dst), (ins GR8:$src1, memsrc:$src2),
261 "addc.b\t{$src2, $dst|$dst, $src2}",
262 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2))),
264 def ADC16rm : Pseudo<(outs GR16:$dst), (ins GR16:$src1, memsrc:$src2),
265 "addc.w\t{$src2, $dst|$dst, $src2}",
266 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2))),
269 let isTwoAddress = 0 in {
270 def ADC8mr : Pseudo<(outs), (ins memdst:$dst, GR8:$src),
271 "addc.b\t{$src, $dst|$dst, $src}",
272 [(store (adde (load addr:$dst), GR8:$src), addr:$dst),
274 def ADC16mr : Pseudo<(outs), (ins memdst:$dst, GR16:$src),
275 "addc.w\t{$src, $dst|$dst, $src}",
276 [(store (adde (load addr:$dst), GR16:$src), addr:$dst),
279 def ADC8mi : Pseudo<(outs), (ins memdst:$dst, i8imm:$src),
280 "addc.b\t{$src, $dst|$dst, $src}",
281 [(store (adde (load addr:$dst), (i8 imm:$src)), addr:$dst),
283 def ADC16mi : Pseudo<(outs), (ins memdst:$dst, i16imm:$src),
284 "addc.w\t{$src, $dst|$dst, $src}",
285 [(store (adde (load addr:$dst), (i16 imm:$src)), addr:$dst),
288 def ADC8mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src),
289 "addc.b\t{$src, $dst|$dst, $src}",
290 [(store (adde (load addr:$dst), (i8 (load addr:$src))), addr:$dst),
292 def ADC16mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src),
293 "addc.w\t{$src, $dst|$dst, $src}",
294 [(store (adde (load addr:$dst), (i16 (load addr:$src))), addr:$dst),
300 let isCommutable = 1 in { // X = AND Y, Z == X = AND Z, Y
301 def AND8rr : Pseudo<(outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
302 "and.b\t{$src2, $dst|$dst, $src2}",
303 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
305 def AND16rr : Pseudo<(outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
306 "and.w\t{$src2, $dst|$dst, $src2}",
307 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
311 def AND8ri : Pseudo<(outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
312 "and.b\t{$src2, $dst|$dst, $src2}",
313 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
315 def AND16ri : Pseudo<(outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
316 "and.w\t{$src2, $dst|$dst, $src2}",
317 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
320 def AND8rm : Pseudo<(outs GR8:$dst), (ins GR8:$src1, memsrc:$src2),
321 "and.b\t{$src2, $dst|$dst, $src2}",
322 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2))),
324 def AND16rm : Pseudo<(outs GR16:$dst), (ins GR16:$src1, memsrc:$src2),
325 "and.w\t{$src2, $dst|$dst, $src2}",
326 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2))),
329 let isTwoAddress = 0 in {
330 def AND8mr : Pseudo<(outs), (ins memdst:$dst, GR8:$src),
331 "and.b\t{$src, $dst|$dst, $src}",
332 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
334 def AND16mr : Pseudo<(outs), (ins memdst:$dst, GR16:$src),
335 "and.w\t{$src, $dst|$dst, $src}",
336 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
339 def AND8mi : Pseudo<(outs), (ins memdst:$dst, i8imm:$src),
340 "and.b\t{$src, $dst|$dst, $src}",
341 [(store (and (load addr:$dst), (i8 imm:$src)), addr:$dst),
343 def AND16mi : Pseudo<(outs), (ins memdst:$dst, i16imm:$src),
344 "and.w\t{$src, $dst|$dst, $src}",
345 [(store (and (load addr:$dst), (i16 imm:$src)), addr:$dst),
348 def AND8mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src),
349 "and.b\t{$src, $dst|$dst, $src}",
350 [(store (and (load addr:$dst), (i8 (load addr:$src))), addr:$dst),
352 def AND16mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src),
353 "and.w\t{$src, $dst|$dst, $src}",
354 [(store (and (load addr:$dst), (i16 (load addr:$src))), addr:$dst),
359 let isCommutable = 1 in { // X = XOR Y, Z == X = XOR Z, Y
360 def XOR8rr : Pseudo<(outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
361 "xor.b\t{$src2, $dst|$dst, $src2}",
362 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
364 def XOR16rr : Pseudo<(outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
365 "xor.w\t{$src2, $dst|$dst, $src2}",
366 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
370 def XOR8ri : Pseudo<(outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
371 "xor.b\t{$src2, $dst|$dst, $src2}",
372 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
374 def XOR16ri : Pseudo<(outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
375 "xor.w\t{$src2, $dst|$dst, $src2}",
376 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
379 def XOR8rm : Pseudo<(outs GR8:$dst), (ins GR8:$src1, memsrc:$src2),
380 "xor.b\t{$src2, $dst|$dst, $src2}",
381 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
383 def XOR16rm : Pseudo<(outs GR16:$dst), (ins GR16:$src1, memsrc:$src2),
384 "xor.w\t{$src2, $dst|$dst, $src2}",
385 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
388 let isTwoAddress = 0 in {
389 def XOR8mr : Pseudo<(outs), (ins memdst:$dst, GR8:$src),
390 "xor.b\t{$src, $dst|$dst, $src}",
391 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
393 def XOR16mr : Pseudo<(outs), (ins memdst:$dst, GR16:$src),
394 "xor.w\t{$src, $dst|$dst, $src}",
395 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
398 def XOR8mi : Pseudo<(outs), (ins memdst:$dst, i8imm:$src),
399 "xor.b\t{$src, $dst|$dst, $src}",
400 [(store (xor (load addr:$dst), (i8 imm:$src)), addr:$dst),
402 def XOR16mi : Pseudo<(outs), (ins memdst:$dst, i16imm:$src),
403 "xor.w\t{$src, $dst|$dst, $src}",
404 [(store (xor (load addr:$dst), (i16 imm:$src)), addr:$dst),
407 def XOR8mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src),
408 "xor.b\t{$src, $dst|$dst, $src}",
409 [(store (xor (load addr:$dst), (i8 (load addr:$src))), addr:$dst),
411 def XOR16mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src),
412 "xor.w\t{$src, $dst|$dst, $src}",
413 [(store (xor (load addr:$dst), (i16 (load addr:$src))), addr:$dst),
418 def SUB8rr : Pseudo<(outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
419 "sub.b\t{$src2, $dst|$dst, $src2}",
420 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
422 def SUB16rr : Pseudo<(outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
423 "sub.w\t{$src2, $dst|$dst, $src2}",
424 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
427 def SUB8ri : Pseudo<(outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
428 "sub.b\t{$src2, $dst|$dst, $src2}",
429 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
431 def SUB16ri : Pseudo<(outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
432 "sub.w\t{$src2, $dst|$dst, $src2}",
433 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
436 def SUB8rm : Pseudo<(outs GR8:$dst), (ins GR8:$src1, memsrc:$src2),
437 "sub.b\t{$src2, $dst|$dst, $src2}",
438 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
440 def SUB16rm : Pseudo<(outs GR16:$dst), (ins GR16:$src1, memsrc:$src2),
441 "sub.w\t{$src2, $dst|$dst, $src2}",
442 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
445 let isTwoAddress = 0 in {
446 def SUB8mr : Pseudo<(outs), (ins memdst:$dst, GR8:$src),
447 "sub.b\t{$src, $dst|$dst, $src}",
448 [(store (sub (load addr:$dst), GR8:$src), addr:$dst),
450 def SUB16mr : Pseudo<(outs), (ins memdst:$dst, GR16:$src),
451 "sub.w\t{$src, $dst|$dst, $src}",
452 [(store (sub (load addr:$dst), GR16:$src), addr:$dst),
455 def SUB8mi : Pseudo<(outs), (ins memdst:$dst, i8imm:$src),
456 "sub.b\t{$src, $dst|$dst, $src}",
457 [(store (sub (load addr:$dst), (i8 imm:$src)), addr:$dst),
459 def SUB16mi : Pseudo<(outs), (ins memdst:$dst, i16imm:$src),
460 "sub.w\t{$src, $dst|$dst, $src}",
461 [(store (sub (load addr:$dst), (i16 imm:$src)), addr:$dst),
464 def SUB8mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src),
465 "sub.b\t{$src, $dst|$dst, $src}",
466 [(store (sub (load addr:$dst), (i8 (load addr:$src))), addr:$dst),
468 def SUB16mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src),
469 "sub.w\t{$src, $dst|$dst, $src}",
470 [(store (sub (load addr:$dst), (i16 (load addr:$src))), addr:$dst),
474 let Uses = [SRW] in {
475 def SBC8rr : Pseudo<(outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
476 "subc.b\t{$src2, $dst|$dst, $src2}",
477 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2)),
479 def SBC16rr : Pseudo<(outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
480 "subc.w\t{$src2, $dst|$dst, $src2}",
481 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2)),
484 def SBC8ri : Pseudo<(outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
485 "subc.b\t{$src2, $dst|$dst, $src2}",
486 [(set GR8:$dst, (sube GR8:$src1, imm:$src2)),
488 def SBC16ri : Pseudo<(outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
489 "subc.w\t{$src2, $dst|$dst, $src2}",
490 [(set GR16:$dst, (sube GR16:$src1, imm:$src2)),
493 def SBC8rm : Pseudo<(outs GR8:$dst), (ins GR8:$src1, memsrc:$src2),
494 "subc.b\t{$src2, $dst|$dst, $src2}",
495 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2))),
497 def SBC16rm : Pseudo<(outs GR16:$dst), (ins GR16:$src1, memsrc:$src2),
498 "subc.w\t{$src2, $dst|$dst, $src2}",
499 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2))),
502 let isTwoAddress = 0 in {
503 def SBC8mr : Pseudo<(outs), (ins memdst:$dst, GR8:$src),
504 "subc.b\t{$src, $dst|$dst, $src}",
505 [(store (sube (load addr:$dst), GR8:$src), addr:$dst),
507 def SBC16mr : Pseudo<(outs), (ins memdst:$dst, GR16:$src),
508 "subc.w\t{$src, $dst|$dst, $src}",
509 [(store (sube (load addr:$dst), GR16:$src), addr:$dst),
512 def SBC8mi : Pseudo<(outs), (ins memdst:$dst, i8imm:$src),
513 "subc.b\t{$src, $dst|$dst, $src}",
514 [(store (sube (load addr:$dst), (i8 imm:$src)), addr:$dst),
516 def SBC16mi : Pseudo<(outs), (ins memdst:$dst, i16imm:$src),
517 "subc.w\t{$src, $dst|$dst, $src}",
518 [(store (sube (load addr:$dst), (i16 imm:$src)), addr:$dst),
521 def SBC8mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src),
522 "subc.b\t{$src, $dst|$dst, $src}",
523 [(store (sube (load addr:$dst), (i8 (load addr:$src))), addr:$dst),
525 def SBC16mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src),
526 "subc.w\t{$src, $dst|$dst, $src}",
527 [(store (sube (load addr:$dst), (i16 (load addr:$src))), addr:$dst),
533 // FIXME: Provide proper encoding!
534 def SAR16r1 : Pseudo<(outs GR16:$dst), (ins GR16:$src),
536 [(set GR16:$dst, (MSP430rra GR16:$src)),
539 def SEXT16r : Pseudo<(outs GR16:$dst), (ins GR16:$src),
541 [(set GR16:$dst, (sext_inreg GR16:$src, i8)),
544 //def SEXT16r : Pseudo<(outs GR16:$dst), (ins GR16:$src),
546 // [(set GR16:$dst, (sext_inreg GR16:$src, i8)),
551 let isCommutable = 1 in { // X = OR Y, Z == X = OR Z, Y
552 def OR8rr : Pseudo<(outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
553 "bis.b\t{$src2, $dst|$dst, $src2}",
554 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
555 def OR16rr : Pseudo<(outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
556 "bis.w\t{$src2, $dst|$dst, $src2}",
557 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>;
560 def OR8ri : Pseudo<(outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
561 "bis.b\t{$src2, $dst|$dst, $src2}",
562 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
563 def OR16ri : Pseudo<(outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
564 "bis.w\t{$src2, $dst|$dst, $src2}",
565 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>;
567 def OR8rm : Pseudo<(outs GR8:$dst), (ins GR8:$src1, memsrc:$src2),
568 "bis.b\t{$src2, $dst|$dst, $src2}",
569 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
570 def OR16rm : Pseudo<(outs GR16:$dst), (ins GR16:$src1, memsrc:$src2),
571 "bis.w\t{$src2, $dst|$dst, $src2}",
572 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>;
574 let isTwoAddress = 0 in {
575 def OR8mr : Pseudo<(outs), (ins memdst:$dst, GR8:$src),
576 "bis.b\t{$src, $dst|$dst, $src}",
577 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
579 def OR16mr : Pseudo<(outs), (ins memdst:$dst, GR16:$src),
580 "bis.w\t{$src, $dst|$dst, $src}",
581 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
584 def OR8mi : Pseudo<(outs), (ins memdst:$dst, i8imm:$src),
585 "bis.b\t{$src, $dst|$dst, $src}",
586 [(store (or (load addr:$dst), (i8 imm:$src)), addr:$dst),
588 def OR16mi : Pseudo<(outs), (ins memdst:$dst, i16imm:$src),
589 "bis.w\t{$src, $dst|$dst, $src}",
590 [(store (or (load addr:$dst), (i16 imm:$src)), addr:$dst),
593 def OR8mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src),
594 "bis.b\t{$src, $dst|$dst, $src}",
595 [(store (or (load addr:$dst), (i8 (load addr:$src))), addr:$dst),
597 def OR16mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src),
598 "bis.w\t{$src, $dst|$dst, $src}",
599 [(store (or (load addr:$dst), (i16 (load addr:$src))), addr:$dst),
603 } // isTwoAddress = 1
605 //===----------------------------------------------------------------------===//
606 // Non-Instruction Patterns
609 def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
612 def : Pat<(i8 (trunc GR16:$src)),
613 (EXTRACT_SUBREG GR16:$src, subreg_8bit)>;
616 def : Pat<(i16 (MSP430Wrapper tglobaladdr:$dst)), (MOV16ri tglobaladdr:$dst)>;
618 def : Pat<(add GR16:$src1, (MSP430Wrapper tglobaladdr :$src2)),
619 (ADD16ri GR16:$src1, tglobaladdr:$src2)>;
622 def : Pat<(MSP430call (i16 tglobaladdr:$dst)),
623 (CALLi tglobaladdr:$dst)>;