[PATCH] Implement Bit-field lowering

2023-07-13 Thread naveenh--- via Gcc-patches
From: Naveen H S 

This patch adds lowering bit-field and opposite endian accesses pass.
The patch addresses many issues in:-
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=19466

2023-07-14  Andrew Pinski   
Co-authored-by: Naveen H S 

gcc/ChangeLog:

* Makefile.in (OBJS): Add gimple-lower-accesses.o.
* gimple-lower-accesses.cc: New file.
* passes.def (pass_lower_accesses): Add.
* tree-pass.h (make_pass_lower_accesses): Define.

gcc/testsuite/ChangeLog:

* gcc.dg/store_merging_14.c: Modify the pattern found as per new code.
* gcc.dg/store_merging_16.c: Likewise.
* gcc.dg/store_merging_20.c: Likewise.
* gcc.dg/store_merging_21.c: Likewise.
* gcc.dg/store_merging_24.c: Likewise.
* gcc.dg/store_merging_25.c: Likewise.
* gcc.dg/store_merging_6.c: Likewise.
* gcc.dg/tree-ssa/20030729-1.c: Likewise.
* gcc.dg/tree-ssa/20030814-6.c: Likewise.
* gcc.dg/tree-ssa/loop-interchange-14.c: Likewise.
* gcc.dg/tree-ssa/20030714-1.c: Remove.
---
 gcc/Makefile.in   |   1 +
 gcc/gimple-lower-accesses.cc  | 463 ++
 gcc/passes.def|   4 +
 gcc/testsuite/gcc.dg/store_merging_10.c   |   2 +-
 gcc/testsuite/gcc.dg/store_merging_14.c   |   2 +-
 gcc/testsuite/gcc.dg/store_merging_16.c   |   4 +-
 gcc/testsuite/gcc.dg/store_merging_20.c   |   2 +-
 gcc/testsuite/gcc.dg/store_merging_21.c   |   2 +-
 gcc/testsuite/gcc.dg/store_merging_24.c   |   4 +-
 gcc/testsuite/gcc.dg/store_merging_25.c   |   4 +-
 gcc/testsuite/gcc.dg/store_merging_6.c|   2 +-
 gcc/testsuite/gcc.dg/tree-ssa/20030714-1.c|  45 --
 gcc/testsuite/gcc.dg/tree-ssa/20030729-1.c|   5 +-
 gcc/testsuite/gcc.dg/tree-ssa/20030814-6.c|   5 +-
 .../gcc.dg/tree-ssa/loop-interchange-14.c |   2 +-
 gcc/tree-pass.h   |   1 +
 16 files changed, 485 insertions(+), 63 deletions(-)
 create mode 100644 gcc/gimple-lower-accesses.cc
 delete mode 100644 gcc/testsuite/gcc.dg/tree-ssa/20030714-1.c

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index c478ec85201..50bd28f4d04 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1338,6 +1338,7 @@ OBJS = \
$(GIMPLE_MATCH_PD_SEQ_O) \
gimple-match-exports.o \
$(GENERIC_MATCH_PD_SEQ_O) \
+   gimple-lower-accesses.o \
insn-attrtab.o \
insn-automata.o \
insn-dfatab.o \
diff --git a/gcc/gimple-lower-accesses.cc b/gcc/gimple-lower-accesses.cc
new file mode 100644
index 000..9d87acfba56
--- /dev/null
+++ b/gcc/gimple-lower-accesses.cc
@@ -0,0 +1,463 @@
+/* GIMPLE lowering bit-field and opposite endian accesses pass.
+
+   Copyright (C) 2017-2023 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC 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.
+
+GCC 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 GCC; see the file COPYING3.  If not see
+.  */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "backend.h"
+#include "rtl.h"
+#include "tree.h"
+#include "gimple.h"
+#include "cfghooks.h"
+#include "tree-pass.h"
+#include "ssa.h"
+#include "fold-const.h"
+#include "stor-layout.h"
+#include "tree-eh.h"
+#include "gimplify.h"
+#include "gimple-iterator.h"
+#include "gimplify-me.h"
+#include "tree-cfg.h"
+#include "tree-dfa.h"
+#include "tree-ssa.h"
+#include "tree-ssa-propagate.h"
+#include "tree-hasher.h"
+#include "cfgloop.h"
+#include "cfganal.h"
+#include "alias.h"
+#include "expr.h"
+#include "tree-pretty-print.h"
+
+namespace {
+
+class lower_accesses
+{
+  function *fn;
+public:
+  lower_accesses (function *f) : fn(f) {}
+  unsigned int execute (void);
+};
+
+
+/* Handle reference to a bitfield EXPR.
+   If BITPOS_P is non-null assume that reference is LHS and set *BITPOS_P
+   to bit position of the field.
+   If REF_P is non-null set it to the memory reference for the encompassing
+   allocation unit.
+   Note *BITPOS_P is suitable only for BIT_FIELD_REF/BIT_FIELD_INSERT.  */
+
+tree
+extract_bitfield (tree expr, tree *bitpos_p, tree *bitsize_p,
+ bool *preversep)
+{
+  tree base, addr, ref;
+  tree base_type;
+  tree bytepos;
+  machine_mode mode1;
+  int unsignedp = false, volatilep = false, reversep = false;
+
+  poly_int64 bitsize, bitpos;
+  HOST_WIDE_INT ibitsize = 0, ibitpos = 0;
+
+  poly_uint64 bitregion_start = 0;
+  poly_uint64 bitregion_end = 0;
+
+  if (dump_file && (dump_flags & TDF_DETAILS))
+{
+  fprintf (dump_file, "Trying to expand bitfield reference: \n");
+ 

[PATCH] Add scalar_storage_order support to C++

2023-05-25 Thread naveenh--- via Gcc-patches
From: Naveen H S 

This patch adds support scalar_storage_order attribute to C++ front-end.
It treats the opposite order fields similar as the packed fields are
treated such that they will not bind to references.
For arrays, the attributes applies to the inner type rather than the array
type similar. The code is similar to how it is handled in the C front-end.

2021-04-03  Andrew Pinski   

Co-authored-by: Naveen H S 

gcc/ChangeLog:

* c-family/c-attribs.cc (handle_scalar_storage_order_attribute):
Do not reject the C++ cases.
* cp/class.cc (layout_nonempty_base_or_field): Fix the type of
arrays in C++.
* cp/call.cc (reference_binding): Treat reversed field similar as
packed fields.
(build_temp): Likewise.
(convert_like_internal): Emit error code for non binding reversed
endian field.
* cp/cp-tree.h (clk_implicit_rval) : Add clk_reversed.
* cp/cp-tree.c (lvalue_kind) : Handle reverse storage ordered operands.

gcc/testsuite/ChangeLog:

* c-c++-common/sso/dump.h: Move from gcc.dg/sso to c-c++-common/sso.
* c-c++-common/sso/init1.h: Likewise.
* c-c++-common/sso/init13.h: Likewise.
* c-c++-common/sso/init2.h: Likewise.
* c-c++-common/sso/init3.h: Likewise.
* c-c++-common/sso/init4.h: Likewise.
* c-c++-common/sso/init5.h: Likewise.
* c-c++-common/sso/init6.h: Likewise.
* c-c++-common/sso/init7.h: Likewise.
* c-c++-common/sso/init8.h: Likewise.
* c-c++-common/sso/init9.h: Likewise.
* c-c++-common/sso/p1.c: Likewise.
* c-c++-common/sso/p13.c: Likewise.
* c-c++-common/sso/p2.c: Likewise.
* c-c++-common/sso/p3.c: Likewise.
* c-c++-common/sso/p4.c: Likewise.
* c-c++-common/sso/p5.c: Likewise.
* c-c++-common/sso/p6.c: Likewise.
* c-c++-common/sso/p7.c: Likewise.
* c-c++-common/sso/p8.c: Likewise.
* c-c++-common/sso/p9.c: Likewise.
* c-c++-common/sso/q1.c: Likewise.
* c-c++-common/sso/q13.c: Likewise.
* c-c++-common/sso/q2.c: Likewise.
* c-c++-common/sso/q3.c: Likewise.
* c-c++-common/sso/q4.c: Likewise.
* c-c++-common/sso/q5.c: Likewise.
* c-c++-common/sso/q6.c: Likewise.
* c-c++-common/sso/q7.c: Likewise.
* c-c++-common/sso/q8.c: Likewise.
* c-c++-common/sso/q9.c: Likewise.
* c-c++-common/sso/r3.c: Likewise.
* c-c++-common/sso/r5.c: Likewise.
* c-c++-common/sso/r6.c: Likewise.
* c-c++-common/sso/r7.c: Likewise.
* c-c++-common/sso/r8.c: Likewise.
* c-c++-common/sso/s3.c: Likewise.
* c-c++-common/sso/s5.c: Likewise.
* c-c++-common/sso/s6.c: Likewise.
* c-c++-common/sso/s7.c: Likewise.
* c-c++-common/sso/s8.c: Likewise.
* c-c++-common/sso/t1.c: Likewise.
* c-c++-common/sso/t13.c: Likewise.
* c-c++-common/sso/t2.c: Likewise.
* c-c++-common/sso/t3.c: Likewise.
* c-c++-common/sso/t4.c: Likewise.
* c-c++-common/sso/t5.c: Likewise.
* c-c++-common/sso/t6.c: Likewise.
* c-c++-common/sso/t7.c: Likewise.
* c-c++-common/sso/t8.c: Likewise.
* c-c++-common/sso/t9.c: Likewise.
* c-c++-common/sso/u5.c: Likewise.
* c-c++-common/sso/t6.c: Likewise.
* g++.dg/sso/sso.exp: New file.
* g++.dg/sso/auto-1.C: New file.
* g++.dg/sso/auto-2.C: New file.
* g++.dg/sso/auto-3.C: New file.
* g++.dg/sso/template-reference-1.C: New file.
* g++.dg/sso/template-reference-2.C: New file.
* g++.dg/sso/template-reference-3.C: New file.
* g++.dg/sso/template-reference-4.C: New file.
* g++.dg/sso-1.C: Modified.
---
 gcc/c-family/c-attribs.cc |  2 +-
 gcc/cp/call.cc| 17 ++-
 gcc/cp/class.cc   | 22 ++
 gcc/cp/cp-tree.h  |  3 +-
 gcc/cp/tree.cc|  5 ++-
 .../{gcc.dg => c-c++-common}/sso/dump.h   |  0
 .../{gcc.dg => c-c++-common}/sso/init1.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init13.h |  0
 .../{gcc.dg => c-c++-common}/sso/init2.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init3.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init4.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init5.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init6.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init7.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init8.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init9.h  |  0
 .../{gcc.dg => c-c++-common}/sso/p1.c |  0
 .../{gcc.dg => c-c++-common}/sso/p13.c|  1 +
 .../{gcc.dg => c-c++-common}/sso/p2.c |  0
 .../{gcc.dg => c-c++-common}/sso/p3.c |  0
 .../{gcc.dg => c-c++-common}/sso/p4.c |  0
 .../{gcc.dg => c-c++-common}/sso/p5.c |  0
 .../{gcc.dg => 

[PATCH] Add scalar_storage_order support to C++

2023-05-25 Thread naveenh--- via Gcc-patches
From: Naveen H S 

This patch adds support scalar_storage_order attribute to C++ front-end.
It treats the opposite order fields similar as the packed fields are
treated such that they will not bind to references.
For arrays, the attributes applies to the inner type rather than the array
type similar. The code is similar to how it is handled in the C front-end.

2021-04-03  Andrew Pinski   

gcc/ChangeLog:

* c-family/c-attribs.cc (handle_scalar_storage_order_attribute):
Do not reject the C++ cases.
* cp/class.cc (layout_nonempty_base_or_field): Fix the type of
arrays in C++.
* cp/call.cc (reference_binding): Treat reversed field similar as
packed fields.
(build_temp): Likewise.
(convert_like_internal): Emit error code for non binding reversed
endian field.
* cp/cp-tree.h (clk_implicit_rval) : Add clk_reversed.
* cp/cp-tree.c (lvalue_kind) : Handle reverse storage ordered operands.

gcc/testsuite/ChangeLog:

* c-c++-common/sso/dump.h: Move from gcc.dg/sso to c-c++-common/sso.
* c-c++-common/sso/init1.h: Likewise.
* c-c++-common/sso/init13.h: Likewise.
* c-c++-common/sso/init2.h: Likewise.
* c-c++-common/sso/init3.h: Likewise.
* c-c++-common/sso/init4.h: Likewise.
* c-c++-common/sso/init5.h: Likewise.
* c-c++-common/sso/init6.h: Likewise.
* c-c++-common/sso/init7.h: Likewise.
* c-c++-common/sso/init8.h: Likewise.
* c-c++-common/sso/init9.h: Likewise.
* c-c++-common/sso/p1.c: Likewise.
* c-c++-common/sso/p13.c: Likewise.
* c-c++-common/sso/p2.c: Likewise.
* c-c++-common/sso/p3.c: Likewise.
* c-c++-common/sso/p4.c: Likewise.
* c-c++-common/sso/p5.c: Likewise.
* c-c++-common/sso/p6.c: Likewise.
* c-c++-common/sso/p7.c: Likewise.
* c-c++-common/sso/p8.c: Likewise.
* c-c++-common/sso/p9.c: Likewise.
* c-c++-common/sso/q1.c: Likewise.
* c-c++-common/sso/q13.c: Likewise.
* c-c++-common/sso/q2.c: Likewise.
* c-c++-common/sso/q3.c: Likewise.
* c-c++-common/sso/q4.c: Likewise.
* c-c++-common/sso/q5.c: Likewise.
* c-c++-common/sso/q6.c: Likewise.
* c-c++-common/sso/q7.c: Likewise.
* c-c++-common/sso/q8.c: Likewise.
* c-c++-common/sso/q9.c: Likewise.
* c-c++-common/sso/r3.c: Likewise.
* c-c++-common/sso/r5.c: Likewise.
* c-c++-common/sso/r6.c: Likewise.
* c-c++-common/sso/r7.c: Likewise.
* c-c++-common/sso/r8.c: Likewise.
* c-c++-common/sso/s3.c: Likewise.
* c-c++-common/sso/s5.c: Likewise.
* c-c++-common/sso/s6.c: Likewise.
* c-c++-common/sso/s7.c: Likewise.
* c-c++-common/sso/s8.c: Likewise.
* c-c++-common/sso/t1.c: Likewise.
* c-c++-common/sso/t13.c: Likewise.
* c-c++-common/sso/t2.c: Likewise.
* c-c++-common/sso/t3.c: Likewise.
* c-c++-common/sso/t4.c: Likewise.
* c-c++-common/sso/t5.c: Likewise.
* c-c++-common/sso/t6.c: Likewise.
* c-c++-common/sso/t7.c: Likewise.
* c-c++-common/sso/t8.c: Likewise.
* c-c++-common/sso/t9.c: Likewise.
* c-c++-common/sso/u5.c: Likewise.
* c-c++-common/sso/t6.c: Likewise.
* g++.dg/sso/sso.exp: New file.
* g++.dg/sso/auto-1.C: New file.
* g++.dg/sso/auto-2.C: New file.
* g++.dg/sso/auto-3.C: New file.
* g++.dg/sso/template-reference-1.C: New file.
* g++.dg/sso/template-reference-2.C: New file.
* g++.dg/sso/template-reference-3.C: New file.
* g++.dg/sso/template-reference-4.C: New file.
* g++.dg/sso-1.C: Modified.
---
 gcc/c-family/c-attribs.cc |  2 +-
 gcc/cp/call.cc| 17 ++-
 gcc/cp/class.cc   | 22 ++
 gcc/cp/cp-tree.h  |  3 +-
 gcc/cp/tree.cc|  5 ++-
 .../{gcc.dg => c-c++-common}/sso/dump.h   |  0
 .../{gcc.dg => c-c++-common}/sso/init1.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init13.h |  0
 .../{gcc.dg => c-c++-common}/sso/init2.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init3.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init4.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init5.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init6.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init7.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init8.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init9.h  |  0
 .../{gcc.dg => c-c++-common}/sso/p1.c |  0
 .../{gcc.dg => c-c++-common}/sso/p13.c|  1 +
 .../{gcc.dg => c-c++-common}/sso/p2.c |  0
 .../{gcc.dg => c-c++-common}/sso/p3.c |  0
 .../{gcc.dg => c-c++-common}/sso/p4.c |  0
 .../{gcc.dg => c-c++-common}/sso/p5.c |  0
 .../{gcc.dg => c-c++-common}/sso/p6.c   

[PATCH] Add scalar_storage_order support to C++

2023-05-25 Thread naveenh--- via Gcc-patches
From: Naveen H S 

This patch adds support scalar_storage_order attribute to C++ front-end.
It treats the opposite order fields similar as the packed fields are
treated such that they will not bind to references.
For arrays, the attributes applies to the inner type rather than the array
type similar. The code is similar to how it is handled in the C front-end.

2021-04-03  Andrew Pinski   

gcc/ChangeLog:

* c-family/c-attribs.cc (handle_scalar_storage_order_attribute):
Do not reject the C++ cases.
* cp/class.cc (layout_nonempty_base_or_field): Fix the type of
arrays in C++.
* cp/call.cc (reference_binding): Treat reversed field similar as
packed fields.
(build_temp): Likewise.
(convert_like_internal): Emit error code for non binding reversed
endian field.
* cp/cp-tree.h (clk_implicit_rval) : Add clk_reversed.
* cp/cp-tree.c (lvalue_kind) : Handle reverse storage ordered operands.

gcc/testsuite/ChangeLog:

* c-c++-common/sso/dump.h: Move from gcc.dg/sso to c-c++-common/sso.
* c-c++-common/sso/init1.h: Likewise.
* c-c++-common/sso/init13.h: Likewise.
* c-c++-common/sso/init2.h: Likewise.
* c-c++-common/sso/init3.h: Likewise.
* c-c++-common/sso/init4.h: Likewise.
* c-c++-common/sso/init5.h: Likewise.
* c-c++-common/sso/init6.h: Likewise.
* c-c++-common/sso/init7.h: Likewise.
* c-c++-common/sso/init8.h: Likewise.
* c-c++-common/sso/init9.h: Likewise.
* c-c++-common/sso/p1.c: Likewise.
* c-c++-common/sso/p13.c: Likewise.
* c-c++-common/sso/p2.c: Likewise.
* c-c++-common/sso/p3.c: Likewise.
* c-c++-common/sso/p4.c: Likewise.
* c-c++-common/sso/p5.c: Likewise.
* c-c++-common/sso/p6.c: Likewise.
* c-c++-common/sso/p7.c: Likewise.
* c-c++-common/sso/p8.c: Likewise.
* c-c++-common/sso/p9.c: Likewise.
* c-c++-common/sso/q1.c: Likewise.
* c-c++-common/sso/q13.c: Likewise.
* c-c++-common/sso/q2.c: Likewise.
* c-c++-common/sso/q3.c: Likewise.
* c-c++-common/sso/q4.c: Likewise.
* c-c++-common/sso/q5.c: Likewise.
* c-c++-common/sso/q6.c: Likewise.
* c-c++-common/sso/q7.c: Likewise.
* c-c++-common/sso/q8.c: Likewise.
* c-c++-common/sso/q9.c: Likewise.
* c-c++-common/sso/r3.c: Likewise.
* c-c++-common/sso/r5.c: Likewise.
* c-c++-common/sso/r6.c: Likewise.
* c-c++-common/sso/r7.c: Likewise.
* c-c++-common/sso/r8.c: Likewise.
* c-c++-common/sso/s3.c: Likewise.
* c-c++-common/sso/s5.c: Likewise.
* c-c++-common/sso/s6.c: Likewise.
* c-c++-common/sso/s7.c: Likewise.
* c-c++-common/sso/s8.c: Likewise.
* c-c++-common/sso/t1.c: Likewise.
* c-c++-common/sso/t13.c: Likewise.
* c-c++-common/sso/t2.c: Likewise.
* c-c++-common/sso/t3.c: Likewise.
* c-c++-common/sso/t4.c: Likewise.
* c-c++-common/sso/t5.c: Likewise.
* c-c++-common/sso/t6.c: Likewise.
* c-c++-common/sso/t7.c: Likewise.
* c-c++-common/sso/t8.c: Likewise.
* c-c++-common/sso/t9.c: Likewise.
* c-c++-common/sso/u5.c: Likewise.
* c-c++-common/sso/t6.c: Likewise.
* g++.dg/sso/sso.exp: New file.
* g++.dg/sso/auto-1.C: New file.
* g++.dg/sso/auto-2.C: New file.
* g++.dg/sso/auto-3.C: New file.
* g++.dg/sso/template-reference-1.C: New file.
* g++.dg/sso/template-reference-2.C: New file.
* g++.dg/sso/template-reference-3.C: New file.
* g++.dg/sso/template-reference-4.C: New file.
* g++.dg/sso-1.C: Modified.

Co-authored-by: Naveen H S 
---
 gcc/c-family/c-attribs.cc |  2 +-
 gcc/cp/call.cc| 17 ++-
 gcc/cp/class.cc   | 22 ++
 gcc/cp/cp-tree.h  |  3 +-
 gcc/cp/tree.cc|  5 ++-
 .../{gcc.dg => c-c++-common}/sso/dump.h   |  0
 .../{gcc.dg => c-c++-common}/sso/init1.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init13.h |  0
 .../{gcc.dg => c-c++-common}/sso/init2.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init3.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init4.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init5.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init6.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init7.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init8.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init9.h  |  0
 .../{gcc.dg => c-c++-common}/sso/p1.c |  0
 .../{gcc.dg => c-c++-common}/sso/p13.c|  1 +
 .../{gcc.dg => c-c++-common}/sso/p2.c |  0
 .../{gcc.dg => c-c++-common}/sso/p3.c |  0
 .../{gcc.dg => c-c++-common}/sso/p4.c |  0
 .../{gcc.dg => c-c++-common}/sso/p5.c |  0
 .../{gcc.dg => 

[PATCH] Add scalar_storage_order support to C++

2023-05-25 Thread naveenh--- via Gcc-patches
From: Naveen H S 

This patch adds support scalar_storage_order attribute to C++ front-end.
It treats the opposite order fields similar as the packed fields are
treated such that they will not bind to references.
For arrays, the attributes applies to the inner type rather than the array
type similar. The code is similar to how it is handled in the C front-end.

2021-04-03  Andrew Pinski   

gcc/ChangeLog:

* c-family/c-attribs.cc (handle_scalar_storage_order_attribute):
Do not reject the C++ cases.
* cp/class.cc (layout_nonempty_base_or_field): Fix the type of
arrays in C++.
* cp/call.cc (reference_binding): Treat reversed field similar as
packed fields.
(build_temp): Likewise.
(convert_like_internal): Emit error code for non binding reversed
endian field.
* cp/cp-tree.h (clk_implicit_rval) : Add clk_reversed.
* cp/cp-tree.c (lvalue_kind) : Handle reverse storage ordered operands.

gcc/testsuite/ChangeLog:

* c-c++-common/sso/dump.h: Move from gcc.dg/sso to c-c++-common/sso.
* c-c++-common/sso/init1.h: Likewise.
* c-c++-common/sso/init13.h: Likewise.
* c-c++-common/sso/init2.h: Likewise.
* c-c++-common/sso/init3.h: Likewise.
* c-c++-common/sso/init4.h: Likewise.
* c-c++-common/sso/init5.h: Likewise.
* c-c++-common/sso/init6.h: Likewise.
* c-c++-common/sso/init7.h: Likewise.
* c-c++-common/sso/init8.h: Likewise.
* c-c++-common/sso/init9.h: Likewise.
* c-c++-common/sso/p1.c: Likewise.
* c-c++-common/sso/p13.c: Likewise.
* c-c++-common/sso/p2.c: Likewise.
* c-c++-common/sso/p3.c: Likewise.
* c-c++-common/sso/p4.c: Likewise.
* c-c++-common/sso/p5.c: Likewise.
* c-c++-common/sso/p6.c: Likewise.
* c-c++-common/sso/p7.c: Likewise.
* c-c++-common/sso/p8.c: Likewise.
* c-c++-common/sso/p9.c: Likewise.
* c-c++-common/sso/q1.c: Likewise.
* c-c++-common/sso/q13.c: Likewise.
* c-c++-common/sso/q2.c: Likewise.
* c-c++-common/sso/q3.c: Likewise.
* c-c++-common/sso/q4.c: Likewise.
* c-c++-common/sso/q5.c: Likewise.
* c-c++-common/sso/q6.c: Likewise.
* c-c++-common/sso/q7.c: Likewise.
* c-c++-common/sso/q8.c: Likewise.
* c-c++-common/sso/q9.c: Likewise.
* c-c++-common/sso/r3.c: Likewise.
* c-c++-common/sso/r5.c: Likewise.
* c-c++-common/sso/r6.c: Likewise.
* c-c++-common/sso/r7.c: Likewise.
* c-c++-common/sso/r8.c: Likewise.
* c-c++-common/sso/s3.c: Likewise.
* c-c++-common/sso/s5.c: Likewise.
* c-c++-common/sso/s6.c: Likewise.
* c-c++-common/sso/s7.c: Likewise.
* c-c++-common/sso/s8.c: Likewise.
* c-c++-common/sso/t1.c: Likewise.
* c-c++-common/sso/t13.c: Likewise.
* c-c++-common/sso/t2.c: Likewise.
* c-c++-common/sso/t3.c: Likewise.
* c-c++-common/sso/t4.c: Likewise.
* c-c++-common/sso/t5.c: Likewise.
* c-c++-common/sso/t6.c: Likewise.
* c-c++-common/sso/t7.c: Likewise.
* c-c++-common/sso/t8.c: Likewise.
* c-c++-common/sso/t9.c: Likewise.
* c-c++-common/sso/u5.c: Likewise.
* c-c++-common/sso/t6.c: Likewise.
* g++.dg/sso/sso.exp: New file.
* g++.dg/sso/auto-1.C: New file.
* g++.dg/sso/auto-2.C: New file.
* g++.dg/sso/auto-3.C: New file.
* g++.dg/sso/template-reference-1.C: New file.
* g++.dg/sso/template-reference-2.C: New file.
* g++.dg/sso/template-reference-3.C: New file.
* g++.dg/sso/template-reference-4.C: New file.
* g++.dg/sso-1.C: Modified.

Co-authored-by: Naveen H S 
---
 gcc/c-family/c-attribs.cc |  2 +-
 gcc/cp/call.cc| 17 ++-
 gcc/cp/class.cc   | 22 ++
 gcc/cp/cp-tree.h  |  3 +-
 gcc/cp/tree.cc|  5 ++-
 .../{gcc.dg => c-c++-common}/sso/dump.h   |  0
 .../{gcc.dg => c-c++-common}/sso/init1.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init13.h |  0
 .../{gcc.dg => c-c++-common}/sso/init2.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init3.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init4.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init5.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init6.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init7.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init8.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init9.h  |  0
 .../{gcc.dg => c-c++-common}/sso/p1.c |  0
 .../{gcc.dg => c-c++-common}/sso/p13.c|  1 +
 .../{gcc.dg => c-c++-common}/sso/p2.c |  0
 .../{gcc.dg => c-c++-common}/sso/p3.c |  0
 .../{gcc.dg => c-c++-common}/sso/p4.c |  0
 .../{gcc.dg => c-c++-common}/sso/p5.c |  0
 .../{gcc.dg => 

[PATCH] Add scalar_storage_order support to C++

2023-05-25 Thread naveenh--- via Gcc-patches
From: Naveen H S 

This patch adds support scalar_storage_order attribute to C++ front-end.
It treats the opposite order fields similar as the packed fields are
treated such that they will not bind to references.
For arrays, the attributes applies to the inner type rather than the array
type similar. The code is similar to how it is handled in the C front-end.

2021-04-03  Andrew Pinski   

gcc/ChangeLog:

* c-family/c-attribs.cc (handle_scalar_storage_order_attribute):
Do not reject the C++ cases.
* cp/class.cc (layout_nonempty_base_or_field): Fix the type of
arrays in C++.
* cp/call.cc (reference_binding): Treat reversed field similar as
packed fields.
(build_temp): Likewise.
(convert_like_internal): Emit error code for non binding reversed
endian field.
* cp/cp-tree.h (clk_implicit_rval) : Add clk_reversed.
* cp/cp-tree.c (lvalue_kind) : Handle reverse storage ordered operands.

gcc/testsuite/ChangeLog:

* c-c++-common/sso/dump.h: Move from gcc.dg/sso to c-c++-common/sso.
* c-c++-common/sso/init1.h: Likewise.
* c-c++-common/sso/init13.h: Likewise.
* c-c++-common/sso/init2.h: Likewise.
* c-c++-common/sso/init3.h: Likewise.
* c-c++-common/sso/init4.h: Likewise.
* c-c++-common/sso/init5.h: Likewise.
* c-c++-common/sso/init6.h: Likewise.
* c-c++-common/sso/init7.h: Likewise.
* c-c++-common/sso/init8.h: Likewise.
* c-c++-common/sso/init9.h: Likewise.
* c-c++-common/sso/p1.c: Likewise.
* c-c++-common/sso/p13.c: Likewise.
* c-c++-common/sso/p2.c: Likewise.
* c-c++-common/sso/p3.c: Likewise.
* c-c++-common/sso/p4.c: Likewise.
* c-c++-common/sso/p5.c: Likewise.
* c-c++-common/sso/p6.c: Likewise.
* c-c++-common/sso/p7.c: Likewise.
* c-c++-common/sso/p8.c: Likewise.
* c-c++-common/sso/p9.c: Likewise.
* c-c++-common/sso/q1.c: Likewise.
* c-c++-common/sso/q13.c: Likewise.
* c-c++-common/sso/q2.c: Likewise.
* c-c++-common/sso/q3.c: Likewise.
* c-c++-common/sso/q4.c: Likewise.
* c-c++-common/sso/q5.c: Likewise.
* c-c++-common/sso/q6.c: Likewise.
* c-c++-common/sso/q7.c: Likewise.
* c-c++-common/sso/q8.c: Likewise.
* c-c++-common/sso/q9.c: Likewise.
* c-c++-common/sso/r3.c: Likewise.
* c-c++-common/sso/r5.c: Likewise.
* c-c++-common/sso/r6.c: Likewise.
* c-c++-common/sso/r7.c: Likewise.
* c-c++-common/sso/r8.c: Likewise.
* c-c++-common/sso/s3.c: Likewise.
* c-c++-common/sso/s5.c: Likewise.
* c-c++-common/sso/s6.c: Likewise.
* c-c++-common/sso/s7.c: Likewise.
* c-c++-common/sso/s8.c: Likewise.
* c-c++-common/sso/t1.c: Likewise.
* c-c++-common/sso/t13.c: Likewise.
* c-c++-common/sso/t2.c: Likewise.
* c-c++-common/sso/t3.c: Likewise.
* c-c++-common/sso/t4.c: Likewise.
* c-c++-common/sso/t5.c: Likewise.
* c-c++-common/sso/t6.c: Likewise.
* c-c++-common/sso/t7.c: Likewise.
* c-c++-common/sso/t8.c: Likewise.
* c-c++-common/sso/t9.c: Likewise.
* c-c++-common/sso/u5.c: Likewise.
* c-c++-common/sso/t6.c: Likewise.
* g++.dg/sso/sso.exp: New file.
* g++.dg/sso/auto-1.C: New file.
* g++.dg/sso/auto-2.C: New file.
* g++.dg/sso/auto-3.C: New file.
* g++.dg/sso/template-reference-1.C: New file.
* g++.dg/sso/template-reference-2.C: New file.
* g++.dg/sso/template-reference-3.C: New file.
* g++.dg/sso/template-reference-4.C: New file.
* g++.dg/sso-1.C: Modified.

Co-authored-by: Naveen H S 
---
 gcc/c-family/c-attribs.cc |  2 +-
 gcc/cp/call.cc| 17 ++-
 gcc/cp/class.cc   | 22 ++
 gcc/cp/cp-tree.h  |  3 +-
 gcc/cp/tree.cc|  5 ++-
 .../{gcc.dg => c-c++-common}/sso/dump.h   |  0
 .../{gcc.dg => c-c++-common}/sso/init1.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init13.h |  0
 .../{gcc.dg => c-c++-common}/sso/init2.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init3.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init4.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init5.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init6.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init7.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init8.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init9.h  |  0
 .../{gcc.dg => c-c++-common}/sso/p1.c |  0
 .../{gcc.dg => c-c++-common}/sso/p13.c|  1 +
 .../{gcc.dg => c-c++-common}/sso/p2.c |  0
 .../{gcc.dg => c-c++-common}/sso/p3.c |  0
 .../{gcc.dg => c-c++-common}/sso/p4.c |  0
 .../{gcc.dg => c-c++-common}/sso/p5.c |  0
 .../{gcc.dg => 

[PATCH] Add scalar_storage_order support to C++

2023-05-25 Thread naveenh--- via Gcc-patches
From: Naveen H S 

This patch adds support scalar_storage_order attribute to C++ front-end.
It treats the opposite order fields similar as the packed fields are
treated such that they will not bind to references.
For arrays, the attributes applies to the inner type rather than the array
type similar. The code is similar to how it is handled in the C front-end.

2021-04-03  Andrew Pinski   

Co-authored-by: Naveen H S 

gcc/ChangeLog:

* c-family/c-attribs.cc (handle_scalar_storage_order_attribute):
Do not reject the C++ cases.
* cp/class.cc (layout_nonempty_base_or_field): Fix the type of
arrays in C++.
* cp/call.cc (reference_binding): Treat reversed field similar as
packed fields.
(build_temp): Likewise.
(convert_like_internal): Emit error code for non binding reversed
endian field.
* cp/cp-tree.h (clk_implicit_rval) : Add clk_reversed.
* cp/cp-tree.c (lvalue_kind) : Handle reverse storage ordered operands.

gcc/testsuite/ChangeLog:

* c-c++-common/sso/dump.h: Move from gcc.dg/sso to c-c++-common/sso.
* c-c++-common/sso/init1.h: Likewise.
* c-c++-common/sso/init13.h: Likewise.
* c-c++-common/sso/init2.h: Likewise.
* c-c++-common/sso/init3.h: Likewise.
* c-c++-common/sso/init4.h: Likewise.
* c-c++-common/sso/init5.h: Likewise.
* c-c++-common/sso/init6.h: Likewise.
* c-c++-common/sso/init7.h: Likewise.
* c-c++-common/sso/init8.h: Likewise.
* c-c++-common/sso/init9.h: Likewise.
* c-c++-common/sso/p1.c: Likewise.
* c-c++-common/sso/p13.c: Likewise.
* c-c++-common/sso/p2.c: Likewise.
* c-c++-common/sso/p3.c: Likewise.
* c-c++-common/sso/p4.c: Likewise.
* c-c++-common/sso/p5.c: Likewise.
* c-c++-common/sso/p6.c: Likewise.
* c-c++-common/sso/p7.c: Likewise.
* c-c++-common/sso/p8.c: Likewise.
* c-c++-common/sso/p9.c: Likewise.
* c-c++-common/sso/q1.c: Likewise.
* c-c++-common/sso/q13.c: Likewise.
* c-c++-common/sso/q2.c: Likewise.
* c-c++-common/sso/q3.c: Likewise.
* c-c++-common/sso/q4.c: Likewise.
* c-c++-common/sso/q5.c: Likewise.
* c-c++-common/sso/q6.c: Likewise.
* c-c++-common/sso/q7.c: Likewise.
* c-c++-common/sso/q8.c: Likewise.
* c-c++-common/sso/q9.c: Likewise.
* c-c++-common/sso/r3.c: Likewise.
* c-c++-common/sso/r5.c: Likewise.
* c-c++-common/sso/r6.c: Likewise.
* c-c++-common/sso/r7.c: Likewise.
* c-c++-common/sso/r8.c: Likewise.
* c-c++-common/sso/s3.c: Likewise.
* c-c++-common/sso/s5.c: Likewise.
* c-c++-common/sso/s6.c: Likewise.
* c-c++-common/sso/s7.c: Likewise.
* c-c++-common/sso/s8.c: Likewise.
* c-c++-common/sso/t1.c: Likewise.
* c-c++-common/sso/t13.c: Likewise.
* c-c++-common/sso/t2.c: Likewise.
* c-c++-common/sso/t3.c: Likewise.
* c-c++-common/sso/t4.c: Likewise.
* c-c++-common/sso/t5.c: Likewise.
* c-c++-common/sso/t6.c: Likewise.
* c-c++-common/sso/t7.c: Likewise.
* c-c++-common/sso/t8.c: Likewise.
* c-c++-common/sso/t9.c: Likewise.
* c-c++-common/sso/u5.c: Likewise.
* c-c++-common/sso/t6.c: Likewise.
* g++.dg/sso/sso.exp: New file.
* g++.dg/sso/auto-1.C: New file.
* g++.dg/sso/auto-2.C: New file.
* g++.dg/sso/auto-3.C: New file.
* g++.dg/sso/template-reference-1.C: New file.
* g++.dg/sso/template-reference-2.C: New file.
* g++.dg/sso/template-reference-3.C: New file.
* g++.dg/sso/template-reference-4.C: New file.
* g++.dg/sso-1.C: Modified.
---
 gcc/c-family/c-attribs.cc |  2 +-
 gcc/cp/call.cc| 17 ++-
 gcc/cp/class.cc   | 22 ++
 gcc/cp/cp-tree.h  |  3 +-
 gcc/cp/tree.cc|  5 ++-
 .../{gcc.dg => c-c++-common}/sso/dump.h   |  0
 .../{gcc.dg => c-c++-common}/sso/init1.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init13.h |  0
 .../{gcc.dg => c-c++-common}/sso/init2.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init3.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init4.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init5.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init6.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init7.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init8.h  |  0
 .../{gcc.dg => c-c++-common}/sso/init9.h  |  0
 .../{gcc.dg => c-c++-common}/sso/p1.c |  0
 .../{gcc.dg => c-c++-common}/sso/p13.c|  1 +
 .../{gcc.dg => c-c++-common}/sso/p2.c |  0
 .../{gcc.dg => c-c++-common}/sso/p3.c |  0
 .../{gcc.dg => c-c++-common}/sso/p4.c |  0
 .../{gcc.dg => c-c++-common}/sso/p5.c |  0
 .../{gcc.dg => 

[PATCH] aarch64 : Modify __ARM_ARCH as per latest ACLE

2021-03-04 Thread naveenh--- via Gcc-patches
From: Naveen H S 

Please find attached the patch that modifies "__ARM_ARCH" as per latest ACLE.
Built and tested the patch on aarch64-marvell-linux-gnu.
Please review the patch and let me know if it's okay.

2021-04-03  Naveen H S  

PR tree-optimization/99312

* config/aarch64/aarch64-arches.def (armv8.1-a): Modify ARCH_REV as per 
latest ACLE.
(armv8.2-a): Likewise.
(armv8.3-a): Likewise.
(armv8.4-a): Likewise.
(armv8.5-a): Likewise.
(armv8.6-a): Likewise.
---
 gcc/config/aarch64/aarch64-arches.def | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/gcc/config/aarch64/aarch64-arches.def 
b/gcc/config/aarch64/aarch64-arches.def
index b7497277bb8..acaf5566927 100644
--- a/gcc/config/aarch64/aarch64-arches.def
+++ b/gcc/config/aarch64/aarch64-arches.def
@@ -25,18 +25,19 @@
constant.  The CORE is the identifier for a core representative of
this architecture.  ARCH_IDENT is the architecture identifier.  It must be
unique and be syntactically valid to appear as part of an enum identifier.
-   ARCH_REV is an integer specifying the architecture major revision.
+   ARCH_REV is an integer (X * 100 + Y  E.g. for Armv8.1 it's 801. Except for
+   Armv8-a which is still 8) specifying the architecture major revision.
FLAGS are the flags implied by the architecture.
Due to the assumptions about the positions of these fields in config.gcc,
the NAME should be kept as the first argument and FLAGS as the last.  */
 
 AARCH64_ARCH("armv8-a",  generic,   8A,8,  
AARCH64_FL_FOR_ARCH8)
-AARCH64_ARCH("armv8.1-a", generic,  8_1A,  8,  
AARCH64_FL_FOR_ARCH8_1)
-AARCH64_ARCH("armv8.2-a", generic,  8_2A,  8,  
AARCH64_FL_FOR_ARCH8_2)
-AARCH64_ARCH("armv8.3-a", generic,  8_3A,  8,  
AARCH64_FL_FOR_ARCH8_3)
-AARCH64_ARCH("armv8.4-a", generic,  8_4A,  8,  
AARCH64_FL_FOR_ARCH8_4)
-AARCH64_ARCH("armv8.5-a", generic,  8_5A,  8,  
AARCH64_FL_FOR_ARCH8_5)
-AARCH64_ARCH("armv8.6-a", generic,  8_6A,  8,  
AARCH64_FL_FOR_ARCH8_6)
+AARCH64_ARCH("armv8.1-a", generic,  8_1A,  801,  
AARCH64_FL_FOR_ARCH8_1)
+AARCH64_ARCH("armv8.2-a", generic,  8_2A,  802,  
AARCH64_FL_FOR_ARCH8_2)
+AARCH64_ARCH("armv8.3-a", generic,  8_3A,  803,  
AARCH64_FL_FOR_ARCH8_3)
+AARCH64_ARCH("armv8.4-a", generic,  8_4A,  804,  
AARCH64_FL_FOR_ARCH8_4)
+AARCH64_ARCH("armv8.5-a", generic,  8_5A,  805,  
AARCH64_FL_FOR_ARCH8_5)
+AARCH64_ARCH("armv8.6-a", generic,  8_6A,  806,  
AARCH64_FL_FOR_ARCH8_6)
 AARCH64_ARCH("armv8-r",   generic,  8R  ,  8,  
AARCH64_FL_FOR_ARCH8_R)
 
 #undef AARCH64_ARCH
-- 
2.11.0