<br><br><div class="gmail_quote">On Thu, Nov 1, 2012 at 1:39 PM, David Tweed <span dir="ltr"><<a href="mailto:david.tweed@arm.com" target="_blank">david.tweed@arm.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div link="blue" vlink="purple" lang="EN-GB"><div><div><p class="MsoNormal" style="margin-bottom:12.0pt">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?<u></u><u></u></p>
<div><p class="MsoNormal"><br>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:<span style="color:#1f497d"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">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.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Cheers,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Dave</span></p></div></div></div></div></blockquote><div><br>Actually, for enums, it might not be so far ahead in C++03:<br>
<br>CPUArch const withCoolFeature[] = <span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><span style="color:rgb(0,0,0)">{ARMv7,ARMv7f,</span><span style="color:rgb(0,0,0)">ARMv7k,ARMv7s};</span><br>
<span style="color:rgb(0,0,0)">if (isIn(a, withCoolFeature)) { ... }<br><br><br>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; }<br>
<br>It's quite sugary I think, no ?<br><br>-- Matthieu<br></span></span></div></div>