Aurelien Buhrig <aurelien.buhrig.gcc@xxxxxxxxx> writes: > 2011/6/28 Ian Lance Taylor <iant@xxxxxxxxxx>: >> Aurelien Buhrig <aurelien.buhrig.gcc@xxxxxxxxx> writes: >> >>> I'm trying to implement TARGET_SECONDARY_RELOAD but I cannot make it >>> work properly. >>> The hook seems to work for preventing from moving from BASE_REG to >>> BASE_REG in HImode by inserting a GENERAL_REG. >>> But I also want to insert a GENERAL_REGS intermediate register when >>> moving between BASE_REGS registers and memory in HImode. >>> >>> So I wrote something like that in my TARGET_SECONDARY_RELOAD: >>> if (MEM_P(x) && (reload_mode == HImode) && reload_class == BASE_REGS) >>> return GENERAL_REGS; >>> >>> >>> But it seems this do not work. For instance with DI function parameter >>> access (movdi reg:DI <-- m) which are (automatically) split into movhi >>> subreg:HI <-- m; then in movhi reg:HI <- m. But the hook do not seem >>> to work since the reg:HI is reloaded into a BASE_REG... >>> >>> So when is this hook called? Is there something specific with spliting >>> insn? Or just a general thing about TARGET_SECONDARY_RELOAD I missed ? >> >> The hook is called during reload, which is run as part of register >> allocation. When are you splitting the DImode load? >> >> Ian >> > I have no instruction for it. GCC automatically splits it, and it does > it at the very beginning (131r.expand) by affecting a subreg:HI, and > affects a reg:HI at 139r.subregs, and a hard base_reg at 176r.greg. It > is never changed after. > > Would it be a reg class pb ? > For now, I defined BASE_REGS class for address registers which does > not intersect with GENERAL_REGS class (the data registers). Should I > define Address register and data register as general register, with a > class for address register and a new class for data registers (such as > m68k) ? > > Does GCC treat GENERALS_REGS differently than other classes ? Yes, but I don't see why this would be your problem. >From your description I don't know why this is not working. You are going to have to debug it. Probably the first thing to try would be a few debug statements in your TARGET_SECONDARY_RELOAD to see if it is being invoked as you expect. Ian