diff options
author | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2008-06-06 00:58:26 +0000 |
---|---|---|
committer | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2008-06-06 00:58:26 +0000 |
commit | 07cec75913b74d04df40ff7fecf51f87175076c1 (patch) | |
tree | 54235299d2c7d3f61f573bbcff9378f3d0bdc4f6 /lib/Target/Mips/MipsISelDAGToDAG.cpp | |
parent | 836bfcd6896526a21ad1c800b1ca5ae90de1df0a (diff) | |
download | llvm-07cec75913b74d04df40ff7fecf51f87175076c1.tar.gz llvm-07cec75913b74d04df40ff7fecf51f87175076c1.tar.bz2 llvm-07cec75913b74d04df40ff7fecf51f87175076c1.tar.xz |
Added custom SELECT_CC lowering
Added special isel for ADDE,SUBE and new patterns to match SUBC,ADDC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52031 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/Mips/MipsISelDAGToDAG.cpp')
-rw-r--r-- | lib/Target/Mips/MipsISelDAGToDAG.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/lib/Target/Mips/MipsISelDAGToDAG.cpp b/lib/Target/Mips/MipsISelDAGToDAG.cpp index b2ad66670b..8043f7b173 100644 --- a/lib/Target/Mips/MipsISelDAGToDAG.cpp +++ b/lib/Target/Mips/MipsISelDAGToDAG.cpp @@ -226,6 +226,52 @@ Select(SDOperand N) default: break; + case ISD::ADDE: { + // ADDE is usally attached with a ADDC instruction, we must + // compare ADDC operands and set a register if we have a carry. + SDOperand InFlag = Node->getOperand(2); + unsigned Opc = InFlag.getOpcode(); + assert((Opc == ISD::ADDC || Opc == ISD::ADDE) && + "ADDE flag operand must come from a ADDC or ADDE"); + SDOperand Ops[] = { InFlag.getValue(0), InFlag.getOperand(1) }; + + SDOperand LHS = Node->getOperand(0); + SDOperand RHS = Node->getOperand(1); + AddToISelQueue(LHS); + AddToISelQueue(RHS); + + MVT::ValueType VT = LHS.getValueType(); + SDNode *Carry = CurDAG->getTargetNode(Mips::SLTu, VT, Ops, 2); + SDNode *AddCarry = CurDAG->getTargetNode(Mips::ADDu, VT, + SDOperand(Carry,0), RHS); + + return CurDAG->SelectNodeTo(N.Val, Mips::ADDu, VT, MVT::Flag, + LHS, SDOperand(AddCarry,0)); + } + + case ISD::SUBE: { + // SUBE is usally attached with a SUBC instruction, we must + // compare SUBC operands and set a register if we have a carry. + SDOperand InFlag = Node->getOperand(2); + unsigned Opc = InFlag.getOpcode(); + assert((Opc == ISD::SUBC || Opc == ISD::SUBE) && + "SUBE flag operand must come from a SUBC or SUBE"); + SDOperand Ops[] = { InFlag.getOperand(0), InFlag.getOperand(1) }; + + SDOperand LHS = Node->getOperand(0); + SDOperand RHS = Node->getOperand(1); + AddToISelQueue(LHS); + AddToISelQueue(RHS); + + MVT::ValueType VT = LHS.getValueType(); + SDNode *Carry = CurDAG->getTargetNode(Mips::SLTu, VT, Ops, 2); + SDNode *AddCarry = CurDAG->getTargetNode(Mips::ADDu, VT, + SDOperand(Carry,0), RHS); + + return CurDAG->SelectNodeTo(N.Val, Mips::SUBu, VT, MVT::Flag, + LHS, SDOperand(AddCarry,0)); + } + /// Special Mul operations case ISD::MULHS: case ISD::MULHU: { |