LangOptions & CodeGenOptions over-ride

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?

Thank you

robert

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

Hi Ben,

I've added xcore to return appropriate boolean to:
    isSignedCharDefault()
    shouldUseFramePointer()
    shouldUseLeafFramePointer()

also added a call in Clang::ConstructJob() to:
    void Clang::AddXCoreTargetArgs(const ArgList &Args,
                                     ArgStringList &CmdArgs) const {
      CmdArgs.push_back("-fno-common");
    }

This is almost what I want - I'll follow up problem with bitfield chars in another email thread!

robert