[llvm-branch-commits] [cfe-branch] r351441 - Merging r351344:
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Jan 17 05:31:58 PST 2019
Author: hans
Date: Thu Jan 17 05:31:58 2019
New Revision: 351441
URL: http://llvm.org/viewvc/llvm-project?rev=351441&view=rev
Log:
Merging r351344:
------------------------------------------------------------------------
r351344 | asl | 2019-01-16 14:44:01 +0100 (Wed, 16 Jan 2019) | 10 lines
[MSP430] Improve support of 'interrupt' attribute
* Accept as an argument constants in range 0..63 (aligned with TI headers and linker scripts provided with TI GCC toolchain).
* Emit function attribute 'interrupt'='xx' instead of aliases (used in the backend to create a section for particular interrupt vector).
* Add more diagnostics.
Patch by Kristina Bessonova!
Differential Revision: https://reviews.llvm.org/D56663
------------------------------------------------------------------------
Added:
cfe/branches/release_80/test/CodeGen/attr-msp430.c
- copied unchanged from r351344, cfe/trunk/test/CodeGen/attr-msp430.c
Modified:
cfe/branches/release_80/ (props changed)
cfe/branches/release_80/include/clang/Basic/DiagnosticSemaKinds.td
cfe/branches/release_80/lib/CodeGen/TargetInfo.cpp
cfe/branches/release_80/lib/Sema/SemaDeclAttr.cpp
cfe/branches/release_80/test/Sema/attr-msp430.c
Propchange: cfe/branches/release_80/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jan 17 05:31:58 2019
@@ -1,4 +1,4 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:351334,351340,351360
+/cfe/trunk:351334,351340,351344,351360
/cfe/trunk/test:170344
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_80/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_80/include/clang/Basic/DiagnosticSemaKinds.td?rev=351441&r1=351440&r2=351441&view=diff
==============================================================================
--- cfe/branches/release_80/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/branches/release_80/include/clang/Basic/DiagnosticSemaKinds.td Thu Jan 17 05:31:58 2019
@@ -274,6 +274,10 @@ def warn_riscv_interrupt_attribute : War
"RISC-V 'interrupt' attribute only applies to functions that have "
"%select{no parameters|a 'void' return type}0">,
InGroup<IgnoredAttributes>;
+def warn_msp430_interrupt_attribute : Warning<
+ "MSP430 'interrupt' attribute only applies to functions that have "
+ "%select{no parameters|a 'void' return type}0">,
+ InGroup<IgnoredAttributes>;
def warn_unused_parameter : Warning<"unused parameter %0">,
InGroup<UnusedParameter>, DefaultIgnore;
def warn_unused_variable : Warning<"unused variable %0">,
Modified: cfe/branches/release_80/lib/CodeGen/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_80/lib/CodeGen/TargetInfo.cpp?rev=351441&r1=351440&r2=351441&view=diff
==============================================================================
--- cfe/branches/release_80/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/branches/release_80/lib/CodeGen/TargetInfo.cpp Thu Jan 17 05:31:58 2019
@@ -6774,21 +6774,19 @@ void MSP430TargetCodeGenInfo::setTargetA
if (GV->isDeclaration())
return;
if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D)) {
- if (const MSP430InterruptAttr *attr = FD->getAttr<MSP430InterruptAttr>()) {
- // Handle 'interrupt' attribute:
- llvm::Function *F = cast<llvm::Function>(GV);
+ const auto *InterruptAttr = FD->getAttr<MSP430InterruptAttr>();
+ if (!InterruptAttr)
+ return;
- // Step 1: Set ISR calling convention.
- F->setCallingConv(llvm::CallingConv::MSP430_INTR);
+ // Handle 'interrupt' attribute:
+ llvm::Function *F = cast<llvm::Function>(GV);
- // Step 2: Add attributes goodness.
- F->addFnAttr(llvm::Attribute::NoInline);
+ // Step 1: Set ISR calling convention.
+ F->setCallingConv(llvm::CallingConv::MSP430_INTR);
- // Step 3: Emit ISR vector alias.
- unsigned Num = attr->getNumber() / 2;
- llvm::GlobalAlias::create(llvm::Function::ExternalLinkage,
- "__isr_" + Twine(Num), F);
- }
+ // Step 2: Add attributes goodness.
+ F->addFnAttr(llvm::Attribute::NoInline);
+ F->addFnAttr("interrupt", llvm::utostr(InterruptAttr->getNumber()));
}
}
Modified: cfe/branches/release_80/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_80/lib/Sema/SemaDeclAttr.cpp?rev=351441&r1=351440&r2=351441&view=diff
==============================================================================
--- cfe/branches/release_80/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/branches/release_80/lib/Sema/SemaDeclAttr.cpp Thu Jan 17 05:31:58 2019
@@ -5377,6 +5377,27 @@ static void handleARMInterruptAttr(Sema
}
static void handleMSP430InterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+ // MSP430 'interrupt' attribute is applied to
+ // a function with no parameters and void return type.
+ if (!isFunctionOrMethod(D)) {
+ S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type)
+ << "'interrupt'" << ExpectedFunctionOrMethod;
+ return;
+ }
+
+ if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) {
+ S.Diag(D->getLocation(), diag::warn_msp430_interrupt_attribute)
+ << 0;
+ return;
+ }
+
+ if (!getFunctionOrMethodResultType(D)->isVoidType()) {
+ S.Diag(D->getLocation(), diag::warn_msp430_interrupt_attribute)
+ << 1;
+ return;
+ }
+
+ // The attribute takes one integer argument.
if (!checkAttributeNumArgs(S, AL, 1))
return;
@@ -5386,8 +5407,6 @@ static void handleMSP430InterruptAttr(Se
return;
}
- // FIXME: Check for decl - it should be void ()(void).
-
Expr *NumParamsExpr = static_cast<Expr *>(AL.getArgAsExpr(0));
llvm::APSInt NumParams(32);
if (!NumParamsExpr->isIntegerConstantExpr(NumParams, S.Context)) {
@@ -5396,9 +5415,9 @@ static void handleMSP430InterruptAttr(Se
<< NumParamsExpr->getSourceRange();
return;
}
-
+ // The argument should be in range 0..63.
unsigned Num = NumParams.getLimitedValue(255);
- if ((Num & 1) || Num > 30) {
+ if (Num > 63) {
S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_bounds)
<< AL << (int)NumParams.getSExtValue()
<< NumParamsExpr->getSourceRange();
Modified: cfe/branches/release_80/test/Sema/attr-msp430.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_80/test/Sema/attr-msp430.c?rev=351441&r1=351440&r2=351441&view=diff
==============================================================================
--- cfe/branches/release_80/test/Sema/attr-msp430.c (original)
+++ cfe/branches/release_80/test/Sema/attr-msp430.c Thu Jan 17 05:31:58 2019
@@ -1,6 +1,13 @@
// RUN: %clang_cc1 -triple msp430-unknown-unknown -fsyntax-only -verify %s
+__attribute__((interrupt(1))) int t; // expected-warning {{'interrupt' attribute only applies to functions}}
+
int i;
-void f(void) __attribute__((interrupt(i))); /* expected-error {{'interrupt' attribute requires an integer constant}} */
+__attribute__((interrupt(i))) void f(void); // expected-error {{'interrupt' attribute requires an integer constant}}
+__attribute__((interrupt(1, 2))) void f2(void); // expected-error {{'interrupt' attribute takes one argument}}
+__attribute__((interrupt(1))) int f3(void); // expected-warning {{MSP430 'interrupt' attribute only applies to functions that have a 'void' return type}}
+__attribute__((interrupt(1))) void f4(int a); // expected-warning {{MSP430 'interrupt' attribute only applies to functions that have no parameters}}
+__attribute__((interrupt(64))) void f5(void); // expected-error {{'interrupt' attribute parameter 64 is out of bounds}}
-void f2(void) __attribute__((interrupt(12)));
+__attribute__((interrupt(0))) void f6(void);
+__attribute__((interrupt(63))) void f7(void);
More information about the llvm-branch-commits
mailing list