public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Umesh Kalappa <umesh.kalappa0@gmail.com>
To: gcc-patches@gcc.gnu.org
Subject: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84762
Date: Tue, 11 Dec 2018 12:01:00 -0000	[thread overview]
Message-ID: <CAGfacvR-LJbkXGTET2x5zmN67pPigoUkpdwLSxZJurVYpBHNxA@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 148 bytes --]

Hi All,

Please find the attached patch for the subjected issue .

Do please let me know your thoughts and comments on the same .

Thank you
~Umesh

[-- Attachment #2: pr84762.patch --]
[-- Type: application/octet-stream, Size: 5980 bytes --]

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ee5f183..d1c0edb 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2018-12-06  Lokesh Janghel  <lokeshjanghel91@gmail.com>
+
+        PR target/84762
+        * config/rs6000/rs6000.c (rs6000_return_in_msb): Retrun in svr4 for
+	 small struct value.
+	 (rs6000_option_override_internal): Modify the condition for aix or
+	 svr4. 
+	* config/rs6000/rs6000.opt : Modify the -msvr4-struct-return option.
+	* config/rs6000/rs6000-opts.h : Add enum for svr4 option (Big endian 
+	and Little endian).
+
 2018-11-21  Uros Bizjak  <ubizjak@gmail.com>
 
 	Revert the revert:
diff --git a/gcc/config/rs6000/rs6000-opts.h b/gcc/config/rs6000/rs6000-opts.h
index 1212d11..c405a37 100644
--- a/gcc/config/rs6000/rs6000-opts.h
+++ b/gcc/config/rs6000/rs6000-opts.h
@@ -130,6 +130,14 @@ enum rs6000_cmodel {
   CMODEL_LARGE
 };
 
+/* Return small structs in register,
+   gnu: LSB-aligned,
+   standard: MSB-aligned    */
+enum rs6000_svr4_struct_return {
+  SVR4_STRUCT_RETURN_GNU=1,
+  SVR4_STRUCT_RETURN_STD
+};
+
 /* Describe which vector unit to use for a given machine mode.  The
    VECTOR_MEM_* and VECTOR_UNIT_* macros assume that Altivec, VSX, and
    P8_VECTOR are contiguous.  */
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 2765263..4751b61 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -4632,7 +4632,8 @@ rs6000_option_override_internal (bool global_init_p)
       /* Set aix_struct_return last, after the ABI is determined.
 	 If -maix-struct-return or -msvr4-struct-return was explicitly
 	 used, don't override with the ABI default.  */
-      if (!global_options_set.x_aix_struct_return)
+      if (!global_options_set.x_aix_struct_return
+	   && !rs6000_current_svr4_struct_return)
 	aix_struct_return = (DEFAULT_ABI != ABI_V4 || DRAFT_V4_STRUCT_RET);
 
 #if 0
@@ -10616,8 +10617,10 @@ rs6000_return_in_memory (const_tree type, const_tree fntype ATTRIBUTE_UNUSED)
 static bool
 rs6000_return_in_msb (const_tree valtype)
 {
-  return (DEFAULT_ABI == ABI_ELFv2
-	  && BYTES_BIG_ENDIAN
+  return ((DEFAULT_ABI == ABI_ELFv2
+          || (DEFAULT_ABI == ABI_V4
+          && rs6000_current_svr4_struct_return == SVR4_STRUCT_RETURN_STD))
+ 	  && BYTES_BIG_ENDIAN
 	  && AGGREGATE_TYPE_P (valtype)
 	  && (rs6000_function_arg_padding (TYPE_MODE (valtype), valtype)
 	      == PAD_UPWARD));
diff --git a/gcc/config/rs6000/rs6000.opt b/gcc/config/rs6000/rs6000.opt
index 7042859..a49fb56 100644
--- a/gcc/config/rs6000/rs6000.opt
+++ b/gcc/config/rs6000/rs6000.opt
@@ -92,6 +92,10 @@ unsigned char rs6000_alignment_flags
 TargetVariable
 enum rs6000_cmodel rs6000_current_cmodel = CMODEL_SMALL
 
+;; Retrun small struct in register
+TargetVariable
+enum rs6000_svr4_struct_return rs6000_current_svr4_struct_return = SVR4_STRUCT_RETURN_GNU
+
 ;; What type of reciprocal estimation instructions to generate
 TargetVariable
 unsigned int rs6000_recip_control
@@ -258,9 +262,18 @@ maix-struct-return
 Target Report RejectNegative Var(aix_struct_return) Save
 Return all structures in memory (AIX default).
 
-msvr4-struct-return
-Target Report RejectNegative Var(aix_struct_return,0) Save
-Return small structures in registers (SVR4 default).
+msvr4-struct-return=
+Target RejectNegative Joined Enum(rs6000_svr4_struct_return)  Var(rs6000_current_svr4_struct_return)
+-msvr4-struct-return=[standard,gnu] Return small structures in registers (SVR4 default).
+
+Enum
+Name(rs6000_svr4_struct_return) Type(enum rs6000_svr4_struct_return)
+
+EnumValue
+Enum(rs6000_svr4_struct_return) String(standard) Value(SVR4_STRUCT_RETURN_STD) 
+
+EnumValue
+Enum(rs6000_svr4_struct_return) String(gnu) Value(SVR4_STRUCT_RETURN_GNU) 
 
 mxl-compat
 Target Report Var(TARGET_XL_COMPAT) Save
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index afd928e..8f36fbd 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2018-12-06  Lokesh Janghel  <lokeshjanghel91@gmail.com>
+
+        PR target/84762
+        * gcc.target/pr84762-1.c: New testcase.
+        * gcc.target/pr84762-2.c: New testcase.
+        * gcc.target/pr84762-3.c: New testcase.
+
 2018-11-21  Jakub Jelinek  <jakub@redhat.com>
 
 	PR c++/88122
diff --git a/gcc/testsuite/gcc.target/powerpc/pr84762-1.c b/gcc/testsuite/gcc.target/powerpc/pr84762-1.c
new file mode 100644
index 0000000..cb417d1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr84762-1.c
@@ -0,0 +1,9 @@
+/* { dg-do run { target powerpc*-*-* rs6000-*-* } } */
+struct smallstruct { char a; char b; char c; };
+
+struct smallstruct f(void)
+{
+  struct smallstruct s = { 0x11, 0x22, 0x33 };
+
+  return s;
+}
diff --git a/gcc/testsuite/gcc.target/powerpc/pr84762-2.c b/gcc/testsuite/gcc.target/powerpc/pr84762-2.c
new file mode 100644
index 0000000..44305f2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr84762-2.c
@@ -0,0 +1,12 @@
+/* { dg-do compile { target powerpc*-*-* rs6000-*-* } } */
+/* { dg-options "-O2 -msvr4-struct-return=gnu" } */
+/* { dg-final { scan-assembler-times "lis \[\n\]*,0x\[\n\]*" 1 } } */
+/* { dg-final { scan-assembler-times "ori \[\n\]*,\[\n\]*,0x\[\n\]*" 1 } } */
+struct smallstruct { char a; char b; char c; };
+
+struct smallstruct f(void)
+{
+  struct smallstruct s = { 0x11, 0x22, 0x33 };
+
+  return s;
+}
diff --git a/gcc/testsuite/gcc.target/powerpc/pr84762-3.c b/gcc/testsuite/gcc.target/powerpc/pr84762-3.c
new file mode 100644
index 0000000..f01dc83
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr84762-3.c
@@ -0,0 +1,12 @@
+/* { dg-do compile { target powerpc*-*-* rs6000-*-* } } */
+/* { dg-options "-O2 -msvr4-struct-return=standard" } */
+/* { dg-final { scan-assembler-times "lis \[\n\]*,0x\[\n\]*" 1 } } */
+/* { dg-final { scan-assembler-times "ori \[\n\]*,\[\n\]*,0x\[\n\]*" 1 } } */
+struct smallstruct { char a; char b; char c; };
+
+struct smallstruct f(void)
+{
+  struct smallstruct s = { 0x11, 0x22, 0x33 };
+
+  return s;
+}

             reply	other threads:[~2018-12-11 12:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-11 12:01 Umesh Kalappa [this message]
2018-12-11 12:28 ` https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84762 Jakub Jelinek
2018-12-11 13:30   ` https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84762 Jonathan Wakely
2018-12-11 14:47   ` https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84762 Umesh Kalappa
2018-12-11 13:53 ` https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84762 Segher Boessenkool
2018-12-11 15:08   ` https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84762 Umesh Kalappa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAGfacvR-LJbkXGTET2x5zmN67pPigoUkpdwLSxZJurVYpBHNxA@mail.gmail.com \
    --to=umesh.kalappa0@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).