Add a hook "legalizeInstrinsic" to allow backends to override this and custom lower/legalize intrinsics.
One caveat is the handling of case where target deleted the intrinsic instruction. It is possible that the intrinsic was successfully lowered/legalized but the additional instructions that were created can't be legalized and finally when we try to reportGISelFailure, we might be dealing with a erased instruction.
Instead, the target would return an enum value indicating that the instruction needs to be erased which we can erase after making sure we don't need to reportGISelFailure.
This unfortunately has to expose LegalizeHelper to the backends.
Looking forward to your feedback.
I think this need to directly return LegalizeResult. Some intrinsics may be AlreadyLegal, or Legalized