On Wed, Mar 9, 2011 at 1:07 AM, Alan Modra <amo...@gmail.com> wrote: > This patch > a) Moves the offsettable_ok_by_alignment call from rs6000_emit_move to > legitimate_constant_pool_address_p, and > b) teaches offsettable_ok_by_alignment how to handle -fsection-anchors > addresses, and > c) teaches offsettable_ok_by_alignment about other SYMBOL_REF_DECL > trees I see there, various constant trees and CONSTRUCTOR. > > About (a), well, that's just the way I should have written the > cmodel=medium optimization in the first place. There is no alignment > reason to not create a cmodel=medium address (ie. addis,addi relative > to toc pointer), it's just that they do need to be sufficiently > aligned to use in a MEM. We want reg=cmodel_medium_losum; mem[reg] > whenever we can do so, rather than creating a toc entry, but must not > allow the sequence to be combined into mem[cmodel_medium_losum] if > cmodel_medium_losum is not offsettable to access all the bytes of mem. > Perhaps legitimate_constant_pool_address_p should be renamed. I > didn't do that because it already allows the non-constant-pool > cmodel=medium addresses, and the name is long enough now. I commented > the function instead. > > (b) is necessary because -fsection-anchors unfortunately loses the > real SYMBOL_REF_DECL when substituting anchor+offset into MEMs. The > way I imlemented this is why legitimate_constant_pool_address_p needs > the MEM mode. I suppose it would be possible to keep the original > SYMBOL_REF_DECL around in the rtl by some means or find the decl in > the struct object_block info, but both of these options seem like > overkill to me. Note that I pass QImode to l_c_p_a_p from > rs6000_mode_dependent_address, print_operand_address, and the 'R' > constraint to indicate that any cmodel=medium address is permissable. > > (c) was developed specifically to fix problems found on > ibm/gcc-4_5-branch. I'd still like to commit this on mainline even > though it seems that mainline creates VAR_DECLs for constants. > > Bootstrapped and regression tested powerpc64-linux. OK to apply?
Alan, I agree that this is a better approach. You might want to ask Richard Sandiford to look at the section anchors issue. Thanks, David