[llvm-commits] [SignlessTypes] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
Reid Spencer
reid at x10sys.com
Sun Oct 22 01:59:32 PDT 2006
Changes in directory llvm/lib/CodeGen/SelectionDAG:
SelectionDAGISel.cpp updated: 1.289.2.4 -> 1.289.2.5
---
Log message:
Implement the FDIV instruction for floating point divide.
---
Diffs of the changes: (+42 -16)
SelectionDAGISel.cpp | 58 ++++++++++++++++++++++++++++++++++++---------------
1 files changed, 42 insertions(+), 16 deletions(-)
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.289.2.4 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.289.2.5
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.289.2.4 Fri Oct 20 03:19:49 2006
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Sun Oct 22 03:59:00 2006
@@ -499,24 +499,35 @@
void visitInvoke(InvokeInst &I) { assert(0 && "TODO"); }
void visitUnwind(UnwindInst &I) { assert(0 && "TODO"); }
- void visitBinary(User &I, unsigned IntOp, unsigned FPOp, unsigned VecOp);
+ void visitIntBinary(User &I, unsigned IntOp, unsigned VecOp);
+ void visitFPBinary(User &I, unsigned FPOp, unsigned VecOp);
void visitShift(User &I, unsigned Opcode);
void visitAdd(User &I) {
- visitBinary(I, ISD::ADD, ISD::FADD, ISD::VADD);
+ if (I.getType()->isFloatingPoint())
+ visitFPBinary(I, ISD::FADD, ISD::VADD);
+ else
+ visitIntBinary(I, ISD::ADD, ISD::VADD);
}
void visitSub(User &I);
- void visitMul(User &I) {
- visitBinary(I, ISD::MUL, ISD::FMUL, ISD::VMUL);
+ void visitMul(User &I) {
+ if (I.getType()->isFloatingPoint())
+ visitFPBinary(I, ISD::FMUL, ISD::VMUL);
+ else
+ visitIntBinary(I, ISD::MUL, ISD::VMUL);
}
- void visitUDiv(User &I) { visitBinary(I, ISD::UDIV, ISD::FDIV, ISD::VUDIV); }
- void visitSDiv(User &I) { visitBinary(I, ISD::SDIV, ISD::FDIV, ISD::VSDIV); }
+ void visitUDiv(User &I) { visitIntBinary(I, ISD::UDIV, ISD::VUDIV); }
+ void visitSDiv(User &I) { visitIntBinary(I, ISD::SDIV, ISD::VSDIV); }
+ void visitFDiv(User &I) { visitFPBinary(I, ISD::FDIV, ISD::VSDIV); }
void visitRem(User &I) {
const Type *Ty = I.getType();
- visitBinary(I, Ty->isSigned() ? ISD::SREM : ISD::UREM, ISD::FREM, 0);
- }
- void visitAnd(User &I) { visitBinary(I, ISD::AND, 0, ISD::VAND); }
- void visitOr (User &I) { visitBinary(I, ISD::OR, 0, ISD::VOR); }
- void visitXor(User &I) { visitBinary(I, ISD::XOR, 0, ISD::VXOR); }
+ if (Ty->isFloatingPoint())
+ visitFPBinary(I, ISD::FREM, 0);
+ else
+ visitIntBinary(I, Ty->isSigned() ? ISD::SREM : ISD::UREM, 0);
+ }
+ void visitAnd(User &I) { visitIntBinary(I, ISD::AND, ISD::VAND); }
+ void visitOr (User &I) { visitIntBinary(I, ISD::OR, ISD::VOR); }
+ void visitXor(User &I) { visitIntBinary(I, ISD::XOR, ISD::VXOR); }
void visitShl(User &I) { visitShift(I, ISD::SHL); }
void visitShr(User &I) {
visitShift(I, I.getType()->isUnsigned() ? ISD::SRL : ISD::SRA);
@@ -1091,19 +1102,34 @@
setValue(&I, DAG.getNode(ISD::FNEG, Op2.getValueType(), Op2));
return;
}
- }
- visitBinary(I, ISD::SUB, ISD::FSUB, ISD::VSUB);
+ visitFPBinary(I, ISD::FSUB, ISD::VSUB);
+ } else
+ visitIntBinary(I, ISD::SUB, ISD::VSUB);
}
-void SelectionDAGLowering::visitBinary(User &I, unsigned IntOp, unsigned FPOp,
- unsigned VecOp) {
+void
+SelectionDAGLowering::visitIntBinary(User &I, unsigned IntOp, unsigned VecOp) {
const Type *Ty = I.getType();
SDOperand Op1 = getValue(I.getOperand(0));
SDOperand Op2 = getValue(I.getOperand(1));
if (Ty->isIntegral()) {
setValue(&I, DAG.getNode(IntOp, Op1.getValueType(), Op1, Op2));
- } else if (Ty->isFloatingPoint()) {
+ } else {
+ const PackedType *PTy = cast<PackedType>(Ty);
+ SDOperand Num = DAG.getConstant(PTy->getNumElements(), MVT::i32);
+ SDOperand Typ = DAG.getValueType(TLI.getValueType(PTy->getElementType()));
+ setValue(&I, DAG.getNode(VecOp, MVT::Vector, Op1, Op2, Num, Typ));
+ }
+}
+
+void
+SelectionDAGLowering::visitFPBinary(User &I, unsigned FPOp, unsigned VecOp) {
+ const Type *Ty = I.getType();
+ SDOperand Op1 = getValue(I.getOperand(0));
+ SDOperand Op2 = getValue(I.getOperand(1));
+
+ if (Ty->isFloatingPoint()) {
setValue(&I, DAG.getNode(FPOp, Op1.getValueType(), Op1, Op2));
} else {
const PackedType *PTy = cast<PackedType>(Ty);
More information about the llvm-commits
mailing list