[cfe-dev] How do I specify a specific PowerPC CPU to clang?

Hal Finkel hfinkel at anl.gov
Mon Jul 2 06:43:17 PDT 2012


On Mon, 2 Jul 2012 15:09:31 +0200
Andy Gibbs <andyg1001 at hotmail.co.uk> wrote:

> On Tuesday, June 19, 2012 2:09 AM, Hal Finkel wrote:
> > Sean, Richard,
> > 
> > I added -mcpu support for PPC to trunk clang in r158334. Does this
> > not work for you?
> > 
> > -Hal
> 
> Hal,
> 
> Thanks for adding this feature.
> 

Andy,

> Please can I offer an improvement to it? 

Of course :)

> In your commit comments you
> stated "a few preprocessor defines for common CPU types have been
> added".  Attached is a patch that adds more. 

A few quick things:

> +  /// \brief Flags for architecture specific defines.
> +  typedef enum {
> +    ppc_arch_none  = 0,
> +    ppc_arch_name  = 1 << 0, // <name> is substituted for arch name.
> +    ppc_arch_ppcgr = 1 << 1,

You need to follow the coding conventions for naming the constants here:
http://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly


> +  ppc_arch_t defs = (ppc_arch_t)llvm::StringSwitch<int>(CPU)
> +        .Case("440",   ppc_arch_name)
> +        .Case("450",   ppc_arch_name | ppc_arch_440)
> +        .Case("601",   ppc_arch_name)

The indentation of the .Case seems odd here. I think just one
indentation level is fine.

Otherwise, I think this looks good. Thanks!

Please send an updated patch and I'll commit.

 -Hal

> I have tried to match
> the defines that gcc generates and the IBM compiler documentation,
> where the two agree and where I have been able to confirm by
> testing.  FWIW, I am porting code that requires the _ARCH_PPCGR and
> _ARCH_PWRx defines to compile correctly, hence my motive!
> 
> In addition to the defines you added, I have added ones for 60x and
> 74xx series, additionally defining _ARCH_PPCGR where applicable.  I
> also fleshed out the 970, pwr6 and pwr7 sets to include
> _ARCH_PWR{4-6}, _ARCH_PPCGR and _ARCH_PPCSQ as applicable (which are
> additionally defined by gcc for these architectures).
> 
> Cheers
> Andy
> 



-- 
Hal Finkel
Postdoctoral Appointee
Leadership Computing Facility
Argonne National Laboratory



More information about the cfe-dev mailing list