Hi Paul,
Probably the patch in the original message is broken somehow. Anyway I
attach updated patch to this mail.
$ svn up
Updating '.':
At revision 251918.
$ patch -p0 < ~/add_short_call_attribute.patch
patching file gcc/config/mips/mips.c
patching file gcc/doc/extend.texi
patching file gcc/testsuite/gcc.target/mips/near-far-1.c
patching file gcc/testsuite/gcc.target/mips/near-far-2.c
patching file gcc/testsuite/gcc.target/mips/near-far-3.c
patching file gcc/testsuite/gcc.target/mips/near-far-4.c
On Sat, Sep 09, 2017 at 11:26:57AM +0800, Paul Hua wrote:
> I would like to testing your patch on mips64el target. but your patch
> can't apply to current trunk.
>
> On Thu, Sep 7, 2017 at 7:22 PM, Simon Atanasyan <[email protected]> wrote:
> > This is a ping for a small MIPS specific patch adds `short_call`
> > synonym for existing `near` attribute. The patch has not been approved
> > or commented on.
> >
> > Add 'short_call' attribute for MIPS targets.
> > https://gcc.gnu.org/ml/gcc-patches/2017-08/msg01280.html
--
Simon Atanasyan
Index: gcc/config/mips/mips.c
===================================================================
--- gcc/config/mips/mips.c (revision 251917)
+++ gcc/config/mips/mips.c (working copy)
@@ -598,6 +598,7 @@ static const struct attribute_spec mips_attribute_
/* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
om_diagnostic } */
{ "long_call", 0, 0, false, true, true, NULL, false },
+ { "short_call", 0, 0, false, true, true, NULL, false },
{ "far", 0, 0, false, true, true, NULL, false },
{ "near", 0, 0, false, true, true, NULL, false },
/* We would really like to treat "mips16" and "nomips16" as type
@@ -1171,13 +1172,14 @@ mflip_mips16_use_mips16_p (tree decl)
return *slot;
}
-/* Predicates to test for presence of "near" and "far"/"long_call"
+/* Predicates to test for presence of "near"/"short_call" and "far"/"long_call"
attributes on the given TYPE. */
static bool
mips_near_type_p (const_tree type)
{
- return lookup_attribute ("near", TYPE_ATTRIBUTES (type)) != NULL;
+ return (lookup_attribute ("short_call", TYPE_ATTRIBUTES (type)) != NULL
+ || lookup_attribute ("near", TYPE_ATTRIBUTES (type)) != NULL);
}
static bool
Index: gcc/doc/extend.texi
===================================================================
--- gcc/doc/extend.texi (revision 251917)
+++ gcc/doc/extend.texi (working copy)
@@ -4528,10 +4528,12 @@ void __attribute__ ((interrupt("vector=hw3"))) v9
@end smallexample
@item long_call
+@itemx short_call
@itemx near
@itemx far
@cindex indirect calls, MIPS
@cindex @code{long_call} function attribute, MIPS
+@cindex @code{short_call} function attribute, MIPS
@cindex @code{near} function attribute, MIPS
@cindex @code{far} function attribute, MIPS
These attributes specify how a particular function is called on MIPS@.
@@ -4539,8 +4541,9 @@ The attributes override the @option{-mlong-calls}
command-line switch. The @code{long_call} and @code{far} attributes are
synonyms, and cause the compiler to always call
the function by first loading its address into a register, and then using
-the contents of that register. The @code{near} attribute has the opposite
-effect; it specifies that non-PIC calls should be made using the more
+the contents of that register. The @code{short_call} and @code{near}
+attributes are synonyms, and have the opposite
+effect; they specify that non-PIC calls should be made using the more
efficient @code{jal} instruction.
@item mips16
Index: gcc/testsuite/gcc.target/mips/near-far-1.c
===================================================================
--- gcc/testsuite/gcc.target/mips/near-far-1.c (revision 251917)
+++ gcc/testsuite/gcc.target/mips/near-far-1.c (working copy)
@@ -3,6 +3,7 @@
extern int long_call_func () __attribute__((long_call));
extern int far_func () __attribute__((far));
+extern int short_call_func () __attribute__((short_call));
extern int near_func () __attribute__((near));
extern int normal_func ();
@@ -10,6 +11,7 @@ int test ()
{
return (long_call_func ()
+ far_func ()
+ + short_call_func ()
+ near_func ()
+ normal_func ());
}
@@ -16,5 +18,6 @@ int test ()
/* { dg-final { scan-assembler-not "\tjal\tlong_call_func\n" } } */
/* { dg-final { scan-assembler-not "\tjal\tfar_func\n" } } */
+/* { dg-final { scan-assembler "\t(jal(|s)|balc)\tshort_call_func\n" } } */
/* { dg-final { scan-assembler "\t(jal(|s)|balc)\tnear_func\n" } } */
/* { dg-final { scan-assembler-not "\tjal\tnormal_func\n" } } */
Index: gcc/testsuite/gcc.target/mips/near-far-2.c
===================================================================
--- gcc/testsuite/gcc.target/mips/near-far-2.c (revision 251917)
+++ gcc/testsuite/gcc.target/mips/near-far-2.c (working copy)
@@ -3,6 +3,7 @@
extern int long_call_func () __attribute__((long_call));
extern int far_func () __attribute__((far));
+extern int short_call_func () __attribute__((short_call));
extern int near_func () __attribute__((near));
extern int normal_func ();
@@ -10,6 +11,7 @@ int test ()
{
return (long_call_func ()
+ far_func ()
+ + short_call_func ()
+ near_func ()
+ normal_func ());
}
@@ -16,5 +18,6 @@ int test ()
/* { dg-final { scan-assembler-not "\tjal(|s)\tlong_call_func\n" } } */
/* { dg-final { scan-assembler-not "\tjal(|s)\tfar_func\n" } } */
+/* { dg-final { scan-assembler "\t(jal(|s)|balc)\tshort_call_func\n" } } */
/* { dg-final { scan-assembler "\t(jal(|s)|balc)\tnear_func\n" } } */
/* { dg-final { scan-assembler "\t(jal(|s)|balc)\tnormal_func\n" } } */
Index: gcc/testsuite/gcc.target/mips/near-far-3.c
===================================================================
--- gcc/testsuite/gcc.target/mips/near-far-3.c (revision 251917)
+++ gcc/testsuite/gcc.target/mips/near-far-3.c (working copy)
@@ -3,6 +3,7 @@
NOMIPS16 extern int long_call_func () __attribute__((long_call));
NOMIPS16 extern int far_func () __attribute__((far));
+NOMIPS16 extern int short_call_func () __attribute__((short_call));
NOMIPS16 extern int near_func () __attribute__((near));
NOMIPS16 extern int normal_func ();
@@ -10,8 +11,10 @@ NOMIPS16 int test1 () { return long_call_func ();
NOMIPS16 int test2 () { return far_func (); }
NOMIPS16 int test3 () { return near_func (); }
NOMIPS16 int test4 () { return normal_func (); }
+NOMIPS16 int test5 () { return short_call_func (); }
/* { dg-final { scan-assembler-not "\tj\tlong_call_func\n" } } */
/* { dg-final { scan-assembler-not "\tj\tfar_func\n" } } */
/* { dg-final { scan-assembler "\t(j(|al|als)|b(|al)c)\tnear_func\n" } } */
/* { dg-final { scan-assembler-not "\tj\tnormal_func\n" } } */
+/* { dg-final { scan-assembler "\t(j(|al|als)|b(|al)c)\tshort_call_func\n" } } */
Index: gcc/testsuite/gcc.target/mips/near-far-4.c
===================================================================
--- gcc/testsuite/gcc.target/mips/near-far-4.c (revision 251917)
+++ gcc/testsuite/gcc.target/mips/near-far-4.c (working copy)
@@ -3,6 +3,7 @@
NOMIPS16 extern int long_call_func () __attribute__((long_call));
NOMIPS16 extern int far_func () __attribute__((far));
+NOMIPS16 extern int short_call_func () __attribute__((short_call));
NOMIPS16 extern int near_func () __attribute__((near));
NOMIPS16 extern int normal_func ();
@@ -10,8 +11,10 @@ NOMIPS16 int test1 () { return long_call_func ();
NOMIPS16 int test2 () { return far_func (); }
NOMIPS16 int test3 () { return near_func (); }
NOMIPS16 int test4 () { return normal_func (); }
+NOMIPS16 int test5 () { return short_call_func (); }
/* { dg-final { scan-assembler-not "\tj\tlong_call_func\n" } } */
/* { dg-final { scan-assembler-not "\tj\tfar_func\n" } } */
/* { dg-final { scan-assembler "\t(j(|al|als)|b(|al)c)\tnear_func\n" } } */
/* { dg-final { scan-assembler "\t(j(|al|als)|b(|al)c)\tnormal_func\n" } } */
+/* { dg-final { scan-assembler "\t(j(|al|als)|b(|al)c)\tshort_call_func\n" } } */