atanasyan created this revision. atanasyan added a project: clang. Herald added a subscriber: arichardson.
This change enables `long_call/short_call/far/near`, `micromips`, and `interrupt` attributes on MIPS64 targets. In case of using the `mips16` attribute with any ABI except `O32` compiler shows an error. Repository: rL LLVM https://reviews.llvm.org/D36208 Files: include/clang/Basic/Attr.td include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDeclAttr.cpp test/CodeGen/long-call-attr.c test/CodeGen/micromips-attr.c test/CodeGen/mips-interrupt-attr.c test/Sema/attr-long-call.c test/Sema/attr-micromips64.c test/Sema/mips-interrupt-attr64.c
Index: test/Sema/mips-interrupt-attr64.c =================================================================== --- /dev/null +++ test/Sema/mips-interrupt-attr64.c @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 %s -triple mips64-img-elf -verify -fsyntax-only +struct a { int b; }; + +struct a test __attribute__((interrupt)); // expected-warning {{'interrupt' attribute only applies to functions and methods}} + +__attribute__((interrupt("EIC"))) void foo1() {} // expected-warning {{'interrupt' attribute argument not supported: 'EIC'}} + +__attribute__((interrupt("eic", 1))) void foo2() {} // expected-error {{'interrupt' attribute takes no more than 1 argument}} + +__attribute__((interrupt("eic"))) void foo3() {} +__attribute__((interrupt("vector=sw0"))) void foo4() {} +__attribute__((interrupt("vector=hw0"))) void foo5() {} +__attribute__((interrupt("vector=hw1"))) void foo6() {} +__attribute__((interrupt("vector=hw2"))) void foo7() {} +__attribute__((interrupt("vector=hw3"))) void foo8() {} +__attribute__((interrupt("vector=hw4"))) void foo9() {} +__attribute__((interrupt("vector=hw5"))) void fooa() {} +__attribute__((interrupt(""))) void food() {} + +__attribute__((interrupt)) int foob() {return 0;} // expected-warning {{MIPS 'interrupt' attribute only applies to functions that have a 'void' return type}} +__attribute__((interrupt())) void fooc(int a) {} // expected-warning {{MIPS 'interrupt' attribute only applies to functions that have no parameters}} +__attribute__((interrupt,mips16)) void fooe() {} // expected-error {{'mips16' attribute is supported by o32 ABI only}} +__attribute__((mips16,interrupt)) void foof() {} // expected-error {{'mips16' attribute is supported by o32 ABI only}} +__attribute__((interrupt)) __attribute__ ((mips16)) void foo10() {} // expected-error {{'mips16' attribute is supported by o32 ABI only}} +__attribute__((mips16)) __attribute ((interrupt)) void foo11() {} // expected-error {{'mips16' attribute is supported by o32 ABI only}} Index: test/Sema/attr-micromips64.c =================================================================== --- /dev/null +++ test/Sema/attr-micromips64.c @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -triple mips64-linux-gnu -fsyntax-only -verify %s + +__attribute__((nomicromips(0))) void foo1(); // expected-error {{'nomicromips' attribute takes no arguments}} +__attribute__((micromips(1))) void foo2(); // expected-error {{'micromips' attribute takes no arguments}} + +__attribute((nomicromips)) int a; // expected-error {{attribute only applies to functions}} +__attribute((micromips)) int b; // expected-error {{attribute only applies to functions}} + +__attribute__((micromips,mips16)) void foo5(); // expected-error {{'mips16' attribute is supported by o32 ABI only}} +__attribute__((mips16,micromips)) void foo6(); // expected-error {{'mips16' attribute is supported by o32 ABI only}} + +__attribute((micromips)) void foo7(); +__attribute((nomicromips)) void foo8(); +__attribute__((mips16)) void foo9(void) __attribute__((micromips)); // expected-error {{'mips16' attribute is supported by o32 ABI only}} Index: test/Sema/attr-long-call.c =================================================================== --- test/Sema/attr-long-call.c +++ test/Sema/attr-long-call.c @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -triple mips-linux-gnu -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple mips64-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}} Index: test/CodeGen/mips-interrupt-attr.c =================================================================== --- test/CodeGen/mips-interrupt-attr.c +++ test/CodeGen/mips-interrupt-attr.c @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -triple mipsel-unknown-linux -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple mips64-unknown-linux -emit-llvm -o - %s | FileCheck %s void __attribute__ ((interrupt("vector=sw0"))) isr_sw0 (void) Index: test/CodeGen/micromips-attr.c =================================================================== --- test/CodeGen/micromips-attr.c +++ test/CodeGen/micromips-attr.c @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -triple mips-linux-gnu -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple mips64-linux-gnu -emit-llvm -o - %s | FileCheck %s void __attribute__((micromips)) foo (void) {} Index: test/CodeGen/long-call-attr.c =================================================================== --- test/CodeGen/long-call-attr.c +++ test/CodeGen/long-call-attr.c @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -triple mips-linux-gnu -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple mips64-linux-gnu -emit-llvm -o - %s | FileCheck %s void __attribute__((long_call)) foo1 (void); void __attribute__((short_call)) foo4 (void); Index: lib/Sema/SemaDeclAttr.cpp =================================================================== --- lib/Sema/SemaDeclAttr.cpp +++ lib/Sema/SemaDeclAttr.cpp @@ -5424,6 +5424,8 @@ break; case llvm::Triple::mipsel: case llvm::Triple::mips: + case llvm::Triple::mips64el: + case llvm::Triple::mips64: handleMipsInterruptAttr(S, D, Attr); break; case llvm::Triple::x86: @@ -5974,11 +5976,19 @@ handleDLLAttr(S, D, Attr); break; case AttributeList::AT_Mips16: - handleSimpleAttributeWithExclusions<Mips16Attr, MicroMipsAttr, - MipsInterruptAttr>(S, D, Attr); + if (S.Context.getTargetInfo().getABI() != "o32") + S.Diag(Attr.getLoc(), diag::err_attribute_supported_by_o32) + << Attr.getName() << D->getLocation(); + else + handleSimpleAttributeWithExclusions<Mips16Attr, MicroMipsAttr, + MipsInterruptAttr>(S, D, Attr); break; case AttributeList::AT_NoMips16: - handleSimpleAttribute<NoMips16Attr>(S, D, Attr); + if (S.Context.getTargetInfo().getABI() != "o32") + S.Diag(Attr.getLoc(), diag::err_attribute_supported_by_o32) + << Attr.getName() << D->getLocation(); + else + handleSimpleAttribute<NoMips16Attr>(S, D, Attr); break; case AttributeList::AT_MicroMips: handleSimpleAttributeWithExclusions<MicroMipsAttr, Mips16Attr>(S, D, Attr); Index: include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -259,6 +259,8 @@ "a pointer as the first parameter|a %2 type as the second parameter}1">; def err_anyx86_interrupt_called : Error< "interrupt service routine cannot be called directly">; +def err_attribute_supported_by_o32: Error< + "%0 attribute is supported by o32 ABI only">; def warn_arm_interrupt_calling_convention : Warning< "call to function without interrupt attribute could clobber interruptee's VFP registers">, InGroup<Extra>; Index: include/clang/Basic/Attr.td =================================================================== --- include/clang/Basic/Attr.td +++ include/clang/Basic/Attr.td @@ -264,7 +264,7 @@ } def TargetARM : TargetArch<["arm", "thumb", "armeb", "thumbeb"]>; def TargetAVR : TargetArch<["avr"]>; -def TargetMips : TargetArch<["mips", "mipsel"]>; +def TargetMips : TargetArch<["mips", "mipsel", "mips64", "mips64el"]>; def TargetMSP430 : TargetArch<["msp430"]>; def TargetX86 : TargetArch<["x86"]>; def TargetAnyX86 : TargetArch<["x86", "x86_64"]>;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits