Commit 8101ec85 by Simon Atanasyan Committed by Matthew Fortune

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
parent 45e3a33d
2017-09-12 Simon Atanasyan <simon.atanasyan@imgtec.com>
* 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 <jakub@redhat.com>
PR target/82112
......
......@@ -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
......
......@@ -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
......
2017-09-12 Simon Atanasyan <simon.atanasyan@imgtec.com>
* 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 <jakub@redhat.com>
PR target/82112
......
......@@ -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" } } */
......@@ -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" } } */
......@@ -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" } } */
......@@ -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" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment