From: Simon Atanasyan Date: Tue, 12 Sep 2017 12:51:40 +0000 (+0000) Subject: Add short_call function attribute for MIPS X-Git-Tag: upstream/12.2.0~37061 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8101ec8538ba93c76250d160f30015913c1f9a15;p=platform%2Fupstream%2Fgcc.git Add short_call function attribute for MIPS gcc/ * config/mips/mips.c (mips_attribute_table): Add 'short_call' attribute. (mips_near_type_p): Add 'short_call' attribute as a synonym for 'near'. * doc/extend.texi (short_call): Document new function attribute. gcc/testsuite * gcc.target/mips/near-far-1.c: Add check for 'short_call' attribute. * gcc.target/mips/near-far-2.c: Likewise. * gcc.target/mips/near-far-3.c: Likewise. * gcc.target/mips/near-far-4.c: Likewise. From-SVN: r252006 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 52085f8..67753a2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2017-09-12 Simon Atanasyan + + * config/mips/mips.c (mips_attribute_table): Add 'short_call' + attribute. + (mips_near_type_p): Add 'short_call' attribute as a synonym + for 'near'. + * doc/extend.texi (short_call): Document new function attribute. + 2017-09-12 Jakub Jelinek PR target/82112 diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index bb94405..5c9094b 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -598,6 +598,7 @@ static const struct attribute_spec mips_attribute_table[] = { /* { 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 diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 649be01..cd5733e 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -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} (@pxref{MIPS Options}) 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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2c04a2d..5d81c58 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2017-09-12 Simon Atanasyan + + * gcc.target/mips/near-far-1.c: Add check for 'short_call' + attribute. + * gcc.target/mips/near-far-2.c: Likewise. + * gcc.target/mips/near-far-3.c: Likewise. + * gcc.target/mips/near-far-4.c: Likewise. + 2017-09-12 Jakub Jelinek PR target/82112 diff --git a/gcc/testsuite/gcc.target/mips/near-far-1.c b/gcc/testsuite/gcc.target/mips/near-far-1.c index b746cf6..356f7ad 100644 --- a/gcc/testsuite/gcc.target/mips/near-far-1.c +++ b/gcc/testsuite/gcc.target/mips/near-far-1.c @@ -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,11 +11,13 @@ int test () { return (long_call_func () + far_func () + + short_call_func () + near_func () + normal_func ()); } /* { 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" } } */ diff --git a/gcc/testsuite/gcc.target/mips/near-far-2.c b/gcc/testsuite/gcc.target/mips/near-far-2.c index 2c140e2..2e8dbb1 100644 --- a/gcc/testsuite/gcc.target/mips/near-far-2.c +++ b/gcc/testsuite/gcc.target/mips/near-far-2.c @@ -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,11 +11,13 @@ int test () { return (long_call_func () + far_func () + + short_call_func () + near_func () + normal_func ()); } /* { 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" } } */ diff --git a/gcc/testsuite/gcc.target/mips/near-far-3.c b/gcc/testsuite/gcc.target/mips/near-far-3.c index 7bf3e14..19e1b3a 100644 --- a/gcc/testsuite/gcc.target/mips/near-far-3.c +++ b/gcc/testsuite/gcc.target/mips/near-far-3.c @@ -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" } } */ diff --git a/gcc/testsuite/gcc.target/mips/near-far-4.c b/gcc/testsuite/gcc.target/mips/near-far-4.c index cd12a1d..ac7d727 100644 --- a/gcc/testsuite/gcc.target/mips/near-far-4.c +++ b/gcc/testsuite/gcc.target/mips/near-far-4.c @@ -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" } } */