From 54f30d3fc94e055f13e6744378323d05c5c050ba Mon Sep 17 00:00:00 2001 From: Anton Korobeynikov Date: Sun, 3 May 2009 13:06:26 +0000 Subject: [PATCH] Add normal and trunc stores git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70724 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/MSP430/MSP430ISelLowering.cpp | 4 ++++ lib/Target/MSP430/MSP430InstrInfo.td | 25 +++++++++++++++++++++++- lib/Target/MSP430/MSP430RegisterInfo.td | 2 ++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/lib/Target/MSP430/MSP430ISelLowering.cpp b/lib/Target/MSP430/MSP430ISelLowering.cpp index bd0db9bed42..81494fccdc0 100644 --- a/lib/Target/MSP430/MSP430ISelLowering.cpp +++ b/lib/Target/MSP430/MSP430ISelLowering.cpp @@ -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); } diff --git a/lib/Target/MSP430/MSP430InstrInfo.td b/lib/Target/MSP430/MSP430InstrInfo.td index 4a261e415c6..2554135d210 100644 --- a/lib/Target/MSP430/MSP430InstrInfo.td +++ b/lib/Target/MSP430/MSP430InstrInfo.td @@ -35,12 +35,17 @@ def MSP430rra : SDNode<"MSP430ISD::RRA", SDTIntUnaryOp, []>; // MSP430 Operand Definitions. //===----------------------------------------------------------------------===// -// Address operand +// Address operands def memsrc : Operand { let PrintMethod = "printSrcMemOperand"; let MIOperandInfo = (ops i16imm, GR16); } +def memdst : Operand { + 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)>; diff --git a/lib/Target/MSP430/MSP430RegisterInfo.td b/lib/Target/MSP430/MSP430RegisterInfo.td index 7564402860f..4078626ea2d 100644 --- a/lib/Target/MSP430/MSP430RegisterInfo.td +++ b/lib/Target/MSP430/MSP430RegisterInfo.td @@ -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, -- 2.34.1