r308719 - [mips] Add `short_call` to the set of `long_call/far/near` attributes

Simon Atanasyan via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 21 01:10:57 PDT 2017


Author: atanasyan
Date: Fri Jul 21 01:10:57 2017
New Revision: 308719

URL: http://llvm.org/viewvc/llvm-project?rev=308719&view=rev
Log:
[mips] Add `short_call` to the set of `long_call/far/near` attributes

MIPS gcc supports `long_call/far/near` attributes only, but other
targets have the `short_call` attribut, so let's support it for MIPS
for consistency.

Modified:
    cfe/trunk/include/clang/Basic/Attr.td
    cfe/trunk/include/clang/Basic/AttrDocs.td
    cfe/trunk/test/CodeGen/long-call-attr.c
    cfe/trunk/test/Sema/attr-long-call.c

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=308719&r1=308718&r2=308719&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Fri Jul 21 01:10:57 2017
@@ -1195,7 +1195,7 @@ def MipsLongCall : InheritableAttr, Targ
 }
 
 def MipsShortCall : InheritableAttr, TargetSpecificAttr<TargetMips> {
-  let Spellings = [GCC<"near">];
+  let Spellings = [GCC<"short_call">, GCC<"near">];
   let Subjects = SubjectList<[Function]>;
   let Documentation = [MipsShortCallStyleDocs];
 }

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=308719&r1=308718&r2=308719&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Fri Jul 21 01:10:57 2017
@@ -1348,13 +1348,14 @@ def MipsShortCallStyleDocs : Documentati
   let Category = DocCatFunction;
   let Content = [{
 Clang supports the ``__attribute__((long_call))``, ``__attribute__((far))``,
-and ``__attribute__((near))`` attributes on MIPS targets. These attributes may
-only be added to function declarations and change the code generated
-by the compiler when directly calling the function. The ``near`` attribute
-allows calls to the function to be made using the ``jal`` instruction, which
-requires the function to be located in the same naturally aligned 256MB
-segment as the caller.  The ``long_call`` and ``far`` attributes are synonyms
-and require the use of a different call sequence that works regardless
+``__attribute__((short__call))``, and ``__attribute__((near))`` attributes
+on MIPS targets. These attributes may only be added to function declarations
+and change the code generated by the compiler when directly calling
+the function. The ``short_call`` and ``near`` attributes are synonyms and
+allow calls to the function to be made using the ``jal`` instruction, which
+requires the function to be located in the same naturally aligned 256MB segment
+as the caller.  The ``long_call`` and ``far`` attributes are synonyms and
+require the use of a different call sequence that works regardless
 of the distance between the functions.
 
 These attributes have no effect for position-independent code.

Modified: cfe/trunk/test/CodeGen/long-call-attr.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/long-call-attr.c?rev=308719&r1=308718&r2=308719&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/long-call-attr.c (original)
+++ cfe/trunk/test/CodeGen/long-call-attr.c Fri Jul 21 01:10:57 2017
@@ -1,17 +1,20 @@
 // RUN: %clang_cc1 -triple mips-linux-gnu -emit-llvm  -o  - %s | FileCheck %s
 
 void __attribute__((long_call)) foo1 (void);
+void __attribute__((short_call)) foo4 (void);
 
 void __attribute__((far)) foo2 (void) {}
 
 // CHECK: define void @foo2() [[FAR:#[0-9]+]]
 
-void __attribute__((near)) foo3 (void) { foo1(); }
+void __attribute__((near)) foo3 (void) { foo1(); foo4(); }
 
 // CHECK: define void @foo3() [[NEAR:#[0-9]+]]
 
 // CHECK: declare void @foo1() [[LONGDECL:#[0-9]+]]
+// CHECK: declare void @foo4() [[SHORTDECL:#[0-9]+]]
 
 // CHECK: attributes [[FAR]] = { {{.*}} "long-call" {{.*}} }
 // CHECK: attributes [[NEAR]] = { {{.*}} "short-call" {{.*}} }
 // CHECK: attributes [[LONGDECL]] = { {{.*}} "long-call" {{.*}} }
+// CHECK: attributes [[SHORTDECL]] = { {{.*}} "short-call" {{.*}} }

Modified: cfe/trunk/test/Sema/attr-long-call.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-long-call.c?rev=308719&r1=308718&r2=308719&view=diff
==============================================================================
--- cfe/trunk/test/Sema/attr-long-call.c (original)
+++ cfe/trunk/test/Sema/attr-long-call.c Fri Jul 21 01:10:57 2017
@@ -1,18 +1,25 @@
 // RUN: %clang_cc1 -triple mips-linux-gnu -fsyntax-only -verify %s
 
 __attribute__((long_call(0))) void foo1();  // expected-error {{'long_call' attribute takes no arguments}}
+__attribute__((short_call(0))) void foo9();  // expected-error {{'short_call' attribute takes no arguments}}
 __attribute__((far(0))) void foo2();  // expected-error {{'far' attribute takes no arguments}}
 __attribute__((near(0))) void foo3();  // expected-error {{'near' attribute takes no arguments}}
 
 __attribute((long_call)) int a; // expected-warning {{attribute only applies to functions}}
+__attribute((short_call)) int d; // expected-warning {{attribute only applies to functions}}
 __attribute((far)) int a; // expected-warning {{attribute only applies to functions}}
 __attribute((near)) int a; // expected-warning {{attribute only applies to functions}}
 
 __attribute((long_call)) void foo4();
+__attribute((short_call)) void foo10();
 __attribute((far)) void foo5();
 __attribute((near)) void foo6();
 
 __attribute((long_call, far)) void foo7();
+__attribute((short_call, near)) void foo11();
 
 __attribute((far, near)) void foo8(); // expected-error {{'far' and 'near' attributes are not compatible}} \
                                       // expected-note {{conflicting attribute is here}}
+
+__attribute((short_call, long_call)) void foo12(); // expected-error {{'short_call' and 'long_call' attributes are not compatible}} \
+                                                   // expected-note {{conflicting attribute is here}}




More information about the cfe-commits mailing list