[llvm-commits] [llvm] r78793 - in /llvm/trunk: include/llvm/Support/MathExtras.h lib/Target/Blackfin/BlackfinInstrInfo.td lib/Target/Blackfin/BlackfinRegisterInfo.cpp lib/Target/Blackfin/BlackfinRegisterInfo.h

Jakob Stoklund Olesen stoklund at 2pi.dk
Wed Aug 12 22:17:53 PDT 2009


On 13/08/2009, at 04.56, Daniel Dunbar wrote:

> Hi Jakob,
>
> On Tue, Aug 11, 2009 at 11:22 PM, Jakob Stoklund Olesen<stoklund at 2pi.dk 
> > wrote:
>> +template<unsigned N>
>> +inline bool isInt(int64_t x) {
>> +  return -(INT64_C(1)<<(N-1)) <= x && x < (INT64_C(1)<<(N-1));
>> +}
>> +
>> +template<unsigned N>
>> +inline bool isUint(uint64_t x) {
>> +  return x < (UINT64_C(1)<<N);
>> +}
>
> It's probably worth fixing this for N == 64, just in case.

You're right. I'll do that.

I actually wanted to make the uint64_t a template parameter too:

template<unsigned N, typename T>
inline bool isUint(T x) {
   return 0 <= x && x < (T(1)<<N);
}

But my compiler brilliantly warns me about the 0 <= X comparison when  
T is unsigned. Not sure how to get rid of that, I just went for  
uint64_t.




More information about the llvm-commits mailing list