try to get everything to compile correctly again

base/intmath.hh:
    Don't return -1 in FloorLog2.  That's wierd.  Assert instead.
    If you care about this, you should check for zero yourself.
    Create seprate versions for uint32_t, uint64_t, int32_t, and
    int64_t.  signed vs unsigned so that error checking can be done
    correctly.  32 vs 64 for speed.
    Finally, fix a little bug in CeilLog2 that will make it return
    the correct result for 1.
kern/tru64/tru64_events.cc:
    fix #includes

--HG--
extra : convert_revision : c47915fc417fdc194a5561949a5366ffb266e693
This commit is contained in:
Nathan Binkert 2003-10-14 18:04:20 -04:00
parent 638a07d15a
commit f8d850195b
2 changed files with 43 additions and 6 deletions

View file

@ -29,6 +29,10 @@
#ifndef __INTMATH_HH__ #ifndef __INTMATH_HH__
#define __INTMATH_HH__ #define __INTMATH_HH__
#include <assert.h>
#include "sim/host.hh"
// Returns the prime number one less than n. // Returns the prime number one less than n.
int PrevPrime(int n); int PrevPrime(int n);
@ -68,12 +72,10 @@ IsPowerOf2(T n)
return n != 0 && LeastSigBit(n) == n; return n != 0 && LeastSigBit(n) == n;
} }
template <class T>
inline int inline int
FloorLog2(T x) FloorLog2(uint32_t x)
{ {
if (x == 0) assert(x > 0);
return -1;
int y = 0; int y = 0;
@ -86,11 +88,45 @@ FloorLog2(T x)
return y; return y;
} }
inline int
FloorLog2(uint64_t x)
{
assert(x > 0);
int y = 0;
if (x & ULL(0xffffffff00000000)) { y += 32; x >>= 32; }
if (x & ULL(0x00000000ffff0000)) { y += 16; x >>= 16; }
if (x & ULL(0x000000000000ff00)) { y += 8; x >>= 8; }
if (x & ULL(0x00000000000000f0)) { y += 4; x >>= 4; }
if (x & ULL(0x000000000000000c)) { y += 2; x >>= 2; }
if (x & ULL(0x0000000000000002)) { y += 1; }
return y;
}
inline int
FloorLog2(int32_t x)
{
assert(x > 0);
return FloorLog2(x);
}
inline int
FloorLog2(int64_t x)
{
assert(x > 0);
return FloorLog2(x);
}
template <class T> template <class T>
inline int inline int
CeilLog2(T n) CeilLog2(T n)
{ {
return FloorLog2(n - 1) + 1; if (n == 1)
return 0;
return FloorLog2(n - (T)1) + 1;
} }
template <class T> template <class T>

View file

@ -27,8 +27,9 @@
*/ */
#include "cpu/exec_context.hh" #include "cpu/exec_context.hh"
#include "cpu/base_cpu.hh"
#include "cpu/full_cpu/bpred.hh" #include "cpu/full_cpu/bpred.hh"
#include "cpu/full_cpu/cpu.hh" #include "cpu/full_cpu/full_cpu.hh"
#include "kern/tru64/dump_mbuf.hh" #include "kern/tru64/dump_mbuf.hh"
#include "kern/tru64/printf.hh" #include "kern/tru64/printf.hh"
#include "kern/tru64/tru64_events.hh" #include "kern/tru64/tru64_events.hh"