@@ -154,6 +154,7 @@ def cg16imm : Operand<i16>,
154154//===----------------------------------------------------------------------===//
155155
156156def addr : ComplexPattern<iPTR, 2, "SelectAddr", [], []>;
157+ def addrIndReg : ComplexPattern<iPTR, 1, "SelectIndirectReg", [], [], 10>;
157158
158159//===----------------------------------------------------------------------===//
159160// Pattern Fragments
@@ -288,10 +289,12 @@ let isCall = 1,
288289 def CALLr : II16r<0b101,
289290 (outs), (ins GR16:$rs),
290291 "call\t$rs", [(MSP430call GR16:$rs)]>;
292+ def CALLn : II16n<0b101,
293+ (outs), (ins indreg:$rs),
294+ "call\t$rs", [(MSP430call (load addrIndReg:$rs))]>;
291295 def CALLm : II16m<0b101,
292296 (outs), (ins memsrc:$src),
293297 "call\t$src", [(MSP430call (load addr:$src))]>;
294- def CALLn : II16n<0b101, (outs), (ins indreg:$rs), "call\t$rs", []>;
295298 def CALLp : II16p<0b101, (outs), (ins postreg:$rs), "call\t$rs", []>;
296299}
297300
@@ -374,6 +377,10 @@ def MOVZX16rm8 : I8rm<0b0100,
374377 (outs GR16:$rd), (ins memsrc:$src),
375378 "mov.b\t{$src, $rd}",
376379 [(set GR16:$rd, (zextloadi16i8 addr:$src))]>;
380+ def MOVZX16rn8 : I8rn<0b0100,
381+ (outs GR16:$rd), (ins indreg:$rs),
382+ "mov.b\t{$rs, $rd}",
383+ [(set GR16:$rd, (zextloadi16i8 addrIndReg:$rs))]>;
377384}
378385
379386let mayLoad = 1, hasExtraDefRegAllocReq = 1, Constraints = "$rs = $wb" in {
@@ -685,9 +692,14 @@ def RRA16m : II16m<0b010,
685692 "rra\t$src",
686693 [(store (MSP430rra (i16 (load addr:$src))), addr:$src),
687694 (implicit SR)]>;
688-
689- def RRA8n : II8n<0b010, (outs), (ins indreg:$rs), "rra.b\t$rs", []>;
690- def RRA16n : II16n<0b010, (outs), (ins indreg:$rs), "rra\t$rs", []>;
695+ def RRA8n : II8n<0b010, (outs), (ins indreg:$rs), "rra.b\t$rs",
696+ [(store
697+ (MSP430rra (i8 (load addrIndReg:$rs))), addrIndReg:$rs),
698+ (implicit SR)]>;
699+ def RRA16n : II16n<0b010, (outs), (ins indreg:$rs), "rra\t$rs",
700+ [(store
701+ (MSP430rra (i16 (load addrIndReg:$rs))), addrIndReg:$rs),
702+ (implicit SR)]>;
691703def RRA8p : II8p<0b010, (outs), (ins postreg:$rs), "rra.b\t$rs", []>;
692704def RRA16p : II16p<0b010, (outs), (ins postreg:$rs), "rra\t$rs", []>;
693705
@@ -703,8 +715,18 @@ def RRC16m : II16m<0b000,
703715 [(store (MSP430rrc (i16 (load addr:$src))), addr:$src),
704716 (implicit SR)]>;
705717
706- def RRC8n : II8n<0b000, (outs), (ins indreg:$rs), "rrc.b\t$rs", []>;
707- def RRC16n : II16n<0b000, (outs), (ins indreg:$rs), "rrc\t$rs", []>;
718+ def RRC8n : II8n<0b000,
719+ (outs), (ins indreg:$rs),
720+ "rrc.b\t$rs",
721+ [(store
722+ (MSP430rrc (i8 (load addrIndReg:$rs))), addrIndReg:$rs),
723+ (implicit SR)]>;
724+ def RRC16n : II16n<0b000,
725+ (outs), (ins indreg:$rs),
726+ "rrc\t$rs",
727+ [(store
728+ (MSP430rrc (i16 (load addrIndReg:$rs))), addrIndReg:$rs),
729+ (implicit SR)]>;
708730def RRC8p : II8p<0b000, (outs), (ins postreg:$rs), "rrc.b\t$rs", []>;
709731def RRC16p : II16p<0b000, (outs), (ins postreg:$rs), "rrc\t$rs", []>;
710732
@@ -716,7 +738,10 @@ def SEXT16m : II16m<0b011,
716738 [(store (sext_inreg (extloadi16i8 addr:$src), i8),
717739 addr:$src),
718740 (implicit SR)]>;
719- def SEXT16n : II16n<0b011, (outs), (ins indreg:$rs), "sxt\t$rs", []>;
741+ def SEXT16n : II16n<0b011, (outs), (ins indreg:$rs), "sxt\t$rs",
742+ [(store (sext_inreg (extloadi16i8 addrIndReg:$rs), i8),
743+ addrIndReg:$rs),
744+ (implicit SR)]>;
720745def SEXT16p : II16p<0b011, (outs), (ins postreg:$rs), "sxt\t$rs", []>;
721746
722747} // Defs = [SR]
@@ -725,7 +750,9 @@ def SWPB16m : II16m<0b001,
725750 (outs), (ins memsrc:$src),
726751 "swpb\t$src",
727752 [(store (bswap (i16 (load addr:$src))), addr:$src)]>;
728- def SWPB16n : II16n<0b001, (outs), (ins indreg:$rs), "swpb\t$rs", []>;
753+ def SWPB16n : II16n<0b001, (outs), (ins indreg:$rs), "swpb\t$rs",
754+ [(store
755+ (bswap (i16 (load addrIndReg:$rs))), addrIndReg:$rs)]>;
729756def SWPB16p : II16p<0b001, (outs), (ins postreg:$rs), "swpb\t$rs", []>;
730757
731758// Integer comparisons
@@ -791,9 +818,15 @@ def CMP16rm : I16rm<0b1001,
791818 (implicit SR)]>;
792819
793820def CMP8rn : I8rn<0b1001,
794- (outs), (ins GR8:$rd, indreg:$rs), "cmp.b\t$rs, $rd", []>;
821+ (outs), (ins GR8:$rd, indreg:$rs),
822+ "cmp.b\t$rs, $rd",
823+ [(MSP430cmp GR8:$rd, (load addrIndReg:$rs)),
824+ (implicit SR)]>;
795825def CMP16rn : I16rn<0b1001,
796- (outs), (ins GR16:$rd, indreg:$rs), "cmp\t$rs, $rd", []>;
826+ (outs), (ins GR16:$rd, indreg:$rs),
827+ "cmp\t$rs, $rd",
828+ [(MSP430cmp GR16:$rd, (load addrIndReg:$rs)),
829+ (implicit SR)]>;
797830
798831def CMP8rp : I8rp<0b1001,
799832 (outs), (ins GR8:$rd, postreg:$rs), "cmp.b\t$rs, $rd", []>;
@@ -820,10 +853,16 @@ def CMP16mm : I16mm<0b1001, (outs), (ins memdst:$dst, memsrc:$src),
820853 [(MSP430cmp (load addr:$dst), (i16 (load addr:$src))),
821854 (implicit SR)]>;
822855
823- def CMP8mn : I8mn<0b1001, (outs), (ins memsrc:$dst, indreg:$rs),
824- "cmp.b\t$rs, $dst", []>;
825- def CMP16mn : I16mn<0b1001, (outs), (ins memsrc:$dst, indreg:$rs),
826- "cmp\t$rs, $dst", []>;
856+ def CMP8mn : I8mn<0b1001,
857+ (outs), (ins memsrc:$dst, indreg:$rs),
858+ "cmp.b\t$rs, $dst",
859+ [(MSP430cmp (load addr:$dst), (i8 (load addrIndReg:$rs))),
860+ (implicit SR)]>;
861+ def CMP16mn : I16mn<0b1001,
862+ (outs), (ins memsrc:$dst, indreg:$rs),
863+ "cmp\t$rs, $dst",
864+ [(MSP430cmp (load addr:$dst), (i16 (load addrIndReg:$rs))),
865+ (implicit SR)]>;
827866
828867def CMP8mp : I8mp<0b1001, (outs), (ins memsrc:$dst, postreg:$rs),
829868 "cmp.b\t$rs, $dst", []>;
@@ -877,10 +916,16 @@ def BIT16rm : I16rm<0b1011,
877916 [(MSP430cmp (and_su GR16:$rd, (load addr:$src)), 0),
878917 (implicit SR)]>;
879918
880- def BIT8rn : I8rn<0b1011, (outs), (ins GR8:$rd, indreg:$rs),
881- "bit.b\t$rs, $rd", []>;
882- def BIT16rn : I16rn<0b1011, (outs), (ins GR16:$rd, indreg:$rs),
883- "bit\t$rs, $rd", []>;
919+ def BIT8rn : I8rn<0b1011,
920+ (outs), (ins GR8:$rd, indreg:$rs),
921+ "bit.b\t$rs, $rd",
922+ [(MSP430cmp (and_su GR8:$rd, (load addrIndReg:$rs)), 0),
923+ (implicit SR)]>;
924+ def BIT16rn : I16rn<0b1011,
925+ (outs), (ins GR16:$rd, indreg:$rs),
926+ "bit\t$rs, $rd",
927+ [(MSP430cmp (and_su GR16:$rd, (load addrIndReg:$rs)), 0),
928+ (implicit SR)]>;
884929
885930def BIT8rp : I8rp<0b1011, (outs), (ins GR8:$rd, postreg:$rs),
886931 "bit.b\t$rs, $rd", []>;
@@ -956,6 +1001,7 @@ def TST16m : InstAlias<"tst\t$dst", (CMP16mc memdst:$dst, 0)>;
9561001
9571002// extload
9581003def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
1004+ def : Pat<(extloadi16i8 addrIndReg:$rs), (MOVZX16rn8 addrIndReg:$rs)>;
9591005
9601006// anyext
9611007def : Pat<(i16 (anyext GR8:$src)),
0 commit comments