[Mesa-dev] [PATCH 3/3] radeon/llvm: custom lowering for FP_TO_UINT when dst is i1 (bool)
Tom Stellard
tstellar at gmail.com
Tue Aug 21 07:06:46 PDT 2012
On Tue, Aug 21, 2012 at 12:41:09AM +0200, Vincent Lejeune wrote:
> ---
> src/gallium/drivers/radeon/R600ISelLowering.cpp | 27 +++++++++++++++++++++++++
> src/gallium/drivers/radeon/R600ISelLowering.h | 6 ++++--
> 2 files changed, 31 insertions(+), 2 deletions(-)
>
> diff --git a/src/gallium/drivers/radeon/R600ISelLowering.cpp b/src/gallium/drivers/radeon/R600ISelLowering.cpp
> index 3aeb6ff..636fe0a 100644
> --- a/src/gallium/drivers/radeon/R600ISelLowering.cpp
> +++ b/src/gallium/drivers/radeon/R600ISelLowering.cpp
> @@ -45,6 +45,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);
Just like patch 2, I don't think this will apply cleanly due to this
commented out context line.
> }
>
> @@ -285,6 +286,32 @@ SDValue R600TargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const
> }
> }
>
> +void R600TargetLowering::ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue> &Results, SelectionDAG &DAG) const
> +{
> + switch (N->getOpcode()) {
> + default: assert(0 && "Not Implemented !");
> + case ISD::FP_TO_UINT: Results.push_back(LowerFPTOUINT(N->getOperand(0), DAG));
> + }
> +}
> +
I'm curious, why are you calling this from ReplaceNodeResult, rather than
LowerOperation
> +SDValue R600TargetLowering::LowerFPTOUINT(SDValue Op, SelectionDAG &DAG) const
> +{
> + SDValue BoolAsFlt = DAG.getNode(
> + ISD::SELECT_CC,
> + Op.getDebugLoc(),
> + MVT::f32,
> + Op, DAG.getConstantFP(0.0, MVT::f32),
> + DAG.getConstantFP(1., MVT::f32),
> + DAG.getConstantFP(0., MVT::f32),
Please use 1.0f and 0.0f instead of 1. and 0.
> + DAG.getCondCode(ISD::SETNE)
> + );
> + return DAG.getNode(
> + ISD::FP_TO_UINT,
> + Op.getDebugLoc(),
> + MVT::i32,
> + BoolAsFlt);
> +}
> +
> 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 f57ee97..15d83b6 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;
>
> @@ -45,7 +47,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;
> --
> 1.7.11.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list