Does anyone know if this really needs to be an immutable pass?
Was it done this way for efficiency?
I am trying to see if I can turn it into a function pass.
Playing with it for an hour I made the compilation changes but ran into a bunch of "make check" failures.
I'm wondering if the module level passes are dependent on this pass.
I don't know the answers to your questions, but ARM allows mixed ARM and THUMB instructions using the blx instruction. Can you not do something similar to what the ARM backend does to handle it?
This is mimicking functionality that exists with gcc for mips16 and mips32.
It's very involved and is needed for various things; including some aspects of mips16 hard float when you can mix that code with mips 32 code.
There are other ways to intermix mips16 and mips32 but this particular scheme requires that you be able to decide on a per function basis whether you want to generate mips16 or mips32 code.
I'm working through the problem little by little but I don't know in detail the non target dependent parts of the compiler that are relevant here.