From 74c74aa05ee8757210dfb16f6198024e6dc445d5 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Wed, 20 Dec 2017 12:52:30 +0000 Subject: poly_int: DWARF locations This patch adds support for DWARF location expressions that involve polynomial offsets. It adds a target hook that says how the runtime invariants used in the offsets should be represented in DWARF. SVE vectors have to be a multiple of 128 bits in size, so the GCC port uses the number of 128-bit blocks minus one as the runtime invariant. However, in DWARF, the vector length is exposed via a pseudo "VG" register that holds the number of 64-bit elements in a vector. Thus: indeterminate 1 == (VG / 2) - 1 The hook needs to be general enough to express this. Note that in most cases the division and subtraction fold away into surrounding expressions. 2017-12-20 Richard Sandiford Alan Hayward David Sherwood gcc/ * target.def (dwarf_poly_indeterminate_value): New hook. * targhooks.h (default_dwarf_poly_indeterminate_value): Declare. * targhooks.c (default_dwarf_poly_indeterminate_value): New function. * doc/tm.texi.in (TARGET_DWARF_POLY_INDETERMINATE_VALUE): Document. * doc/tm.texi: Regenerate. * dwarf2out.h (build_cfa_loc, build_cfa_aligned_loc): Take the offset as a poly_int64. * dwarf2out.c (new_reg_loc_descr): Move later in file. Take the offset as a poly_int64. (loc_descr_plus_const, loc_list_plus_const, build_cfa_aligned_loc): Take the offset as a poly_int64. (build_cfa_loc): Likewise. Use loc_descr_plus_const. (frame_pointer_fb_offset): Change to a poly_int64. (int_loc_descriptor): Take the offset as a poly_int64. Use targetm.dwarf_poly_indeterminate_value for polynomial offsets. (based_loc_descr): Take the offset as a poly_int64. Use strip_offset_and_add to handle (plus X (const)). Use new_reg_loc_descr instead of an open-coded version of the previous implementation. (mem_loc_descriptor): Handle CONST_POLY_INT. (compute_frame_pointer_to_fb_displacement): Take the offset as a poly_int64. Use strip_offset_and_add to handle (plus X (const)). Co-Authored-By: Alan Hayward Co-Authored-By: David Sherwood From-SVN: r255868 --- gcc/doc/tm.texi | 13 +++++++++++++ gcc/doc/tm.texi.in | 2 ++ 2 files changed, 15 insertions(+) (limited to 'gcc/doc') diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index fc73bb2..434c42a 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -3130,6 +3130,19 @@ the CFI label attached to the insn, @var{pattern} is the pattern of the insn and @var{index} is @code{UNSPEC_INDEX} or @code{UNSPECV_INDEX}. @end deftypefn +@deftypefn {Target Hook} {unsigned int} TARGET_DWARF_POLY_INDETERMINATE_VALUE (unsigned int @var{i}, unsigned int *@var{factor}, int *@var{offset}) +Express the value of @code{poly_int} indeterminate @var{i} as a DWARF +expression, with @var{i} counting from 1. Return the number of a DWARF +register @var{R} and set @samp{*@var{factor}} and @samp{*@var{offset}} such +that the value of the indeterminate is: +@smallexample +value_of(@var{R}) / @var{factor} - @var{offset} +@end smallexample + +A target only needs to define this hook if it sets +@samp{NUM_POLY_INT_COEFFS} to a value greater than 1. +@end deftypefn + @defmac INCOMING_FRAME_SP_OFFSET A C expression whose value is an integer giving the offset, in bytes, from the value of the stack pointer register to the top of the stack diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index ff00673..c1d2a8c 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -2544,6 +2544,8 @@ terminate the stack backtrace. New ports should avoid this. @hook TARGET_DWARF_HANDLE_FRAME_UNSPEC +@hook TARGET_DWARF_POLY_INDETERMINATE_VALUE + @defmac INCOMING_FRAME_SP_OFFSET A C expression whose value is an integer giving the offset, in bytes, from the value of the stack pointer register to the top of the stack -- cgit v1.1