Re: [C++ PATCH] Speed up inplace_merge algorithm & fix inefficient logic(PR libstdc++/83938)

2019-06-09 Thread François Dumont

On 12/21/18 9:57 PM, Jonathan Wakely wrote:

On 29/10/18 07:06 +0100, François Dumont wrote:

Hi

    Some feedback regarding this patch ?


Sorry this got missed, please resubmit during stage 1.

You haven't CC'd the original patch author (chang jc) to give them a
chance to comment on your proposed changes to the patch.

The attached PDF on PR libstdc++/83938 has extensive discussion of the
performance issue, but I don't see any for your version. Some
performance benchmarks for your version would be helpful.


Here is this patch again.

This time it is much closer to John's original one, I just kept my 
change on the size of the temporary buffer which doesn't need to be as 
large as it is currently allocated, especially with John's patch.


The performance tests are showing the good improvements, attached are 
the before/after. Surprisingly I do not see any change regarding 
allocated memory, I guess measures are not accurate enough. However 
working on them also show that current implementation is fragile. If you 
reduce the allowed allocated memory too much you end up with a stack 
overflow because of the recursive implementation.


I already have a patch to keep on trying to allocate memory as long as 
above a given threshold rather than 0 but I am also working on making 
implementation non-recursive. We'll see if even a buffer of size 1 is 
better than no buffer at all then.


    PR libstdc++/83938
    * include/bits/stl_algo.h:
    (__merge_adaptive): When buffer too small consider smallest range first
    and cut based on buffer size.
    (__inplace_merge): Take temporary buffer length from smallest range.
    (__stable_sort): Limit temporary buffer length.
    * include/bits/stl_tempbuf.h (get_temporary_buffer): Change function
    to reduce requested buffer length on allocation failure.
    * testsuite/performance/25_algorithms/inplace_merge.cc: New.
    * testsuite/performance/25_algorithms/stable_sort.cc: Rework to allow
    execution with different level of memory.

François

inplace_merge.ccreverse   19r   19u
0s48mem0pf 
inplace_merge.ccforwards   0r0u
0s 0mem0pf 
inplace_merge.ccrandom18r   18u
0s 0mem0pf 
inplace_merge.ccreverse   10r   10u
0s 0mem0pf 
inplace_merge.ccforwards   8r8u
0s 0mem0pf 
inplace_merge.ccrandom22r   22u
0s 0mem0pf 
inplace_merge.ccbench 1/2 memory1891r 1884u
7s   928mem0pf 
inplace_merge.ccreverse   19r   18u
0s 0mem0pf 
inplace_merge.ccforwards   0r0u
0s 0mem0pf 
inplace_merge.ccrandom18r   18u
0s 0mem0pf 
inplace_merge.ccreverse   10r   10u
0s 0mem0pf 
inplace_merge.ccforwards   3r3u
0s 0mem0pf 
inplace_merge.ccrandom22r   22u
0s 0mem0pf 
inplace_merge.ccbench 1/4 memory1867r 1861u
6s   192mem0pf 
inplace_merge.ccreverse   17r   17u
0s 0mem0pf 
inplace_merge.ccforwards   0r0u
0s 0mem0pf 
inplace_merge.ccrandom25r   24u
0s 0mem0pf 
inplace_merge.ccreverse   28r   28u
0s 0mem0pf 
inplace_merge.ccforwards   0r0u
0s 0mem0pf 
inplace_merge.ccrandom   289r  289u
0s 0mem0pf 
inplace_merge.ccbench no memory 2155r 2149u
6s   192mem0pf 
stable_sort.cc  reverse  240r  240u
1s 0mem0pf 
stable_sort.cc  forwards 205r  205u
0s 0mem0pf 
stable_sort.cc  random   493r  493u
0s 0mem0pf 
stable_sort.cc  bench full memory945r  939u
5s   752mem0pf 
stable_sort.cc  reverse  236r  236u
0s 0mem0pf 
stable_sort.cc  forwards 199r  199u
0s 0mem0pf 
stable_sort.cc  random   487r  487u
0s 0mem0pf 
stable_sort.cc  bench 1/2 memory  

[C++ PATCH] Add test for c++/60366

2019-06-09 Thread Marek Polacek
This one ICEd but was, curiously, fixed very recently by r271811.

Tested x86_64-linux, applying to trunk.

2019-06-09  Marek Polacek  

PR c++/60366
* g++.dg/cpp0x/lambda/lambda-ice32.C: New test.

diff --git gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice32.C 
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice32.C
new file mode 100644
index 000..6f8d37c02e8
--- /dev/null
+++ gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice32.C
@@ -0,0 +1,9 @@
+// PR c++/60366
+// { dg-do compile { target c++11 } }
+
+void
+fn ()
+{
+  auto f = [](const struct __lambda0 &self) { self(self); }; // { dg-error "" }
+  f(f); // { dg-error "" }
+}


[doc] extend.texi -- clarify no_sanitize

2019-06-09 Thread Gerald Pfeifer
In some interpretations "not...of all" may not be seen as 
100% clear, so I propose to use "not...of any".

On the way fix the grammar in the next sentence.

Sandra, and Martin as the original author, does this makes 
sense for you?

Gerald


2019-06-09  Gerald Pfeifer  

* doc/extend.texi (Common Function Attributes): Clarify
no_sanitize.  Fix grammar.

Index: doc/extend.texi
===
--- doc/extend.texi (revision 272089)
+++ doc/extend.texi (working copy)
@@ -3215,9 +3215,9 @@ marked symbols.
 @item no_sanitize ("@var{sanitize_option}")
 @cindex @code{no_sanitize} function attribute
 The @code{no_sanitize} attribute on functions is used
-to inform the compiler that it should not do sanitization of all options
+to inform the compiler that it should not do sanitization of any option
 mentioned in @var{sanitize_option}.  A list of values acceptable by
-@option{-fsanitize} option can be provided.
+the @option{-fsanitize} option can be provided.
 
 @smallexample
 void __attribute__ ((no_sanitize ("alignment", "object-size")))


[PATCH, doc] Update fortran file locations

2019-06-09 Thread Maya Rashish
doc/invoke.texi: Update fortran file locations.

---
 gcc/doc/invoke.texi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 5e3e8873d35..f1d22e87cbc 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -29242,7 +29242,7 @@ Like @samp{%g}, except if @option{-pipe} is in effect.  
In that case
 all.  These are the two most common ways to instruct a program that it
 should read from standard input or write to standard output.  If you
 need something more elaborate you can use an @samp{%@{pipe:@code{X}@}}
-construct: see for example @file{f/lang-specs.h}.
+construct: see for example @file{gcc/fortran/lang-specs.h}.
 
 @item %.@var{SUFFIX}
 Substitutes @var{.SUFFIX} for the suffixes of a matched switch's args
-- 
2.21.0



Re: [PATCH, OpenACC] (1/2) Fix implicit mapping for array slices on lexically-enclosing data constructs (PR70828)

2019-06-09 Thread Julian Brown
On Wed, 5 Dec 2018 21:10:45 +
Julian Brown  wrote:

> Thanks for review! How's this version?
> 
> I took the liberty of fixing the patch for Fortran array-descriptor
> mappings that use a PSET, also, and adding another test for that
> functionality.

This is a ping/new version of this patch, incorporating previous review
comments and also fixing the inheritance behaviour for references (e.g.
for array slices of Fortran function arguments). I've also merged the
two patches sent below into one:

https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01790.html
https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01791.html

The second part having been conditionally approved based on approval of
the first already, and rebased.

Re-tested with offloading to NVPTX. OK?

Thanks,

Julian

2019-06-09  Julian Brown  
Cesar Philippidis  

gcc/ 
* gimplify.c (oacc_array_mapping_info): New struct.
(gimplify_omp_ctx): Add decl_data_clause hash map.
(new_omp_context): Zero-initialise above.
(delete_omp_context): Delete above if allocated.
(gimplify_scan_omp_clauses): Scan for array mappings on data
constructs, and record in above map.
(gomp_oacc_needs_data_present): New function.
(gimplify_adjust_omp_clauses_1): Handle data mappings (e.g.
array slices) declared in lexically-enclosing data constructs.
* omp-low.c (lower_omp_target): Allow decl for bias not to be
present in OpenACC context. 

gcc/fortran/
* trans-openmp.c (gfc_omp_finish_clause): Don't raise error for
assumed-size array if present in a lexically-enclosing data
construct.
(gfc_omp_finish_clause): Guard addition of clauses for pointers
with DECL_P.

gcc/testsuite/ 
* c-c++-common/goacc/acc-data-chain.c: New test.
* gfortran.dg/goacc/pr70828.f90: New test.
* gfortran.dg/goacc/pr70828-2.f90: New test.

libgomp/ 
* testsuite/libgomp.oacc-c-c++-common/pr70828.c: New test.
* testsuite/libgomp.oacc-fortran/implicit_copy.f90: New test.
* testsuite/libgomp.oacc-fortran/pr70828.f90: New test.
* testsuite/libgomp.oacc-fortran/pr70828-2.f90: New test.
* testsuite/libgomp.oacc-fortran/pr70828-3.f90: New test.
* testsuite/libgomp.oacc-fortran/pr70828-4.f90: New test.
* testsuite/libgomp.oacc-fortran/pr70828-5.f90: New test.
* testsuite/libgomp.oacc-fortran/pr70828-6.f90: New test.
commit db3025e82a47ee8ca9fa8c87daa4eb9a7007fe75
Author: Julian Brown 
Date:   Thu Aug 16 20:02:10 2018 -0700

Inheritance of array sections on data constructs

2018-08-28  Julian Brown  
Cesar Philippidis  

gcc/
* gimplify.c (oacc_array_mapping_info): New struct.
(gimplify_omp_ctx): Add decl_data_clause hash map.
(new_omp_context): Zero-initialise above.
(delete_omp_context): Delete above if allocated.
(gimplify_scan_omp_clauses): Scan for array mappings on data constructs,and record in above map.
(gomp_oacc_needs_data_present): New function.
(gimplify_adjust_omp_clauses_1): Handle data mappings (e.g. array
slices) declared in lexically-enclosing data constructs.
* omp-low.c (lower_omp_target): Allow decl for bias not to be present
in OpenACC context.

gcc/fortran/
* trans-openmp.c (gfc_omp_finish_clause): Don't raise error for
assumed-size array if present in a lexically-enclosing data construct.
(gfc_omp_finish_clause): Guard addition of clauses for pointers with
DECL_P.

gcc/testsuite/
* c-c++-common/goacc/acc-data-chain.c: New test.
* gfortran.dg/goacc/pr70828.f90: New test.
* gfortran.dg/goacc/pr70828-2.f90: New test.

libgomp/
* testsuite/libgomp.oacc-c-c++-common/pr70828.c: New test.
* testsuite/libgomp.oacc-fortran/implicit_copy.f90: New test.
* testsuite/libgomp.oacc-fortran/pr70828.f90: New test.
* testsuite/libgomp.oacc-fortran/pr70828-2.f90: New test.
* testsuite/libgomp.oacc-fortran/pr70828-3.f90: New test.
* testsuite/libgomp.oacc-fortran/pr70828-4.f90: New test.
* testsuite/libgomp.oacc-fortran/pr70828-5.f90: New test.
* testsuite/libgomp.oacc-fortran/pr70828-6.f90: New test.

diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c
index 0eb5956cc53..56d56151a00 100644
--- a/gcc/fortran/trans-openmp.c
+++ b/gcc/fortran/trans-openmp.c
@@ -1076,9 +1076,13 @@ gfc_omp_finish_clause (tree c, gimple_seq *pre_p)
 
   tree decl = OMP_CLAUSE_DECL (c);
 
-  /* Assumed-size arrays can't be mapped implicitly, they have to be
- mapped explicitly using array sections.  */
-  if (TREE_CODE (decl) == PARM_DECL
+  /* Assumed-size arrays can't

Re: [libstdc++,doc] doc/xml/manual/support.xml - link adjustment and simplification

2019-06-09 Thread Gerald Pfeifer
On Thu, 30 May 2019, Jonathan Wakely wrote:
> I decided to make a few small changes, and ended up rewriting several
> sections. Committed to trunk.

Thank you!  That also nicely addressed the changed URLs I had noticed. 

Gerald


Re: [wwwdocs] Make it more obvious which releases are still supported

2019-06-09 Thread Gerald Pfeifer
So, this is probably the patch in GCC that's seen the longest delays
between different steps. :-o

On Mon, 30 Jan 2017, Jonathan Wakely wrote:
>> Thanks for doing that, Jonathan!
>>
>> Only one curious question: Why "Supported Releases" on our
>> main page versus "This release is no longer maintained." for
>> the individual releases?  That is, "supported" vs "maintained"?
> No reason. For consistency's sake changing it to "no longer supported"
> makes sense.

Done with the patch below, where I also moved this a little up,
directly below the title (but put it in parentheses), removed a
bit or two which was commented out for ages.

Oh, and also added this comment for GCC 5 and GCC 6, which have
reached end of life since then. ;-)

Committed.

Gerald


Index: gcc-2.95/index.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-2.95/index.html,v
retrieving revision 1.9
diff -u -r1.9 index.html
--- gcc-2.95/index.html 30 Sep 2018 14:38:49 -  1.9
+++ gcc-2.95/index.html 9 Jun 2019 19:21:03 -
@@ -9,11 +9,12 @@
 
 GCC 2.95
 
+(This release series is no longer supported.)
+
+
 March 16, 2001: The GNU project and the GCC developers are
 pleased to announce the release of GCC version 2.95.3.
 
-This release is no longer maintained.
-
 Release History
 
 
Index: gcc-3.0/index.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-3.0/index.html,v
retrieving revision 1.21
diff -u -r1.21 index.html
--- gcc-3.0/index.html  30 Sep 2018 14:38:49 -  1.21
+++ gcc-3.0/index.html  9 Jun 2019 19:21:03 -
@@ -10,6 +10,9 @@
 
 GCC 3.0.4
 
+(This release series is no longer supported.)
+
+
 February 20, 2002
 
 The http://www.gnu.org/";>GNU project and the GCC
@@ -17,8 +20,6 @@
 a bug-fix release for the GCC 3.0 series.
 
 
-This release series is no longer maintained.
-
 GCC used to stand for the GNU C Compiler, but since the compiler
 supports several other languages aside from C, it now stands for the
 GNU Compiler Collection.
Index: gcc-3.1/index.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-3.1/index.html,v
retrieving revision 1.10
diff -u -r1.10 index.html
--- gcc-3.1/index.html  30 Sep 2018 14:38:49 -  1.10
+++ gcc-3.1/index.html  9 Jun 2019 19:21:03 -
@@ -10,6 +10,9 @@
 
 GCC 3.1
 
+(This release series is no longer supported.)
+
+
 July 27, 2002
 
 The http://www.gnu.org/";>GNU project and the GCC
@@ -17,8 +20,6 @@
 
 The links below still apply to GCC 3.1.1.
 
-This release series is no longer maintained.
-
 May 15, 2002
 
 The http://www.gnu.org/";>GNU project and the GCC
Index: gcc-3.2/index.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-3.2/index.html,v
retrieving revision 1.18
diff -u -r1.18 index.html
--- gcc-3.2/index.html  30 Sep 2018 14:38:50 -  1.18
+++ gcc-3.2/index.html  9 Jun 2019 19:21:03 -
@@ -10,6 +10,9 @@
 
 GCC 3.2 Release Series
 
+(This release series is no longer supported.)
+
+
 April 25, 2003
 
 The http://www.gnu.org";>GNU project and the GCC
@@ -27,7 +30,6 @@
 Please refer to our detailed list of news,
 caveats, and bug-fixes for further information.
 
-This release series is no longer maintained.
 
 Release History
 
Index: gcc-3.3/index.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-3.3/index.html,v
retrieving revision 1.26
diff -u -r1.26 index.html
--- gcc-3.3/index.html  30 Sep 2018 14:38:50 -  1.26
+++ gcc-3.3/index.html  9 Jun 2019 19:21:03 -
@@ -10,6 +10,9 @@
 
 GCC 3.3 Release Series
 
+(This release series is no longer supported.)
+
+
 May 03, 2005
 
 The http://www.gnu.org";>GNU project and the GCC
@@ -25,12 +28,6 @@
 href="https://gcc.gnu.org/onlinedocs/gcc/Contributors.html";>amazing
 group of volunteers.
 
-This release series is no longer maintained.
-
-
 
 Release History
 
Index: gcc-3.4/index.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-3.4/index.html,v
retrieving revision 1.18
diff -u -r1.18 index.html
--- gcc-3.4/index.html  30 Sep 2018 14:38:50 -  1.18
+++ gcc-3.4/index.html  9 Jun 2019 19:21:03 -
@@ -10,6 +10,9 @@
 
 GCC 3.4 Release Series
 
+(This release series is no longer supported.)
+
+
 May 26, 2006
 
 The http://www.gnu.org";>GNU project and the GCC developers are
@@ -24,12 +27,6 @@
 href="https://gcc.gnu.org/onlinedocs/gcc/Contributors.html";>amazing
 group of volunteers.
 
-This release series is no longer maintained.
-
-
 
 Release History
 
Index: gcc-4.0/index.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.0/index.html,v
retrieving revision 1.17
diff -u -r1.17 index.html
--- gcc-4.0/index.html  30 Sep 2018 14:38:50 -  1.17
+++ gcc-4.0/index.html  9 Jun 2019 

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

2019-06-09 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:

2019-06-07  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/target-supports.exp | 5 +
 gcc/testsuite/lib/target-utils.exp| 4 
 2 files changed, 9 insertions(+)

diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index b60eab6d75d..2b3290619dc 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -8765,6 +8765,11 @@ proc check_effective_target_tiny {} {
&& [check_effective_target_avr_tiny] } {
   return 1
   }
+  # PRU Program Counter is 16-bits, and trampolines are not supported.
+  # Hence directly declare as a tiny target.
+  if [istarget pru-*-*] {
+  return 1
+  }
   return 0
 }]
 }
diff --git a/gcc/testsuite/lib/target-utils.exp 
b/gcc/testsuite/lib/target-utils.exp
index e847fdd4279..23137d4702c 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 v6 02/10] Initial TI PRU libgcc port

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

libgcc/ChangeLog:

2019-06-07  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 d75e2b5d7aa..588fd7c3324 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -175,6 +175,9 @@ or1k*-*-*)
 powerpc*-*-*)
cpu_type=rs6000
;;
+pru-*-*)
+   cpu_type=pru
+   ;;
 rs6000*-*-*)
;;
 riscv*-*-*)
@@ -1178,6 +1181,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..7d8d8f672f4
--- /dev/null
+++ b/libgcc/config/pru/asri.c
@@ -0,0 +1,33 @@
+/* PRU ABI compatibility functions
+   Arithmetic right shift
+   Copyright (C) 2017-2019 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
+   L

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

2019-06-09 Thread Dimitar Dimitrov
This is the latest patch set for adding TI PRU I/O processor backend to GCC.
Comments from all previous series have been addressed [1], [2], [3], [4], [5].

Test results can be downloaded from here:
   http://dinux.eu/gnupru/testresults/20190607-c16eb7019be/

Changes since patch series v5 [5] are minimal:

- A few whitespace and comment fixes.
- doloop_end_internal length expression fix.
- Define TARGET_HARD_REGNO_CALL_PART_CLOBBERED hook for PRU.
- Use uniform naming for the PRU register number constants.

[1] http://gcc.gnu.org/ml/gcc-patches/2018-06/msg00775.html
[2] http://gcc.gnu.org/ml/gcc-patches/2018-07/msg01779.html
[3] http://gcc.gnu.org/ml/gcc-patches/2018-08/msg00927.html
[4] http://gcc.gnu.org/ml/gcc-patches/2018-09/msg00392.html
[5] http://gcc.gnu.org/ml/gcc-patches/2018-10/msg00979.html

Regards,
Dimitar

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 |  181 ++
 gcc/config/pru/constraints.md  |  108 +
 gcc/config/pru/predicates.md   |  287 ++
 gcc/config/pru/pru-opts.h  |   31 +
 gcc/config/pru/pru-passes.c|  228 ++
 gcc/config/pru/pru-pragma.c|   86 +
 gcc/config/pru/pru-protos.h|   72 +
 gcc/config/pru/pru.c   | 3036 
 gcc/config/pru/pru.h   |  573 
 gcc/config/pru/pru.md  | 1022 +++
 gcc/config/pru/pru.opt |   54 +
 gcc/config/pru/t-pru   |   31 +
 gcc/doc/extend.texi|   21 +
 gcc/doc/invoke.texi|   65 +
 gcc/doc/md.texi|   19 +
 gcc/testsuite/g++.old-deja/g++.abi/ptrmem.C|2 +-
 gcc/testsuite/gcc.c-torture/execute/20101011-1.c   |2 +
 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.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/te

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

2019-06-09 Thread Dimitar Dimitrov
gcc/testsuite/ChangeLog:

2019-06-07  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 e6440142e1d..b2642228808 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 v6 03/10] testsuite: Add PRU tests

2019-06-09 Thread Dimitar Dimitrov
gcc/testsuite/ChangeLog:

2019-06-07  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 v6 06/10] testsuite: Remove PRU from test cases requiring hosted environment

2019-06-09 Thread Dimitar Dimitrov
gcc/testsuite/ChangeLog:

2019-06-07  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 | 2 ++
 gcc/testsuite/gcc.dg/20020312-2.c| 2 ++
 2 files changed, 4 insertions(+)

diff --git a/gcc/testsuite/gcc.c-torture/execute/20101011-1.c 
b/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
index d2beeb52a0e..4a9cc63fde8 100644
--- a/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
@@ -102,6 +102,8 @@ __aeabi_idiv0 (int return_value)
 # define DO_TEST 0
 #elif defined (__or1k__)
   /* On OpenRISC division by zero does not trap.  */
+#elif defined (__pru__)
+/* There isn't even a signal function.  */
 # define DO_TEST 0
 #else
 # define DO_TEST 1
diff --git a/gcc/testsuite/gcc.dg/20020312-2.c 
b/gcc/testsuite/gcc.dg/20020312-2.c
index c584d35908e..dae3599563a 100644
--- a/gcc/testsuite/gcc.dg/20020312-2.c
+++ b/gcc/testsuite/gcc.dg/20020312-2.c
@@ -121,6 +121,8 @@ extern void abort (void);
 /* No pic register.  */
 #elif defined (__AMDGCN__)
 /* No pic register.  */
+#elif defined(__PRU__)
+/* No pic register.  */
 #else
 # error "Modify the test for your target."
 #endif
-- 
2.11.0



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

2019-06-09 Thread Dimitar Dimitrov
Not all C language features are supported when -mabi=ti option is
used for PRU target.

gcc/testsuite/ChangeLog:

2019-06-07  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 c56e8e80ae0..e23b63cf3d1 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -422,6 +422,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 2b3290619dc..01472879062 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -2644,6 +2644,32 @@ proc check_effective_target_size20plus { } {
 }]
 }
 
+# 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 large_return_values assembly {
+   #ifdef __PRU_EABI_GNU__
+   #error unsupported
+   #endif
+   }]
+}
+return 1
+}
+
 # Return 1 if we support 24-bit or larger array and structure sizes
 # using default options, 0 otherwise.
 # This implies at least a 32-bit address space, as no targets have an address
diff --git a/gcc/testsuite/lib/target-utils.exp 
b/gcc/testsuite/lib/target-utils.exp
index 23137d4702c..0dd1f3494e8 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 v6 08/10] testsuite: Mark that PRU has one-cycle jumps

2019-06-09 Thread Dimitar Dimitrov
gcc/testsuite/ChangeLog:

2019-06-07  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.

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 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/20040204-1.c 
b/gcc/testsuite/gcc.dg/tree-ssa/20040204-1.c
index 255b6273341..2f3dcb502ad 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*-*-* or1k*-*-* msp430-*-*" } } } 
} */
+/* { 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*-*-* or1k*-*-* msp430-*-* 
pru*-*-*" } } } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-33.c 
b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-33.c
index 28cd7799ce1..db0ce4c8463 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*-*-* or1k-*-*-*"} } } */
+/* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* 
moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* 
hppa*-*-* nios2*-*-* or1k-*-*-* pru*-*-*"} } } */
 
 /* { dg-options "-O2 -fno-inline -fdump-tree-reassoc1-details --param 
logical-op-non-short-circuit=1" } */
 /* { 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 f1087113f51..31e10a44bb1 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*-*-* or1k*-*-*"} } } */
+/* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* 
moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* 
hppa*-*-* nios2*-*-* or1k*-*-* pru*-*-*"} } } */
 
 /* { dg-options "-O2 -fno-inline -fdump-tree-reassoc1-details --param 
logical-op-non-short-circuit=1" } */
 /* { 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 98ea2ad9ebe..d509d9f12c6 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*-*-* or1k*-*-*"} } } */
+/* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* 
moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* 
hppa*-*-* nios2*-*-* or1k*-*-* pru*-*-*"} } } */
 
 /* { dg-options "-O2 -fno-inline -fdump-tree-reassoc1-details --param 
logical-op-non-short-circuit=1" } */
 /* { 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 d9184102383..2ad46f59da0 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*-*-* or1k*-*-*"} } } */
+/* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* 
moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* 
hppa*-*-* nios2*-*-* or1k*-*-* pru*-*-*"} } } */
 
 /* { dg-options "-O2 -fno-inline -fdump-tree-reassoc1-details --param 
logical-op-non-short-circuit=1" } */
 /* { dg-additional-options "-mbranch

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

2019-06-09 Thread Dimitar Dimitrov
gcc/testsuite/ChangeLog:

2019-06-07  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 v6 10/10] testsuite: Mark testsuite that PRU has different calling convention

2019-06-09 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:

2019-06-07  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 3eadc773a51..06ef24ef56b 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*-*-* amdgcn-*-*" } } */
-/* { dg-skip-if "Variadic funcs use different argument passing from normal 
funcs." { "riscv*-*-* or1k*-*-* msp430-*-*" } } */
+/* { dg-skip-if "Variadic funcs use different argument passing from normal 
funcs." { "riscv*-*-* or1k*-*-* msp430-*-* 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 1c6fe4fc5ff..31585a0ae69 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*-*-* or1k*-*-* msp430-*-* amdgcn-*-* } 
} } */
+/* { dg-skip-if "Variadic funcs use different argument passing from normal 
funcs" { arm_hf_eabi || { avr-*-* riscv*-*-* or1k*-*-* msp430-*-* amdgcn-*-* 
pru-*-* } } } */
 /* { dg-skip-if "Variadic funcs have all args on stack. Normal funcs have args 
in registers." { nds32*-*-* } { v850*-*-* } } */
 /* { dg-require-effective-target untyped_assembly } */

-- 
2.11.0



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

2019-06-09 Thread Andreas Schwab
On Jun 09 2019, Dimitar Dimitrov  wrote:

> diff --git a/gcc/testsuite/gcc.c-torture/execute/20101011-1.c 
> b/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
> index d2beeb52a0e..4a9cc63fde8 100644
> --- a/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
> +++ b/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
> @@ -102,6 +102,8 @@ __aeabi_idiv0 (int return_value)
>  # define DO_TEST 0
>  #elif defined (__or1k__)
>/* On OpenRISC division by zero does not trap.  */
> +#elif defined (__pru__)
> +/* There isn't even a signal function.  */
>  # define DO_TEST 0

That removes the define from the __or1k__ branch.

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: Test for C++20 p0858 - ConstexprIterator requirements.

2019-06-09 Thread Ed Smith-Rowland via gcc-patches

On 6/8/19 4:28 PM, Jonathan Wakely wrote:

On 08/06/19 12:05 -0400, Ed Smith-Rowland wrote:

On 6/7/19 11:42 AM, Jonathan Wakely wrote:

On 01/06/19 15:40 -0400, Ed Smith-Rowland via libstdc++ wrote:

On 6/1/19 2:42 PM, Ville Voutilainen wrote:
On Sat, 1 Jun 2019 at 21:09, Ed Smith-Rowland <3dw...@verizon.net> 
wrote:

On 5/31/19 6:29 PM, Ville Voutilainen wrote:

On Sat, 1 Jun 2019 at 01:24, Ed Smith-Rowland via libstdc++
 wrote:

Greetings,

Iterators for  and  are usabe in a 
constexpr context

since C++2017.

This just adds a compile test to make sure and check a box for 
C++20

p0858 - ConstexprIterator requirements.

Those tests don't use the iterators in a constexpr context. To do
that, maybe do those std::copy operations
in a constexpr function and then initialize a constexpr variable 
with

the result of a call to that function?

Thanks Ville,

I had completely forgotten to make these test functions constexpr 
- FIXED.

.but that doesn't enforce a constexpr context. If you add another
function that calls these functions
and initializes a constexpr variable, then we have the enforcement I
seek. Such as

void test2()
{
?? constexpr char x = test();
}


Ok, third time's a charm.

I was brain dead about the constexpr patch.?? I'm now setting a 
constexpr variable from test() in a caller.


But static_assert is a constexpr context no?

Ed





2019-06-03?? Edward Smith-Rowland <3dw...@verizon.net>

Test for C++20 p0858 - ConstexprIterator requirements.
* 
testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc:

New test.
* 
testsuite/23_containers/array/requirements/constexpr_iter.cc:

New test.



Index: 
testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc

===
--- 
testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc 
(nonexistent)
+++ 
testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc 
(working copy)

@@ -0,0 +1,43 @@
+// { dg-do compile { target c++2a } }


Please check the testsuite/libstdc++.log or testsuite/libstdc++.sum
files for the new tests. I expect they are both UNSUPPORTED.

That's because you've given a target c++2a which means they won't be
run unless a suitable -std option is given. And you haven't given one.

You need to add { dg-options "-std=gnu++2a" } before the dg-do line.

Also if the tests are restricted to C++2a then there's no point having
the #if __cplusplus > 201703L check, because that will never be false.

I had supplied the option for gnu++2a by hand and they passed.?? They 
were not UNSUPPORTED.


I just added the dg-options (at very top) and reran the testsuite 
without fancy tricks (except for gnu++2a).


I also took out the #if __cplusplus.?? I was just playing around and 
discovered that these pass in C++17 if you comment out the C++20 
constexpr algos.


OK for trunk?


OK for trunk.

Committed 272084.


Also, we could declare victory for this for gcc-9.?? May I backport 
after this is in?


Yes, these tests are also OK to backport to gcc-9-branch (assuming
they pass on the branch, which I agree they should do).

Thanks!

The backport is the same less the calls to std::copy. CL and patch 
attached. Committed 272097.


Ed

2019-06-09  Edward Smith-Rowland  <3dw...@verizon.net>

Test for C++20 p0858 - ConstexprIterator requirements.
* testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc:
New test.
* testsuite/23_containers/array/requirements/constexpr_iter.cc:
New test.

Index: testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc
===
--- testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc   
(nonexistent)
+++ testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc   
(working copy)
@@ -0,0 +1,39 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+//
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// .
+
+#include 
+#include 
+
+constexpr char
+test()
+{
+  constexpr std::string_view hw("Hello, World!");
+  static_assert('H' == *hw.begin());
+  auto ch = hw[4];
+  static_assert('W' =

Re: Test for C++20 p0858 - ConstexprIterator requirements.

2019-06-09 Thread Rainer Orth
Hi Ed,

>>> I had supplied the option for gnu++2a by hand and they passed.?? They
>>> were not UNSUPPORTED.
>>>
>>> I just added the dg-options (at very top) and reran the testsuite
>>> without fancy tricks (except for gnu++2a).
>>>
>>> I also took out the #if __cplusplus.?? I was just playing around and
>>> discovered that these pass in C++17 if you comment out the C++20
>>> constexpr algos.
>>>
>>> OK for trunk?
>>
>> OK for trunk.
> Committed 272084.

272085 actually ;-)  Unfortunately, the new tests seem to FAIL (almost?)
everywhere:

+FAIL: 21_strings/basic_string_view/requirements/constexpr_iter.cc (test for 
excess errors)

Excess errors:
/vol/gcc/src/hg/trunk/local/libstdc++-v3/testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc:33:
 error: call to non-'constexpr' function '_OI std::copy(_II, _II, _OI) [with 
_II = const char*; _OI = int*]'
/vol/gcc/src/hg/trunk/local/libstdc++-v3/testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc:41:
 error: 'constexpr char test()' called in a constant expression

+FAIL: 23_containers/array/requirements/constexpr_iter.cc (test for excess 
errors)

/vol/gcc/src/hg/trunk/local/libstdc++-v3/testsuite/23_containers/array/requirements/constexpr_iter.cc:32:
 error: call to non-'constexpr' function '_OI std::copy(_II, _II, _OI) [with 
_II = const int*; _OI = int*]'
/vol/gcc/src/hg/trunk/local/libstdc++-v3/testsuite/23_containers/array/requirements/constexpr_iter.cc:40:
 error: 'constexpr int test()' called in a constant expression

I'm seeing those on i386-pc-solaris2.11 and sparc-sun-solaris2.11, and
there are gcc-testresults reports on aarch64-unknown-linux-gnu,
i686-pc-linux-gnu, powerpc64le-unknown-linux-gnu, and
x86_64-pc-linux-gnu, among others.

Please fix.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: Test for C++20 p0858 - ConstexprIterator requirements.

2019-06-09 Thread Ville Voutilainen
On Mon, 10 Jun 2019 at 01:03, Rainer Orth  wrote:
>
> Hi Ed,
>
> >>> I had supplied the option for gnu++2a by hand and they passed.?? They
> >>> were not UNSUPPORTED.
> >>>
> >>> I just added the dg-options (at very top) and reran the testsuite
> >>> without fancy tricks (except for gnu++2a).
> >>>
> >>> I also took out the #if __cplusplus.?? I was just playing around and
> >>> discovered that these pass in C++17 if you comment out the C++20
> >>> constexpr algos.
> >>>
> >>> OK for trunk?
> >>
> >> OK for trunk.
> > Committed 272084.
>
> 272085 actually ;-)  Unfortunately, the new tests seem to FAIL (almost?)
> everywhere:
>
> +FAIL: 21_strings/basic_string_view/requirements/constexpr_iter.cc (test for 
> excess errors)
>
> Excess errors:
> /vol/gcc/src/hg/trunk/local/libstdc++-v3/testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc:33:
>  error: call to non-'constexpr' function '_OI std::copy(_II, _II, _OI) [with 
> _II = const char*; _OI = int*]'
> /vol/gcc/src/hg/trunk/local/libstdc++-v3/testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc:41:
>  error: 'constexpr char test()' called in a constant expression
>
> +FAIL: 23_containers/array/requirements/constexpr_iter.cc (test for excess 
> errors)
>
> /vol/gcc/src/hg/trunk/local/libstdc++-v3/testsuite/23_containers/array/requirements/constexpr_iter.cc:32:
>  error: call to non-'constexpr' function '_OI std::copy(_II, _II, _OI) [with 
> _II = const int*; _OI = int*]'
> /vol/gcc/src/hg/trunk/local/libstdc++-v3/testsuite/23_containers/array/requirements/constexpr_iter.cc:40:
>  error: 'constexpr int test()' called in a constant expression
>
> I'm seeing those on i386-pc-solaris2.11 and sparc-sun-solaris2.11, and
> there are gcc-testresults reports on aarch64-unknown-linux-gnu,
> i686-pc-linux-gnu, powerpc64le-unknown-linux-gnu, and
> x86_64-pc-linux-gnu, among others.
>
> Please fix.

Indeed. std::copy isn't constexpr yet. I don't see how Ed's test run
can pass. We either need to put this on hold until enough of
 is constexprified,
or we need to use loops in this test and test (constexpr) algorithms'
use of (constexpr) iterators separately later.


Re: Test for C++20 p0858 - ConstexprIterator requirements.

2019-06-09 Thread Jonathan Wakely

On 10/06/19 00:03 +0200, Rainer Orth wrote:

Hi Ed,


I had supplied the option for gnu++2a by hand and they passed.?? They
were not UNSUPPORTED.

I just added the dg-options (at very top) and reran the testsuite
without fancy tricks (except for gnu++2a).

I also took out the #if __cplusplus.?? I was just playing around and
discovered that these pass in C++17 if you comment out the C++20
constexpr algos.

OK for trunk?


OK for trunk.

Committed 272084.


272085 actually ;-)  Unfortunately, the new tests seem to FAIL (almost?)
everywhere:

+FAIL: 21_strings/basic_string_view/requirements/constexpr_iter.cc (test for 
excess errors)

Excess errors:
/vol/gcc/src/hg/trunk/local/libstdc++-v3/testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc:33:
 error: call to non-'constexpr' function '_OI std::copy(_II, _II, _OI) [with 
_II = const char*; _OI = int*]'
/vol/gcc/src/hg/trunk/local/libstdc++-v3/testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc:41:
 error: 'constexpr char test()' called in a constant expression

+FAIL: 23_containers/array/requirements/constexpr_iter.cc (test for excess 
errors)

/vol/gcc/src/hg/trunk/local/libstdc++-v3/testsuite/23_containers/array/requirements/constexpr_iter.cc:32:
 error: call to non-'constexpr' function '_OI std::copy(_II, _II, _OI) [with 
_II = const int*; _OI = int*]'
/vol/gcc/src/hg/trunk/local/libstdc++-v3/testsuite/23_containers/array/requirements/constexpr_iter.cc:40:
 error: 'constexpr int test()' called in a constant expression

I'm seeing those on i386-pc-solaris2.11 and sparc-sun-solaris2.11, and
there are gcc-testresults reports on aarch64-unknown-linux-gnu,
i686-pc-linux-gnu, powerpc64le-unknown-linux-gnu, and
x86_64-pc-linux-gnu, among others.


Presumably because std::copy isn't actually constexpr yet.

Ed, do you have uncommitted local changes that allow this test to
pass? Because I don't see how it can pass otherwise.




Re: [PATCH v6 01/10] Initial TI PRU GCC port

2019-06-09 Thread Segher Boessenkool
Hi Dimitar,

Just some comments, do with it what you want :-)

On Sun, Jun 09, 2019 at 11:01:38PM +0300, Dimitar Dimitrov wrote:
> +; An unfortunate side effect is that quite a few invalid RTL patterns are
> +; generated.  For example:
> +;  ... (zero_extend:SI (match_operand:SI ...)) ...

You could perhaps use a mode iterator like rs6000's EXTHI and friends.

> +; These patterns are harmless since no pass should generate such RTL.  This
> +; shortcut allows us to keep small and concise machine description patterns.

But the generated code (of GCC itself) will be larger.  It's also not
harmless in that it can complicate your debugging, problems take longer
to spot.


> +(define_insn 
> "add_impl_"

Many lines are too long.  Not that it is clear how to fix that in this
particular case ;-)


> +  [(set_attr "type" "alu,alu,alu")])

You can just say

  [(set_attr "type" "alu")])

if all alternatives are the same value for an attribute.


> +(define_insn "one_impl_"

The standard pattern is called one_cmpl, so maybe you want one_cmpl_impl
here?  one_impl looks like a typo.


> +(define_subst "alu2_zext_subst"
> +  [(set (match_operand:EQD 0 "" "")
> + (ALUOP2:EQD (zero_extend:EQD (match_operand:EQD 1 "" ""]

I don't know if this actually works for define_subst, but at least in many
other cases you can write this like

(define_subst "alu2_zext_subst"
  [(set (match_operand:EQD 0)
(ALUOP2:EQD (zero_extend:EQD (match_operand:EQD 1]

(you can omit trailing empty string arguments).


> +(define_predicate "pru_muldst_operand"
> +  (match_code "subreg,reg")
> +{
> +  if (register_operand (op, mode))
> +{
> +  int regno;
> +
> +  if (REG_P (op))
> + regno = REGNO (op);
> +  else if (GET_CODE (op) == SUBREG && REG_P (SUBREG_REG (op)))
> + regno = REGNO (SUBREG_REG (op));
> +  else
> + return 0;
> +
> +  return REGNO_REG_CLASS (regno) == MULDST_REGS
> +  || regno >= FIRST_PSEUDO_REGISTER;
> +}
> +  return 0;
> +})


> +static bool
> +pru_hard_regno_scratch_ok (unsigned int regno)
> +{
> +  /* Don't allow hard registers that might be part of the frame pointer.
> + Some places in the compiler just test for [HARD_]FRAME_POINTER_REGNUM
> + and don't handle a frame pointer that spans more than one register.
> + TODO: Fix those faulty places.  */
> +
> +  if ((!reload_completed || frame_pointer_needed)
> +  && ((regno >= HARD_FRAME_POINTER_REGNUM
> +&& regno <= HARD_FRAME_POINTER_REGNUM + 3)
> +   || (regno >= FRAME_POINTER_REGNUM
> +   && regno <= FRAME_POINTER_REGNUM + 3)))
> +return false;

Use IN_RANGE?


> +  /* QBxx conditional branching cannot cope with block reordering.  */
> +  if (flag_reorder_blocks_and_partition)
> +{
> +  inform (input_location, "%<-freorder-blocks-and-partition%> "
> +   "not supported on this architecture");
> +  flag_reorder_blocks_and_partition = 0;
> +  flag_reorder_blocks = 1;
> +}

What you cannot cope with is the hot/cold partitioning, I guess --
otherwise you'd have to disable reorder_blocks itself, and that would
result in pretty terrible code.


> +; There is no pipeline, so our scheduling description is simple.
> +(define_automaton "pru")
> +(define_cpu_unit "cpu" "pru")
> +
> +(define_insn_reservation "everything" 1 (match_test "true") "cpu")

Because you have a scheduling description, INSN_SCHEDULING is defined,
and that makes combine not create SUBREGs of MEM.  Which is pretty
important :-)


It looks like a quite complete port, congratulations :-)


Segher


[C++ PATCH] Add test for c++/65175

2019-06-09 Thread Marek Polacek
This one was fairly difficult to reduce but finally I've come up with something
that compiles without warnings with trunk/clang++/icc.

It was fixed by r261709 which has a much simpler test but I suppose there's
value in exercising more involved code.

Tested on x86_64-linux, applying to trunk.

2019-06-09  Marek Polacek  

PR c++/65175
* g++.dg/cpp0x/alias-decl-69.C: New test.

diff --git gcc/testsuite/g++.dg/cpp0x/alias-decl-69.C 
gcc/testsuite/g++.dg/cpp0x/alias-decl-69.C
new file mode 100644
index 000..7dd7aa2379c
--- /dev/null
+++ gcc/testsuite/g++.dg/cpp0x/alias-decl-69.C
@@ -0,0 +1,40 @@
+// PR c++/65175
+// { dg-do compile { target c++11 } }
+
+template  using au = typename a::av;
+template  using az = a;
+template  class b, class... bf> struct d {
+  template  struct f { typedef bh e; };
+  static auto g(int) -> f>;
+  typedef typename decltype(g(0))::e e;
+};
+template  class h;
+template  class, class...> struct i;
+struct j {
+  typedef int bu;
+};
+namespace bv {
+template  struct k : j {};
+template  struct l : i {};
+} // namespace bv
+template  auto bw(bx) -> az::c, typename bv::l::bz>;
+template  struct n : j { au av; };
+template  struct K : j { au av; };
+template  struct o {
+  typedef typename cj::e e;
+  static const bool c = true;
+  typedef h bz;
+};
+template  class cj, class... bf>
+struct i : o> {};
+template  class h {
+public:
+  typedef int av;
+  struct : i {} s;
+  template  struct p : i, int> {};
+  template 
+  auto m_fn2(bx, cl) -> az::c, typename p::bz>;
+  template  static auto q(int, int, bx cm) -> decltype(bw(cm));
+};
+int a, b;
+void c() { h<>::q(b, 5, a).m_fn2(5, a); }


[C++ PATCH] Add test for c++/67533 (or not?)

2019-06-09 Thread Marek Polacek
This testcase used to ICE but was fixed by r259067.  We now issue

67533.C:5:26: error: conversion from ‘void’ to non-scalar type ‘Tls’ requested
5 | thread_local Tls mytls = mytls; // { dg-error "" }
  |  ^

whereas clang++ and icc compile it.  However, the test uses a reserved 
identifier
([lex.name]/3), and I think the error is fine.

Do you think it's worth adding this test?  I thought so, just to check we don't
ICE, but who uses a mangled name as an identifier?!

Tested x86_64-linux, ok for trunk?

2019-06-09  Marek Polacek  

PR c++/67533
* g++.dg/tls/thread_local-ice5.C: New test.

diff --git gcc/testsuite/g++.dg/tls/thread_local-ice5.C 
gcc/testsuite/g++.dg/tls/thread_local-ice5.C
new file mode 100644
index 000..4147c322e7b
--- /dev/null
+++ gcc/testsuite/g++.dg/tls/thread_local-ice5.C
@@ -0,0 +1,7 @@
+// PR c++/67533
+// { dg-do compile { target c++11 } }
+// { dg-require-effective-target tls }
+
+struct Tls {};
+void _ZTW5mytls();
+thread_local Tls mytls = mytls; // { dg-error "" }


Re: Test for C++20 p0858 - ConstexprIterator requirements.

2019-06-09 Thread Ed Smith-Rowland via gcc-patches

On 6/9/19 6:28 PM, Jonathan Wakely wrote:

On 10/06/19 00:03 +0200, Rainer Orth wrote:

Hi Ed,


I had supplied the option for gnu++2a by hand and they passed.?? They
were not UNSUPPORTED.

I just added the dg-options (at very top) and reran the testsuite
without fancy tricks (except for gnu++2a).

I also took out the #if __cplusplus.?? I was just playing around and
discovered that these pass in C++17 if you comment out the C++20
constexpr algos.

OK for trunk?


OK for trunk.

Committed 272084.


272085 actually ;-)?? Unfortunately, the new tests seem to FAIL (almost?)
everywhere:

+FAIL: 21_strings/basic_string_view/requirements/constexpr_iter.cc 
(test for excess errors)


Excess errors:
/vol/gcc/src/hg/trunk/local/libstdc++-v3/testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc:33: 
error: call to non-'constexpr' function '_OI std::copy(_II, _II, _OI) 
[with _II = const char*; _OI = int*]'
/vol/gcc/src/hg/trunk/local/libstdc++-v3/testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc:41: 
error: 'constexpr char test()' called in a constant expression


+FAIL: 23_containers/array/requirements/constexpr_iter.cc (test for 
excess errors)


/vol/gcc/src/hg/trunk/local/libstdc++-v3/testsuite/23_containers/array/requirements/constexpr_iter.cc:32: 
error: call to non-'constexpr' function '_OI std::copy(_II, _II, _OI) 
[with _II = const int*; _OI = int*]'
/vol/gcc/src/hg/trunk/local/libstdc++-v3/testsuite/23_containers/array/requirements/constexpr_iter.cc:40: 
error: 'constexpr int test()' called in a constant expression


I'm seeing those on i386-pc-solaris2.11 and sparc-sun-solaris2.11, and
there are gcc-testresults reports on aarch64-unknown-linux-gnu,
i686-pc-linux-gnu, powerpc64le-unknown-linux-gnu, and
x86_64-pc-linux-gnu, among others.


Presumably because std::copy isn't actually constexpr yet.

Ed, do you have uncommitted local changes that allow this test to
pass? Because I don't see how it can pass otherwise.


Darn it, I had those constexpr lib patches in tree.

Attached are what I just committed to gcc-9 and passes there. Those 
std::copy didn't really add anything anyway.


Note to self - no matter how small work on a separate branch.

I'm testing on a new clean branch unless someone beats me to it.

Sorry for all the noise.

Ed


Index: testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc
===
--- testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc   
(revision 272098)
+++ testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc   
(working copy)
@@ -29,9 +29,6 @@
   auto ch = hw[4];
   static_assert('W' == *(hw.cbegin() + 7));
 
-  std::array a2{{0,0,0,0,0,0,0,0,0,0,0,0,0}};
-  std::copy(hw.begin(), hw.end(), a2.begin());
-
   return *(hw.cbegin() + 3);
 }
 
Index: testsuite/23_containers/array/requirements/constexpr_iter.cc
===
--- testsuite/23_containers/array/requirements/constexpr_iter.cc
(revision 272098)
+++ testsuite/23_containers/array/requirements/constexpr_iter.cc
(working copy)
@@ -28,9 +28,6 @@
   auto n = a1[0] * a1[1]* a1[2];
   static_assert(1 == *a1.cbegin());
 
-  std::array a2{{0, 0, 0}};
-  std::copy(a1.begin(), a1.end(), a2.begin());
-
   return n;
 }
 


C++ PATCH for c++/90736 - bogus error with alignof

2019-06-09 Thread Marek Polacek
The problem here is that we're getting "requested alignment is not an
integer constant" since r261971, because of this part of the patch:

@ -4676,7 +4685,11 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, 
tree t,
 conversion.  */
  return fold (t);

-   if (tcode == UNARY_PLUS_EXPR)
+   /* Handle an array's bounds having been deduced after we built
+  the wrapping expression.  */
+   if (same_type_ignoring_tlq_and_bounds_p (type, TREE_TYPE (op)))
+ r = op;
+   else if (tcode == UNARY_PLUS_EXPR)
  r = fold_convert (TREE_TYPE (t), op);
else
  r = fold_build1 (tcode, type, op);

where type was "int" and TREE_TYPE (op) was "const int", so we just used OP
which was an INTEGER_CST of type "const int".  That resulted in a NOP_EXPR
causing the error above.  Previously, we'd fold_build, returning an INTEGER_CST
with type "int".

It seems weird to me to have an INTEGER_CST with a cv-qual type, so the
following patch handles that case in adjust_temp_type.

Bootstrapped/regtested on x86_64-linux, ok for trunk and 9?

2019-06-09  Marek Polacek  

PR c++/90736 - bogus error with alignof.
* constexpr.c (adjust_temp_type): Use cv_unqualified type.

* g++.dg/cpp0x/alignof5.C: New test.

diff --git gcc/cp/constexpr.c gcc/cp/constexpr.c
index 10afc419a33..a0d09de064d 100644
--- gcc/cp/constexpr.c
+++ gcc/cp/constexpr.c
@@ -1337,7 +1337,9 @@ adjust_temp_type (tree type, tree temp)
   if (TREE_CODE (temp) == EMPTY_CLASS_EXPR)
 return build0 (EMPTY_CLASS_EXPR, type);
   gcc_assert (scalarish_type_p (type));
-  return cp_fold_convert (type, temp);
+  /* Now we know we're dealing with a scalar, and a prvalue of non-class
+ type is cv-unqualified.  */
+  return cp_fold_convert (cv_unqualified (type), temp);
 }
 
 /* Callback for walk_tree used by unshare_constructor.  */
diff --git gcc/testsuite/g++.dg/cpp0x/alignof5.C 
gcc/testsuite/g++.dg/cpp0x/alignof5.C
new file mode 100644
index 000..09354d3e1d0
--- /dev/null
+++ gcc/testsuite/g++.dg/cpp0x/alignof5.C
@@ -0,0 +1,6 @@
+// PR c++/90736 - bogus error with alignof.
+// { dg-do compile { target c++11 } }
+
+constexpr int fn(const int b) { return b; }
+constexpr int c = fn(alignof(int));
+alignas(c) char d;


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

2019-06-09 Thread Dimitar Dimitrov
On неделя, 9 юни 2019 г. 22:34:23 EEST Andreas Schwab wrote:
> On Jun 09 2019, Dimitar Dimitrov  wrote:
> > diff --git a/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
> > b/gcc/testsuite/gcc.c-torture/execute/20101011-1.c index
> > d2beeb52a0e..4a9cc63fde8 100644
> > --- a/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
> > +++ b/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
> > @@ -102,6 +102,8 @@ __aeabi_idiv0 (int return_value)
> > 
> >  # define DO_TEST 0
> >  #elif defined (__or1k__)
> >  
> >/* On OpenRISC division by zero does not trap.  */
> > 
> > +#elif defined (__pru__)
> > +/* There isn't even a signal function.  */
> > 
> >  # define DO_TEST 0
> 
> That removes the define from the __or1k__ branch.
> 
> Andreas.
Sorry about that. Must have slipped through one of the numerous rebases I've 
been doing. I'll fix it.

Thanks for spotting it,
Dimitar



Re: Test for C++20 p0858 - ConstexprIterator requirements.

2019-06-09 Thread Ville Voutilainen
On Mon, 10 Jun 2019 at 02:53, Ed Smith-Rowland <3dw...@verizon.net> wrote:

> Darn it, I had those constexpr lib patches in tree.
> Attached are what I just committed to gcc-9 and passes there. Those
> std::copy didn't really add anything anyway.

They added a test that *i++ = *j++ works, and that i != j works.


[PATCH][OBVIOUS] Fix build with --enable-gather-detailed-mem-stats.

2019-06-09 Thread Martin Liška
Hi.

This is one more fix of the hash_table where I forgot to pass
a new parameter in hash_table::hash_table.

I'm going to install it as obvious.
Martin

gcc/ChangeLog:

2019-06-10  Martin Liska  

* hash-map.h: Pass default value to hash_table ctor.
* hash-table.h: Add default value to call of a ctor.
---
 gcc/hash-map.h   | 6 --
 gcc/hash-table.h | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)


diff --git a/gcc/hash-map.h b/gcc/hash-map.h
index a3ef283a1f9..a8eb42d5a03 100644
--- a/gcc/hash-map.h
+++ b/gcc/hash-map.h
@@ -120,12 +120,14 @@ public:
   explicit hash_map (size_t n = 13, bool ggc = false,
 		 bool gather_mem_stats = GATHER_STATISTICS
 		 CXX_MEM_STAT_INFO)
-: m_table (n, ggc, gather_mem_stats, HASH_MAP_ORIGIN PASS_MEM_STAT) {}
+: m_table (n, ggc, true, gather_mem_stats, HASH_MAP_ORIGIN PASS_MEM_STAT)
+  {
+  }
 
   explicit hash_map (const hash_map &h, bool ggc = false,
 		 bool gather_mem_stats = GATHER_STATISTICS
 		 CXX_MEM_STAT_INFO)
-: m_table (h.m_table, ggc, gather_mem_stats,
+: m_table (h.m_table, ggc, true, gather_mem_stats,
 	   HASH_MAP_ORIGIN PASS_MEM_STAT) {}
 
   /* Create a hash_map in ggc memory.  */
diff --git a/gcc/hash-table.h b/gcc/hash-table.h
index 686a13dbd4b..6c1fca3459b 100644
--- a/gcc/hash-table.h
+++ b/gcc/hash-table.h
@@ -389,7 +389,7 @@ public:
   create_ggc (size_t n CXX_MEM_STAT_INFO)
   {
 hash_table *table = ggc_alloc ();
-new (table) hash_table (n, true, GATHER_STATISTICS,
+new (table) hash_table (n, true, true, GATHER_STATISTICS,
 			HASH_TABLE_ORIGIN PASS_MEM_STAT);
 return table;
   }