X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTarget%2FMSP430%2FMSP430InstrInfo.td;h=b5f9491b453af67b8ef227cf62af3dcb10dc391f;hb=6b16eff207f99bbde3c0f7340452a5287218772c;hp=df60209d3da20503e4e1909dc362f7c46e8bfe34;hpb=49ebc2278472656e05541248eaedccb13e1b7d7d;p=oota-llvm.git diff --git a/lib/Target/MSP430/MSP430InstrInfo.td b/lib/Target/MSP430/MSP430InstrInfo.td index df60209d3da..b5f9491b453 100644 --- a/lib/Target/MSP430/MSP430InstrInfo.td +++ b/lib/Target/MSP430/MSP430InstrInfo.td @@ -26,13 +26,11 @@ def SDT_MSP430Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>; def SDT_MSP430CallSeqStart : SDCallSeqStart<[SDTCisVT<0, i16>]>; def SDT_MSP430CallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i16>, SDTCisVT<1, i16>]>; def SDT_MSP430Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>; -def SDT_MSP430SetCC : SDTypeProfile<1, 2, [SDTCisVT<0, i8>, - SDTCisVT<1, i8>, SDTCisVT<2, i16>]>; def SDT_MSP430Cmp : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>; -def SDT_MSP430BrCond : SDTypeProfile<0, 3, [SDTCisVT<0, OtherVT>, - SDTCisVT<1, i8>, SDTCisVT<2, i16>]>; -def SDT_MSP430Select : SDTypeProfile<1, 4, [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, - SDTCisVT<3, i8>, SDTCisVT<4, i16>]>; +def SDT_MSP430BrCC : SDTypeProfile<0, 2, [SDTCisVT<0, OtherVT>, + SDTCisVT<1, i8>]>; +def SDT_MSP430SelectCC : SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, + SDTCisVT<3, i8>]>; //===----------------------------------------------------------------------===// // MSP430 Specific Node Definitions. @@ -42,6 +40,7 @@ def MSP430retflag : SDNode<"MSP430ISD::RET_FLAG", SDTNone, def MSP430rra : SDNode<"MSP430ISD::RRA", SDTIntUnaryOp, []>; def MSP430rla : SDNode<"MSP430ISD::RLA", SDTIntUnaryOp, []>; +def MSP430rrc : SDNode<"MSP430ISD::RRC", SDTIntUnaryOp, []>; def MSP430call : SDNode<"MSP430ISD::CALL", SDT_MSP430Call, [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>; @@ -52,10 +51,9 @@ def MSP430callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_MSP430CallSeqEnd, [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>; def MSP430Wrapper : SDNode<"MSP430ISD::Wrapper", SDT_MSP430Wrapper>; -def MSP430setcc : SDNode<"MSP430ISD::SETCC", SDT_MSP430SetCC>; -def MSP430cmp : SDNode<"MSP430ISD::CMP", SDT_MSP430Cmp>; -def MSP430brcond : SDNode<"MSP430ISD::BRCOND", SDT_MSP430BrCond, [SDNPHasChain]>; -def MSP430select : SDNode<"MSP430ISD::SELECT", SDT_MSP430Select>; +def MSP430cmp : SDNode<"MSP430ISD::CMP", SDT_MSP430Cmp, [SDNPOutFlag]>; +def MSP430brcc : SDNode<"MSP430ISD::BR_CC", SDT_MSP430BrCC, [SDNPHasChain, SDNPInFlag]>; +def MSP430selectcc: SDNode<"MSP430ISD::SELECT_CC", SDT_MSP430SelectCC, [SDNPInFlag]>; //===----------------------------------------------------------------------===// // MSP430 Operand Definitions. @@ -109,10 +107,14 @@ def ADJCALLSTACKUP : Pseudo<(outs), (ins i16imm:$amt1, i16imm:$amt2), } let usesCustomDAGSchedInserter = 1 in { + def Select8 : Pseudo<(outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cc), + "# Select8 PSEUDO", + [(set GR8:$dst, + (MSP430selectcc GR8:$src1, GR8:$src2, imm:$cc))]>; def Select16 : Pseudo<(outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$cc), "# Select16 PSEUDO", [(set GR16:$dst, - (MSP430select GR16:$src1, GR16:$src2, imm:$cc, SRW))]>; + (MSP430selectcc GR16:$src1, GR16:$src2, imm:$cc))]>; } let neverHasSideEffects = 1 in @@ -139,7 +141,7 @@ let isBarrier = 1 in let Uses = [SRW] in def JCC : Pseudo<(outs), (ins brtarget:$dst, cc:$cc), "j$cc $dst", - [(MSP430brcond bb:$dst, imm:$cc, SRW)]>; + [(MSP430brcc bb:$dst, imm:$cc)]>; } // isBranch, isTerminator //===----------------------------------------------------------------------===// @@ -211,6 +213,22 @@ def MOVZX16rm8 : Pseudo<(outs GR16:$dst), (ins memsrc:$src), "mov.b\t{$src, $dst}", [(set GR16:$dst, (zextloadi16i8 addr:$src))]>; +// Any instruction that defines a 8-bit result leaves the high half of the +// register. Truncate can be lowered to EXTRACT_SUBREG, and CopyFromReg may +// be copying from a truncate, but any other 8-bit operation will zero-extend +// up to 16 bits. +def def8 : PatLeaf<(i8 GR8:$src), [{ + return N->getOpcode() != ISD::TRUNCATE && + N->getOpcode() != TargetInstrInfo::EXTRACT_SUBREG && + N->getOpcode() != ISD::CopyFromReg; +}]>; + +// In the case of a 8-bit def that is known to implicitly zero-extend, +// we can use a SUBREG_TO_REG. +def : Pat<(i16 (zext def8:$src)), + (SUBREG_TO_REG (i16 0), GR8:$src, subreg_8bit)>; + + def MOV8mi : Pseudo<(outs), (ins memdst:$dst, i8imm:$src), "mov.b\t{$src, $dst}", [(store (i8 imm:$src), addr:$dst)]>; @@ -587,16 +605,35 @@ def SBC16mm : Pseudo<(outs), (ins memdst:$dst, memsrc:$src), } // Uses = [SRW] // FIXME: Provide proper encoding! +def SAR8r1 : Pseudo<(outs GR8:$dst), (ins GR8:$src), + "rra.b\t$dst", + [(set GR8:$dst, (MSP430rra GR8:$src)), + (implicit SRW)]>; def SAR16r1 : Pseudo<(outs GR16:$dst), (ins GR16:$src), "rra.w\t$dst", [(set GR16:$dst, (MSP430rra GR16:$src)), (implicit SRW)]>; +def SHL8r1 : Pseudo<(outs GR8:$dst), (ins GR8:$src), + "rla.b\t$dst", + [(set GR8:$dst, (MSP430rla GR8:$src)), + (implicit SRW)]>; def SHL16r1 : Pseudo<(outs GR16:$dst), (ins GR16:$src), "rla.w\t$dst", [(set GR16:$dst, (MSP430rla GR16:$src)), (implicit SRW)]>; +def SAR8r1c : Pseudo<(outs GR8:$dst), (ins GR8:$src), + "clrc\n\t" + "rrc.b\t$dst", + [(set GR8:$dst, (MSP430rrc GR8:$src)), + (implicit SRW)]>; +def SAR16r1c : Pseudo<(outs GR16:$dst), (ins GR16:$src), + "clrc\n\t" + "rrc.w\t$dst", + [(set GR16:$dst, (MSP430rrc GR16:$src)), + (implicit SRW)]>; + def SEXT16r : Pseudo<(outs GR16:$dst), (ins GR16:$src), "sxt\t$dst", [(set GR16:$dst, (sext_inreg GR16:$src, i8)), @@ -671,12 +708,19 @@ def CMP16rr : Pseudo<(outs), (ins GR16:$src1, GR16:$src2), "cmp.w\t{$src1, $src2}", [(MSP430cmp GR16:$src1, GR16:$src2), (implicit SRW)]>; -def CMP8ri : Pseudo<(outs), (ins GR8:$src1, i8imm:$src2), +def CMP8ir : Pseudo<(outs), (ins i8imm:$src1, GR8:$src2), + "cmp.b\t{$src1, $src2}", + [(MSP430cmp imm:$src1, GR8:$src2), (implicit SRW)]>; +def CMP16ir : Pseudo<(outs), (ins i16imm:$src1, GR16:$src2), + "cmp.w\t{$src1, $src2}", + [(MSP430cmp imm:$src1, GR16:$src2), (implicit SRW)]>; + +def CMP8im : Pseudo<(outs), (ins i8imm:$src1, memsrc:$src2), "cmp.b\t{$src1, $src2}", - [(MSP430cmp GR8:$src1, imm:$src2), (implicit SRW)]>; -def CMP16ri : Pseudo<(outs), (ins GR16:$src1, i16imm:$src2), + [(MSP430cmp (i8 imm:$src1), (load addr:$src2)), (implicit SRW)]>; +def CMP16im : Pseudo<(outs), (ins i16imm:$src1, memsrc:$src2), "cmp.w\t{$src1, $src2}", - [(MSP430cmp GR16:$src1, imm:$src2), (implicit SRW)]>; + [(MSP430cmp (i16 imm:$src1), (load addr:$src2)), (implicit SRW)]>; def CMP8rm : Pseudo<(outs), (ins GR8:$src1, memsrc:$src2), "cmp.b\t{$src1, $src2}", @@ -692,19 +736,37 @@ def CMP16mr : Pseudo<(outs), (ins memsrc:$src1, GR16:$src2), "cmp.w\t{$src1, $src2}", [(MSP430cmp (load addr:$src1), GR16:$src2), (implicit SRW)]>; -def CMP8mi : Pseudo<(outs), (ins memsrc:$src1, i8imm:$src2), - "cmp.b\t{$src1, $src2}", - [(MSP430cmp (load addr:$src1), (i8 imm:$src2)), (implicit SRW)]>; -def CMP16mi : Pseudo<(outs), (ins memsrc:$src1, i16imm:$src2), - "cmp.w\t{$src1, $src2}", - [(MSP430cmp (load addr:$src1), (i16 imm:$src2)), (implicit SRW)]>; +def CMP8mi0 : Pseudo<(outs), (ins memsrc:$src1), + "cmp.b\t{$src1, #0}", + [(MSP430cmp (load addr:$src1), (i8 0)), (implicit SRW)]>; +def CMP16mi0: Pseudo<(outs), (ins memsrc:$src1), + "cmp.w\t{$src1, #0}", + [(MSP430cmp (load addr:$src1), (i16 0)), (implicit SRW)]>; +def CMP8mi1 : Pseudo<(outs), (ins memsrc:$src1), + "cmp.b\t{$src1, #1}", + [(MSP430cmp (load addr:$src1), (i8 1)), (implicit SRW)]>; +def CMP16mi1: Pseudo<(outs), (ins memsrc:$src1), + "cmp.w\t{$src1, #1}", + [(MSP430cmp (load addr:$src1), (i16 1)), (implicit SRW)]>; +def CMP8mi2 : Pseudo<(outs), (ins memsrc:$src1), + "cmp.b\t{$src1, #2}", + [(MSP430cmp (load addr:$src1), (i8 2)), (implicit SRW)]>; +def CMP16mi2: Pseudo<(outs), (ins memsrc:$src1), + "cmp.w\t{$src1, #2}", + [(MSP430cmp (load addr:$src1), (i16 2)), (implicit SRW)]>; +def CMP8mi4 : Pseudo<(outs), (ins memsrc:$src1), + "cmp.b\t{$src1, #4}", + [(MSP430cmp (load addr:$src1), (i8 4)), (implicit SRW)]>; +def CMP16mi4: Pseudo<(outs), (ins memsrc:$src1), + "cmp.w\t{$src1, #4}", + [(MSP430cmp (load addr:$src1), (i16 4)), (implicit SRW)]>; +def CMP8mi8 : Pseudo<(outs), (ins memsrc:$src1), + "cmp.b\t{$src1, #8}", + [(MSP430cmp (load addr:$src1), (i8 8)), (implicit SRW)]>; +def CMP16mi8: Pseudo<(outs), (ins memsrc:$src1), + "cmp.w\t{$src1, #8}", + [(MSP430cmp (load addr:$src1), (i16 8)), (implicit SRW)]>; -def CMP8mm : Pseudo<(outs), (ins memsrc:$src1, memsrc:$src2), - "cmp.b\t{$src1, $src2}", - [(MSP430cmp (load addr:$src1), (i8 (load addr:$src2))), (implicit SRW)]>; -def CMP16mm : Pseudo<(outs), (ins memsrc:$src1, memsrc:$src2), - "cmp.w\t{$src1, $src2}", - [(MSP430cmp (load addr:$src1), (i16 (load addr:$src2))), (implicit SRW)]>; } // Defs = [SRW] //===----------------------------------------------------------------------===// @@ -713,6 +775,9 @@ def CMP16mm : Pseudo<(outs), (ins memsrc:$src1, memsrc:$src2), // extload def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>; +// anyext +def : Pat<(anyext addr:$src), (MOVZX16rr8 GR8:$src)>; + // truncs def : Pat<(i8 (trunc GR16:$src)), (EXTRACT_SUBREG GR16:$src, subreg_8bit)>;