|
Jakub Jelinek |
e6fdd7 |
--- valgrind-3.2.3/cachegrind/cg_sim.c.jj 2007-01-08 02:43:10.000000000 -0500
|
|
Jakub Jelinek |
e6fdd7 |
+++ valgrind-3.2.3/cachegrind/cg_sim.c 2007-02-13 07:15:46.000000000 -0500
|
|
Jakub Jelinek |
8f5f0f |
@@ -42,29 +42,32 @@ typedef struct {
|
|
Jakub Jelinek |
8f5f0f |
Int size; /* bytes */
|
|
Jakub Jelinek |
8f5f0f |
Int assoc;
|
|
Jakub Jelinek |
8f5f0f |
Int line_size; /* bytes */
|
|
Jakub Jelinek |
8f5f0f |
- Int sets;
|
|
Jakub Jelinek |
8f5f0f |
Int sets_min_1;
|
|
Jakub Jelinek |
8f5f0f |
Int assoc_bits;
|
|
Jakub Jelinek |
8f5f0f |
Int line_size_bits;
|
|
Jakub Jelinek |
8f5f0f |
Int tag_shift;
|
|
Jakub Jelinek |
8f5f0f |
- Char desc_line[128];
|
|
Jakub Jelinek |
8f5f0f |
UWord* tags;
|
|
Jakub Jelinek |
8f5f0f |
-} cache_t2;
|
|
Jakub Jelinek |
8f5f0f |
+ Char desc_line[128];
|
|
Jakub Jelinek |
8f5f0f |
+} cache_t2
|
|
Jakub Jelinek |
8f5f0f |
+#ifdef __GNUC__
|
|
Jakub Jelinek |
8f5f0f |
+__attribute__ ((aligned (8 * sizeof (Int))))
|
|
Jakub Jelinek |
8f5f0f |
+#endif
|
|
Jakub Jelinek |
8f5f0f |
+;
|
|
Jakub Jelinek |
8f5f0f |
|
|
Jakub Jelinek |
8f5f0f |
/* By this point, the size/assoc/line_size has been checked. */
|
|
Jakub Jelinek |
8f5f0f |
static void cachesim_initcache(cache_t config, cache_t2* c)
|
|
Jakub Jelinek |
8f5f0f |
{
|
|
Jakub Jelinek |
8f5f0f |
- Int i;
|
|
Jakub Jelinek |
8f5f0f |
+ Int sets;
|
|
Jakub Jelinek |
8f5f0f |
|
|
Jakub Jelinek |
8f5f0f |
c->size = config.size;
|
|
Jakub Jelinek |
8f5f0f |
c->assoc = config.assoc;
|
|
Jakub Jelinek |
8f5f0f |
c->line_size = config.line_size;
|
|
Jakub Jelinek |
8f5f0f |
|
|
Jakub Jelinek |
8f5f0f |
- c->sets = (c->size / c->line_size) / c->assoc;
|
|
Jakub Jelinek |
8f5f0f |
- c->sets_min_1 = c->sets - 1;
|
|
Jakub Jelinek |
8f5f0f |
+ sets = (c->size / c->line_size) / c->assoc;
|
|
Jakub Jelinek |
8f5f0f |
+ c->sets_min_1 = sets - 1;
|
|
Jakub Jelinek |
8f5f0f |
c->assoc_bits = VG_(log2)(c->assoc);
|
|
Jakub Jelinek |
8f5f0f |
c->line_size_bits = VG_(log2)(c->line_size);
|
|
Jakub Jelinek |
8f5f0f |
- c->tag_shift = c->line_size_bits + VG_(log2)(c->sets);
|
|
Jakub Jelinek |
8f5f0f |
+ c->tag_shift = c->line_size_bits + VG_(log2)(sets);
|
|
Jakub Jelinek |
8f5f0f |
|
|
Jakub Jelinek |
8f5f0f |
if (c->assoc == 1) {
|
|
Jakub Jelinek |
8f5f0f |
VG_(sprintf)(c->desc_line, "%d B, %d B, direct-mapped",
|
|
Jakub Jelinek |
8f5f0f |
@@ -74,10 +77,7 @@ static void cachesim_initcache(cache_t c
|
|
Jakub Jelinek |
8f5f0f |
c->size, c->line_size, c->assoc);
|
|
Jakub Jelinek |
8f5f0f |
}
|
|
Jakub Jelinek |
8f5f0f |
|
|
Jakub Jelinek |
8f5f0f |
- c->tags = VG_(malloc)(sizeof(UWord) * c->sets * c->assoc);
|
|
Jakub Jelinek |
8f5f0f |
-
|
|
Jakub Jelinek |
8f5f0f |
- for (i = 0; i < c->sets * c->assoc; i++)
|
|
Jakub Jelinek |
8f5f0f |
- c->tags[i] = 0;
|
|
Jakub Jelinek |
8f5f0f |
+ c->tags = VG_(calloc)(sizeof(UWord) * sets, c->assoc);
|
|
Jakub Jelinek |
8f5f0f |
}
|
|
Jakub Jelinek |
8f5f0f |
|
|
Jakub Jelinek |
8f5f0f |
/* This is done as a macro rather than by passing in the cache_t2 as an
|
|
Jakub Jelinek |
8f5f0f |
@@ -140,8 +140,7 @@ void cachesim_##L##_doref(Addr a, UChar
|
|
Jakub Jelinek |
8f5f0f |
return; \
|
|
Jakub Jelinek |
8f5f0f |
\
|
|
Jakub Jelinek |
8f5f0f |
/* Second case: word straddles two lines. */ \
|
|
Jakub Jelinek |
8f5f0f |
- /* Nb: this is a fast way of doing ((set1+1) % L.sets) */ \
|
|
Jakub Jelinek |
8f5f0f |
- } else if (((set1 + 1) & (L.sets-1)) == set2) { \
|
|
Jakub Jelinek |
8f5f0f |
+ } else if (((set1 + 1) & (L.sets_min_1)) == set2) { \
|
|
Jakub Jelinek |
8f5f0f |
set = &(L.tags[set1 << L.assoc_bits]); \
|
|
Jakub Jelinek |
8f5f0f |
if (tag == set[0]) { \
|
|
Jakub Jelinek |
8f5f0f |
goto block2; \
|