This patch adds support for the interrupt attribute for mips32r2+.
Details
- Reviewers
dsanders aaron.ballman - Commits
- rGbd3f47f5b53b: [mips] Interrupt attribute support.
rG586be024958b: [mips] Interrupt attribute support.
rC254205: [mips] Interrupt attribute support.
rC254203: [mips] Interrupt attribute support.
rL254205: [mips] Interrupt attribute support.
rL254203: [mips] Interrupt attribute support.
Diff Detail
Event Timeline
LGTM with a few nits
include/clang/Basic/Attr.td | ||
---|---|---|
864–865 | if -> If Also, you should update the comments for ARMInterrupt and MSP430Interrupt to mention MipsInterrupt. | |
include/clang/Basic/AttrDocs.td | ||
726–727 | Aside from "eic" shouldn't these be "vector=..."? | |
lib/Sema/SemaDeclAttr.cpp | ||
4479 | I think you also need to cover aarch64, thumb, etc. It's probably best to leave it as an else clause and add mips above it. |
Missing tests for the semantic warnings. For instance, I don't see any tests exercising err_attribute_too_many_arguments or warn_attribute_type_not_supported.
~Aaron
Nits addressed and XFAIL tests added for functions having arguments and the interrupt attribute.
Test added to cover semantic warnings.
Rejects functions with mips16 & interrupt attributes.
Text in the bullet points of MipsInterruptDocs section expanded.
Updated tests along the lines of what vkalintiris did for corresponding llvm part as of r251295.
This is coming along nicely! There are some minor nits that should be trivial to fix, but the fatal errors need to become semantic errors, and some tests are missing.
include/clang/Basic/AttrDocs.td | ||
---|---|---|
721 | s/ot/to | |
725 | Comma after "By default" | |
730 | Comma after mode. | |
746 | Comma after prologue. | |
749 | The function return? | |
lib/CodeGen/TargetInfo.cpp | ||
5897 | No space between * and Attr. May want to run clang-format over the patch. | |
5902 | This should be a semantic error for improved diagnostic behavior. | |
5906 | Same here. Also, missing a semantic test for this. | |
lib/Sema/SemaDeclAttr.cpp | ||
4431 | Please have Str in quotes in the diagnostic (since it's something the user wrote). | |
4435 | Sink Index into the constructor arguments. | |
test/CodeGen/mips-interrupt-attr-arg.c | ||
5 ↗ | (On Diff #38533) | This should be folded into the other semantic test when this becomes a semantic error instead of a hard failure. |
test/Sema/mips-interrupt-attr.c | ||
19 | Also missing semantic tests for placing the attribute on something other than a function (which I presume should be an error?). |
Updated documentation text.
Switched the various hard failures to semantic warnings/failures.
Strangely, the 'interrupt' attribute on a non-function defaults to a warning.
Thanks.
include/clang/Basic/DiagnosticSemaKinds.td | ||
---|---|---|
255 | I would combine these, and name the result so that it is obvious it relates to the MIPS interrupt attribute. This can then become: "MIPS 'interrupt' attribute only applies to functions %select{with no parameters|a 'void' return type}0" Generally speaking, we make these warnings instead of errors (though the choice is obviously yours), and add them to the IgnoredAttributes group (so you warn, and then never attach the attribute to the declaration). | |
lib/Sema/SemaDeclAttr.cpp | ||
4441 | No need for this; you can pass any NamedDecl * into Diag() and it will get quoted and displayed properly. Since you've already checked that it's a function or method, you can simply use cast<NamedDecl>(D) when needed. | |
4448 | No need for the extra set of parens. | |
4453 | Please use checkAttrMutualExclusion() instead. Also, you need to add a similar check to the Mips16 attribute handler to ensure the mutual exclusion is properly checked. Should have semantic test cases for both orderings: __attribute__((mips16)) __attribute__((interrupt)) void f(); __attribute__((interrupt)) __attribute__((mips16)) void g(); What about the nomips16 attribute? Should this be mutually exclusive as well? |
Updated comments, used cast as suggested, added mutual exclusion check for mips16+interrupt combination.
Extended mips16/nomips16 attribute handlers for mutual exclusion, add to pre-existing test.
Thanks.
include/clang/Basic/DiagnosticSemaKinds.td | ||
---|---|---|
256 | No need for \'; you can use ' directly. I think the wording is still a bit awkward. Function declarations generally don't "take arguments", but have parameters, and "the void return type" reads weird. I think: "MIPS 'interrupt' attribute only applies to functions with %select{no parameters|a 'void' return type}0" would be an improvement. | |
lib/Sema/SemaDeclAttr.cpp | ||
4439 | No need for \', you can use ' directly. | |
4462 | No need for \', can use ' directly. | |
4484 | This is a good change, but should be as part of a separate patch since it has nothing to do with MIPS interrupt. | |
4495 | Same with this. | |
test/Sema/mips16_attr_allowed.c | ||
22 ↗ | (On Diff #40782) | This should be part of a separate patch. |
Updated text of return type/parameters warning to Aaron's suggestion.
Dropped '\' escape characters from warning/error text.
Removed mips16/nomips16 check.
Tweak of comment in handleMipsInterruptAttr.
LGTM, once one minor nit is fixed. Thank you for working on this!
include/clang/Basic/DiagnosticSemaKinds.td | ||
---|---|---|
257 | Spurious \' around 'void' |
Nit addressed.
Daniel or Aaron, can one of you commit on my behalf? Thanks.
Aaron, thanks for the review.
if -> If
ARMInterrupts's -> ARMInterrupt's
Also, you should update the comments for ARMInterrupt and MSP430Interrupt to mention MipsInterrupt.