[cfe-commits] [PING^2] Handling of target attributes

Anton Korobeynikov anton at korobeynikov.info
Sat Jan 9 03:46:47 PST 2010


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.

Any objections?
-- 
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University



More information about the cfe-commits mailing list