[cfe-commits] [patch] Add a llvm::Triple::CPUArch enum

Matthieu Monrocq matthieu.monrocq at gmail.com
Thu Nov 1 05:19:12 PDT 2012


On Thu, Nov 1, 2012 at 10:04 AM, David Tweed <david.tweed at arm.com> wrote:

> Hi Rafael,
>
> This looks like a reasonable goal, but obviously the ARM architecture
> being quite modular there are a lot more actual variants (and a huge number
> more "potential" variants) than for other CPUs (and those listed in the
> table). Is there any nice mechanism for checking if an enum is one of a
> list of enum-values in the clang codebase?
>
>
The simplest way would be to group all ARM architecture in a contiguous
range, have a First / Last elements (with redundant values), and then
perform a in-range check:

enum CPUArch {
    ...
    ARM_Begin,
    ARM_Arch0 = ARM_Begin,
    ARM_Arch1,
    ....
    ARM_End,
    NonArm = ARM_End,
    ....
};

bool isARM(CPUArch a) { return a >= ARM_Begin and a < ARM_End; }

Cheap, efficient, relatively easy to keep up-to-date.

-- Matthieu



> Anyway, if this goes in we'll probably need to keep patching up both the
> enum and the string-mapping as new use cases are discovered.
>
> Cheers,
> Dave
>
> -----Original Message-----
> From: cfe-commits-bounces at cs.uiuc.edu [mailto:
> cfe-commits-bounces at cs.uiuc.edu] On Behalf Of Rafael EspĂ­ndola
> Sent: 30 October 2012 03:58
> To: llvm cfe
> Subject: [cfe-commits] [patch] Add a llvm::Triple::CPUArch enum
>
> There is a lot of char* being passed around in the clang driver. At
> least part of that seems to be because we have an enum
> (llvm::Triple::ArchType) that can distinguish  an ARM from an X86, but
> we don't have an enum that can distinguish a ARMv6 form an ARMv7 for
> example.
>
> The attached patches add the enum llvm::Triple::CPUArch and use that
> to replace a long if chain in clang. I think it can be used in more
> places, but this should be sufficient to illustrate the idea.
>
> Cheers,
> Rafael
>
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121101/564c3e38/attachment.html>


More information about the cfe-commits mailing list