Re: [PATCH] testsuite:analyzer: Fix header include for FreeBSD

2020-05-03 Thread Andreas Tobler

On 03.05.20 18:27, Kamil Rytarowski wrote:

On 01.05.2020 21:49, Andreas Tobler wrote:

Hi all,

FreeBSD does not have the alloca.h header. Do not include it in the test
cases which do include alloca.h.

There are two versions of this patch available, the one attached which
uses ifdef or another one which defines alloca with __builtin_alloca.

I tested both approaches and they work on FreeBSD. I do not know which
one you prefer.

Opinions welcome.

Ok for trunk?
TIA,
Andreas


Please include in your patch "|| defined(__NetBSD__)".


is this ok for you?

This is one reason why I'd prefer #define alloca __builtin_alloca and 
leave the include away.


Andreas
From 70165e30fb5b4398c903b4522d6496c7da7c12fa Mon Sep 17 00:00:00 2001
From: Andreas Tobler 
Date: Fri, 1 May 2020 21:10:39 +0200
Subject: [PATCH] testsuite: analyzer: Fix header include for Free/NetBSD

FreeBSD and NetBSD do not have the alloca.h header.
Fix this with ifndef on alloca.h.
---
 gcc/testsuite/ChangeLog| 8 
 gcc/testsuite/gcc.dg/analyzer/alloca-leak.c| 5 -
 gcc/testsuite/gcc.dg/analyzer/data-model-1.c   | 2 ++
 gcc/testsuite/gcc.dg/analyzer/malloc-1.c   | 2 ++
 gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c | 2 ++
 5 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 185f9ea725e..3f7b409bd42 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2020-05-03  Andreas Tobler  
+
+   * gcc.dg/analyzer/alloca-leak.c: Do not include
+ alloca.h for Free/NetBSD.
+   * gcc.dg/analyzer/data-model-1.c: Likewise
+   * gcc.dg/analyzer/malloc-1.c: Likewise.
+   * gcc.dg/analyzer/malloc-paths-8.c: Likewise.
+
 2020-05-01  H.J. Lu  
 
PR target/93492
diff --git a/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c 
b/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c
index 6d9fe3431ce..631e81b8cf4 100644
--- a/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c
+++ b/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c
@@ -1,5 +1,8 @@
+#if defined (__FreeBSD__) || defined(__NetBSD__)
+#include 
+#else
 #include 
-
+#endif
 void *test (void)
 {
   void *ptr = alloca (64);
diff --git a/gcc/testsuite/gcc.dg/analyzer/data-model-1.c 
b/gcc/testsuite/gcc.dg/analyzer/data-model-1.c
index 1db99133d50..f06651802a5 100644
--- a/gcc/testsuite/gcc.dg/analyzer/data-model-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/data-model-1.c
@@ -1,7 +1,9 @@
 #include 
 #include 
 #include 
+#if (!defined(__FreeBSD__) && !defined(__NetBSD__))
 #include 
+#endif
 #include "analyzer-decls.h"
 
 struct foo
diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-1.c 
b/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
index 3024e546137..046e3353192 100644
--- a/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
@@ -1,4 +1,6 @@
+#if (!defined(__FreeBSD__) && !defined(__NetBSD__))
 #include 
+#endif
 #include 
 
 extern int foo (void);
diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c 
b/gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c
index 10b97a05402..d55d6350da8 100644
--- a/gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c
+++ b/gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c
@@ -1,7 +1,9 @@
 /* { dg-additional-options "-fanalyzer-transitivity" } */
 
 #include 
+#if (!defined(__FreeBSD__) && !defined(__NetBSD__))
 #include 
+#endif
 #include 
 
 extern void do_stuff (const void *);
-- 
2.24.1



New Swedish PO file for 'gcc' (version 10.1-b20200322)

2020-05-03 Thread Translation Project Robot
Hello, gentle maintainer.

This is a message from the Translation Project robot.

A revised PO file for textual domain 'gcc' has been submitted
by the Swedish team of translators.  The file is available at:

https://translationproject.org/latest/gcc/sv.po

(This file, 'gcc-10.1-b20200322.sv.po', has just now been sent to you in
a separate email.)

All other PO files for your package are available in:

https://translationproject.org/latest/gcc/

Please consider including all of these in your next release, whether
official or a pretest.

Whenever you have a new distribution with a new version number ready,
containing a newer POT file, please send the URL of that distribution
tarball to the address below.  The tarball may be just a pretest or a
snapshot, it does not even have to compile.  It is just used by the
translators when they need some extra translation context.

The following HTML page has been updated:

https://translationproject.org/domain/gcc.html

If any question arises, please contact the translation coordinator.

Thank you for all your work,

The Translation Project robot, in the
name of your translation coordinator.




[committed] i386: Use plus_constant instead of gen_rtx_PLUS

2020-05-03 Thread Uros Bizjak via Gcc-patches
Replace gen_rtx_PLUS with a GEN_INT with plus_constant.

2020-05-03  Uroš Bizjak  

* config/i386/i386-expand.c (ix86_expand_int_movcc):
Use plus_constant instead of gen_rtx_PLUS with GEN_INT.
(emit_memmov): Ditto.
(emit_memset): Ditto.
(ix86_expand_strlensi_unroll_1): Ditto.
(release_scratch_register_on_entry): Ditto.
(gen_frame_set): Ditto.
(ix86_emit_restore_reg_using_pop): Ditto.
(ix86_emit_outlined_ms2sysv_restore): Ditto.
(ix86_expand_epilogue): Ditto.
(ix86_expand_split_stack_prologue): Ditto.
* config/i386/i386.md (push immediate splitter): Ditto.
(strmov): Ditto.
(strset): Ditto.

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

Committed to mainline.

Uros.
diff --git a/gcc/config/i386/i386-expand.c b/gcc/config/i386/i386-expand.c
index 48f00c5fcfc..26531585c5f 100644
--- a/gcc/config/i386/i386-expand.c
+++ b/gcc/config/i386/i386-expand.c
@@ -3170,7 +3170,7 @@ ix86_expand_int_movcc (rtx operands[])
}
  if (cf != 0)
{
- tmp = gen_rtx_PLUS (mode, tmp, GEN_INT (cf));
+ tmp = plus_constant (mode, tmp, cf);
  nops++;
}
  if (!rtx_equal_p (tmp, out))
@@ -5986,7 +5986,7 @@ static rtx
 emit_memmov (rtx destmem, rtx *srcmem, rtx destptr, rtx srcptr,
 HOST_WIDE_INT size_to_move)
 {
-  rtx dst = destmem, src = *srcmem, adjust, tempreg;
+  rtx dst = destmem, src = *srcmem, tempreg;
   enum insn_code code;
   machine_mode move_mode;
   int piece_size, i;
@@ -6022,7 +6022,7 @@ emit_memmov (rtx destmem, rtx *srcmem, rtx destptr, rtx 
srcptr,
 
   /* Emit moves.  We'll need SIZE_TO_MOVE/PIECE_SIZES moves.  */
   gcc_assert (size_to_move % piece_size == 0);
-  adjust = GEN_INT (piece_size);
+
   for (i = 0; i < size_to_move; i += piece_size)
 {
   /* We move from memory to memory, so we'll need to do it via
@@ -6032,9 +6032,9 @@ emit_memmov (rtx destmem, rtx *srcmem, rtx destptr, rtx 
srcptr,
   emit_insn (GEN_FCN (code) (dst, tempreg));
 
   emit_move_insn (destptr,
- gen_rtx_PLUS (Pmode, copy_rtx (destptr), adjust));
+ plus_constant (Pmode, copy_rtx (destptr), piece_size));
   emit_move_insn (srcptr,
- gen_rtx_PLUS (Pmode, copy_rtx (srcptr), adjust));
+ plus_constant (Pmode, copy_rtx (srcptr), piece_size));
 
   dst = adjust_automodify_address_nv (dst, move_mode, destptr,
  piece_size);
@@ -6191,7 +6191,7 @@ static rtx
 emit_memset (rtx destmem, rtx destptr, rtx promoted_val,
 HOST_WIDE_INT size_to_move)
 {
-  rtx dst = destmem, adjust;
+  rtx dst = destmem;
   enum insn_code code;
   machine_mode move_mode;
   int piece_size, i;
@@ -6216,7 +6216,7 @@ emit_memset (rtx destmem, rtx destptr, rtx promoted_val,
 
   /* Emit moves.  We'll need SIZE_TO_MOVE/PIECE_SIZES moves.  */
   gcc_assert (size_to_move % piece_size == 0);
-  adjust = GEN_INT (piece_size);
+
   for (i = 0; i < size_to_move; i += piece_size)
 {
   if (piece_size <= GET_MODE_SIZE (word_mode))
@@ -6230,7 +6230,7 @@ emit_memset (rtx destmem, rtx destptr, rtx promoted_val,
   emit_insn (GEN_FCN (code) (dst, promoted_val));
 
   emit_move_insn (destptr,
- gen_rtx_PLUS (Pmode, copy_rtx (destptr), adjust));
+ plus_constant (Pmode, copy_rtx (destptr), piece_size));
 
   dst = adjust_automodify_address_nv (dst, move_mode, destptr,
  piece_size);
@@ -7783,7 +7783,7 @@ ix86_expand_strlensi_unroll_1 (rtx out, rtx src, rtx 
align_rtx)
 reg,
 tmpreg)));
/* Emit lea manually to avoid clobbering of flags.  */
-   emit_insn (gen_rtx_SET (reg2, gen_rtx_PLUS (Pmode, out, const2_rtx)));
+   emit_insn (gen_rtx_SET (reg2, plus_constant (Pmode, out, 2)));
 
tmp = gen_rtx_REG (CCNOmode, FLAGS_REG);
tmp = gen_rtx_EQ (VOIDmode, tmp, const0_rtx);
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 1a9823ec844..458fafb3cc9 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -7103,14 +7103,14 @@ release_scratch_register_on_entry (struct scratch_reg 
*sr, HOST_WIDE_INT offset,
 
  /* The RX FRAME_RELATED_P mechanism doesn't know about pop.  */
  RTX_FRAME_RELATED_P (insn) = 1;
- x = gen_rtx_PLUS (Pmode, stack_pointer_rtx, GEN_INT (UNITS_PER_WORD));
+ x = plus_constant (Pmode, stack_pointer_rtx, UNITS_PER_WORD);
  x = gen_rtx_SET (stack_pointer_rtx, x);
  add_reg_note (insn, REG_FRAME_RELATED_EXPR, x);
  m->fs.sp_offset -= UNITS_PER_WORD;
}
   else
{
- rtx x = gen_rtx_PLUS (Pmode, stack_pointer_rtx, GEN_INT (offset));
+ rtx x = plus_constant (Pmode, stack_pointer_rtx, offset);
  x = gen_rtx_SET 

Re: [PATH] Enable GCC support for SERIALIZE

2020-05-03 Thread Uros Bizjak via Gcc-patches
On Wed, Apr 1, 2020 at 9:23 AM Hongtao Liu  wrote:
>
> Hi:
>   This patch is about to enable GCC support for SERIALIZE which would
> be in GLC. There's only 1 instruction: SERIALIZE, more details please
> refer to 
> https://software.intel.com/sites/default/files/managed/c5/15/architecture-instruction-set-extensions-programming-reference.pdf
>   I know it's stage4 right now, and patches are approved only for bug
> fixed, but since many users prefer to use release version other than
> build from trunk, i'd like to see this patch landed on GCC10, after
> all it's only 1 instruction, without any significant changes.
>
>   Bootstrap ok, regression test on i386/x86 backend is ok.
>
> gcc/Changelog:
> * gcc/common/config/i386/i386-common.c 
> (OPTION_MASK_ISA2_SERIALIZE_SET,
> OPTION_MASK_ISA2_SERIALIZE_UNSET): New macros.
> (ix86_handle_option): Handle -mserialize.
> * gcc/config.gcc (serializeintrin.h): New header file.
> * gcc/config/i386/cpuid.h (bit_SERIALIZE): New bit.
> * gcc/config/i386/driver-i386.c (host_detect_local_cpu): Detect
> -mserialize.
> * gcc/config/i386/i386-builtin.def: Add new builtin.
> * gcc/config/i386/i386-c.c (__SERIALIZE__): New macro.
> * gcc/config/i386/i386-options.c (ix86_target_opts_isa2_opts):
>   Add -mserialize.
> * (ix86_valid_target_attribute_inner_p): Add target attribute
> * for serialize.
> * gcc/config/i386/i386.h (TARGET_SERIALIZE, TARGET_SERIALIZE_P):
>   New macros.
> * gcc/config/i386/i386.md (UNSPECV_SERIALIZE): New unspec.
>   (serialize): New define_insn.
> * gcc/config/i386/i386.opt (mserialize): New option
> * gcc/config/i386/immintrin.h: Include serailizeintrin.h.
> * gcc/config/i386/serializeintrin.h: New header file.
> * gcc/doc/invoke.texi: Add documents for -mserialize.
>
> gcc/testsuite/Changelog
> * gcc/testsuite/gcc.target/i386/serialize-1.c: New test.
> * gcc/testsuite/g++.dg/other/i386-2.C: Add -mserialize.
> * gcc/testsuite/g++.dg/other/i386-3.C: Ditto.
> * gcc/testsuite/gcc.target/i386/sse-12.c: Ditto.
> * gcc/testsuite/gcc.target/i386/sse-13.c: Ditto.
> * gcc/testsuite/gcc.target/i386/sse-14.c: Ditto.
> * gcc/testsuite/gcc.target/i386/sse-22.c: Ditto.
> * gcc/testsuite/gcc.target/i386/sse-23.c: Ditto.
>

Please add new option to gcc.target/i386/funcspec-56.h test file.

Just a couple of nits:

+/* { dg-final { scan-assembler-times "serialize\[^-]"  1 } } */

Simply scan for "\tserialize", we are sure that file name won't
interfere, because it is always quoted.

/* { dg-final { scan-assembler "\tserialize" } } */

+void
+foo (void)
+{
+   _serialize ();
+   return;
+}

No need for explicit return.

OK with the above fixes.

Thanks,
Uros.


>
> --
> BR,
> Hongtao


Re: [PATCH] Enable GCC support for TSXLDTRK

2020-05-03 Thread Uros Bizjak via Gcc-patches
On Wed, Apr 1, 2020 at 9:27 AM Hongtao Liu  wrote:
>
> Hi:
>   This patch is about to enable GCC support for TSXLDTRK which would
> be in GLC. There's only 2 instructions: XRESLDTRK, XSUSLDTRK, more
> details please
> refer to 
> https://software.intel.com/sites/default/files/managed/c5/15/architecture-instruction-set-extensions-programming-reference.pdf
>   I know it's stage4 right now, and patches are approved only for bug
> fixed, but since many users prefer to use release version other than
> build from trunk, i'd like to see this patch land on GCC10, after
> all it's only 2 instructions, without any significant changes.
>
>   Bootstrap ok, regression test on i386/x86 backend is ok.
>
> gcc/Changelog
> * common/config/i386/i386-common.c (OPTION_MASK_ISA2_TSXLDTRK_SET,
> OPTION_MASK_ISA2_TSXLDTRK_UNSET): New macros.
> * config.gcc: Add tsxldtrkintrin.h to extra_headers.
> * config/i386/driver-i386.c (host_detect_local_cpu): Detect
> TSXLDTRK.
> * config/i386/i386-builtin.def: Add new builtins.
> * config/i386/i386-c.c (ix86_target_macros_internal): Define
> __TSXLDTRK__.
> * config/i386/i386-options.c (ix86_target_string): Add
> -mtsxldtrk.
> * config/i386/i386.h (TARGET_TSXLDTRK, TARGET_TSXLDTRK_P):
> New.
> * config/i386/i386.md (define_c_enum "unspec"): Add
> UNSPECV_SUSLDTRK, UNSPECV_RESLDTRK.
> (TSXLDTRK): New define_int_iterator.
> (""): New define_insn.
> * config/i386/i386.opt: Add -mtsxldtrk.
> * config/i386/immintrin.h: Include tsxldtrkintrin.h.
> * config/i386/tsxldtrkintrin.h: New.
> * doc/invoke.texi: Document -mtsxldtrk.
>
> gcc/testsuite/Changelog
> * g++.dg/other/i386-2.c: Add -mtsxldtrk.
> * g++.dg/other/i386-3.c: Likewise.
> * gcc.target/i386/sse-12.c: Likewise.
> * gcc.target/i386/sse-13.c: Likewise.
> * gcc.target/i386/sse-14.c: Likewise.
> * gcc.target/i386/sse-22.c: Likewsie.
> * gcc.target/i386/sse-23.c: Likewise.
> * gcc.target/i386/tsxldtrk-1.c: New test.

The part above is OK, but you are missing support for
__attribute__((__target__("..."))). Please see how for example -msgx
is handled in isa2_opts in i386-options.c and in
gcc.target/i386/funcspec-56.h test source.

Please repost the patch with added missing part.

Uros.


Re: [PATCH] testsuite:analyzer: Fix header include for FreeBSD

2020-05-03 Thread Kamil Rytarowski
On 01.05.2020 21:49, Andreas Tobler wrote:
> Hi all,
> 
> FreeBSD does not have the alloca.h header. Do not include it in the test
> cases which do include alloca.h.
> 
> There are two versions of this patch available, the one attached which
> uses ifdef or another one which defines alloca with __builtin_alloca.
> 
> I tested both approaches and they work on FreeBSD. I do not know which
> one you prefer.
> 
> Opinions welcome.
> 
> Ok for trunk?
> TIA,
> Andreas

Please include in your patch "|| defined(__NetBSD__)".



signature.asc
Description: OpenPGP digital signature


[PATCH v2 3/5] PRU: Fix R3.w0 register class

2020-05-03 Thread Dimitar Dimitrov
TI has clarified [1] that R3.w0 is caller saved, so allow compiler to
use it. This is safe change because older GCC versions treat R3.w0 as
fixed register and never use it.

[1] https://e2e.ti.com/support/tools/ccs/f/81/t/849993

gcc/ChangeLog:

2020-05-03  Dimitar Dimitrov  

* config/pru/pru.h: Mark R3.w0 as caller saved.

gcc/testsuite/ChangeLog:

2020-05-03  Dimitar Dimitrov  

* gcc.target/pru/lra-framepointer-fragmentation-1.c: Update test to
  take into account additional available registers.
* gcc.target/pru/lra-framepointer-fragmentation-2.c: Ditto.

Signed-off-by: Dimitar Dimitrov 
---
 gcc/config/pru/pru.h  | 11 ---
 .../gcc.target/pru/lra-framepointer-fragmentation-1.c |  5 +++--
 .../gcc.target/pru/lra-framepointer-fragmentation-2.c | 10 ++
 3 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/gcc/config/pru/pru.h b/gcc/config/pru/pru.h
index ea6ee109184..314e877a5f9 100644
--- a/gcc/config/pru/pru.h
+++ b/gcc/config/pru/pru.h
@@ -125,7 +125,8 @@
1  r1 Caller Saved.  Also used as a temporary by function.
  profiler and function prologue/epilogue.
2  r2   spStack Pointer.
-   3* r3.w0raReturn Address (16-bit).
+   3* r3.w0  Caller saved.
+   3* r3.w2raReturn Address (16-bit).
4  r4   fpFrame Pointer, also called Argument Pointer in ABI.
5-13   r5-r13 Callee Saved Registers.
14-29  r14-r29Register Arguments.  Caller Saved Registers.
@@ -152,7 +153,7 @@
 
 #define FIXED_REGISTERS\
   {\
-/*   0 */  0,0,0,0, 0,0,0,0, 1,1,1,1, 1,1,1,1, \
+/*   0 */  0,0,0,0, 0,0,0,0, 1,1,1,1, 0,0,1,1, \
 /*   4 */  0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, \
 /*   8 */  0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, \
 /*  12 */  0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, \
@@ -178,10 +179,13 @@
   }
 
 #define PRU_SEQ_R(X)  (X) * 4 + 0, (X) * 4 + 1, (X) * 4 + 2, (X) * 4 + 3
+#define PRU_SEQ_R_W0(X)  (X) * 4 + 0, (X) * 4 + 1
+#define PRU_SEQ_R_W2(X)  (X) * 4 + 2, (X) * 4 + 3
 #define REG_ALLOC_ORDER
\
   {\
 /* Call-clobbered, yet not used for parameters.  */
\
 PRU_SEQ_R (0),  PRU_SEQ_R ( 1),\
+PRU_SEQ_R_W0 (3),  \
\
 PRU_SEQ_R (14), PRU_SEQ_R (15), PRU_SEQ_R (16), PRU_SEQ_R (17),\
 PRU_SEQ_R (18), PRU_SEQ_R (19), PRU_SEQ_R (20), PRU_SEQ_R (21),\
@@ -193,7 +197,8 @@
 PRU_SEQ_R (13),\
\
 PRU_SEQ_R ( 4),\
-PRU_SEQ_R ( 2), PRU_SEQ_R ( 3),\
+PRU_SEQ_R ( 2),\
+PRU_SEQ_R_W2 (3),  \
\
 /* I/O and virtual registers.  */  \
 PRU_SEQ_R (30), PRU_SEQ_R (31), PRU_SEQ_R (32), PRU_SEQ_R (33),\
diff --git a/gcc/testsuite/gcc.target/pru/lra-framepointer-fragmentation-1.c 
b/gcc/testsuite/gcc.target/pru/lra-framepointer-fragmentation-1.c
index ee1288fc2ae..b2a49e3a9e1 100644
--- a/gcc/testsuite/gcc.target/pru/lra-framepointer-fragmentation-1.c
+++ b/gcc/testsuite/gcc.target/pru/lra-framepointer-fragmentation-1.c
@@ -12,6 +12,7 @@ uint64_t __attribute__((noinline)) test(uint64_t a, uint64_t 
b,
   uint64_t l1 = 0x12345678, l2 = 0x87654321, l3 = 1001, l4 = 1002;
   uint64_t l5 = 1004;
   uint32_t l6 = 2005;
+  uint16_t s1 = 4321;
   uint8_t c1 = 101, c2 = 102;
 
   /* The numerous dummy asm input operands create just
@@ -24,10 +25,10 @@ uint64_t __attribute__((noinline)) test(uint64_t a, 
uint64_t b,
: "0" (l1), "r" (a), "r"(b),
"r"(c), "r"(d), "r"(e), "r"(f),
"r"(g), "r"(h), "r"(l2),
-   "r"(c1), "r"(c2),
+   "r"(c1), "r"(c2), "r"(s1),
"r"(l3), "r"(l4), "r"(l5), "r"(l6));
 
-  global = a+b+c+d+e+f+g+h + c1+c2 + l2;
+  global = a+b+c+d+e+f+g+h + s1 + c1+c2 + l2;
 
   return l1;
 }
diff --git a/gcc/testsuite/gcc.target/pru/lra-framepointer-fragmentation-2.c 
b/gcc/testsuite/gcc.target/pru/lra-framepointer-fragmentation-2.c
index 6c98e9bf13b..2f910295f2a 100644
--- a/gcc/testsuite/gcc.target/pru/lra-framepointer-fragmentation-2.c
+++ b/gcc/testsuite/gcc.target/pru/lra-framepointer-fragmentation-2.c
@@ -14,6 +14,7 @@ uint64_t __attribute__((noinline)) test(uint64_t a, uint64_t 
b,
  

[PATCH v2 2/5] PRU: Simplify machine description

2020-05-03 Thread Dimitar Dimitrov
Use the new @insn syntax for simpler gen_* invocation.

gcc/ChangeLog:

2020-05-03  Dimitar Dimitrov  

* config/pru/pru.c (pru_emit_doloop): Use new gen_doloop_end_internal
and gen_doloop_begin_internal.
(pru_reorg_loop): Use gen_pruloop with mode.
* config/pru/pru.md: Use new @insn syntax.

Signed-off-by: Dimitar Dimitrov 
---
 gcc/config/pru/pru.c  | 44 +--
 gcc/config/pru/pru.md |  6 +++---
 2 files changed, 16 insertions(+), 34 deletions(-)

diff --git a/gcc/config/pru/pru.c b/gcc/config/pru/pru.c
index e20b41c6d1f..45b18ed6fe4 100644
--- a/gcc/config/pru/pru.c
+++ b/gcc/config/pru/pru.c
@@ -2345,26 +2345,14 @@ pru_emit_doloop (rtx *operands, int is_end)
 
   tag = GEN_INT (cfun->machine->doloop_tags - 1);
   machine_mode opmode = GET_MODE (operands[0]);
+  gcc_assert (opmode == HImode || opmode == SImode);
+
   if (is_end)
-{
-  if (opmode == HImode)
-   emit_jump_insn (gen_doloop_end_internalhi (operands[0],
-  operands[1], tag));
-  else if (opmode == SImode)
-   emit_jump_insn (gen_doloop_end_internalsi (operands[0],
-  operands[1], tag));
-  else
-   gcc_unreachable ();
-}
+emit_jump_insn (gen_doloop_end_internal (opmode, operands[0],
+operands[1], tag));
   else
-{
-  if (opmode == HImode)
-   emit_insn (gen_doloop_begin_internalhi (operands[0], operands[0], tag));
-  else if (opmode == SImode)
-   emit_insn (gen_doloop_begin_internalsi (operands[0], operands[0], tag));
-  else
-   gcc_unreachable ();
-}
+emit_insn (gen_doloop_begin_internal (opmode, operands[0],
+ operands[0], tag));
 }
 
 
@@ -2607,6 +2595,7 @@ pru_reorg_loop (rtx_insn *insns)
/* Case (1) or (2).  */
rtx_code_label *repeat_label;
rtx label_ref;
+   rtx loop_rtx;
 
/* Create a new label for the repeat insn.  */
repeat_label = gen_label_rtx ();
@@ -2616,23 +2605,16 @@ pru_reorg_loop (rtx_insn *insns)
   will utilize an internal for the PRU core LOOP register.  */
label_ref = gen_rtx_LABEL_REF (VOIDmode, repeat_label);
machine_mode loop_mode = GET_MODE (loop->begin->loop_count);
-   if (loop_mode == HImode)
- emit_insn_before (gen_pruloophi (loop->begin->loop_count, label_ref),
-   loop->begin->insn);
-   else if (loop_mode == SImode)
- {
-   rtx loop_rtx = gen_pruloopsi (loop->begin->loop_count, label_ref);
-   emit_insn_before (loop_rtx, loop->begin->insn);
- }
-   else if (loop_mode == VOIDmode)
+   if (loop_mode == VOIDmode)
  {
gcc_assert (CONST_INT_P (loop->begin->loop_count));
gcc_assert (UBYTE_INT ( INTVAL (loop->begin->loop_count)));
-   rtx loop_rtx = gen_pruloopsi (loop->begin->loop_count, label_ref);
-   emit_insn_before (loop_rtx, loop->begin->insn);
+   loop_mode = SImode;
  }
-   else
- gcc_unreachable ();
+   gcc_assert (loop_mode == HImode || loop_mode == SImode);
+   loop_rtx = gen_pruloop (loop_mode, loop->begin->loop_count, label_ref);
+   emit_insn_before (loop_rtx, loop->begin->insn);
+
delete_insn (loop->begin->insn);
 
/* Insert the repeat label before the first doloop_end.
diff --git a/gcc/config/pru/pru.md b/gcc/config/pru/pru.md
index 67624e2aac0..2f1bc21f025 100644
--- a/gcc/config/pru/pru.md
+++ b/gcc/config/pru/pru.md
@@ -887,7 +887,7 @@ (define_insn 
"cbranch_qbbx_4"
 ;; This insn is volatile because we'd like it to stay in its original
 ;; position, just before the loop header.  If it stays there, we might
 ;; be able to convert it into a "loop" insn.
-(define_insn "doloop_begin_internal"
+(define_insn "@doloop_begin_internal"
   [(set (match_operand:HISI 0 "register_operand" "=r")
(unspec_volatile:HISI
 [(match_operand:HISI 1 "reg_or_ubyte_operand" "rI")
@@ -909,7 +909,7 @@ (define_expand "doloop_begin"
 ; Note: "JUMP_INSNs and CALL_INSNs are not allowed to have any output
 ; reloads;".  Hence this insn must be prepared for a counter that is
 ; not a register.
-(define_insn "doloop_end_internal"
+(define_insn "@doloop_end_internal"
   [(set (pc)
(if_then_else (ne (match_operand:HISI 0 "nonimmediate_operand" "+r,*m")
  (const_int 1))
@@ -951,7 +951,7 @@ (define_expand "doloop_end"
   DONE;
 })
 
-(define_insn "pruloop"
+(define_insn "@pruloop"
   [(set (reg:HISI LOOPCNTR_REGNUM)
(unspec:HISI [(match_operand:HISI 0 "reg_or_ubyte_operand" "rI")
(label_ref (match_operand 1))]
-- 
2.20.1



[PATCH v2 5/5] PRU: Remove TARGET_HARD_REGNO_CALL_PART_CLOBBERED

2020-05-03 Thread Dimitar Dimitrov
Per clarification in [1], macro is supposed to check for partial
clobbering of single HW registers. Since PRU declares only 8-bit
HW registers, and ABI does not define individual bit clobbering,
it is safe to remove the implementation.

[1] https://gcc.gnu.org/ml/gcc-patches/2019-09/msg00778.html

gcc/ChangeLog:

2020-05-03  Dimitar Dimitrov  

* config/pru/pru.c (pru_hard_regno_call_part_clobbered): Remove.
(TARGET_HARD_REGNO_CALL_PART_CLOBBERED): Remove.

Signed-off-by: Dimitar Dimitrov 
---
 gcc/config/pru/pru.c | 34 --
 1 file changed, 34 deletions(-)

diff --git a/gcc/config/pru/pru.c b/gcc/config/pru/pru.c
index 45b18ed6fe4..a715f6b07ce 100644
--- a/gcc/config/pru/pru.c
+++ b/gcc/config/pru/pru.c
@@ -556,37 +556,6 @@ pru_hard_regno_scratch_ok (unsigned int regno)
 }
 
 
-/* Implement TARGET_HARD_REGNO_CALL_PART_CLOBBERED.  */
-
-static bool
-pru_hard_regno_call_part_clobbered (unsigned, unsigned regno,
-   machine_mode mode)
-{
-  HARD_REG_SET caller_saved_set;
-  HARD_REG_SET callee_saved_set;
-
-  CLEAR_HARD_REG_SET (caller_saved_set);
-  CLEAR_HARD_REG_SET (callee_saved_set);
-
-  /* r0 and r1 are caller saved.  */
-  add_range_to_hard_reg_set (_saved_set, 0, 2 * 4);
-
-  add_range_to_hard_reg_set (_saved_set, FIRST_ARG_REGNUM,
-LAST_ARG_REGNUM + 1 - FIRST_ARG_REGNUM);
-
-  /* Treat SP as callee saved.  */
-  add_range_to_hard_reg_set (_saved_set, STACK_POINTER_REGNUM, 4);
-
-  /* r3 to r13 are callee saved.  */
-  add_range_to_hard_reg_set (_saved_set, FIRST_CALLEE_SAVED_REGNUM,
-LAST_CALEE_SAVED_REGNUM + 1
-- FIRST_CALLEE_SAVED_REGNUM);
-
-  return overlaps_hard_reg_set_p (caller_saved_set, mode, regno)
-&& overlaps_hard_reg_set_p (callee_saved_set, mode, regno);
-}
-
-
 /* Worker function for `HARD_REGNO_RENAME_OK'.
Return nonzero if register OLD_REG can be renamed to register NEW_REG.  */
 
@@ -2935,9 +2904,6 @@ pru_unwind_word_mode (void)
 
 #undef  TARGET_HARD_REGNO_SCRATCH_OK
 #define TARGET_HARD_REGNO_SCRATCH_OK pru_hard_regno_scratch_ok
-#undef  TARGET_HARD_REGNO_CALL_PART_CLOBBERED
-#define TARGET_HARD_REGNO_CALL_PART_CLOBBERED \
-  pru_hard_regno_call_part_clobbered
 
 #undef TARGET_FUNCTION_ARG
 #define TARGET_FUNCTION_ARG pru_function_arg
-- 
2.20.1



[PATCH v2 4/5] testsuite: pru: Add clobber test

2020-05-03 Thread Dimitar Dimitrov
gcc/testsuite/ChangeLog:

2020-05-03  Dimitar Dimitrov  

* gcc.target/pru/clobber-sp.c: New test.

Signed-off-by: Dimitar Dimitrov 
---
 gcc/testsuite/gcc.target/pru/clobber-sp.c | 24 +++
 1 file changed, 24 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/pru/clobber-sp.c

diff --git a/gcc/testsuite/gcc.target/pru/clobber-sp.c 
b/gcc/testsuite/gcc.target/pru/clobber-sp.c
new file mode 100644
index 000..3cc0a60bfc9
--- /dev/null
+++ b/gcc/testsuite/gcc.target/pru/clobber-sp.c
@@ -0,0 +1,24 @@
+/* Test inline ASM clobber for SP register */
+
+/* { dg-do compile } */
+/* { dg-options "-O1" } */
+
+/* -O1 in the options is significant.  */
+
+extern void abort (void);
+
+int
+test1 (void)
+{
+  int res;
+
+  /* { dg-warning "listing the stack pointer register 'sp' in a clobber list 
is deprecated" "" { target pru-*-* } .+2 } */
+  /* { dg-message "note: the value of the stack pointer after an 'asm' 
statement must be the same as it was before the statement" "" { target pru-*-* 
} .+1 } */
+  asm volatile(
+  "ldi %[res], 101 \n\t"
+  : [res] "=r" (res)
+  :
+  : "sp");
+
+  return res;
+}
-- 
2.20.1



[PATCH v2 1/5] PRU: Fix comment to avoid fall through warning

2020-05-03 Thread Dimitar Dimitrov
gcc/ChangeLog:

2020-05-03  Dimitar Dimitrov  

* config/pru/pru.c (pru_print_operand): Fix fall through comment.

Signed-off-by: Dimitar Dimitrov 
---
 gcc/config/pru/pru.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/pru/pru.c b/gcc/config/pru/pru.c
index 37394c5e3b9..e20b41c6d1f 100644
--- a/gcc/config/pru/pru.c
+++ b/gcc/config/pru/pru.c
@@ -1650,7 +1650,7 @@ pru_print_operand (FILE *file, rtx op, int letter)
  return;
case 'Q':
  cond = swap_condition (cond);
- /* Fall through to reverse.  */
+ /* Fall through.  */
case 'R':
  fprintf (file, "%s", pru_comparison_str (reverse_condition (cond)));
  return;
-- 
2.20.1



[PATCH v2 0/5] Updates for PRU backend

2020-05-03 Thread Dimitar Dimitrov
One of the changes frees a previously fixed register, per
ABI clarification from TI, for local usage from function.
The change is backwards compatible.

Rest of changes are cleanups.

Testsuite did not reveal any regressions.

Dimitar Dimitrov (5):
  PRU: Fix comment to avoid fall through warning
  PRU: Simplify machine description
  PRU: Fix R3.w0 register class
  testsuite: pru: Add clobber test
  PRU: Remove TARGET_HARD_REGNO_CALL_PART_CLOBBERED

 gcc/config/pru/pru.c  | 80 ---
 gcc/config/pru/pru.h  | 11 ++-
 gcc/config/pru/pru.md |  6 +-
 gcc/testsuite/gcc.target/pru/clobber-sp.c | 24 ++
 .../pru/lra-framepointer-fragmentation-1.c|  5 +-
 .../pru/lra-framepointer-fragmentation-2.c| 10 ++-
 6 files changed, 58 insertions(+), 78 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/pru/clobber-sp.c

-- 
2.20.1



Re: [PATCH] fix Ada bootstrap on Cygwin64 (PR bootstrap/94918)

2020-05-03 Thread Mikael Pettersson via Gcc-patches
On Sat, May 2, 2020 at 9:46 PM Arnaud Charlet  wrote:
>
> > This fixes three compilation errors preventing bootstrap of gcc-10/11
> > with Ada on x86_64-pc-cygwin.  See PR bootstrap/94918 for details.
> >
> > Tested by bootstrapping on x86_64-pc-cygwin, and since it touches code
> > shared with mingw, also by building a cross to x86_64-w64-mingw32.
> >
> > Ok for master and gcc-10 branch?
>
> No, the libgnat/g-sercom__mingw.adb is wrong and isn't needed.
>
> If there is an issue, it would be in "s-oscons-tmplt.c" which is supposed
> to define Serial_Port_Descriptor as:
>
>subtype Serial_Port_Descriptor is System.Win32.HANDLE;
>
> See:
>
> #if defined (__MINGW32__) || defined (__CYGWIN__)
> # define TARGET_OS "Windows"
> # define Serial_Port_Descriptor "System.Win32.HANDLE"
> TXT("with System.Win32;")

Thanks, the "|| defined(__CYGWIN__)" is missing so
Serial_Port_Descriptor becomes "int" on Cygwin, triggering the error.
Revised patch below, re-tested on Cygwin64.

This fixes three compilation errors preventing bootstrap of gcc-10/11
with Ada on x86_64-pc-cygwin.  See PR bootstrap/94918 for details.

Tested by bootstrapping on x86_64-pc-cygwin, and since it touches code
shared with mingw, also by building a cross to x86_64-w64-mingw32.

Ok for master and gcc-10 branch?

(I don't have commit rights, so I will need assistance with that.)

(The patch is also attached, since gmail _will_ corrupt this text.)

gcc/ada/

2020-05-03  Mikael Pettersson  

PR bootstrap/94918

* mingw32.h: Prevent windows.h from including emmintrin.h on Cygwin64.
* s-oscons-tmplt.c (Serial_Port_Descriptor): Define as
System.Win32.HANDLE also on Cygwin.

libgcc/

2020-05-03  Mikael Pettersson  

PR bootstrap/94918

* unwind-generic.h (__SEH__): Prevent windows.h from including
x86intrin.h and emmintrin.h.

--- gcc-10.1.0-RC-20200430/gcc/ada/mingw32.h.~1~2020-04-30
22:51:33.0 +0200
+++ gcc-10.1.0-RC-20200430/gcc/ada/mingw32.h2020-05-02
17:18:44.196573200 +0200
@@ -56,6 +56,7 @@
 /* Note: windows.h on cygwin-64 includes x86intrin.h which uses malloc.
That fails to compile, if malloc is poisoned, i.e. if !IN_RTS.  */
 #define _X86INTRIN_H_INCLUDED
+#define _EMMINTRIN_H_INCLUDED
 #endif
 #include 

--- gcc-10.1.0-RC-20200430/gcc/ada/s-oscons-tmplt.c.~1~ 2020-04-30
22:51:33.0 +0200
+++ gcc-10.1.0-RC-20200430/gcc/ada/s-oscons-tmplt.c 2020-05-03
11:06:32.958993300 +0200
@@ -261,7 +261,7 @@ main (void) {
 TXT("--  This is the version for " TARGET)
 TXT("")
 TXT("with Interfaces.C;")
-#if defined (__MINGW32__)
+#if defined (__MINGW32__) || defined (__CYGWIN__)
 # define TARGET_OS "Windows"
 # define Serial_Port_Descriptor "System.Win32.HANDLE"
 TXT("with System.Win32;")
--- gcc-10.1.0-RC-20200430/libgcc/unwind-generic.h.~1~  2020-04-30
22:51:36.0 +0200
+++ gcc-10.1.0-RC-20200430/libgcc/unwind-generic.h  2020-05-02
17:18:44.212239100 +0200
@@ -30,6 +30,8 @@

 #if defined (__SEH__) && !defined (__USING_SJLJ_EXCEPTIONS__)
 /* Only for _GCC_specific_handler.  */
+#define _X86INTRIN_H_INCLUDED
+#define _EMMINTRIN_H_INCLUDED
 #include 
 #endif
--- gcc-10.1.0-RC-20200430/gcc/ada/mingw32.h.~1~2020-04-30 
22:51:33.0 +0200
+++ gcc-10.1.0-RC-20200430/gcc/ada/mingw32.h2020-05-02 17:18:44.196573200 
+0200
@@ -56,6 +56,7 @@
 /* Note: windows.h on cygwin-64 includes x86intrin.h which uses malloc.
That fails to compile, if malloc is poisoned, i.e. if !IN_RTS.  */
 #define _X86INTRIN_H_INCLUDED
+#define _EMMINTRIN_H_INCLUDED
 #endif
 #include 
 
--- gcc-10.1.0-RC-20200430/gcc/ada/s-oscons-tmplt.c.~1~ 2020-04-30 
22:51:33.0 +0200
+++ gcc-10.1.0-RC-20200430/gcc/ada/s-oscons-tmplt.c 2020-05-03 
11:06:32.958993300 +0200
@@ -261,7 +261,7 @@ main (void) {
 TXT("--  This is the version for " TARGET)
 TXT("")
 TXT("with Interfaces.C;")
-#if defined (__MINGW32__)
+#if defined (__MINGW32__) || defined (__CYGWIN__)
 # define TARGET_OS "Windows"
 # define Serial_Port_Descriptor "System.Win32.HANDLE"
 TXT("with System.Win32;")
--- gcc-10.1.0-RC-20200430/libgcc/unwind-generic.h.~1~  2020-04-30 
22:51:36.0 +0200
+++ gcc-10.1.0-RC-20200430/libgcc/unwind-generic.h  2020-05-02 
17:18:44.212239100 +0200
@@ -30,6 +30,8 @@
 
 #if defined (__SEH__) && !defined (__USING_SJLJ_EXCEPTIONS__)
 /* Only for _GCC_specific_handler.  */
+#define _X86INTRIN_H_INCLUDED
+#define _EMMINTRIN_H_INCLUDED
 #include 
 #endif
 


[committed] libstdc++: Make byte-sized std::fill_n a constant expression (PR 94933)

2020-05-03 Thread Jonathan Wakely via Gcc-patches
The overload for byte types uses memset and isn't constexpr. This adds
the specifier and uses std::is_constant_evaluated() to provide a
compile-time alternative.

PR libstdc++/94933
* include/bits/stl_algobase.h (__fill_a1): Make overload for byte types
usable in constant expressions.
* testsuite/25_algorithms/fill_n/constexpr.cc: Test with bytes and
non-scalars.

Tested powerpc64le-linux. Committed to master.

This should be backported to gcc-10 but I'll wait for 10.2


commit 22b6b5d6cfb76deb68ca5bc0bcae8b4245df946d
Author: Jonathan Wakely 
Date:   Sun May 3 12:46:15 2020 +0100

libstdc++: Make byte-sized std::fill_n a constant expression (PR 94933)

The overload for byte types uses memset and isn't constexpr. This adds
the specifier and uses std::is_constant_evaluated() to provide a
compile-time alternative.

PR libstdc++/94933
* include/bits/stl_algobase.h (__fill_a1): Make overload for byte 
types
usable in constant expressions.
* testsuite/25_algorithms/fill_n/constexpr.cc: Test with bytes and
non-scalars.

diff --git a/libstdc++-v3/include/bits/stl_algobase.h 
b/libstdc++-v3/include/bits/stl_algobase.h
index a7e92d4b473..bed61fd9d00 100644
--- a/libstdc++-v3/include/bits/stl_algobase.h
+++ b/libstdc++-v3/include/bits/stl_algobase.h
@@ -875,11 +875,20 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
 
   // Specialization: for char types we can use memset.
   template
+_GLIBCXX20_CONSTEXPR
 inline typename
 __gnu_cxx::__enable_if<__is_byte<_Tp>::__value, void>::__type
 __fill_a1(_Tp* __first, _Tp* __last, const _Tp& __c)
 {
   const _Tp __tmp = __c;
+#if __cpp_lib_is_constant_evaluated
+  if (std::is_constant_evaluated())
+   {
+ for (; __first != __last; ++__first)
+   *__first = __tmp;
+ return;
+   }
+#endif
   if (const size_t __len = __last - __first)
__builtin_memset(__first, static_cast(__tmp), __len);
 }
diff --git a/libstdc++-v3/testsuite/25_algorithms/fill_n/constexpr.cc 
b/libstdc++-v3/testsuite/25_algorithms/fill_n/constexpr.cc
index c18b6c99eda..17c9aa5a8d7 100644
--- a/libstdc++-v3/testsuite/25_algorithms/fill_n/constexpr.cc
+++ b/libstdc++-v3/testsuite/25_algorithms/fill_n/constexpr.cc
@@ -28,7 +28,37 @@ test()
 
   const auto outd = std::fill_n(ma0.begin(), 6, 77);
 
-  return outd == ma0.begin() + 6;
+  return outd == ma0.begin() + 6 && ma0[5] == 77 && ma0[6] == 0;
 }
 
 static_assert(test());
+
+constexpr bool
+test_byte()
+{
+  // PR libstdc++/94933
+  std::array ma0{};
+
+  const auto outd = std::fill_n(ma0.begin(), 6, 77);
+
+  return outd == ma0.begin() + 6 && ma0[5] == 77 && ma0[6] == 0;
+}
+
+static_assert( test_byte() );
+
+struct S
+{
+  int i = 0;
+};
+
+constexpr bool
+test_nonscalar()
+{
+  std::array ma0{};
+
+  const auto outd = std::fill_n(ma0.begin(), 6, S{77});
+
+  return outd == ma0.begin() + 6 && ma0[5].i == 77 && ma0[6].i == 0;
+}
+
+static_assert( test_nonscalar() );


Re: [PATCH] gfortran: Get asan library from TEST_ALWAYS_FLAGS

2020-05-03 Thread Thomas Koenig via Gcc-patches

Hi H.J.,


I checked in this patch to fix:

https://gcc.gnu.org/pipermail/gcc-regression/2020-May/072549.html


Thanks for the fix!


Re: [PATCH] libiberty: Update D symbol demangling for latest ABI spec.

2020-05-03 Thread Iain Buclaw via Gcc-patches
Ping.

There is a new mangle string "Nm" in the abi to denote the @live attribute, 
however will add support in a follow up patch.


On 15 April 2020 12:04:29 CEST, Iain Buclaw via Gcc-patches 
 wrote:
>Ping.
>
>On 04/04/2020 13:33, Iain Buclaw wrote:
>> Hi,
>> 
>> Some small improvements and clarifications have been done in the D ABI
>> specification to remove all ambiguities found in the current grammar,
>> this implementation now more closely resembles the spec, whilst
>> maintaining compatibility with the old ABI.
>> 
>> Three new rules have been added to the ABI.
>> 
>> 1. Back references using 'Q', analogous to C++ substitutions, compresses
>>repeated identifiers, types, and template symbol and value parameters.
>> 
>> 2. Template aliases to externally mangled symbols are prefixed with 'X'.
>>This includes any symbol that isn't extern(D), or has its name
>>overriden with pragma(mangle).  This fixes an ambiguity where it was
>>not clear whether 'V' was an encoded calling convention, or the next
>>template value parameter.
>> 
>> 3. Alias parameters, templates, and tuple symbols no longer encode the
>>symbol length of its subpart.  Tuples are now terminated with 'Z'.
>>This fixes another ambiguity where the first character of the mangled
>>name can be a digit as well, so the demangler had to figure out where
>>to split the two adjacent numbers by trying out each combination.
>> 
>> This patch was originally written by Rainer Schuetze, with clean-ups and
>> backwards compatibility added by myself.
>> 
>> Bootstrapped and regression tested on x86_linux-gnu, OK for mainline?
>> 
>> Regards
>> Iain.
>> 
>> ---
>> 
>> libiberty/ChangeLog:
>> 
>> 2019-04-04  Rainer Schuetze  
>> Iain Buclaw  
>> 
>>  * d-demangle.c (enum dlang_symbol_kinds): Remove enum.
>>  (struct dlang_info): New struct
>>  (dlang_decode_backref): New function.
>>  (dlang_backref): New function.
>>  (dlang_symbol_backref): New function.
>>  (dlang_type_backref): New function.
>>  (dlang_symbol_name_p): New function.
>>  (dlang_function_type_noreturn): New function.
>>  (dlang_function_type): Add 'info' parameter.  Decode function type
>>  with dlang_function_type_noreturn.
>>  (dlang_function_args): Add 'info' parameter.
>>  (dlang_type): Add 'info' parameter.  Handle back referenced types.
>>  (dlang_identifier): Replace 'kind' parameter with 'info'.  Handle back
>>  referenced symbols.  Split off decoding of plain identifiers to...
>>  (dlang_lname): ...here.
>>  (dlang_parse_mangle): Replace 'kind' parameter with 'info'.  Decode
>>  function type and return with dlang_type.
>>  (dlang_parse_qualified): Replace 'kind' parameter with 'info', add
>>  'suffix_modifier' parameter.  Decode function type with
>>  dlang_function_type_noreturn.
>>  (dlang_parse_tuple): Add 'info' parameter.
>>  (dlang_template_symbol_param): New function.
>>  (dlang_template_args): Add 'info' parameter.  Decode symbol parameter
>>  with dlang_template_symbol_param.  Handle back referenced values, and
>>  externally mangled parameters.
>>  (dlang_parse_template): Add 'info' parameter.
>>  (dlang_demangle_init_info): New function.
>>  (dlang_demangle): Initialize and pass 'info' parameter.
>>  * testsuite/d-demangle-expected: Add new tests.
>> 
>> ---
>>  libiberty/d-demangle.c  | 769 
>>  libiberty/testsuite/d-demangle-expected |  72 +++
>>  2 files changed, 580 insertions(+), 261 deletions(-)
>> 
>> diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c
>> index a9702858a6e..5856bc2930f 100644
>> --- a/libiberty/d-demangle.c
>> +++ b/libiberty/d-demangle.c
>> @@ -160,37 +160,42 @@ string_prepend (string *p, const char *s)
>>  }
>>  }
>>  
>> -/* What kinds of symbol we could be parsing.  */
>> -enum dlang_symbol_kinds
>> +/* Demangle information structure we pass around.  */
>> +struct dlang_info
>>  {
>> -  /* Top-level symbol, needs it's type checked.  */
>> -  dlang_top_level,
>> -  /* Function symbol, needs it's type checked.   */
>> -  dlang_function,
>> -  /* Strongly typed name, such as for classes, structs and enums.  */
>> -  dlang_type_name,
>> -  /* Template identifier.  */
>> -  dlang_template_ident,
>> -  /* Template symbol parameter.  */
>> -  dlang_template_param
>> +  /* The string we are demangling.  */
>> +  const char *s;
>> +  /* The index of the last back reference.  */
>> +  int last_backref;
>>  };
>>  
>> +/* Pass as the LEN to dlang_parse_template if symbol length is not known.  
>> */
>> +enum { TEMPLATE_LENGTH_UNKNOWN = -1 };
>> +
>>  /* Prototypes for forward referenced functions */
>> -static const char *dlang_function_args (string *, const char *);
>> +static const char *dlang_function_type (string *, const char *,
>> +struct dlang_info *);
>>  
>> -static const char *dlang_type