This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PowerPC64 large toc model


On Tue, Jun 8, 2010 at 8:57 AM, Alan Modra <amodra@gmail.com> wrote:
> PowerPC64 gcc support for a larger TOC via -mcmodel option.
>
> -mcmodel=small
> ?uses 16-bit toc offsets, ie. what we had before.
>
> -mcmodel=medium
> ?uses 32-bit toc offsets and addresses static data, string constants
> ?etc. relative to the toc pointer. ?Limits data to around 2G.
>
> -mcmodel=large
> ?uses 32-bit toc offsets, no limit on static data.
>
> Default is -mcmodel=medium unless you specify other toc options. ?For
> example, -mminimal-toc gets you -mcmodel=small.
>
> Bootstrapped and regression tested powerpc64-linux. ?Comments follow
> associated changelog entry.
>
> ? ? ? ?* doc/invoke.texi: Add mcmodel to powerpc options.
> ? ? ? ?* configure.ac: Add HAVE_LD_LARGE_TOC test.
> ? ? ? ?* configure: Regenerate.
> ? ? ? ?* config.in: Regenerate.
> ? ? ? ?* config/rs6000/linux64.opt (mcmodel): New.
> ? ? ? ?* config/rs6000/linux64.h (TARGET_USES_LINUX64_OPT): Define.
> ? ? ? ?(TARGET_CMODEL): Define.
> ? ? ? ?(SUBSUBTARGET_OVERRIDE_OPTIONS): Check user -mcmodel choice,
> ? ? ? ?select CMODEL_MEDIUM default.
> ? ? ? ?* config/rs6000/rs6000.h (enum rs6000_cmodel): New.
> ? ? ? ?(TARGET_CMODEL): Define default.
> ? ? ? ?* config/rs6000/rs6000.c (cmodel): New variable.
> ? ? ? ?(rs6000_explicit_options): Add cmodel field.
> ? ? ? ?(rs6000_handle_option): Handle -mcmodel.
> ? ? ? ?(create_TOC_reference): Add bigtoc_reg param. ?Generate high,
> ? ? ? ?lo_sum rtl for CMODEL_MEDIUM and CMODEL_LARGE. ?Update all callers.
> ? ? ? ?(rs6000_delegitimize_address): Recognise new toc reference rtl
> ? ? ? ?and minimal-toc rtl.
> ? ? ? ?(rs6000_legitimize_reload_address): Handle new toc references.
> ? ? ? ?(print_operand_address): Handle legitimate_constant_pool_address_p
> ? ? ? ?match before lo_sum.
> ? ? ? ?(rs6000_eliminate_indexed_memrefs): Tidy.
> ? ? ? ?(rs6000_emit_move): Tweak threshold for inlining constants.
> ? ? ? ?Keep rs6000_emit_allocate_stack large stack frame offsets
> ? ? ? ?loaded into r0 inline.
> ? ? ? ?(rs6000_generate_compare <cmptf_internal2>): One more clobber.
> Basic big toc support.
>
> ? ? ? ?(tocrel_base, tocrel_offset): New variables.
> ? ? ? ?(toc_relative_expr_p): Set them here.
> ? ? ? ?(print_operand_address): Skip over any offset on constant pool
> ? ? ? ?address.
> ? ? ? ?(rs6000_output_addr_const_extra): Print tocrel_offset before @toc.
> I'm not too proud of this hack but can't see a better way of
> rearranging the assembly.
>
> ? ? ? ?(rs6000_mode_dependent_address <LO_SUM>): False for new toc refs.
> Necessary to support insns using "o" constraint.
>
> ? ? ? ?(offsettable_ok_by_alignment): New function.
> ? ? ? ?(rs6000_emit_move): Address suitably aligned local symbol_refs
> ? ? ? ?relative to the toc pointer for -mcmodel=medium.
> We can't support toc pointer relative addressing for non-local vars
> since ELF shared library semantics require such variables to be
> overridable by the main executable or other shared libs. ?That would
> mean text relocs.
>
> ? ? ? ?(legitimate_constant_pool_address_p): Add strict param. ?Allow
> ? ? ? ?lo_sum version of addressing. ?Verify reg used for -mminimal-toc
> ? ? ? ?and -mcmodel != small. ?Update all callers.
> ? ? ? ?* config/rs6000/constraints.md: Update for above change.
> ? ? ? ?* config/rs6000/predicates.md: Likewise.
> Without properly checking the reg I found testsuite failures due to
> reload not giving the high part address a hard reg. ?I'm not sure why
> this problem didn't trigger with -mminimal-toc..
> .../gcc.c-torture/compile/20051216-1.c:131:1: error: insn does not satisfy its constraints:
> (insn 105 562 666 27 ... (set (reg/v:DF 60 28 [orig:208 share_x ] [208])
> ? ? ? ?(mem/u/c/i:DF (lo_sum:DI (mem/c:DI (plus:DI (reg/f:DI 1 1)
> ? ? ? ? ? ? ? ? ? ? ? ?(const_int 208 [0xd0])) [0 %sfp+208 S8 A64])
> ? ? ? ? ? ? ? ?(const:DI (unspec:DI [
> ? ? ? ? ? ? ? ? ? ? ? ? ? ?(symbol_ref/u:DI ("*.LC2") [flags 0x2])
> ? ? ? ? ? ? ? ? ? ? ? ?] 49))) [0 S8 A64])) 360 {*movdf_hardfloat64} (expr_list:REG_EQUAL (const_double:DF 0.0 [0x0.0p+0])
> ? ? ? ?(nil)))
>
> ? ? ? ?* config/rs6000/rs6000.md (tls_gd_aix): Generate -mcmodel=medium/large
> ? ? ? ?code.
> ? ? ? ?(tls_gd): Split for -mcmodel=medium/large.
> ? ? ? ?(tls_gd_high, tls_gd_low): New.
> ? ? ? ?(tls_ld_aix, tls_ld, tls_ld_high, tls_ld_low): Similarly.
> ? ? ? ?(tls_got_dtprel, tls_got_dtprel_high, tls_got_dtprel_low): Similarly.
> ? ? ? ?(tls_got_tprel, tls_got_tprel_high, tls_got_tprel_low): Similarly.
> ? ? ? ?(bigtoc_high, bigtoc_low): New.
> ? ? ? ?(cmptf_internal2): Add clobber.
> ? ? ? ?* config/rs6000/rs6000-protos.h: Update.

The patch is okay, with the appropriate updates for the other recent patches.

But please change bigtoc_reg, bigtoc_high and bigtoc_low to something
else.  Maybe largetoc?  Bigtoc means something specific on AIX and I
want to avoid confusion.

Thanks, David


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]