Move stats code out of cpu.c
This commit is contained in:
parent
eaf8b94702
commit
e97037043e
3 changed files with 25 additions and 42 deletions
29
cpu.c
29
cpu.c
|
@ -25,23 +25,6 @@
|
||||||
|
|
||||||
#include "cpu_instrument.h"
|
#include "cpu_instrument.h"
|
||||||
|
|
||||||
u32 memory_region_access_read_u8[16];
|
|
||||||
u32 memory_region_access_read_s8[16];
|
|
||||||
u32 memory_region_access_read_u16[16];
|
|
||||||
u32 memory_region_access_read_s16[16];
|
|
||||||
u32 memory_region_access_read_u32[16];
|
|
||||||
u32 memory_region_access_write_u8[16];
|
|
||||||
u32 memory_region_access_write_u16[16];
|
|
||||||
u32 memory_region_access_write_u32[16];
|
|
||||||
u32 memory_reads_u8;
|
|
||||||
u32 memory_reads_s8;
|
|
||||||
u32 memory_reads_u16;
|
|
||||||
u32 memory_reads_s16;
|
|
||||||
u32 memory_reads_u32;
|
|
||||||
u32 memory_writes_u8;
|
|
||||||
u32 memory_writes_u16;
|
|
||||||
u32 memory_writes_u32;
|
|
||||||
|
|
||||||
const u8 bit_count[256] =
|
const u8 bit_count[256] =
|
||||||
{
|
{
|
||||||
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3,
|
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3,
|
||||||
|
@ -866,8 +849,7 @@ const u32 spsr_masks[4] = { 0x00000000, 0x000000EF, 0xF0000000, 0xF00000EF };
|
||||||
/* Account for cycles and other stats */ \
|
/* Account for cycles and other stats */ \
|
||||||
u8 region = _address >> 24; \
|
u8 region = _address >> 24; \
|
||||||
cycles_remaining -= ws_cyc_nseq[region][(size - 8) / 16]; \
|
cycles_remaining -= ws_cyc_nseq[region][(size - 8) / 16]; \
|
||||||
memory_region_access_read_##type[region]++; \
|
STATS_MEMORY_ACCESS(read, type, region); \
|
||||||
memory_reads_##type++; \
|
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
if ( \
|
if ( \
|
||||||
|
@ -892,8 +874,7 @@ const u32 spsr_masks[4] = { 0x00000000, 0x000000EF, 0xF0000000, 0xF00000EF };
|
||||||
{ \
|
{ \
|
||||||
u8 region = _address >> 24; \
|
u8 region = _address >> 24; \
|
||||||
cycles_remaining -= ws_cyc_nseq[region][(size - 8) / 16]; \
|
cycles_remaining -= ws_cyc_nseq[region][(size - 8) / 16]; \
|
||||||
memory_region_access_write_##type[region]++; \
|
STATS_MEMORY_ACCESS(write, type, region); \
|
||||||
memory_writes_##type++; \
|
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
cpu_alert = write_memory##size(_address, value); \
|
cpu_alert = write_memory##size(_address, value); \
|
||||||
|
@ -908,8 +889,7 @@ const u32 spsr_masks[4] = { 0x00000000, 0x000000EF, 0xF0000000, 0xF00000EF };
|
||||||
/* Account for cycles and other stats */ \
|
/* Account for cycles and other stats */ \
|
||||||
u8 region = _address >> 24; \
|
u8 region = _address >> 24; \
|
||||||
cycles_remaining -= ws_cyc_seq[region][1]; \
|
cycles_remaining -= ws_cyc_seq[region][1]; \
|
||||||
memory_region_access_read_u32[region]++; \
|
STATS_MEMORY_ACCESS(read, u32, region); \
|
||||||
memory_reads_u32++; \
|
|
||||||
} \
|
} \
|
||||||
if(_address < 0x10000000 && map) \
|
if(_address < 0x10000000 && map) \
|
||||||
{ \
|
{ \
|
||||||
|
@ -929,8 +909,7 @@ const u32 spsr_masks[4] = { 0x00000000, 0x000000EF, 0xF0000000, 0xF00000EF };
|
||||||
/* Account for cycles and other stats */ \
|
/* Account for cycles and other stats */ \
|
||||||
u8 region = _address >> 24; \
|
u8 region = _address >> 24; \
|
||||||
cycles_remaining -= ws_cyc_seq[region][1]; \
|
cycles_remaining -= ws_cyc_seq[region][1]; \
|
||||||
memory_region_access_write_u32[region]++; \
|
STATS_MEMORY_ACCESS(write, u32, region); \
|
||||||
memory_writes_u32++; \
|
|
||||||
} \
|
} \
|
||||||
cpu_alert = write_memory32(_address, value); \
|
cpu_alert = write_memory32(_address, value); \
|
||||||
} \
|
} \
|
||||||
|
|
17
cpu.h
17
cpu.h
|
@ -179,23 +179,6 @@ extern const u32 cpu_modes[16];
|
||||||
extern const u32 cpsr_masks[4][2];
|
extern const u32 cpsr_masks[4][2];
|
||||||
extern const u32 spsr_masks[4];
|
extern const u32 spsr_masks[4];
|
||||||
|
|
||||||
extern u32 memory_region_access_read_u8[16];
|
|
||||||
extern u32 memory_region_access_read_s8[16];
|
|
||||||
extern u32 memory_region_access_read_u16[16];
|
|
||||||
extern u32 memory_region_access_read_s16[16];
|
|
||||||
extern u32 memory_region_access_read_u32[16];
|
|
||||||
extern u32 memory_region_access_write_u8[16];
|
|
||||||
extern u32 memory_region_access_write_u16[16];
|
|
||||||
extern u32 memory_region_access_write_u32[16];
|
|
||||||
extern u32 memory_reads_u8;
|
|
||||||
extern u32 memory_reads_s8;
|
|
||||||
extern u32 memory_reads_u16;
|
|
||||||
extern u32 memory_reads_s16;
|
|
||||||
extern u32 memory_reads_u32;
|
|
||||||
extern u32 memory_writes_u8;
|
|
||||||
extern u32 memory_writes_u16;
|
|
||||||
extern u32 memory_writes_u32;
|
|
||||||
|
|
||||||
void init_cpu(void);
|
void init_cpu(void);
|
||||||
void move_reg();
|
void move_reg();
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,27 @@
|
||||||
// Also provides some tracing capabilities
|
// Also provides some tracing capabilities
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef MEMORY_STATS_ANALYZE
|
||||||
|
// Collects memory stats by region, access type, etc.
|
||||||
|
|
||||||
|
u32 memory_region_access_read_u8[16];
|
||||||
|
u32 memory_region_access_read_s8[16];
|
||||||
|
u32 memory_region_access_read_u16[16];
|
||||||
|
u32 memory_region_access_read_s16[16];
|
||||||
|
u32 memory_region_access_read_u32[16];
|
||||||
|
u32 memory_region_access_write_u8[16];
|
||||||
|
u32 memory_region_access_write_u16[16];
|
||||||
|
u32 memory_region_access_write_u32[16];
|
||||||
|
|
||||||
|
#define STATS_MEMORY_ACCESS(op, size, region) \
|
||||||
|
memory_region_access_##op##_##size[region]++;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define STATS_MEMORY_ACCESS(write, u32, region)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef REGISTER_USAGE_ANALYZE
|
#ifdef REGISTER_USAGE_ANALYZE
|
||||||
|
|
||||||
u64 instructions_total = 0;
|
u64 instructions_total = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue