Message ID | CAGyS+DR0Z_jUmym1hhJzyLwj2AM9fh-q=s06hRBT0Lnfp-xeoQ@mail.gmail.com |
---|---|
State | New |
Headers | show |
Simon Atanasyan <simon@atanasyan.com> writes: > Currently GCC supports 'long_call', 'far', and 'near' attributes. The > 'long_call' and 'far' attributes are synonyms. This patch adds support > for the 'short_call' attribute as a synonym for `near` to make this list > complete, consistent with other targets, and compatible with attributes > supported by the Clang. Sorry for the slow reply. Thanks for keeping GCC and Clang in sync. > Tested on mipsel-linux-gnu. > > 2017-08-22 Simon Atanasyan <simon@atanasyan.com> As you do not have a personal copyright assignment on file please can you resubmit using your @imgtec.com address and use that address for the changelog. There are just a couple of indentation issues below as well. > 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. There should be one tab before the lines in each entry <tab>* <filename>, lines here should be wrapped at 74 cols. > > Index: gcc/config/mips/mips.c > =================================================================== > --- gcc/config/mips/mips.c (revision 251219) > +++ 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); The || here should be lined up under the 'l' of lookup_attribute above which will be 1-tab 2-space to save you figuring out the indent rules for GCC again. The space indents in the testcases below are fine as they match the existing lines. If you can repost with your @imgtec address then I'll approve that to commit. Thanks, Matthew
Here is the updated patch with chnaged e-mail address and fixed indentation issues: -8<-------------------- Currently GCC supports 'long_call', 'far', and 'near' attributes. The 'long_call' and 'far' attributes are synonyms. This patch adds support for the 'short_call' attribute as a synonym for `near` to make this list complete, consistent with other targets, and compatible with attributes supported by the Clang. Tested on mipsel-linux-gnu. 2017-08-18 Simon Atanasyan <Simon.Atanasyan@imgtec.com> 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. Index: gcc/config/mips/mips.c =================================================================== --- gcc/config/mips/mips.c (revision 251918) +++ 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 251918) +++ 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 251918) +++ 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 251918) +++ 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 251918) +++ 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 251918) +++ 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" } } */
Simon Atanasyan <simon@atanasyan.com> writes: > Here is the updated patch with chnaged e-mail address and fixed > indentation issues: > -8<-------------------- > Currently GCC supports 'long_call', 'far', and 'near' attributes. The > 'long_call' and 'far' attributes are synonyms. This patch adds support > for the 'short_call' attribute as a synonym for `near` to make this list > complete, consistent with other targets, and compatible with attributes > supported by the Clang. > > Tested on mipsel-linux-gnu. > > 2017-08-18 Simon Atanasyan <Simon.Atanasyan@imgtec.com> > > 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. OK to commit, thanks. Matthew
On Mon, Sep 11, 2017 at 03:26:52PM +0000, Matthew Fortune wrote: > Simon Atanasyan <simon@atanasyan.com> writes: > > Here is the updated patch with chnaged e-mail address and fixed > > indentation issues: > > -8<-------------------- > > Currently GCC supports 'long_call', 'far', and 'near' attributes. The > > 'long_call' and 'far' attributes are synonyms. This patch adds support > > for the 'short_call' attribute as a synonym for `near` to make this list > > complete, consistent with other targets, and compatible with attributes > > supported by the Clang. > > > > Tested on mipsel-linux-gnu. > > > > 2017-08-18 Simon Atanasyan <Simon.Atanasyan@imgtec.com> > > > > 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. > > OK to commit, thanks. Thanks for review. I do not have commit access. Could you commit the patch?
Simon Atanasyan <simon@atanasyan.com> writes: > On Mon, Sep 11, 2017 at 03:26:52PM +0000, Matthew Fortune wrote: > > Simon Atanasyan <simon@atanasyan.com> writes: > > > Here is the updated patch with chnaged e-mail address and fixed > > > indentation issues: > > > -8<-------------------- > > > Currently GCC supports 'long_call', 'far', and 'near' attributes. > > > The 'long_call' and 'far' attributes are synonyms. This patch adds > > > support for the 'short_call' attribute as a synonym for `near` to > > > make this list complete, consistent with other targets, and > > > compatible with attributes supported by the Clang. > > > > > > Tested on mipsel-linux-gnu. > > > > > > 2017-08-18 Simon Atanasyan <Simon.Atanasyan@imgtec.com> > > > > > > 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. > > > > OK to commit, thanks. > > Thanks for review. I do not have commit access. Could you commit the > patch? Sure, committed as r252006. Matthew
Index: gcc/config/mips/mips.c =================================================================== --- gcc/config/mips/mips.c (revision 251219) +++ 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 251219) +++ 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 251219) +++ 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 251219) +++ 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 251219) +++ 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 251219) +++ 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" } } */