LRA is the default

In GCC 7 the default is to use LRA, not the old reload. All existing (in-tree) ports were changed to behave exactly like before, a fair amount of ports were still using reload at first.

As of GCC 14, only a handful of reload targets still exist. The plan is to remove reload if possible for GCC 15 or soon after. Remaining targets need porting urgently.

Switching to LRA

Whether a port uses LRA or old reload is determined by the lra_p target hook, which is set up using the TARGET_LRA_P target macro.

If you want the default (i.e. LRA always on), don't define that macro at all. If you always want old reload, use

#define TARGET_LRA_P hook_bool_void_false

and if you want to be able to switch it (say, with an -mlra switch), use something like

bool
sh_lra_p (void)
{
  return sh_lra_flag;
}
#define TARGET_LRA_P sh_lra_p

where you set up that variable in your .opt file, like

mlra
Target Report Var(sh_lra_flag) Init(0) Save
Use LRA instead of reload (transitional).

Making your port work with LRA

Most things in your port will just work with LRA. A few things are slightly different.

You can use the lra_in_progress variable to make your port do different things during LRA than it does during old reload (where you use reload_in_progress). There also is ira_use_lra_p.

LRA does not use LEGITIMIZE_RELOAD_ADDRESS.

LRA does the elimination of the frame pointer and argument pointer etc. differently.

LRA is stricter about register constraints: they must be defined by means of define_register_constraint or else it can fail to reload into a register. Similarly, memory constraints enforcing an alignment must be defined by means of define_special_memory_constraint or else it can think that it can satisfy them by reloading only the address (that's as documented, but old reload was apparently more forgiving here).

There are more differences, big and small; this is a wiki, please add any material that will help others.

Traps for the unwary

LRA requires the target to not use the old CC0 condition code handling (see CC0 Transition for further details).

None: LRAIsDefault (last edited 2024-03-09 23:41:01 by SamJames)