Whether GEP fits an addressing mode


I wonder there’s an API that determines whether an getelementptr can be completely folded into an addressing mode. I need one such interface in my own transformation pass. I saw TTI has a low-level interface on addressing mode (isLegalAddressingMode), but requires the user to compute the base register, offset, scale, and etc.

I am writing one such interface right now that computes low-level info (e.g. base and offset) from a GEP and calls isLegalAddressingMode, but please shout out if you know any existing/better way.