Mesa (master): radeon/llvm: custom lowering for FP_TO_UINT when dst is i1 ( bool)

Vincent Lejeune vlj at kemper.freedesktop.org
Tue Sep 4 15:54:57 UTC 2012


Module: Mesa
Branch: master
Commit: a4325b32298cb99b1e99620a33ef0bee52298c3c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a4325b32298cb99b1e99620a33ef0bee52298c3c

Author: Vincent Lejeune <vljn at ovi.com>
Date:   Tue Sep  4 17:29:48 2012 +0200

radeon/llvm: custom lowering for FP_TO_UINT when dst is i1 (bool)

v2:-wrap line at 80 characters

Reviewed-by: Tom Stellard <thomas.stellard at amd.com>

---

 src/gallium/drivers/radeon/R600ISelLowering.cpp |   22 ++++++++++++++++++++++
 src/gallium/drivers/radeon/R600ISelLowering.h   |    6 ++++--
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/radeon/R600ISelLowering.cpp b/src/gallium/drivers/radeon/R600ISelLowering.cpp
index 7ad0178..79cd622 100644
--- a/src/gallium/drivers/radeon/R600ISelLowering.cpp
+++ b/src/gallium/drivers/radeon/R600ISelLowering.cpp
@@ -48,6 +48,7 @@ R600TargetLowering::R600TargetLowering(TargetMachine &TM) :
 
   setOperationAction(ISD::SETCC, MVT::i32, Custom);
   setOperationAction(ISD::SETCC, MVT::f32, Custom);
+  setOperationAction(ISD::FP_TO_UINT, MVT::i1, Custom);
   setSchedulingPreference(Sched::VLIW);
 }
 
@@ -330,6 +331,27 @@ SDValue R600TargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const
   return SDValue();
 }
 
+void R600TargetLowering::ReplaceNodeResults(SDNode *N,
+                                            SmallVectorImpl<SDValue> &Results, 
+                                            SelectionDAG &DAG) const
+{
+  switch (N->getOpcode()) {
+  default: return;
+  case ISD::FP_TO_UINT: Results.push_back(LowerFPTOUINT(N->getOperand(0), DAG));
+  }
+}
+
+SDValue R600TargetLowering::LowerFPTOUINT(SDValue Op, SelectionDAG &DAG) const
+{
+  return DAG.getNode(
+      ISD::SETCC,
+      Op.getDebugLoc(),
+      MVT::i1,
+      Op, DAG.getConstantFP(0.0f, MVT::f32),
+      DAG.getCondCode(ISD::SETNE)
+      );
+}
+
 SDValue R600TargetLowering::LowerBR_CC(SDValue Op, SelectionDAG &DAG) const
 {
   SDValue Chain = Op.getOperand(0);
diff --git a/src/gallium/drivers/radeon/R600ISelLowering.h b/src/gallium/drivers/radeon/R600ISelLowering.h
index 2eb7edd..49ea272 100644
--- a/src/gallium/drivers/radeon/R600ISelLowering.h
+++ b/src/gallium/drivers/radeon/R600ISelLowering.h
@@ -27,7 +27,9 @@ public:
   virtual MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr *MI,
       MachineBasicBlock * BB) const;
   virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const;
-
+  void ReplaceNodeResults(SDNode * N,
+      SmallVectorImpl<SDValue> &Results,
+      SelectionDAG &DAG) const;
 private:
   const R600InstrInfo * TII;
 
@@ -48,7 +50,7 @@ private:
 
   SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
   SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG) const;
-
+  SDValue LowerFPTOUINT(SDValue Op, SelectionDAG &DAG) const;
 };
 
 } // End namespace llvm;




More information about the mesa-commit mailing list