Add normal and trunc stores
authorAnton Korobeynikov <asl@math.spbu.ru>
Sun, 3 May 2009 13:06:26 +0000 (13:06 +0000)
committerAnton Korobeynikov <asl@math.spbu.ru>
Sun, 3 May 2009 13:06:26 +0000 (13:06 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70724 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/MSP430/MSP430ISelLowering.cpp
lib/Target/MSP430/MSP430InstrInfo.td
lib/Target/MSP430/MSP430RegisterInfo.td

index bd0db9bed42803321153c3a2d84ed21e2b0e4e47..81494fccdc0dddd0ca080bd8508ff5a45d138548 100644 (file)
@@ -39,6 +39,7 @@ MSP430TargetLowering::MSP430TargetLowering(MSP430TargetMachine &tm) :
   TargetLowering(tm), Subtarget(*tm.getSubtargetImpl()), TM(tm) {
 
   // Set up the register classes.
+  addRegisterClass(MVT::i8,  MSP430::GR8RegisterClass);
   addRegisterClass(MVT::i16, MSP430::GR16RegisterClass);
 
   // Compute derived properties from the register classes
@@ -59,6 +60,9 @@ MSP430TargetLowering::MSP430TargetLowering(MSP430TargetMachine &tm) :
   setLoadExtAction(ISD::SEXTLOAD, MVT::i8, Expand);
   setLoadExtAction(ISD::SEXTLOAD, MVT::i16, Expand);
 
+  // We don't have any truncstores
+  setTruncStoreAction(MVT::i16, MVT::i8, Expand);
+
   setOperationAction(ISD::SRA, MVT::i16, Custom);
   setOperationAction(ISD::RET, MVT::Other, Custom);
 }
index 4a261e415c6802f9f3557e4a5d9dc932f6f22006..2554135d2105c8ff80d19012a3b61b8fdf0a6a7a 100644 (file)
@@ -35,12 +35,17 @@ def MSP430rra     : SDNode<"MSP430ISD::RRA", SDTIntUnaryOp, []>;
 // MSP430 Operand Definitions.
 //===----------------------------------------------------------------------===//
 
-// Address operand
+// Address operands
 def memsrc : Operand<i16> {
   let PrintMethod = "printSrcMemOperand";
   let MIOperandInfo = (ops i16imm, GR16);
 }
 
+def memdst : Operand<i16> {
+  let PrintMethod = "printSrcMemOperand";
+  let MIOperandInfo = (ops i16imm, GR16);
+}
+
 
 //===----------------------------------------------------------------------===//
 // MSP430 Complex Pattern Definitions.
@@ -106,6 +111,20 @@ def MOVZX16rm8 : Pseudo<(outs GR16:$dst), (ins memsrc:$src),
                 "mov.b\t{$src, $dst|$dst, $src}",
                 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>;
 
+def MOV8mi  : Pseudo<(outs), (ins memdst:$dst, i8imm:$src),
+                "mov.b\t{$src, $dst|$dst, $src}",
+                [(store (i8 imm:$src), addr:$dst)]>;
+def MOV16mi : Pseudo<(outs), (ins memdst:$dst, i16imm:$src),
+                "mov.w\t{$src, $dst|$dst, $src}",
+                [(store (i16 imm:$src), addr:$dst)]>;
+
+def MOV8mr  : Pseudo<(outs), (ins memdst:$dst, GR8:$src),
+                "mov.b\t{$src, $dst|$dst, $src}",
+                [(store GR8:$src, addr:$dst)]>;
+def MOV16mr : Pseudo<(outs), (ins memdst:$dst, GR16:$src),
+                "mov.w\t{$src, $dst|$dst, $src}",
+                [(store GR16:$src, addr:$dst)]>;
+
 //===----------------------------------------------------------------------===//
 // Arithmetic Instructions
 
@@ -273,3 +292,7 @@ def OR8ri  : Pseudo<(outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
 
 // extload
 def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
+
+// truncs
+def : Pat<(i8 (trunc GR16:$src)),
+          (EXTRACT_SUBREG GR16:$src, subreg_8bit)>;
index 7564402860fb9808d0f4b272abc7a326ebb390b5..4078626ea2ddda0f0ea8c13191bd345710ef25d2 100644 (file)
@@ -65,6 +65,8 @@ def : SubRegSet<1, [PCW, SPW, SRW, CGW, FPW,
                    [PCB, SPB, SRB, CGB, FPB,
                     R5B, R6B, R7B, R8B, R9B, R10B, R11B, R12B, R13B, R14B, R15B]>;
 
+def subreg_8bit : PatLeaf<(i32 1)>;
+
 def GR8 : RegisterClass<"MSP430", [i8], 8,
    // Volatile registers
   [R12B, R13B, R14B, R15B, R11B, R10B, R9B, R8B, R7B, R6B, R5B,