[cfe-commits] Target-specific handling of attributes

Anton Korobeynikov anton at korobeynikov.info
Tue Dec 22 17:54:48 PST 2009


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.

-- 
With best regards, Anton Korobeynikov.

Faculty of Mathematics & Mechanics, Saint Petersburg State University.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: target.diff
Type: text/x-patch
Size: 156476 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20091223/4a00d71d/attachment.bin>


More information about the cfe-commits mailing list