Commit 070b27da by Alan Modra Committed by Alan Modra

invoke.texi: Add mcmodel to powerpc options.

	* 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 largetoc_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.
	(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.
	(rs6000_mode_dependent_address <LO_SUM>): False for new toc refs.
	(offsettable_ok_by_alignment): New function.
	(rs6000_emit_move): Address suitably aligned local symbol_refs
	relative to the toc pointer for -mcmodel=medium.
	(legitimate_constant_pool_address_p): Make param const_rtx.  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.
	* 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.
	(largetoc_high, largetoc_low): New.
	(cmptf_internal2): Add clobber.
	* config/rs6000/rs6000-protos.h: Update.

From-SVN: r160773
parent 309b8e7d
2010-06-15 Alan Modra <amodra@gmail.com>
* 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 largetoc_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.
(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.
(rs6000_mode_dependent_address <LO_SUM>): False for new toc refs.
(offsettable_ok_by_alignment): New function.
(rs6000_emit_move): Address suitably aligned local symbol_refs
relative to the toc pointer for -mcmodel=medium.
(legitimate_constant_pool_address_p): Make param const_rtx. 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.
* 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.
(largetoc_high, largetoc_low): New.
(cmptf_internal2): Add clobber.
* config/rs6000/rs6000-protos.h: Update.
2010-06-14 Changpeng Fang <changpeng.fang@amd.com>
* tree-ssa-loop-prefetch.c (nothing_to_prefetch_p): New. Return
......
......@@ -1168,6 +1168,12 @@
#endif
/* Define if your PowerPC64 linker supports a large TOC. */
#ifndef USED_FOR_TARGET
#undef HAVE_LD_LARGE_TOC
#endif
/* Define if your PowerPC64 linker only needs function descriptor syms. */
#ifndef USED_FOR_TARGET
#undef HAVE_LD_NO_DOT_SYMS
......
......@@ -166,7 +166,7 @@ usually better to use @samp{m} or @samp{es} in @code{asm} statements)"
(define_constraint "R"
"AIX TOC entry"
(match_test "legitimate_constant_pool_address_p (op)"))
(match_test "legitimate_constant_pool_address_p (op, false)"))
;; General constraints
......
......@@ -63,6 +63,16 @@ extern int dot_symbols;
#define TARGET_PROFILE_KERNEL profile_kernel
#define TARGET_USES_LINUX64_OPT 1
#ifdef HAVE_LD_LARGE_TOC
extern enum rs6000_cmodel cmodel;
#undef TARGET_CMODEL
#define TARGET_CMODEL cmodel
#define SET_CMODEL(opt) cmodel = opt
#else
#define SET_CMODEL(opt)
#endif
#undef PROCESSOR_DEFAULT
#define PROCESSOR_DEFAULT PROCESSOR_POWER6
#undef PROCESSOR_DEFAULT64
......@@ -114,6 +124,23 @@ extern int dot_symbols;
target_flags |= MASK_POWERPC64; \
error ("-m64 requires a PowerPC64 cpu"); \
} \
if ((target_flags_explicit & MASK_MINIMAL_TOC) != 0) \
{ \
if (rs6000_explicit_options.cmodel \
&& cmodel != CMODEL_SMALL) \
error ("-mcmodel incompatible with other toc options"); \
SET_CMODEL (CMODEL_SMALL); \
} \
else \
{ \
if (!rs6000_explicit_options.cmodel) \
SET_CMODEL (CMODEL_MEDIUM); \
if (cmodel != CMODEL_SMALL) \
{ \
TARGET_NO_FP_IN_TOC = 0; \
TARGET_NO_SUM_IN_TOC = 0; \
} \
} \
} \
else \
{ \
......@@ -124,6 +151,11 @@ extern int dot_symbols;
TARGET_PROFILE_KERNEL = 0; \
error (INVALID_32BIT, "profile-kernel"); \
} \
if (rs6000_explicit_options.cmodel) \
{ \
SET_CMODEL (CMODEL_SMALL); \
error (INVALID_32BIT, "cmodel"); \
} \
} \
} \
while (0)
......
......@@ -22,3 +22,7 @@
mprofile-kernel
Target Report Var(profile_kernel)
Call mcount for profiling before a function prologue
mcmodel=
Target RejectNegative Joined
Select code model
......@@ -837,7 +837,7 @@
return 1;
/* A SYMBOL_REF referring to the TOC is valid. */
if (legitimate_constant_pool_address_p (op))
if (legitimate_constant_pool_address_p (op, false))
return 1;
/* A constant pool expression (relative to the TOC) is valid */
......
......@@ -39,7 +39,7 @@ extern int small_data_operand (rtx, enum machine_mode);
extern bool toc_relative_expr_p (rtx);
extern bool invalid_e500_subreg (rtx, enum machine_mode);
extern void validate_condition_mode (enum rtx_code, enum machine_mode);
extern bool legitimate_constant_pool_address_p (rtx);
extern bool legitimate_constant_pool_address_p (const_rtx, bool);
extern bool legitimate_indirect_address_p (rtx, int);
extern bool legitimate_indexed_address_p (rtx, int);
extern bool avoiding_indexed_address_p (enum machine_mode);
......@@ -111,7 +111,7 @@ extern void rs6000_emit_swrsqrt (rtx, rtx);
extern void output_toc (FILE *, rtx, int, enum machine_mode);
extern rtx rs6000_longcall_ref (rtx);
extern void rs6000_fatal_bad_address (rtx);
extern rtx create_TOC_reference (rtx);
extern rtx create_TOC_reference (rtx, rtx);
extern void rs6000_split_multireg_move (rtx, rtx);
extern void rs6000_emit_move (rtx, rtx, enum machine_mode);
extern rtx rs6000_secondary_memory_needed_rtx (enum machine_mode);
......
......@@ -293,6 +293,20 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
#define TARGET_SECURE_PLT 0
#endif
/* Code model for 64-bit linux.
small: 16-bit toc offsets.
medium: 32-bit toc offsets, static data and code within 2G of TOC pointer.
large: 32-bit toc offsets, no limit on static data and code. */
enum rs6000_cmodel {
CMODEL_SMALL,
CMODEL_MEDIUM,
CMODEL_LARGE
};
#ifndef TARGET_CMODEL
#define TARGET_CMODEL CMODEL_SMALL
#endif
#define TARGET_32BIT (! TARGET_64BIT)
#ifndef HAVE_AS_TLS
......
......@@ -24844,6 +24844,43 @@ $as_echo "$gcc_cv_ld_no_dot_syms" >&6; }
$as_echo "#define HAVE_LD_NO_DOT_SYMS 1" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking linker large toc support" >&5
$as_echo_n "checking linker large toc support... " >&6; }
if test "${gcc_cv_ld_large_toc+set}" = set; then :
$as_echo_n "(cached) " >&6
else
gcc_cv_ld_large_toc=no
if test $in_tree_ld = yes ; then
if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 21 -o "$gcc_cv_gld_major_version" -gt 2; then
gcc_cv_ld_large_toc=yes
fi
elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x ; then
cat > conftest.s <<EOF
.section ".tbss","awT",@nobits
.align 3
ie0: .space 8
.global _start
.text
_start:
addis 9,13,ie0@got@tprel@ha
ld 9,ie0@got@tprel@l(9)
EOF
if $gcc_cv_as -a64 -o conftest.o conftest.s > /dev/null 2>&1 \
&& $gcc_cv_ld -melf64ppc --no-toc-sort -o conftest conftest.o > /dev/null 2>&1; then
gcc_cv_ld_large_toc=yes
fi
rm -f conftest conftest.o conftest.s
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld_large_toc" >&5
$as_echo "$gcc_cv_ld_large_toc" >&6; }
if test x"$gcc_cv_ld_large_toc" = xyes; then
$as_echo "#define HAVE_LD_LARGE_TOC 1" >>confdefs.h
fi
;;
esac
......
......@@ -3996,6 +3996,36 @@ EOF
AC_DEFINE(HAVE_LD_NO_DOT_SYMS, 1,
[Define if your PowerPC64 linker only needs function descriptor syms.])
fi
AC_CACHE_CHECK(linker large toc support,
gcc_cv_ld_large_toc,
[gcc_cv_ld_large_toc=no
if test $in_tree_ld = yes ; then
if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 21 -o "$gcc_cv_gld_major_version" -gt 2; then
gcc_cv_ld_large_toc=yes
fi
elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x ; then
cat > conftest.s <<EOF
.section ".tbss","awT",@nobits
.align 3
ie0: .space 8
.global _start
.text
_start:
addis 9,13,ie0@got@tprel@ha
ld 9,ie0@got@tprel@l(9)
EOF
if $gcc_cv_as -a64 -o conftest.o conftest.s > /dev/null 2>&1 \
&& $gcc_cv_ld -melf64ppc --no-toc-sort -o conftest conftest.o > /dev/null 2>&1; then
gcc_cv_ld_large_toc=yes
fi
rm -f conftest conftest.o conftest.s
fi
])
if test x"$gcc_cv_ld_large_toc" = xyes; then
AC_DEFINE(HAVE_LD_LARGE_TOC, 1,
[Define if your PowerPC64 linker supports a large TOC.])
fi
;;
esac
......
......@@ -744,6 +744,7 @@ See RS/6000 and PowerPC Options.
@emph{RS/6000 and PowerPC Options}
@gccoptlist{-mcpu=@var{cpu-type} @gol
-mtune=@var{cpu-type} @gol
-mcmodel=@var{code-model} @gol
-mpower -mno-power -mpower2 -mno-power2 @gol
-mpowerpc -mpowerpc64 -mno-powerpc @gol
-maltivec -mno-altivec @gol
......@@ -14967,6 +14968,22 @@ values for @var{cpu_type} are used for @option{-mtune} as for
architecture, registers, and mnemonics set by @option{-mcpu}, but the
scheduling parameters set by @option{-mtune}.
@item -mcmodel=small
@opindex mcmodel=small
Generate PowerPC64 code for the small model: The TOC is limited to
64k.
@item -mcmodel=medium
@opindex mcmodel=medium
Generate PowerPC64 code for the medium model: The TOC and other static
data may be up to a total of 4G in size.
@item -mcmodel=large
@opindex mcmodel=large
Generate PowerPC64 code for the large model: The TOC may be up to 4G
in size. Other data and code is only limited by the 64-bit address
space.
@item -maltivec
@itemx -mno-altivec
@opindex maltivec
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment