[cfe-commits] Target-specific handling of attributes

Eli Friedman eli.friedman at gmail.com
Wed Dec 23 09:42:25 PST 2009


On Tue, Dec 22, 2009 at 5:54 PM, Anton Korobeynikov
<anton at korobeynikov.info> wrote:
> Hello, Everyone
>
> Almost all targets have their own attributes with different meaning.
> Think about e.g. "interrupt" attribute which might require different
> semantic checks & different codegen for every target.
>
> It is not good to pull such target-specific stuff into generic sema &
> codegen code. Also, it seems it's not possible to "parametrize" the code
> enough - for ISRs almost surely every new target will end with different
> "interrupt style lowering". Some targets might have several different
> "styles of ISRs".
>
> The patch attached tries to solve such problem. Basically, it does a
> "plug-in" approach already used wrt TargetABIInfo. For now the main aim
> of the patch is "regular" attributes sema & codegen. Regular means that
> nothing fancy is required for such attributes (e.g. decl mergeing rules,
> etc).
>
> Patch introduces 2 new classes:
>  - TargetAttributesSema, which does all needed semantic checks on the
> attribute
>  - TargetCodeGenInfo, which does actual codegen. TargetABIInfo is folded
> into TargetCodeGenInfo.
>
> These "plug-in classes" are hooked in the two places:
>  - SemaDeclAttr.cpp:ProcessDeclAttribute()
>  - CodeGenModule::SetCommonAttributes()
>
> As a proof-of-conceps, I added the implementation of MSP430 'interrupt'
> attribute, which is translated into custom calling convention + alias.
> Additional goodness like "used" and "noinline" is added as well.
>
> Please comment.

The idea appears to be sound.

Please don't mix up the CodeGen target attributes with ABI handling;
there's been some discussion that we might want to move the latter out
of clang.  Also, because that part of the patch wasn't generated on
top of an svn copy, it's nearly impossible to review.

-Eli




More information about the cfe-commits mailing list