This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch, mips, tree] align microMIPS functions to 16 bits with -Os


Catherine included an earlier version of this patch with the microMIPS submission a couple years ago:

https://gcc.gnu.org/ml/gcc-patches/2012-07/msg00972.html

Richard's response was:

Looks like the wrong place to do this.  Please treat this as a separate
patch and get a tree expert to comment.

So, here is the separate patch, finally. :-) Can a tree expert comment? I dug around and didn't see another obvious hook to set function alignment in a target-specific way depending on attributes of the function.

Besides the new test cases, I regression-tested this on mips-sde-elf using Mentor's usual assortment of multilibs, specifically including one for microMIPS.

-Sandra


2014-05-19  Iain Sandoe  <iain@codesourcery.com>
	    Catherine Moore  <clm@codesourcery.com>
	    Sandra Loosemore  <sandra@codesourcery.com>

	gcc/
	* config/mips/mips.c (mips_set_current_function): Choose
	function alignment once the current mode is known.

	gcc/testsuite/
	* gcc.target/mips/umips-align-1.c: New.
	* gcc.target/mips/umips-align-2.c: New.
	* gcc.target/mips/umips-align-3.c: New.
	* gcc.target/mips/mips.exp: Add interlink-compressed to
	-mfoo/-mno-foo options.
Index: gcc/config/mips/mips.c
===================================================================
--- gcc/config/mips/mips.c	(revision 210478)
+++ gcc/config/mips/mips.c	(working copy)
@@ -16822,6 +16822,13 @@ static void
 mips_set_current_function (tree fndecl)
 {
   mips_set_compression_mode (mips_get_compress_mode (fndecl));
+
+  if (fndecl
+      && TARGET_MICROMIPS
+      && optimize_size
+      && !TARGET_INTERLINK_COMPRESSED
+      && !DECL_USER_ALIGN (fndecl))
+    DECL_ALIGN (fndecl) = 16;
 }
 
 /* Allocate a chunk of memory for per-function machine-dependent data.  */
Index: gcc/testsuite/gcc.target/mips/umips-align-1.c
===================================================================
--- gcc/testsuite/gcc.target/mips/umips-align-1.c	(revision 0)
+++ gcc/testsuite/gcc.target/mips/umips-align-1.c	(revision 0)
@@ -0,0 +1,14 @@
+/* { dg-options "(-mmicromips) -mno-interlink-compressed" } */
+/* { dg-skip-if "code size optimization" { *-*-* } { "*" } { "-Os" } } */
+
+/* Check that microMIPS functions are aligned on 16-bit (2^1 byte)
+   boundaries with -Os.  */
+
+int MICROMIPS
+f (int x)
+{
+  return x + 42;
+}
+
+/* { dg-final { scan-assembler "\t\\.align\t1" } } */
+
Index: gcc/testsuite/gcc.target/mips/umips-align-2.c
===================================================================
--- gcc/testsuite/gcc.target/mips/umips-align-2.c	(revision 0)
+++ gcc/testsuite/gcc.target/mips/umips-align-2.c	(revision 0)
@@ -0,0 +1,13 @@
+/* { dg-options "(-mmicromips) -minterlink-compressed" } */
+/* { dg-skip-if "code size optimization" { *-*-* } { "*" } { "-Os" } } */
+
+/* Check that -minterlink-compressed suppresses 16-bit alignment of
+   microMIPS functions with -Os.  */
+
+int MICROMIPS
+f (int x)
+{
+  return x + 42;
+}
+
+/* { dg-final { scan-assembler-not "\t\\.align\t1" } } */
Index: gcc/testsuite/gcc.target/mips/umips-align-3.c
===================================================================
--- gcc/testsuite/gcc.target/mips/umips-align-3.c	(revision 0)
+++ gcc/testsuite/gcc.target/mips/umips-align-3.c	(revision 0)
@@ -0,0 +1,14 @@
+/* { dg-options "(-mmicromips) -mno-interlink-compressed" } */
+/* { dg-skip-if "code size optimization" { *-*-* } { "*" } { "-Os" } } */
+
+/* Check that explicit alignment attribute suppresses 16-bit alignment of
+   microMIPS functions with -Os.  */
+
+int MICROMIPS
+__attribute__ ((aligned (16)))
+f (int x) 
+{
+  return x + 42;
+}
+
+/* { dg-final { scan-assembler-not "\t\\.align\t1" } } */
Index: gcc/testsuite/gcc.target/mips/mips.exp
===================================================================
--- gcc/testsuite/gcc.target/mips/mips.exp	(revision 210478)
+++ gcc/testsuite/gcc.target/mips/mips.exp	(working copy)
@@ -260,6 +260,7 @@ foreach option {
     fix-r10000
     fix-vr4130
     gpopt
+    interlink-compressed
     local-sdata
     long-calls
     paired-single

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]