linking an ISD node to a function

Hi all,

Is there any way to link an ISD node to a specific function? What I mean by that is that my target CPU architecture doesn’t have a DIV instruction but there is a divide() function implemented in C. Whenever an ISD::UDIV or ISD::SDIV node is encountered, rather than trying to match a DAG pattern, I just want divide() to be called.

Thanks.

Hi all,
Is there any way to link an ISD node to a specific function? What I mean by that is that my target CPU architecture doesn't have a DIV instruction but there is a divide() function implemented in C. Whenever an ISD::UDIV or ISD::SDIV node is encountered, rather than trying to match a DAG pattern, I just want divide() to be called.

You can mark the node as LibCall in your TargetLowering implementation. For example:
https://github.com/llvm/llvm-project/blob/master/llvm/lib/Target/ARM/ARMISelLowering.cpp#L874

Also, a few lines lower in the file, there is an example of how to specify
your own function name for the library call if you don't want to use
the default.

-Tom