This patch implements the getInstrMapping hook for RISCVRegisterBankInfo and others in order to correctly select the GPR register bank for operands of ALU instructions, and the associated operations introduced by the legalizer.
I'd recommend keeping the subtarget cached in the class
I don't see the point of this loop. It seems like you're just doing a rough legality check, but the function is already required (and enforced by the verifier) to be legal at this point
You shouldn't see noreg on a generic instruction so I'm not sure what you're addressing here
You can drop the IR section