[cfe-commits] [patch] Add a llvm::Triple::CPUArch enum
Matthieu Monrocq
matthieu.monrocq at gmail.com
Thu Nov 1 06:56:09 PDT 2012
On Thu, Nov 1, 2012 at 1:39 PM, David Tweed <david.tweed at arm.com> wrote:
> 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:****
>
> ** **
>
> Sorry, I was a bit unclear in my language (early in the morning!). What I
> meant is the code is creating concrete values at some "level of precision"
> (obviously we really don't want a enumeration of all values). So the
> initial patch has ARMv4t,...,ARMv7,ARMv7f,ARMv7k,ARMv7s. Some things will
> depend just on "is this ARM", others "is this ARM v7", others might care
> about the distinction between "ARMv7f" and "ARMv7s". It'd be nice to be
> able to write something like "if(inList(a,{ARMv7,ARMv7f,ARMv7k,ARMv7s}))"
> but I suspect that kind of C++11 stuff probably isn't suitable.****
>
> ** **
>
> Cheers,****
>
> Dave
>
Actually, for enums, it might not be so far ahead in C++03:
CPUArch const withCoolFeature[] = {ARMv7,ARMv7f,ARMv7k,ARMv7s};
if (isIn(a, withCoolFeature)) { ... }
With: template <typename T, size_t N> bool isIn(T const& t, T const
(&array)[N]) { return std::find(array, array + N, t) != array + N; }
It's quite sugary I think, no ?
-- Matthieu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121101/0ad36337/attachment.html>
More information about the cfe-commits
mailing list