[LLVMdev] getConvertAction/setConvertAction

Dan Gohman gohman at apple.com
Fri Mar 19 16:46:09 PDT 2010


On Mar 19, 2010, at 12:23 PM, Villmow, Micah wrote:

> Is there anywhere in the codebase that actually uses the ConvertAction to determine how conversion functions are lowered?

I don't see any.

>  
> In SDValue SelectionDAGLegalize::LegalizeOp(SDValue Op)
>  
> ...
>   case ISD::SINT_TO_FP:
>   case ISD::UINT_TO_FP:
>   case ISD::EXTRACT_VECTOR_ELT:
>     Action = TLI.getOperationAction(Node->getOpcode(),
>                                     Node->getOperand(0).getValueType());
>  
> This seems incorrect as SINT_TO_FP should be querying the convert action, and not the Operation action.
>  
> i.e. it should be:
>   case ISD::SINT_TO_FP:
>   case ISD::UINT_TO_FP:
>   case ISD::FP_TO_SINT:
>   case ISD::FP_TO_UINT:
>     Action = TLI.getConvertAction(Node->getValueType(),
>                                     Node->getOperand(0).getValueType());
>       break;
>   case ISD::EXTRACT_VECTOR_ELT:
>     Action = TLI.getOperationAction(Node->getOpcode(),
>                                     Node->getOperand(0).getValueType());
>  
>  
>  
> Is this assumption correct? I cannot get LLVM to expand fp64 -> i64 nodes into either to a custom lowered function or expanded to a software function call.
>  
>  
> Is getConvertAction being removed? If so, how should I handle this in the backend?

With the current code, FP_TO_SINT and FP_TO_UINT go to the default case,
which looks up getOperationAction with the result type of the cast. So
you need to mark FP_TO_SINT and/or FP_TO_UINT with the result type as
Expand or Custom, if that's flexible enough.

Dan





More information about the llvm-dev mailing list