[cfe-dev] LangOptions & CodeGenOptions over-ride

Benjamin Kramer benny.kra at gmail.com
Mon Jul 29 10:38:47 PDT 2013


On 29.07.2013, at 19:14, Robert Lytton <robert at xmos.com> wrote:

> Hi,
> 
> I am working on a clang frontend for the XCore processor.
> 
> 
> The XCore ABI requires that 'char' is unsigned.
> I notice the C99 standard does not require it to be signed - contrary to the comment:
>       /// isSignedIntegerType - Return true if this is an integer type that is
>       /// signed, according to C99 6.2.5p4 [char, signed char, short, int, long..],
>       /// or an enum decl which has a signed representation.
> 
> Thus I would like to over-ride the default setting in LangOptions.def:
>         LANGOPT(CharIsSigned      , 1, 1, "signed char")
> 
> I had considered using setForcedLangOptions() - but assume this is the wrong way to use it!
>       virtual void XCoreTargetInfo::setForcedLangOptions(LangOptions &Opts) {
>         ...
>        Opts.CharIsSigned = false;
>       }
> 
> 
> 
> I would also like to make -fomit-frame-pointer" the default behaviour for the target:
>     CODEGENOPT(DisableFPElim     , 1, 0) ///< Set when -fomit-frame-pointer is enabled.
> And the same for -fno-common
>     CODEGENOPT(NoCommon          , 1, 0) ///< Set when -fno-common or C++ is enabled.
> 
> 
> 
> What is the correct place (TargetInfo constructor?) and mechanism to specify alternative default options?
> Is there a target-option.def over-rides mechanism?

We have a couple of ad-hoc hooks in Tools.cpp for this, e.g. shouldUseFramePointer and isSignedCharDefault. It's not a particularly nice solution but adding support for xcore would be easy.

- Ben

> 
> Thank you
> 
> robert
> 
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev





More information about the cfe-dev mailing list