From patchwork Mon Oct 23 17:04:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 116755 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4870458qgn; Mon, 23 Oct 2017 10:05:05 -0700 (PDT) X-Received: by 10.99.96.16 with SMTP id u16mr12349095pgb.257.1508778305534; Mon, 23 Oct 2017 10:05:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508778305; cv=none; d=google.com; s=arc-20160816; b=lSvDA8kYNlsbJ0+NPYh9ft9jYyuIqXKUYDk50E+GI/JMJuzp4t0X4JJFvfqfYuuYfO gZOQA4OwjYKWxmp9h3xC6JHB8V+sWgkScU/DnYSXFD8IqFoAo7APehFfPnK5gbb+mfFd z0nNTpKs0L+GrMoVstHmdSxJARo6pcUP0cuqXOdY41Ki3c+HUtzIU3lVNebRH5xnNh3q HoAWqX3M9zNOmOKrGztqOGlxeTyqIselUC481fGQkiTE9frtWzzkcYR1kx/3cSF0QcZw 7mPmJwRv8j8kC6pq913I9yi+T+9snlxh3FzRfOax1Kus4YQsnKjqT/BWgSCRda8m/P31 GCQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:mail-followup-to:to:from:delivered-to:sender:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=ojLvXPkpP4fh54a7PriX7zOHCoeOhNxYsv2SJE8fPJA=; b=hooWv356SqWrW6BrY1nemSI1akZgHlFlMpJaZdjKNZGaT+NOGfG7DeteRRvCpt09KA ZLvJJHIzfhlMG/oaTUJMjP5Sg5VCd4/yfAS58eSYijCwGXrFBg/B48NfWDm8O4UQqe8X GApF1c4NFd4RBVqRk2U2t/5l3O+byjs/timI7u0hVAA2OBcPleWPa4XFCNTniTxdWQHT RY7Jz2aG+ES70uj5pmiCL9ECzASjsS5wvi+AxzIwKD6e2/yIUk3Ea4JEpnkzluFIPFNS PI7xRNnK5ehLFLT8TluyCOz9N9nABgQoU7aTOc/PYwcXxqDQMxbrasZs/HUhrjBdj1ak Snuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=VGm19xVW; spf=pass (google.com: domain of gcc-patches-return-464787-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464787-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id g68si5154374pgc.304.2017.10.23.10.05.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Oct 2017 10:05:05 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-464787-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=VGm19xVW; spf=pass (google.com: domain of gcc-patches-return-464787-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464787-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=default; b=cT6QQr958RTtHy/JG0wBLu/helD9n sE2IL8jD7QKj4+k8knlsOaw8e4mKTLpsDs2auJ+PZcwXPh3hYiNIuDBrcCvEJ8Ge xHngsPFotcSak6nUAzd0Z7wBiS7YEr1sYofK4ht2+wXqM7Yjbe55TaT1ecUgbKBz 3mi3eW+fEW2xMo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:references:date:in-reply-to:message-id:mime-version :content-type; s=default; bh=AmpA0/dw+f10jKbOzaonYUJC98I=; b=VGm 19xVWVHVeYz0KpeaQKbqpCUNmAnrXYmeGKAqH1V/5lhhTAT30mto9RHrmvHwZUIP VmzyE+sE0odWwaDZLdZL/+5iOYNO9AHVsEBN1HXCe70okOf7bnBv8FMPMdX7n9Dh wzkPkkJRSvTLqe1Zy0Vjtiw8CCZU2u0/KrrvkEjk= Received: (qmail 111604 invoked by alias); 23 Oct 2017 17:04:38 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 111552 invoked by uid 89); 23 Oct 2017 17:04:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-9.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS, URIBL_BLACK autolearn=ham version=3.3.2 spammy=grant X-HELO: mail-wr0-f178.google.com Received: from mail-wr0-f178.google.com (HELO mail-wr0-f178.google.com) (209.85.128.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Oct 2017 17:04:34 +0000 Received: by mail-wr0-f178.google.com with SMTP id l8so5246206wre.12 for ; Mon, 23 Oct 2017 10:04:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:mail-followup-to:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=ojLvXPkpP4fh54a7PriX7zOHCoeOhNxYsv2SJE8fPJA=; b=J+F3DSeLwLTMSHCaRDfwlvTS1c7LDCNqQp8/UJun4/Qy1qE5D/47ACiaY0TgsKYUyM 3+C9QOHGJ66LGSJP4+E45+mb/nkB0zRhqlgdg2Kh4hJJ3/e6FIeJubK+lwd6c9xLr8a+ qQSrbiNvXG8IDMxUQ+Tv+Ds7BVh6RhM5rv/MLZtYZh5oa+RqsEKcgHEGL6ujM11ZC/0Q 7SEU7V35oL8m+FpBWalNu5wspzYRtIJ5LHZgRa2z3HL59iGd4iRg18mTZOYDYD//bJ2g DIJncZsOhkC6khkPLsLKo5GmQ/0dN3Nn4IVbhmjp3TbZEV1w/RSFdPQnvQkmJhUVuXY9 y5bA== X-Gm-Message-State: AMCzsaUCwIvbtDJICq2nsJizAI5R1VAAFX0Im4KQHD0Z+MIeCbL/QvnI 1SjKthiaV8qXH60q5dY9NL/TsZln+7w= X-Google-Smtp-Source: ABhQp+S1/oq3MZ+IVKRnDLeZaogogTWCx/TxkjRe2enKz+itBapPdieNTYBiKEYiPdmL8uCIGMzMjQ== X-Received: by 10.223.171.6 with SMTP id q6mr2503342wrc.117.1508778271908; Mon, 23 Oct 2017 10:04:31 -0700 (PDT) Received: from localhost ([2.26.27.199]) by smtp.gmail.com with ESMTPSA id t131sm3491484wmd.12.2017.10.23.10.04.30 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Oct 2017 10:04:30 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [011/nnn] poly_int: DWARF locations References: <871sltvm7r.fsf@linaro.org> Date: Mon, 23 Oct 2017 18:04:30 +0100 In-Reply-To: <871sltvm7r.fsf@linaro.org> (Richard Sandiford's message of "Mon, 23 Oct 2017 17:54:32 +0100") Message-ID: <87k1zlssm9.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 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-10-23 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)). Index: gcc/target.def =================================================================== --- gcc/target.def 2017-10-23 17:01:04.215112587 +0100 +++ gcc/target.def 2017-10-23 17:01:45.057509456 +0100 @@ -4124,6 +4124,21 @@ the CFI label attached to the insn, @var the insn and @var{index} is @code{UNSPEC_INDEX} or @code{UNSPECV_INDEX}.", void, (const char *label, rtx pattern, int index), NULL) +DEFHOOK +(dwarf_poly_indeterminate_value, + "Express the value of @code{poly_int} indeterminate @var{i} as a DWARF\n\ +expression, with @var{i} counting from 1. Return the number of a DWARF\n\ +register @var{R} and set @samp{*@var{factor}} and @samp{*@var{offset}} such\n\ +that the value of the indeterminate is:\n\ +@smallexample\n\ +value_of(@var{R}) / @var{factor} - @var{offset}\n\ +@end smallexample\n\ +\n\ +A target only needs to define this hook if it sets\n\ +@samp{NUM_POLY_INT_COEFFS} to a value greater than 1.", + unsigned int, (unsigned int i, unsigned int *factor, int *offset), + default_dwarf_poly_indeterminate_value) + /* ??? Documenting this hook requires a GFDL license grant. */ DEFHOOK_UNDOC (stdarg_optimize_hook, Index: gcc/targhooks.h =================================================================== --- gcc/targhooks.h 2017-10-23 17:00:20.920834919 +0100 +++ gcc/targhooks.h 2017-10-23 17:01:45.057509456 +0100 @@ -234,6 +234,9 @@ extern int default_label_align_max_skip extern int default_jump_align_max_skip (rtx_insn *); extern section * default_function_section(tree decl, enum node_frequency freq, bool startup, bool exit); +extern unsigned int default_dwarf_poly_indeterminate_value (unsigned int, + unsigned int *, + int *); extern machine_mode default_dwarf_frame_reg_mode (int); extern fixed_size_mode default_get_reg_raw_mode (int); extern bool default_keep_leaf_when_profiled (); Index: gcc/targhooks.c =================================================================== --- gcc/targhooks.c 2017-10-23 17:00:49.664349224 +0100 +++ gcc/targhooks.c 2017-10-23 17:01:45.057509456 +0100 @@ -1838,6 +1838,15 @@ default_debug_unwind_info (void) return UI_NONE; } +/* Targets that set NUM_POLY_INT_COEFFS to something greater than 1 + must define this hook. */ + +unsigned int +default_dwarf_poly_indeterminate_value (unsigned int, unsigned int *, int *) +{ + gcc_unreachable (); +} + /* Determine the correct mode for a Dwarf frame register that represents register REGNO. */ Index: gcc/doc/tm.texi.in =================================================================== --- gcc/doc/tm.texi.in 2017-10-23 17:00:20.918834478 +0100 +++ gcc/doc/tm.texi.in 2017-10-23 17:01:45.053515150 +0100 @@ -2553,6 +2553,8 @@ terminate the stack backtrace. New port @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 Index: gcc/doc/tm.texi =================================================================== --- gcc/doc/tm.texi 2017-10-23 17:01:04.214113496 +0100 +++ gcc/doc/tm.texi 2017-10-23 17:01:45.052516573 +0100 @@ -3133,6 +3133,19 @@ the CFI label attached to the insn, @var 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 Index: gcc/dwarf2out.h =================================================================== --- gcc/dwarf2out.h 2017-10-23 16:52:20.259541165 +0100 +++ gcc/dwarf2out.h 2017-10-23 17:01:45.056510879 +0100 @@ -267,9 +267,9 @@ struct GTY(()) dw_discr_list_node { /* Interface from dwarf2out.c to dwarf2cfi.c. */ extern struct dw_loc_descr_node *build_cfa_loc - (dw_cfa_location *, HOST_WIDE_INT); + (dw_cfa_location *, poly_int64); extern struct dw_loc_descr_node *build_cfa_aligned_loc - (dw_cfa_location *, HOST_WIDE_INT offset, HOST_WIDE_INT alignment); + (dw_cfa_location *, poly_int64, HOST_WIDE_INT); extern struct dw_loc_descr_node *mem_loc_descriptor (rtx, machine_mode mode, machine_mode mem_mode, enum var_init_status); Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c 2017-10-23 17:00:54.439005782 +0100 +++ gcc/dwarf2out.c 2017-10-23 17:01:45.056510879 +0100 @@ -1307,7 +1307,7 @@ typedef struct GTY(()) dw_loc_list_struc bool force; } dw_loc_list_node; -static dw_loc_descr_ref int_loc_descriptor (HOST_WIDE_INT); +static dw_loc_descr_ref int_loc_descriptor (poly_int64); static dw_loc_descr_ref uint_loc_descriptor (unsigned HOST_WIDE_INT); /* Convert a DWARF stack opcode into its string name. */ @@ -1344,19 +1344,6 @@ new_loc_descr (enum dwarf_location_atom return descr; } -/* Return a pointer to a newly allocated location description for - REG and OFFSET. */ - -static inline dw_loc_descr_ref -new_reg_loc_descr (unsigned int reg, unsigned HOST_WIDE_INT offset) -{ - if (reg <= 31) - return new_loc_descr ((enum dwarf_location_atom) (DW_OP_breg0 + reg), - offset, 0); - else - return new_loc_descr (DW_OP_bregx, reg, offset); -} - /* Add a location description term to a location description expression. */ static inline void @@ -1489,23 +1476,31 @@ loc_descr_equal_p (dw_loc_descr_ref a, d } -/* Add a constant OFFSET to a location expression. */ +/* Add a constant POLY_OFFSET to a location expression. */ static void -loc_descr_plus_const (dw_loc_descr_ref *list_head, HOST_WIDE_INT offset) +loc_descr_plus_const (dw_loc_descr_ref *list_head, poly_int64 poly_offset) { dw_loc_descr_ref loc; HOST_WIDE_INT *p; gcc_assert (*list_head != NULL); - if (!offset) + if (known_zero (poly_offset)) return; /* Find the end of the chain. */ for (loc = *list_head; loc->dw_loc_next != NULL; loc = loc->dw_loc_next) ; + HOST_WIDE_INT offset; + if (!poly_offset.is_constant (&offset)) + { + loc->dw_loc_next = int_loc_descriptor (poly_offset); + add_loc_descr (&loc->dw_loc_next, new_loc_descr (DW_OP_plus, 0, 0)); + return; + } + p = NULL; if (loc->dw_loc_opc == DW_OP_fbreg || (loc->dw_loc_opc >= DW_OP_breg0 && loc->dw_loc_opc <= DW_OP_breg31)) @@ -1531,10 +1526,33 @@ loc_descr_plus_const (dw_loc_descr_ref * } } +/* Return a pointer to a newly allocated location description for + REG and OFFSET. */ + +static inline dw_loc_descr_ref +new_reg_loc_descr (unsigned int reg, poly_int64 offset) +{ + HOST_WIDE_INT const_offset; + if (offset.is_constant (&const_offset)) + { + if (reg <= 31) + return new_loc_descr ((enum dwarf_location_atom) (DW_OP_breg0 + reg), + const_offset, 0); + else + return new_loc_descr (DW_OP_bregx, reg, const_offset); + } + else + { + dw_loc_descr_ref ret = new_reg_loc_descr (reg, 0); + loc_descr_plus_const (&ret, offset); + return ret; + } +} + /* Add a constant OFFSET to a location list. */ static void -loc_list_plus_const (dw_loc_list_ref list_head, HOST_WIDE_INT offset) +loc_list_plus_const (dw_loc_list_ref list_head, poly_int64 offset) { dw_loc_list_ref d; for (d = list_head; d != NULL; d = d->dw_loc_next) @@ -2614,7 +2632,7 @@ output_loc_sequence_raw (dw_loc_descr_re expression. */ struct dw_loc_descr_node * -build_cfa_loc (dw_cfa_location *cfa, HOST_WIDE_INT offset) +build_cfa_loc (dw_cfa_location *cfa, poly_int64 offset) { struct dw_loc_descr_node *head, *tmp; @@ -2627,11 +2645,7 @@ build_cfa_loc (dw_cfa_location *cfa, HOS head->dw_loc_oprnd1.val_entry = NULL; tmp = new_loc_descr (DW_OP_deref, 0, 0); add_loc_descr (&head, tmp); - if (offset != 0) - { - tmp = new_loc_descr (DW_OP_plus_uconst, offset, 0); - add_loc_descr (&head, tmp); - } + loc_descr_plus_const (&head, offset); } else head = new_reg_loc_descr (cfa->reg, offset); @@ -2645,7 +2659,7 @@ build_cfa_loc (dw_cfa_location *cfa, HOS struct dw_loc_descr_node * build_cfa_aligned_loc (dw_cfa_location *cfa, - HOST_WIDE_INT offset, HOST_WIDE_INT alignment) + poly_int64 offset, HOST_WIDE_INT alignment) { struct dw_loc_descr_node *head; unsigned int dwarf_fp @@ -3331,7 +3345,7 @@ static GTY(()) vec *generic /* Offset from the "steady-state frame pointer" to the frame base, within the current function. */ -static HOST_WIDE_INT frame_pointer_fb_offset; +static poly_int64 frame_pointer_fb_offset; static bool frame_pointer_fb_offset_valid; static vec base_types; @@ -3505,7 +3519,7 @@ static dw_loc_descr_ref one_reg_loc_desc enum var_init_status); static dw_loc_descr_ref multiple_reg_loc_descriptor (rtx, rtx, enum var_init_status); -static dw_loc_descr_ref based_loc_descr (rtx, HOST_WIDE_INT, +static dw_loc_descr_ref based_loc_descr (rtx, poly_int64, enum var_init_status); static int is_based_loc (const_rtx); static bool resolve_one_addr (rtx *); @@ -13202,13 +13216,58 @@ int_shift_loc_descriptor (HOST_WIDE_INT return ret; } -/* Return a location descriptor that designates a constant. */ +/* Return a location descriptor that designates constant POLY_I. */ static dw_loc_descr_ref -int_loc_descriptor (HOST_WIDE_INT i) +int_loc_descriptor (poly_int64 poly_i) { enum dwarf_location_atom op; + HOST_WIDE_INT i; + if (!poly_i.is_constant (&i)) + { + /* Create location descriptions for the non-constant part and + add any constant offset at the end. */ + dw_loc_descr_ref ret = NULL; + HOST_WIDE_INT constant = poly_i.coeffs[0]; + for (unsigned int j = 1; j < NUM_POLY_INT_COEFFS; ++j) + { + HOST_WIDE_INT coeff = poly_i.coeffs[j]; + if (coeff != 0) + { + dw_loc_descr_ref start = ret; + unsigned int factor; + int bias; + unsigned int regno = targetm.dwarf_poly_indeterminate_value + (j, &factor, &bias); + + /* Add COEFF * ((REGNO / FACTOR) - BIAS) to the value: + add COEFF * (REGNO / FACTOR) now and subtract + COEFF * BIAS from the final constant part. */ + constant -= coeff * bias; + add_loc_descr (&ret, new_reg_loc_descr (regno, 0)); + if (coeff % factor == 0) + coeff /= factor; + else + { + int amount = exact_log2 (factor); + gcc_assert (amount >= 0); + add_loc_descr (&ret, int_loc_descriptor (amount)); + add_loc_descr (&ret, new_loc_descr (DW_OP_shr, 0, 0)); + } + if (coeff != 1) + { + add_loc_descr (&ret, int_loc_descriptor (coeff)); + add_loc_descr (&ret, new_loc_descr (DW_OP_mul, 0, 0)); + } + if (start) + add_loc_descr (&ret, new_loc_descr (DW_OP_plus, 0, 0)); + } + } + loc_descr_plus_const (&ret, constant); + return ret; + } + /* Pick the smallest representation of a constant, rather than just defaulting to the LEB encoding. */ if (i >= 0) @@ -13574,7 +13633,7 @@ address_of_int_loc_descriptor (int size, /* Return a location descriptor that designates a base+offset location. */ static dw_loc_descr_ref -based_loc_descr (rtx reg, HOST_WIDE_INT offset, +based_loc_descr (rtx reg, poly_int64 offset, enum var_init_status initialized) { unsigned int regno; @@ -13593,11 +13652,7 @@ based_loc_descr (rtx reg, HOST_WIDE_INT if (elim != reg) { - if (GET_CODE (elim) == PLUS) - { - offset += INTVAL (XEXP (elim, 1)); - elim = XEXP (elim, 0); - } + elim = strip_offset_and_add (elim, &offset); gcc_assert ((SUPPORTS_STACK_ALIGNMENT && (elim == hard_frame_pointer_rtx || elim == stack_pointer_rtx)) @@ -13621,7 +13676,15 @@ based_loc_descr (rtx reg, HOST_WIDE_INT gcc_assert (frame_pointer_fb_offset_valid); offset += frame_pointer_fb_offset; - return new_loc_descr (DW_OP_fbreg, offset, 0); + HOST_WIDE_INT const_offset; + if (offset.is_constant (&const_offset)) + return new_loc_descr (DW_OP_fbreg, const_offset, 0); + else + { + dw_loc_descr_ref ret = new_loc_descr (DW_OP_fbreg, 0, 0); + loc_descr_plus_const (&ret, offset); + return ret; + } } } @@ -13636,8 +13699,10 @@ based_loc_descr (rtx reg, HOST_WIDE_INT #endif regno = DWARF_FRAME_REGNUM (regno); + HOST_WIDE_INT const_offset; if (!optimize && fde - && (fde->drap_reg == regno || fde->vdrap_reg == regno)) + && (fde->drap_reg == regno || fde->vdrap_reg == regno) + && offset.is_constant (&const_offset)) { /* Use cfa+offset to represent the location of arguments passed on the stack when drap is used to align stack. @@ -13645,14 +13710,10 @@ based_loc_descr (rtx reg, HOST_WIDE_INT is supposed to track where the arguments live and the register used as vdrap or drap in some spot might be used for something else in other part of the routine. */ - return new_loc_descr (DW_OP_fbreg, offset, 0); + return new_loc_descr (DW_OP_fbreg, const_offset, 0); } - if (regno <= 31) - result = new_loc_descr ((enum dwarf_location_atom) (DW_OP_breg0 + regno), - offset, 0); - else - result = new_loc_descr (DW_OP_bregx, regno, offset); + result = new_reg_loc_descr (regno, offset); if (initialized == VAR_INIT_STATUS_UNINITIALIZED) add_loc_descr (&result, new_loc_descr (DW_OP_GNU_uninit, 0, 0)); @@ -14648,6 +14709,7 @@ mem_loc_descriptor (rtx rtl, machine_mod enum dwarf_location_atom op; dw_loc_descr_ref op0, op1; rtx inner = NULL_RTX; + poly_int64 offset; if (mode == VOIDmode) mode = GET_MODE (rtl); @@ -15328,6 +15390,10 @@ mem_loc_descriptor (rtx rtl, machine_mod } break; + case CONST_POLY_INT: + mem_loc_result = int_loc_descriptor (rtx_to_poly_int64 (rtl)); + break; + case EQ: mem_loc_result = scompare_loc_descriptor (DW_OP_eq, rtl, mem_mode); break; @@ -19637,7 +19703,7 @@ convert_cfa_to_fb_loc_list (HOST_WIDE_IN before the latter is negated. */ static void -compute_frame_pointer_to_fb_displacement (HOST_WIDE_INT offset) +compute_frame_pointer_to_fb_displacement (poly_int64 offset) { rtx reg, elim; @@ -19652,11 +19718,7 @@ compute_frame_pointer_to_fb_displacement elim = (ira_use_lra_p ? lra_eliminate_regs (reg, VOIDmode, NULL_RTX) : eliminate_regs (reg, VOIDmode, NULL_RTX)); - if (GET_CODE (elim) == PLUS) - { - offset += INTVAL (XEXP (elim, 1)); - elim = XEXP (elim, 0); - } + elim = strip_offset_and_add (elim, &offset); frame_pointer_fb_offset = -offset;