[cfe-commits] [patch] Add a llvm::Triple::CPUArch enum
David Tweed
david.tweed at arm.com
Thu Nov 1 05:39:46 PDT 2012
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
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/e002e73b/attachment.html>
More information about the cfe-commits
mailing list