Target-specific code in non-Target part of LLVM

In the loop idiom recognition, it is relatively easy to detect a code pattern for which we have a special, internal function.

Since LoopIdiomRecognize.cpp is meant to be target-independent, adding code like "if (Hexagon) ..." doesn't seem acceptable.

The function implements something quite specific, which doesn't make it an obvious candidate for an intrinsic.

What is the preferred way to address this kind of a scenario? Handling it in on the MI-level is possible, but it would take more work than piggy-backing on the existing IR-level code. Any suggestions?