Re: [PATCH] libgcc: m68k: avoid TEXTRELs in shared library (PR 86224)

2018-07-28 Thread Rich Felker
On Sat, Jul 28, 2018 at 08:47:33PM +0200, Andreas Schwab wrote:
> On Jul 28 2018, sly...@inbox.ru wrote:
> 
> > From: Sergei Trofimovich 
> >
> > Cc: Ian Lance Taylor 
> > Cc: Jeff Law 
> > Cc: Andreas Schwab 
> > Signed-off-by: Sergei Trofimovich 
> > ---
> >  libgcc/config/m68k/lb1sf68.S | 19 ++-
> >  1 file changed, 14 insertions(+), 5 deletions(-)
> >
> > diff --git a/libgcc/config/m68k/lb1sf68.S b/libgcc/config/m68k/lb1sf68.S
> > index 325a7c17d9b..16c6dc3f5a7 100644
> > --- a/libgcc/config/m68k/lb1sf68.S
> > +++ b/libgcc/config/m68k/lb1sf68.S
> > @@ -435,7 +435,10 @@ $_exception_handler:
> > .text
> > FUNC(__mulsi3)
> > .globl  SYM (__mulsi3)
> > +   .globl  SYM (__mulsi3_internal)
> > +   .hidden SYM (__mulsi3_internal)
> 
> No need for extra entry symbols, just mark the real entry point as
> hidden, like in the static library.

That's clearly not correct or valid, as these are public interfaces.
If you make them hidden they'll be dropped from the dynamic symbol
table of libgcc_s.so.

Of course for libgcc.a they need to be hidden (it's an ABI bug if
they're not hidden there already but I think there's a separate layer
of the build system that forces them to be hidden).

Rich


[wwwdocs, committed] Update Nios II info

2018-07-28 Thread Sandra Loosemore
When I was looking at what needed to be done to the web page information 
for the new C-SKY port, I noticed that the Nios II had some problems 
too; there was no link to the processor documentation, and the entry in 
the backend table was obsolete (the port now uses LRA, and there is 
simulator support via QEMU nowadays).  Using my magic powers as both 
Nios II and documentation maintainers, I've checked this in.  :-)


-Sandra
Index: htdocs/backends.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/backends.html,v
retrieving revision 1.77
diff -r1.77 backends.html
99c99
< nios2  |   S Ci
---
> nios2  | Cia
Index: htdocs/readings.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/readings.html,v
retrieving revision 1.295
diff -r1.295 readings.html
226a227,231
>  Nios II
>   Manufacturer: Intel (formerly Altera)
>   https://www.intel.com/content/www/us/en/programmable/products/processors/support.html/;>Nios II Processor Documentation
>  
>  


[PATCH v2] libgcc: m68k: avoid TEXTRELs in shared library (PR 86224)

2018-07-28 Thread slyfox.inbox.ru via gcc-patches
From: Sergei Trofimovich 

Cc: Ian Lance Taylor 
Cc: Jeff Law 
Cc: Andreas Schwab 
Signed-off-by: Sergei Trofimovich 
---
 libgcc/config/m68k/lb1sf68.S | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libgcc/config/m68k/lb1sf68.S b/libgcc/config/m68k/lb1sf68.S
index 325a7c17d9b..d5240d4aa55 100644
--- a/libgcc/config/m68k/lb1sf68.S
+++ b/libgcc/config/m68k/lb1sf68.S
@@ -435,6 +435,7 @@ $_exception_handler:
.text
FUNC(__mulsi3)
.globl  SYM (__mulsi3)
+   .hidden SYM (__mulsi3)
 SYM (__mulsi3):
movew   sp@(4), d0  /* x0 -> d0 */
muluw   sp@(10), d0 /* x0*y1 */
@@ -458,6 +459,7 @@ SYM (__mulsi3):
.text
FUNC(__udivsi3)
.globl  SYM (__udivsi3)
+   .hidden SYM (__udivsi3)
 SYM (__udivsi3):
 #ifndef __mcoldfire__
movel   d2, sp@-
@@ -534,6 +536,7 @@ L2: subql   IMM (1),d4
.text
FUNC(__divsi3)
.globl  SYM (__divsi3)
+   .hidden SYM (__divsi3)
 SYM (__divsi3):
movel   d2, sp@-
 
-- 
2.18.0



Re: [PATCH] libgcc: m68k: avoid TEXTRELs in shared library (PR 86224)

2018-07-28 Thread Andreas Schwab
On Jul 28 2018, sly...@inbox.ru wrote:

> From: Sergei Trofimovich 
>
> Cc: Ian Lance Taylor 
> Cc: Jeff Law 
> Cc: Andreas Schwab 
> Signed-off-by: Sergei Trofimovich 
> ---
>  libgcc/config/m68k/lb1sf68.S | 19 ++-
>  1 file changed, 14 insertions(+), 5 deletions(-)
>
> diff --git a/libgcc/config/m68k/lb1sf68.S b/libgcc/config/m68k/lb1sf68.S
> index 325a7c17d9b..16c6dc3f5a7 100644
> --- a/libgcc/config/m68k/lb1sf68.S
> +++ b/libgcc/config/m68k/lb1sf68.S
> @@ -435,7 +435,10 @@ $_exception_handler:
>   .text
>   FUNC(__mulsi3)
>   .globl  SYM (__mulsi3)
> + .globl  SYM (__mulsi3_internal)
> + .hidden SYM (__mulsi3_internal)

No need for extra entry symbols, just mark the real entry point as
hidden, like in the static library.

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."


Re: [Patch, fortran] PR80477 - [OOP] Polymorphic function result generates memory leak

2018-07-28 Thread Dominique d'Humières
Hi!

> great that you managed to solve this one! The patch looks very good to
> me, but I'm afraid two details may be missing:
>
> 1) If the type has allocatable components, those need to be freed first.
> …

PR86481?

Cheers

Dominique



Re: [Patch, fortran] PR80477 - [OOP] Polymorphic function result generates memory leak

2018-07-28 Thread Janus Weil
Hi Paul,

2018-07-28 9:32 GMT+02:00 Paul Richard Thomas :
> Several attempts, including mine, were made to fix this bug since it
> was posted. They were all attacking the wrong place. Instead of
> providing the free of the class _data as part of the call to
> 'add_a_type' it should be included in the post block of the argument
> processing in the call to 'assign_a_type'. The comment in the patch
> says the rest.
>
> Bootstrapped and regtested on FC28/x86_64 - OK for trunk?

great that you managed to solve this one! The patch looks very good to
me, but I'm afraid two details may be missing:

1) If the type has allocatable components, those need to be freed first.
2) If the type has a finalizer, that needs to be called as well.

I believe that both points can be fixed by calling the _final
component of the vtab before freeing the class data. Should not be
hard to add, I hope (gfc_add_finalizer_call might be useful).

Thanks for your efforts ...

Cheers,
Janus


[PATCH] libgcc: m68k: avoid TEXTRELs in shared library (PR 86224)

2018-07-28 Thread slyfox.inbox.ru via gcc-patches
From: Sergei Trofimovich 

Cc: Ian Lance Taylor 
Cc: Jeff Law 
Cc: Andreas Schwab 
Signed-off-by: Sergei Trofimovich 
---
 libgcc/config/m68k/lb1sf68.S | 19 ++-
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/libgcc/config/m68k/lb1sf68.S b/libgcc/config/m68k/lb1sf68.S
index 325a7c17d9b..16c6dc3f5a7 100644
--- a/libgcc/config/m68k/lb1sf68.S
+++ b/libgcc/config/m68k/lb1sf68.S
@@ -435,7 +435,10 @@ $_exception_handler:
.text
FUNC(__mulsi3)
.globl  SYM (__mulsi3)
+   .globl  SYM (__mulsi3_internal)
+   .hidden SYM (__mulsi3_internal)
 SYM (__mulsi3):
+SYM (__mulsi3_internal):
movew   sp@(4), d0  /* x0 -> d0 */
muluw   sp@(10), d0 /* x0*y1 */
movew   sp@(6), d1  /* x1 -> d1 */
@@ -458,7 +461,10 @@ SYM (__mulsi3):
.text
FUNC(__udivsi3)
.globl  SYM (__udivsi3)
+   .globl  SYM (__udivsi3_internal)
+   .hidden SYM (__udivsi3_internal)
 SYM (__udivsi3):
+SYM (__udivsi3_internal):
 #ifndef __mcoldfire__
movel   d2, sp@-
movel   sp@(12), d1 /* d1 = divisor */
@@ -534,7 +540,10 @@ L2:subql   IMM (1),d4
.text
FUNC(__divsi3)
.globl  SYM (__divsi3)
+   .globl  SYM (__divsi3_internal)
+   .hidden SYM (__divsi3_internal)
 SYM (__divsi3):
+SYM (__divsi3_internal):
movel   d2, sp@-
 
moveq   IMM (1), d2 /* sign of result stored in d2 (=1 or =-1) */
@@ -557,7 +566,7 @@ L1: movel   sp@(8), d0  /* d0 = dividend */
 
 L2:movel   d1, sp@-
movel   d0, sp@-
-   PICCALL SYM (__udivsi3) /* divide abs(dividend) by abs(divisor) */
+   PICCALL SYM (__udivsi3_internal)/* divide abs(dividend) by 
abs(divisor) */
addql   IMM (8), sp
 
tstbd2
@@ -577,13 +586,13 @@ SYM (__umodsi3):
movel   sp@(4), d0  /* d0 = dividend */
movel   d1, sp@-
movel   d0, sp@-
-   PICCALL SYM (__udivsi3)
+   PICCALL SYM (__udivsi3_internal)
addql   IMM (8), sp
movel   sp@(8), d1  /* d1 = divisor */
 #ifndef __mcoldfire__
movel   d1, sp@-
movel   d0, sp@-
-   PICCALL SYM (__mulsi3)  /* d0 = (a/b)*b */
+   PICCALL SYM (__mulsi3_internal) /* d0 = (a/b)*b */
addql   IMM (8), sp
 #else
mulsl   d1,d0
@@ -603,13 +612,13 @@ SYM (__modsi3):
movel   sp@(4), d0  /* d0 = dividend */
movel   d1, sp@-
movel   d0, sp@-
-   PICCALL SYM (__divsi3)
+   PICCALL SYM (__divsi3_internal)
addql   IMM (8), sp
movel   sp@(8), d1  /* d1 = divisor */
 #ifndef __mcoldfire__
movel   d1, sp@-
movel   d0, sp@-
-   PICCALL SYM (__mulsi3)  /* d0 = (a/b)*b */
+   PICCALL SYM (__mulsi3_internal) /* d0 = (a/b)*b */
addql   IMM (8), sp
 #else
mulsl   d1,d0
-- 
2.18.0



Re: [PATCH 3/5] C++: clean up cp_printer

2018-07-28 Thread Jason Merrill
OK.

On Sat, Jul 28, 2018 at 8:02 AM, David Malcolm  wrote:
> This makes it easier to compare cp_printer with gcc_cxxdiag_char_table
> in c-format.c.
>
> No functional change intended.
>
> gcc/cp/ChangeLog:
> * error.c (cp_printer): In the leading comment, move "%H" and "I"
> into alphabetical order, and add missing "%G" and "K".  Within the
> switch statement, move cases 'G', 'H', 'I' and 'K" so that the
> cases are in alphabetical order.
> ---
>  gcc/cp/error.c | 46 --
>  1 file changed, 20 insertions(+), 26 deletions(-)
>
> diff --git a/gcc/cp/error.c b/gcc/cp/error.c
> index b0d8e32..7a644fd 100644
> --- a/gcc/cp/error.c
> +++ b/gcc/cp/error.c
> @@ -4025,6 +4025,10 @@ defer_phase_2_of_type_diff (deferred_printed_type 
> *deferred,
> %D   declaration.
> %E   expression.
> %F   function declaration.
> +   %G   gcall *
> +   %H   type difference (from).
> +   %I   type difference (to).
> +   %K   tree
> %L  language as used in extern "lang".
> %O  binary operator.
> %P   function parameter whose position is indicated by an integer.
> @@ -4032,9 +4036,7 @@ defer_phase_2_of_type_diff (deferred_printed_type 
> *deferred,
> %S   substitution (template + args)
> %T   type.
> %V   cv-qualifier.
> -   %X   exception-specification.
> -   %H   type difference (from)
> -   %I   type difference (to).  */
> +   %X   exception-specification.  */
>  static bool
>  cp_printer (pretty_printer *pp, text_info *text, const char *spec,
> int precision, bool wide, bool set_locus, bool verbose,
> @@ -4076,6 +4078,21 @@ cp_printer (pretty_printer *pp, text_info *text, const 
> char *spec,
>break;
>  case 'E': result = expr_to_string (next_tree); break;
>  case 'F': result = fndecl_to_string (next_tree, verbose);  break;
> +case 'G':
> +  percent_G_format (text);
> +  return true;
> +case 'H':
> +  defer_phase_2_of_type_diff (>m_type_a, next_tree,
> + buffer_ptr, verbose, *quoted);
> +  return true;
> +case 'I':
> +  defer_phase_2_of_type_diff (>m_type_b, next_tree,
> + buffer_ptr, verbose, *quoted);
> +  return true;
> +case 'K':
> +  t = va_arg (*text->args_ptr, tree);
> +  percent_K_format (text, t);
> +  return true;
>  case 'L': result = language_to_string (next_lang); break;
>  case 'O': result = op_to_string (false, next_tcode);   break;
>  case 'P': result = parm_to_string (next_int);  break;
> @@ -4090,29 +4107,6 @@ cp_printer (pretty_printer *pp, text_info *text, const 
> char *spec,
>  case 'V': result = cv_to_string (next_tree, verbose);  break;
>  case 'X': result = eh_spec_to_string (next_tree, verbose);  break;
>
> -case 'G':
> -  percent_G_format (text);
> -  return true;
> -
> -case 'K':
> -  t = va_arg (*text->args_ptr, tree);
> -  percent_K_format (text, t);
> -  return true;
> -
> -case 'H':
> -  {
> -   defer_phase_2_of_type_diff (>m_type_a, next_tree,
> -   buffer_ptr, verbose, *quoted);
> -   return true;
> -  }
> -
> -case 'I':
> -  {
> -   defer_phase_2_of_type_diff (>m_type_b, next_tree,
> -   buffer_ptr, verbose, *quoted);
> -   return true;
> -  }
> -
>  default:
>return false;
>  }
> --
> 1.8.5.3
>


[PATCH v2 08/10] testsuite: Mark that PRU has one-cycle jumps

2018-07-28 Thread Dimitar Dimitrov
gcc/testsuite/ChangeLog:

2018-07-27  Dimitar Dimitrov  

* gcc.dg/tree-ssa/20040204-1.c: XFAIL on pru.
* gcc.dg/tree-ssa/reassoc-33.c: Ditto.
* gcc.dg/tree-ssa/reassoc-34.c: Ditto.
* gcc.dg/tree-ssa/reassoc-35.c: Ditto.
* gcc.dg/tree-ssa/reassoc-36.c: Ditto.
* gcc.dg/tree-ssa/ssa-thread-14.c: Ditto.

Signed-off-by: Dimitar Dimitrov 
---
 gcc/testsuite/gcc.dg/tree-ssa/20040204-1.c| 2 +-
 gcc/testsuite/gcc.dg/tree-ssa/reassoc-33.c| 2 +-
 gcc/testsuite/gcc.dg/tree-ssa/reassoc-34.c| 2 +-
 gcc/testsuite/gcc.dg/tree-ssa/reassoc-35.c| 2 +-
 gcc/testsuite/gcc.dg/tree-ssa/reassoc-36.c| 2 +-
 gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-14.c | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/20040204-1.c 
b/gcc/testsuite/gcc.dg/tree-ssa/20040204-1.c
index a1237cf839b..06b83029fd3 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/20040204-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/20040204-1.c
@@ -33,4 +33,4 @@ void test55 (int x, int y)
that the && should be emitted (based on BRANCH_COST).  Fix this
by teaching dom to look through && and register all components
as true.  */
-/* { dg-final { scan-tree-dump-times "link_error" 0 "optimized" { xfail { ! 
"alpha*-*-* arm*-*-* aarch64*-*-* powerpc*-*-* cris-*-* crisv32-*-* hppa*-*-* 
i?86-*-* mmix-*-* mips*-*-* m68k*-*-* moxie-*-* nds32*-*-* s390*-*-* sh*-*-* 
sparc*-*-* spu-*-* visium-*-* x86_64-*-* riscv*-*-*" } } } } */
+/* { dg-final { scan-tree-dump-times "link_error" 0 "optimized" { xfail { ! 
"alpha*-*-* arm*-*-* aarch64*-*-* powerpc*-*-* cris-*-* crisv32-*-* hppa*-*-* 
i?86-*-* mmix-*-* mips*-*-* m68k*-*-* moxie-*-* nds32*-*-* s390*-*-* sh*-*-* 
sparc*-*-* spu-*-* visium-*-* x86_64-*-* riscv*-*-* pru*-*-*" } } } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-33.c 
b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-33.c
index 5572df4ae24..5e1cd1a6fa7 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-33.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-33.c
@@ -1,4 +1,4 @@
-/* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* 
moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* 
hppa*-*-* nios2*-*-*"} } } */
+/* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* 
moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* 
hppa*-*-* nios2*-*-* pru*-*-*"} } } */
 
 /* { dg-options "-O2 -fno-inline -fdump-tree-reassoc1-details" } */
 /* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-34.c 
b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-34.c
index 9b45f1cd9be..a59df6a7244 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-34.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-34.c
@@ -1,4 +1,4 @@
-/* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* 
moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* 
hppa*-*-* nios2*-*-*"} } } */
+/* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* 
moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* 
hppa*-*-* nios2*-*-* pru*-*-*"} } } */
 
 /* { dg-options "-O2 -fno-inline -fdump-tree-reassoc1-details" } */
 /* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-35.c 
b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-35.c
index 9ee3abca04e..21239372709 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-35.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-35.c
@@ -1,4 +1,4 @@
-/* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* 
moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* 
hppa*-*-* nios2*-*-*"} } } */
+/* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* 
moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* 
hppa*-*-* nios2*-*-* pru*-*-*"} } } */
 
 /* { dg-options "-O2 -fno-inline -fdump-tree-reassoc1-details" } */
 /* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-36.c 
b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-36.c
index ac3a04291b7..f8eb0954ae7 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-36.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-36.c
@@ -1,4 +1,4 @@
-/* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* 
moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* 
hppa*-*-* nios2*-*-*"} } } */
+/* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* 
moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* 
hppa*-*-* nios2*-*-* pru*-*-*"} } } */
 
 /* { dg-options "-O2 -fno-inline -fdump-tree-reassoc1-details" } */
 /* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-14.c 
b/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-14.c
index 

[PATCH v2 02/10] Initial TI PRU libgcc port

2018-07-28 Thread Dimitar Dimitrov
The floating point support has been borrowed from C6X libgcc port
to help with TI PRU toolchain ABI compatibility.

libgcc/ChangeLog:

2018-07-27  Dimitar Dimitrov  

* config.host: Add PRU target.
* config/pru/asri.c: New file.
* config/pru/eqd.c: New file.
* config/pru/eqf.c: New file.
* config/pru/ged.c: New file.
* config/pru/gef.c: New file.
* config/pru/gtd.c: New file.
* config/pru/gtf.c: New file.
* config/pru/led.c: New file.
* config/pru/lef.c: New file.
* config/pru/lib2bitcountHI.c: New file.
* config/pru/lib2divHI.c: New file.
* config/pru/lib2divQI.c: New file.
* config/pru/lib2divSI.c: New file.
* config/pru/libgcc-eabi.ver: New file.
* config/pru/ltd.c: New file.
* config/pru/ltf.c: New file.
* config/pru/mpyll.S: New file.
* config/pru/pru-abi.h: New file.
* config/pru/pru-asm.h: New file.
* config/pru/pru-divmod.h: New file.
* config/pru/sfp-machine.h: New file.
* config/pru/t-pru: New file.

Signed-off-by: Dimitar Dimitrov 
---
 libgcc/config.host |   7 +++
 libgcc/config/pru/asri.c   |  33 ++
 libgcc/config/pru/eqd.c|  45 +
 libgcc/config/pru/eqf.c|  45 +
 libgcc/config/pru/ged.c|  45 +
 libgcc/config/pru/gef.c|  45 +
 libgcc/config/pru/gtd.c|  45 +
 libgcc/config/pru/gtf.c|  45 +
 libgcc/config/pru/led.c|  45 +
 libgcc/config/pru/lef.c|  45 +
 libgcc/config/pru/lib2bitcountHI.c |  43 +
 libgcc/config/pru/lib2divHI.c  |  42 +
 libgcc/config/pru/lib2divQI.c  |  42 +
 libgcc/config/pru/lib2divSI.c  |  48 ++
 libgcc/config/pru/libgcc-eabi.ver  |  88 ++
 libgcc/config/pru/ltd.c|  45 +
 libgcc/config/pru/ltf.c|  45 +
 libgcc/config/pru/mpyll.S  |  57 +
 libgcc/config/pru/pru-abi.h| 109 
 libgcc/config/pru/pru-asm.h|  35 +++
 libgcc/config/pru/pru-divmod.h | 117 ++
 libgcc/config/pru/sfp-machine.h| 125 +
 libgcc/config/pru/t-pru|  50 +++
 23 files changed, 1246 insertions(+)
 create mode 100644 libgcc/config/pru/asri.c
 create mode 100644 libgcc/config/pru/eqd.c
 create mode 100644 libgcc/config/pru/eqf.c
 create mode 100644 libgcc/config/pru/ged.c
 create mode 100644 libgcc/config/pru/gef.c
 create mode 100644 libgcc/config/pru/gtd.c
 create mode 100644 libgcc/config/pru/gtf.c
 create mode 100644 libgcc/config/pru/led.c
 create mode 100644 libgcc/config/pru/lef.c
 create mode 100644 libgcc/config/pru/lib2bitcountHI.c
 create mode 100644 libgcc/config/pru/lib2divHI.c
 create mode 100644 libgcc/config/pru/lib2divQI.c
 create mode 100644 libgcc/config/pru/lib2divSI.c
 create mode 100644 libgcc/config/pru/libgcc-eabi.ver
 create mode 100644 libgcc/config/pru/ltd.c
 create mode 100644 libgcc/config/pru/ltf.c
 create mode 100644 libgcc/config/pru/mpyll.S
 create mode 100644 libgcc/config/pru/pru-abi.h
 create mode 100644 libgcc/config/pru/pru-asm.h
 create mode 100644 libgcc/config/pru/pru-divmod.h
 create mode 100644 libgcc/config/pru/sfp-machine.h
 create mode 100644 libgcc/config/pru/t-pru

diff --git a/libgcc/config.host b/libgcc/config.host
index 18cabaf24f6..ff229c38f0c 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -165,6 +165,9 @@ nios2*-*-*)
 powerpc*-*-*)
cpu_type=rs6000
;;
+pru-*-*)
+   cpu_type=pru
+   ;;
 rs6000*-*-*)
;;
 riscv*-*-*)
@@ -1145,6 +1148,10 @@ powerpcle-*-eabi*)
tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-crtstuff 
t-crtstuff-pic t-fdpbit"
extra_parts="$extra_parts crtbegin.o crtend.o crtbeginS.o crtendS.o 
crtbeginT.o ecrti.o ecrtn.o ncrti.o ncrtn.o"
;;
+pru-*-*)
+   tmake_file="${tmake_file} t-softfp-sfdf t-softfp-excl t-softfp 
t-gnu-prefix pru/t-pru"
+   tm_file="$tm_file pru/pru-abi.h"
+   ;;
 riscv*-*-linux*)
tmake_file="${tmake_file} riscv/t-softfp${host_address} t-softfp 
riscv/t-elf riscv/t-elf${host_address}"
extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o crtendS.o 
crtbeginT.o"
diff --git a/libgcc/config/pru/asri.c b/libgcc/config/pru/asri.c
new file mode 100644
index 000..591d660f227
--- /dev/null
+++ b/libgcc/config/pru/asri.c
@@ -0,0 +1,33 @@
+/* PRU ABI compatibility functions
+   Arithmetic right shift
+   Copyright (C) 2017-2018 Free Software Foundation, Inc.
+   Contributed by Dimitar Dimitrov 
+
+   This file is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   

[PATCH v2 10/10] testsuite: Mark testsuite that PRU has different calling convention

2018-07-28 Thread Dimitar Dimitrov
For variadic functions, the last named and all anonymous arguments
are passed on stack. Regular functions pass arguments in registers.

gcc/testsuite/ChangeLog:

2018-07-27  Dimitar Dimitrov  

* gcc.dg/builtin-apply2.c: Skip for PRU.
* gcc.dg/torture/stackalign/builtin-apply-2.c: Ditto.

Signed-off-by: Dimitar Dimitrov 
---
 gcc/testsuite/gcc.dg/builtin-apply2.c | 2 +-
 gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/builtin-apply2.c 
b/gcc/testsuite/gcc.dg/builtin-apply2.c
index 3768caa5d5a..6ede0f3054b 100644
--- a/gcc/testsuite/gcc.dg/builtin-apply2.c
+++ b/gcc/testsuite/gcc.dg/builtin-apply2.c
@@ -1,7 +1,7 @@
 /* { dg-do run } */
 /* { dg-require-effective-target untyped_assembly } */
 /* { dg-skip-if "Variadic funcs have all args on stack. Normal funcs have args 
in registers." { "avr-*-* nds32*-*-*" } } */
-/* { dg-skip-if "Variadic funcs use different argument passing from normal 
funcs." { "riscv*-*-*" } } */
+/* { dg-skip-if "Variadic funcs use different argument passing from normal 
funcs." { "riscv*-*-* pru-*-*" } } */
 /* { dg-skip-if "Variadic funcs use Base AAPCS.  Normal funcs use VFP 
variant." { arm*-*-* && arm_hf_eabi } } */
 
 /* PR target/12503 */
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c 
b/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c
index d033010dc7c..8b6e693c0f2 100644
--- a/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c
@@ -9,7 +9,7 @@
 /* arm_hf_eabi: Variadic funcs use Base AAPCS.  Normal funcs use VFP variant.
avr: Variadic funcs don't pass arguments in registers, while normal funcs
 do.  */
-/* { dg-skip-if "Variadic funcs use different argument passing from normal 
funcs" { arm_hf_eabi || { avr-*-* riscv*-*-* } } } */
+/* { dg-skip-if "Variadic funcs use different argument passing from normal 
funcs" { arm_hf_eabi || { avr-*-* riscv*-*-* pru-*-* } } } */
 /* { dg-skip-if "Variadic funcs have all args on stack. Normal funcs have args 
in registers." { nds32*-*-* } } */
 /* { dg-require-effective-target untyped_assembly } */

-- 
2.11.0



[PATCH v2 09/10] testsuite: Mark that PRU uses all function pointer bits

2018-07-28 Thread Dimitar Dimitrov
gcc/testsuite/ChangeLog:

2018-07-27  Dimitar Dimitrov  

* g++.old-deja/g++.abi/ptrmem.C: Add PRU to list.

Signed-off-by: Dimitar Dimitrov 
---
 gcc/testsuite/g++.old-deja/g++.abi/ptrmem.C | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/g++.old-deja/g++.abi/ptrmem.C 
b/gcc/testsuite/g++.old-deja/g++.abi/ptrmem.C
index 341735879c5..bda7960d8a2 100644
--- a/gcc/testsuite/g++.old-deja/g++.abi/ptrmem.C
+++ b/gcc/testsuite/g++.old-deja/g++.abi/ptrmem.C
@@ -7,7 +7,7 @@
function.  However, some platforms use all bits to encode a
function pointer.  Such platforms use the lowest bit of the delta,
that is shifted left by one bit.  */
-#if defined __MN10300__ || defined __SH5__ || defined __arm__ || defined 
__thumb__ || defined __mips__ || defined __aarch64__
+#if defined __MN10300__ || defined __SH5__ || defined __arm__ || defined 
__thumb__ || defined __mips__ || defined __aarch64__ || defined __PRU__
 #define ADJUST_PTRFN(func, virt) ((void (*)())(func))
 #define ADJUST_DELTA(delta, virt) (((delta) << 1) + !!(virt))
 #else
-- 
2.11.0



[PATCH v2 06/10] testsuite: Remove PRU from test cases requiring hosted environment

2018-07-28 Thread Dimitar Dimitrov
gcc/testsuite/ChangeLog:

2018-07-27  Dimitar Dimitrov  

* gcc.c-torture/execute/20101011-1.c: Define DO_TEST to 0 for PRU.
* gcc.dg/20020312-2.c: No PIC register for PRU.

Signed-off-by: Dimitar Dimitrov 
---
 gcc/testsuite/gcc.c-torture/execute/20101011-1.c | 3 +++
 gcc/testsuite/gcc.dg/20020312-2.c| 2 ++
 2 files changed, 5 insertions(+)

diff --git a/gcc/testsuite/gcc.c-torture/execute/20101011-1.c 
b/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
index dda49a59852..7f8d14d617c 100644
--- a/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
@@ -93,6 +93,9 @@ __aeabi_idiv0 (int return_value)
 #elif defined (__nvptx__)
 /* There isn't even a signal function.  */
 # define DO_TEST 0
+#elif defined (__pru__)
+/* There isn't even a signal function.  */
+# define DO_TEST 0
 #else
 # define DO_TEST 1
 #endif
diff --git a/gcc/testsuite/gcc.dg/20020312-2.c 
b/gcc/testsuite/gcc.dg/20020312-2.c
index f5929e0b057..209ef67e263 100644
--- a/gcc/testsuite/gcc.dg/20020312-2.c
+++ b/gcc/testsuite/gcc.dg/20020312-2.c
@@ -111,6 +111,8 @@ extern void abort (void);
 /* No pic register.  */
 #elif defined (__nvptx__)
 /* No pic register.  */
+#elif defined(__PRU__)
+/* No pic register.  */
 #else
 # error "Modify the test for your target."
 #endif
-- 
2.11.0



[PATCH v2 03/10] testsuite: Add PRU tests

2018-07-28 Thread Dimitar Dimitrov
gcc/testsuite/ChangeLog:

2018-07-27  Dimitar Dimitrov  

* gcc.target/pru/abi-arg-struct.c: New test.
* gcc.target/pru/ashiftrt.c: New test.
* gcc.target/pru/builtins-1.c: New test.
* gcc.target/pru/builtins-error.c: New test.
* gcc.target/pru/clearbit.c: New test.
* gcc.target/pru/loop-asm.c: New test.
* gcc.target/pru/loop-dowhile.c: New test.
* gcc.target/pru/loop-hi-1.c: New test.
* gcc.target/pru/loop-hi-2.c: New test.
* gcc.target/pru/loop-qi-1.c: New test.
* gcc.target/pru/loop-qi-2.c: New test.
* gcc.target/pru/loop-short-1.c: New test.
* gcc.target/pru/loop-short-2.c: New test.
* gcc.target/pru/loop-si-1.c: New test.
* gcc.target/pru/loop-si-2.c: New test.
* gcc.target/pru/loop-u8_pcrel_overflow.c: New test.
* gcc.target/pru/loop-ubyte-1.c: New test.
* gcc.target/pru/loop-ubyte-2.c: New test.
* gcc.target/pru/lra-framepointer-fragmentation-1.c: New test.
* gcc.target/pru/lra-framepointer-fragmentation-2.c: New test.
* gcc.target/pru/mabi-ti-1.c: New test.
* gcc.target/pru/mabi-ti-2.c: New test.
* gcc.target/pru/mabi-ti-3.c: New test.
* gcc.target/pru/mabi-ti-4.c: New test.
* gcc.target/pru/mabi-ti-5.c: New test.
* gcc.target/pru/mabi-ti-6.c: New test.
* gcc.target/pru/mabi-ti-7.c: New test.
* gcc.target/pru/pr64366.c: New test.
* gcc.target/pru/pragma-ctable_entry.c: New test.
* gcc.target/pru/pru.exp: New file.
* gcc.target/pru/qbbc-1.c: New test.
* gcc.target/pru/qbbc-2.c: New test.
* gcc.target/pru/qbbc-3.c: New test.
* gcc.target/pru/qbbs-1.c: New test.
* gcc.target/pru/qbbs-2.c: New test.
* gcc.target/pru/setbit.c: New test.
* gcc.target/pru/zero_extend-and-hisi.c: New test.
* gcc.target/pru/zero_extend-and-qihi.c: New test.
* gcc.target/pru/zero_extend-and-qisi.c: New test.
* gcc.target/pru/zero_extend-hisi.c: New test.
* gcc.target/pru/zero_extend-qihi.c: New test.
* gcc.target/pru/zero_extend-qisi.c: New test.
* lib/target-supports.exp: Add PRU to feature filters.

Signed-off-by: Dimitar Dimitrov 
---
 gcc/testsuite/gcc.target/pru/abi-arg-struct.c  | 164 +
 gcc/testsuite/gcc.target/pru/ashiftrt.c|  13 ++
 gcc/testsuite/gcc.target/pru/builtins-1.c  |  12 ++
 gcc/testsuite/gcc.target/pru/builtins-error.c  |   6 +
 gcc/testsuite/gcc.target/pru/clearbit.c|  13 ++
 gcc/testsuite/gcc.target/pru/loop-asm.c|  19 +++
 gcc/testsuite/gcc.target/pru/loop-dowhile.c|  45 ++
 gcc/testsuite/gcc.target/pru/loop-hi-1.c   |  38 +
 gcc/testsuite/gcc.target/pru/loop-hi-2.c   |  17 +++
 gcc/testsuite/gcc.target/pru/loop-qi-1.c   |  38 +
 gcc/testsuite/gcc.target/pru/loop-qi-2.c   |  17 +++
 gcc/testsuite/gcc.target/pru/loop-short-1.c|  53 +++
 gcc/testsuite/gcc.target/pru/loop-short-2.c|  21 +++
 gcc/testsuite/gcc.target/pru/loop-si-1.c   |  41 ++
 gcc/testsuite/gcc.target/pru/loop-si-2.c   |  20 +++
 .../gcc.target/pru/loop-u8_pcrel_overflow.c|  42 ++
 gcc/testsuite/gcc.target/pru/loop-ubyte-1.c|  30 
 gcc/testsuite/gcc.target/pru/loop-ubyte-2.c|  18 +++
 .../pru/lra-framepointer-fragmentation-1.c |  33 +
 .../pru/lra-framepointer-fragmentation-2.c |  61 
 gcc/testsuite/gcc.target/pru/mabi-ti-1.c   |  10 ++
 gcc/testsuite/gcc.target/pru/mabi-ti-2.c   |  15 ++
 gcc/testsuite/gcc.target/pru/mabi-ti-3.c   |  12 ++
 gcc/testsuite/gcc.target/pru/mabi-ti-4.c   |  14 ++
 gcc/testsuite/gcc.target/pru/mabi-ti-5.c   |  33 +
 gcc/testsuite/gcc.target/pru/mabi-ti-6.c   |  12 ++
 gcc/testsuite/gcc.target/pru/mabi-ti-7.c   |  21 +++
 gcc/testsuite/gcc.target/pru/pr64366.c | 128 
 gcc/testsuite/gcc.target/pru/pragma-ctable_entry.c |  22 +++
 gcc/testsuite/gcc.target/pru/pru.exp   |  41 ++
 gcc/testsuite/gcc.target/pru/qbbc-1.c  |  29 
 gcc/testsuite/gcc.target/pru/qbbc-2.c  |  15 ++
 gcc/testsuite/gcc.target/pru/qbbc-3.c  |  15 ++
 gcc/testsuite/gcc.target/pru/qbbs-1.c  |  29 
 gcc/testsuite/gcc.target/pru/qbbs-2.c  |  15 ++
 gcc/testsuite/gcc.target/pru/setbit.c  |  13 ++
 .../gcc.target/pru/zero_extend-and-hisi.c  |  16 ++
 .../gcc.target/pru/zero_extend-and-qihi.c  |  16 ++
 .../gcc.target/pru/zero_extend-and-qisi.c  |  16 ++
 gcc/testsuite/gcc.target/pru/zero_extend-hisi.c|  43 ++
 gcc/testsuite/gcc.target/pru/zero_extend-qihi.c|  43 ++
 gcc/testsuite/gcc.target/pru/zero_extend-qisi.c|  43 ++
 gcc/testsuite/lib/target-supports.exp 

[PATCH v2 07/10] testsuite: Define PRU stack usage

2018-07-28 Thread Dimitar Dimitrov
gcc/testsuite/ChangeLog:

2018-07-27  Dimitar Dimitrov  

* gcc.dg/stack-usage-1.c: Define PRU stack usage.

Signed-off-by: Dimitar Dimitrov 
---
 gcc/testsuite/gcc.dg/stack-usage-1.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/stack-usage-1.c 
b/gcc/testsuite/gcc.dg/stack-usage-1.c
index 038bd4ec05c..ffa97da6c32 100644
--- a/gcc/testsuite/gcc.dg/stack-usage-1.c
+++ b/gcc/testsuite/gcc.dg/stack-usage-1.c
@@ -93,6 +93,8 @@
 #  define SIZE 254
 #elif defined (__nios2__)
 #  define SIZE 252
+#elif defined (__PRU__)
+#  define SIZE 252
 #elif defined (__v850__)
 #define SIZE 260
 #elif defined (__mn10300__)
-- 
2.11.0



[PATCH v2 00/10] New backend for the TI PRU processor

2018-07-28 Thread Dimitar Dimitrov
Hi,

This patch series adds support for the TI PRU I/O processor to GCC. All
comments from v1 [1] should be addressed in this second patch revision.

Test results can be downloaded from here:
   http://dinux.eu/gnupru/testresults/20180727-e6562f4b/
I'm working to bringup a testbot sending results to gcc-testresults. I'll
need a few weeks to finish and deploy it.

Changes since patch series v1 [1]:
  - Simplified the load/store_multiple pattern. Replaced the numerous
machine-generated patterns with a single generic one.
  - Removed the patch for MAX_MAX_OPERANDS increase.
  - Generalized testsuite checks for availability of large return values and
function pointers.
  - A few rtx -> rtx_insn fixes.
  - Fixed function declaration formatting.
  - Added missing function comments.
  - Fixed diagnostics string format.
  - Removed unneeded dbxelf.h reference.
  - Removed flag_unwind_tables check.
  - Removed the workaround with subreg from machine description. Looks like
core has meanwhile fixed the rootcause.
  - Added PRU regression tests for LRA framepointer fragmentation issue.
  - Added a new patch to skip two builtin_apply tests for PRU. 

[1] http://gcc.gnu.org/ml/gcc-patches/2018-06/msg00775.html

Dimitar Dimitrov (10):
  Initial TI PRU GCC port
  Initial TI PRU libgcc port
  testsuite: Add PRU tests
  testsuite: Add check for overflowed IMEM region to testsuite
  testsuite: Add check for unsupported TI ABI PRU features to testsuite
  testsuite: Remove PRU from test cases requiring hosted environment
  testsuite: Define PRU stack usage
  testsuite: Mark that PRU has one-cycle jumps
  testsuite: Mark that PRU uses all function pointer bits
  testsuite: Mark testsuite that PRU has different calling convention

 configure.ac   |7 +
 gcc/common/config/pru/pru-common.c |   36 +
 gcc/config.gcc |9 +
 gcc/config/pru/alu-zext.md |  178 ++
 gcc/config/pru/constraints.md  |   88 +
 gcc/config/pru/predicates.md   |  224 ++
 gcc/config/pru/pru-opts.h  |   31 +
 gcc/config/pru/pru-passes.c|  234 ++
 gcc/config/pru/pru-pragma.c|   90 +
 gcc/config/pru/pru-protos.h|   72 +
 gcc/config/pru/pru.c   | 2998 
 gcc/config/pru/pru.h   |  551 
 gcc/config/pru/pru.md  |  956 +++
 gcc/config/pru/pru.opt |   53 +
 gcc/config/pru/t-pru   |   31 +
 gcc/doc/extend.texi|   20 +
 gcc/doc/invoke.texi|   55 +
 gcc/doc/md.texi|   22 +
 gcc/testsuite/g++.old-deja/g++.abi/ptrmem.C|2 +-
 gcc/testsuite/gcc.c-torture/execute/20101011-1.c   |3 +
 gcc/testsuite/gcc.dg/20020312-2.c  |2 +
 gcc/testsuite/gcc.dg/builtin-apply2.c  |2 +-
 gcc/testsuite/gcc.dg/stack-usage-1.c   |2 +
 .../gcc.dg/torture/stackalign/builtin-apply-2.c|2 +-
 gcc/testsuite/gcc.dg/tree-ssa/20040204-1.c |2 +-
 gcc/testsuite/gcc.dg/tree-ssa/reassoc-33.c |2 +-
 gcc/testsuite/gcc.dg/tree-ssa/reassoc-34.c |2 +-
 gcc/testsuite/gcc.dg/tree-ssa/reassoc-35.c |2 +-
 gcc/testsuite/gcc.dg/tree-ssa/reassoc-36.c |2 +-
 gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-14.c  |2 +-
 gcc/testsuite/gcc.target/pru/abi-arg-struct.c  |  164 ++
 gcc/testsuite/gcc.target/pru/ashiftrt.c|   13 +
 gcc/testsuite/gcc.target/pru/builtins-1.c  |   12 +
 gcc/testsuite/gcc.target/pru/builtins-error.c  |6 +
 gcc/testsuite/gcc.target/pru/clearbit.c|   13 +
 gcc/testsuite/gcc.target/pru/loop-asm.c|   19 +
 gcc/testsuite/gcc.target/pru/loop-dowhile.c|   45 +
 gcc/testsuite/gcc.target/pru/loop-hi-1.c   |   38 +
 gcc/testsuite/gcc.target/pru/loop-hi-2.c   |   17 +
 gcc/testsuite/gcc.target/pru/loop-qi-1.c   |   38 +
 gcc/testsuite/gcc.target/pru/loop-qi-2.c   |   17 +
 gcc/testsuite/gcc.target/pru/loop-short-1.c|   53 +
 gcc/testsuite/gcc.target/pru/loop-short-2.c|   21 +
 gcc/testsuite/gcc.target/pru/loop-si-1.c   |   41 +
 gcc/testsuite/gcc.target/pru/loop-si-2.c   |   20 +
 .../gcc.target/pru/loop-u8_pcrel_overflow.c|   42 +
 gcc/testsuite/gcc.target/pru/loop-ubyte-1.c|   30 +
 gcc/testsuite/gcc.target/pru/loop-ubyte-2.c|   18 +
 .../pru/lra-framepointer-fragmentation-1.c |   33 +
 .../pru/lra-framepointer-fragmentation-2.c |   61 +
 gcc/testsuite/gcc.target/pru/mabi-ti-1.c   |   10 +
 gcc/testsuite/gcc.target/pru/mabi-ti-2.c   |   15 +
 

[PATCH v2 05/10] testsuite: Add check for unsupported TI ABI PRU features to testsuite

2018-07-28 Thread Dimitar Dimitrov
Not all C language features are supported when -mabi=ti option is
used for PRU target.

gcc/testsuite/ChangeLog:

2018-07-27  Dimitar Dimitrov  

* lib/gcc-dg.exp: Filter unsupported features in PRU's TI ABI mode.
* lib/target-utils.exp: Ditto.
* lib/target-supports.exp (check_effective_target_function_pointers,
check_effective_target_large_return_values): New.

Signed-off-by: Dimitar Dimitrov 
---
 gcc/testsuite/lib/gcc-dg.exp  | 11 +++
 gcc/testsuite/lib/target-supports.exp | 26 ++
 gcc/testsuite/lib/target-utils.exp|  8 
 3 files changed, 45 insertions(+)

diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index c26d1c73aa0..c061c152f16 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -405,6 +405,17 @@ proc gcc-dg-prune { system text } {
return "::unsupported::memory full"
 }
 
+if { [string match "*error: function pointers not supported*" $text]
+ && ![check_effective_target_function_pointers] } {
+   # The format here is important.  See dg.exp.
+   return "::unsupported::funcptr"
+}
+if { [string match "*error: large return values not supported*" $text]
+ && ![check_effective_target_large_return_values] } {
+   # The format here is important.  See dg.exp.
+   return "::unsupported::large return values"
+}
+
 return $text
 }
 
diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index 5299aaefcc3..711a6db1e97 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -2608,6 +2608,32 @@ proc check_effective_target_ptr32plus { } {
 }]
 }
 
+# Return 1 if target supports function pointers, 0 otherwise.
+
+proc check_effective_target_function_pointers { } {
+if { [istarget pru-*-*] } {
+   return [check_no_compiler_messages func_ptr_avail assembly {
+   #ifdef __PRU_EABI_GNU__
+   #error unsupported
+   #endif
+   }]
+}
+return 1
+}
+
+# Return 1 if target supports arbitrarily large return values, 0 otherwise.
+
+proc check_effective_target_large_return_values { } {
+if { [istarget pru-*-*] } {
+   return [check_no_compiler_messages func_ptr_avail assembly {
+   #ifdef __PRU_EABI_GNU__
+   #error unsupported
+   #endif
+   }]
+}
+return 1
+}
+
 # Return 1 if we support 32-bit or larger array and structure sizes
 # using default options, 0 otherwise.  Avoid false positive on
 # targets with 20 or 24 bit address spaces.
diff --git a/gcc/testsuite/lib/target-utils.exp 
b/gcc/testsuite/lib/target-utils.exp
index 732a1827a02..f636be2cb01 100644
--- a/gcc/testsuite/lib/target-utils.exp
+++ b/gcc/testsuite/lib/target-utils.exp
@@ -44,5 +44,13 @@ proc ${tool}_check_unsupported_p { output } {
 [string match "*exceeds local store*" $output] } {
return "memory full"
 }
+if { [string match "*error: function pointers not supported*" $output]
+ && ![check_effective_target_function_pointers] } {
+   return "function pointers not supported"
+}
+if { [string match "*error: large return values not supported*" $output]
+ && ![check_effective_target_large_return_values] } {
+   return "large return values not supported"
+}
 return ""
 }
-- 
2.11.0



[PATCH v2 04/10] testsuite: Add check for overflowed IMEM region to testsuite

2018-07-28 Thread Dimitar Dimitrov
PRU architecture supports maximum 256k program memory (IMEM). Some GCC
test cases manage to produce executables bigger than that.

gcc/testsuite/ChangeLog:

2018-07-27  Dimitar Dimitrov  

* lib/gcc-dg.exp: Bail on region overflow for tiny targets.
* lib/target-utils.exp: Ditto.
* lib/target-supports.exp: Declare PRU target as tiny.

Signed-off-by: Dimitar Dimitrov 
---
 gcc/testsuite/lib/gcc-dg.exp  | 5 +
 gcc/testsuite/lib/target-supports.exp | 5 +
 gcc/testsuite/lib/target-utils.exp| 4 
 3 files changed, 14 insertions(+)

diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index f5e6bef5dd9..c26d1c73aa0 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -392,6 +392,11 @@ proc gcc-dg-prune { system text } {
 return "::unsupported::memory full"
 }
 
+if { [regexp "(^|\n)\[^\n\]*: region \[^\n\]* overflowed" $text] 
+  && [check_effective_target_tiny] } {
+   return "::unsupported::memory full"
+}
+
 # Likewise, if we see ".text exceeds local store range" or
 # similar.
 if {[string match "spu-*" $system] && \
diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index 60105eb9fd7..5299aaefcc3 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -8833,6 +8833,11 @@ proc check_effective_target_tiny {} {
  && [check_effective_target_avr_tiny] } {
  set et_target_tiny_saved 1
}
+   # PRU Program Counter is 16-bits, and trampolines are not supported.
+   # Hence directly declare as a tiny target.
+   if [istarget pru-*-*] {
+ set et_target_tiny_saved 1
+   }
 }
 
 return $et_target_tiny_saved
diff --git a/gcc/testsuite/lib/target-utils.exp 
b/gcc/testsuite/lib/target-utils.exp
index bd39cc5bc79..732a1827a02 100644
--- a/gcc/testsuite/lib/target-utils.exp
+++ b/gcc/testsuite/lib/target-utils.exp
@@ -35,6 +35,10 @@ proc ${tool}_check_unsupported_p { output } {
   && [check_effective_target_tiny] } {
 return "memory full"
  }
+if { [regexp "(^|\n)\[^\n\]*: region \[^\n\]* overflowed" $output]
+  && [check_effective_target_tiny] } {
+   return "memory full"
+}
 
 if { [istarget spu-*-*] && \
 [string match "*exceeds local store*" $output] } {
-- 
2.11.0



[PATCH v2] libitm: sh: avoid absolute relocation in shared library (PR 86712)

2018-07-28 Thread slyfox.inbox.ru via gcc-patches
From: Sergei Trofimovich 

Cc: Andreas Schwab 
Cc: Torvald Riegel 
Cc: Alexandre Oliva 
Cc: Oleg Endo 
Cc: Kaz Kojima 
Signed-off-by: Sergei Trofimovich 
---
 libitm/config/sh/sjlj.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libitm/config/sh/sjlj.S b/libitm/config/sh/sjlj.S
index 043f36749be..f265ab8f898 100644
--- a/libitm/config/sh/sjlj.S
+++ b/libitm/config/sh/sjlj.S
@@ -53,7 +53,7 @@ _ITM_beginTransaction:
 #else
cfi_def_cfa_offset (4*10)
 #endif
-#if defined HAVE_ATTRIBUTE_VISIBILITY || !defined __PIC__
+#if !defined __PIC__
mov.l   .Lbegin, r1
jsr @r1
 movr15, r5
@@ -78,7 +78,7 @@ _ITM_beginTransaction:
 
.align  2
 .Lbegin:
-#if defined HAVE_ATTRIBUTE_VISIBILITY || !defined __PIC__
+#if !defined __PIC__
.long   GTM_begin_transaction
 #else
.long   GTM_begin_transaction@PCREL-(.Lbegin0-.)
-- 
2.18.0



Re: [PATCH] libitm: sh: avoid absolute relocation in shared library (PR 86712)

2018-07-28 Thread Andreas Schwab
On Jul 28 2018, "slyfox.inbox.ru via gcc-patches"  
wrote:

> diff --git a/libitm/config/sh/sjlj.S b/libitm/config/sh/sjlj.S
> index 043f36749be..80a810d8360 100644
> --- a/libitm/config/sh/sjlj.S
> +++ b/libitm/config/sh/sjlj.S
> @@ -53,7 +53,7 @@ _ITM_beginTransaction:
>  #else
>   cfi_def_cfa_offset (4*10)
>  #endif
> -#if defined HAVE_ATTRIBUTE_VISIBILITY || !defined __PIC__
> +#if defined HAVE_ATTRIBUTE_VISIBILITY && !defined __PIC__
>   mov.l   .Lbegin, r1
>   jsr @r1
>movr15, r5
> @@ -78,7 +78,7 @@ _ITM_beginTransaction:
>  
>   .align  2
>  .Lbegin:
> -#if defined HAVE_ATTRIBUTE_VISIBILITY || !defined __PIC__
> +#if defined HAVE_ATTRIBUTE_VISIBILITY && !defined __PIC__
>   .long   GTM_begin_transaction
>  #else
>   .long   GTM_begin_transaction@PCREL-(.Lbegin0-.)

If those references to hidden symbols cannot be resolved by the linker
then the use of HAVE_ATTRIBUTE_VISIBILITY is pointless.

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."


[PATCH] libitm: sh: avoid absolute relocation in shared library (PR 86712)

2018-07-28 Thread slyfox.inbox.ru via gcc-patches
From: Sergei Trofimovich 

Signed-off-by: Sergei Trofimovich 
---
 libitm/config/sh/sjlj.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libitm/config/sh/sjlj.S b/libitm/config/sh/sjlj.S
index 043f36749be..80a810d8360 100644
--- a/libitm/config/sh/sjlj.S
+++ b/libitm/config/sh/sjlj.S
@@ -53,7 +53,7 @@ _ITM_beginTransaction:
 #else
cfi_def_cfa_offset (4*10)
 #endif
-#if defined HAVE_ATTRIBUTE_VISIBILITY || !defined __PIC__
+#if defined HAVE_ATTRIBUTE_VISIBILITY && !defined __PIC__
mov.l   .Lbegin, r1
jsr @r1
 movr15, r5
@@ -78,7 +78,7 @@ _ITM_beginTransaction:
 
.align  2
 .Lbegin:
-#if defined HAVE_ATTRIBUTE_VISIBILITY || !defined __PIC__
+#if defined HAVE_ATTRIBUTE_VISIBILITY && !defined __PIC__
.long   GTM_begin_transaction
 #else
.long   GTM_begin_transaction@PCREL-(.Lbegin0-.)
-- 
2.18.0



Re: [PATCH 10/11] x86 - add speculation_barrier pattern

2018-07-28 Thread Uros Bizjak
On Fri, Jul 27, 2018 at 11:37 AM, Richard Earnshaw
 wrote:
>
> This patch adds a speculation barrier for x86, based on my
> understanding of the required mitigation for that CPU, which is to use
> an lfence instruction.
>
> This patch needs some review by an x86 expert and if adjustments are
> needed, I'd appreciate it if they could be picked up by the port
> maintainer.  This is supposed to serve as an example of how to deploy
> the new __builtin_speculation_safe_value() intrinsic on this
> architecture.
>
> * config/i386/i386.md (unspecv): Add UNSPECV_SPECULATION_BARRIER.
> (speculation_barrier): New insn.

The implementation is OK, but someone from Intel (CC'd) should clarify
if lfence is the correct insn.

Uros.


Re: [patch] improve internals documentation for nested function descriptors

2018-07-28 Thread Eric Botcazou
> This is precisely what I found so confusing about the original text.  To
> me, "custom" implies that the back end is *customized* to have its own
> descriptor implementation to conform to target-specific ABI standards,
> not that it uses a generic implementation in common code.

To me, "custom" sounds contradictory with "conform to" in this sentence.

And I don't follow your interpretation, back-ends are by definition customized 
to follow external constraints and not every macro/hook has "custom" in it.

> I could make the docs say both things, but from the perspective of a
> back end implementor, being explicit that it's a bit mask used to
> differentiate descriptors from any valid function pointer (so you can
> figure out what an appropriate value to define it to is) is more
> critical than describing what target-independent code does with a
> descriptor once it has identified that's what it's got.

Fair enough.

-- 
Eric Botcazou


[Patch, fortran] PR80477 - [OOP] Polymorphic function result generates memory leak

2018-07-28 Thread Paul Richard Thomas
Several attempts, including mine, were made to fix this bug since it
was posted. They were all attacking the wrong place. Instead of
providing the free of the class _data as part of the call to
'add_a_type' it should be included in the post block of the argument
processing in the call to 'assign_a_type'. The comment in the patch
says the rest.

Bootstrapped and regtested on FC28/x86_64 - OK for trunk?

Paul

2017-07-27  Paul Thomas  

PR fortran/80477
* trans-expr.c (gfc_conv_procedure_call): Allocatable class
results being passed to a derived type formal argument must
have the _data component deallocated after use.

2017-07-27  Paul Thomas  

PR fortran/80477
* gfortran.dg/class_result_7.f90: New test.
Index: gcc/fortran/trans-expr.c
===
*** gcc/fortran/trans-expr.c	(revision 262444)
--- gcc/fortran/trans-expr.c	(working copy)
*** gfc_conv_procedure_call (gfc_se * se, gf
*** 5360,5366 
  		  && e->ts.type == BT_CLASS
  		  && !CLASS_DATA (e)->attr.dimension
  		  && !CLASS_DATA (e)->attr.codimension)
! 		parmse.expr = gfc_class_data_get (parmse.expr);
  
  		  /* Wrap scalar variable in a descriptor. We need to convert
  		 the address of a pointer back to the pointer itself before,
--- 5360,5384 
  		  && e->ts.type == BT_CLASS
  		  && !CLASS_DATA (e)->attr.dimension
  		  && !CLASS_DATA (e)->attr.codimension)
! 		{
! 		  parmse.expr = gfc_class_data_get (parmse.expr);
! 		  /* The result is a class temporary, whose _data component
! 			 must be freed to avoid a memory leak.  */
! 		  if (e->expr_type == EXPR_FUNCTION
! 			  && CLASS_DATA (e)->attr.allocatable)
! 			{
! 			  tree zero;
! 			  zero = build_int_cst (TREE_TYPE (parmse.expr), 0);
! 			  tmp = fold_build2_loc (input_location, NE_EXPR,
! 		 logical_type_node,
! 		 parmse.expr, zero);
! 			  tmp = build3_v (COND_EXPR, tmp,
! 	  gfc_call_free (parmse.expr),
! 	  build_empty_stmt (input_location));
! 			  gfc_add_expr_to_block (, tmp);
! 			  gfc_add_modify (, parmse.expr, zero);
! 			}
! 		}
  
  		  /* Wrap scalar variable in a descriptor. We need to convert
  		 the address of a pointer back to the pointer itself before,
Index: gcc/testsuite/gfortran.dg/class_result_7.f90
===
*** gcc/testsuite/gfortran.dg/class_result_7.f90	(nonexistent)
--- gcc/testsuite/gfortran.dg/class_result_7.f90	(working copy)
***
*** 0 
--- 1,36 
+ ! { dg-do compile }
+ ! { dg-options "-fdump-tree-original" }
+ !
+ !  Test the fix for PR80477
+ !
+ ! Contributed by Stefano Zaghi  
+ !
+ module a_type_m
+implicit none
+type :: a_type_t
+   real :: x
+endtype
+ contains
+subroutine assign_a_type(lhs, rhs)
+   type(a_type_t), intent(inout) :: lhs
+   type(a_type_t), intent(in):: rhs
+   lhs%x = rhs%x
+end subroutine
+ 
+function add_a_type(lhs, rhs) result( res )
+   type(a_type_t), intent(in)  :: lhs
+   type(a_type_t), intent(in)  :: rhs
+   class(a_type_t), allocatable :: res
+   allocate (a_type_t :: res)
+   res%x = lhs%x + rhs%x
+end function
+ end module
+ 
+ program polymorphic_operators_memory_leaks
+use a_type_m
+implicit none
+type(a_type_t) :: a = a_type_t(1) , b = a_type_t(2)
+call assign_a_type (a, add_a_type(a,b))  ! generated a memory leak
+ end
+ ! { dg-final { scan-tree-dump-times "builtin_free" 1 "original" } }
+ ! { dg-final { scan-tree-dump-times "builtin_malloc" 1 "original" } }
Index: gcc/testsuite/gfortran.dg/transfer_class_3.f90
===


Re: [PATCH] Fix DJGPP LTO with debug

2018-07-28 Thread Andris Pavenis

On 07/27/2018 11:51 PM, DJ Delorie wrote:

Richard Biener  writes:

DJ, did you ever run the testsuite with a configuration that has LTO
enabled?  I don't see any djgpp results posted to gcc-testresults.
Quick googling doesn't yield anything useful with regarding on how to
do actual testing with a cross so I only built a i686-pc-msdosdjgpp
cross cc1/lto1 from x86_64-linux which went fine.

CC's Andris, our current gcc maintainer within DJGPP.  I know he just
built 8.2 binaries for us, I don't know what his testing infrastructure
looks like.



No.

II tried to run part of tests from custom scripts (eg. when trying to implement DJGPP support for 
libstdc++fs, not yet submitted to upstream) with native compiler for DJGPP.


Otherwise no DejaGNU support for DJGPP. So no way to run testsuite with native 
compiler.

I should perhaps try to find some way to try to run testsuite using cross-compiler from Linux. 
Possibilities:
- trying to execute test programs under DosEmu (no more possible with linux kernels 4.15+ as DosEmu 
do not support DPMI for them)
- trying to execute test programs under Dosbox. Question: how to configure testsuiite to do that? I 
do not know
- trying to run them through ssh on some Windows 32 bit system (older than Windows 10 as DPMI 
support is rather horribly broken in Windows 10 32 bit since March 2018)


Andris