/******************************************************************************
** FILE: xexit.c
** Function called at simulator termination.
*/

#include <sys/types.h>
#include <sys/time.h>
#include "internal.h"
#include "fastsim.h"

void
xexit()
{
    xlog(1,"[%d] # CPU cycles => %lld",++nstat,xCPU_cycle);
    xlog(1,"[%d] # insts retired => %lld",++nstat,xnum_insts_retired);
#ifdef STATS
    xlog(2,"[%d] # branch predict => %lld",++nstat,count_branch_predict);
    xlog(2,"[%d] # branch direction => %lld",++nstat,count_branch_direction);
    xlog(2,"[%d] nanoseconds in cache => %lld",++nstat,time_cache);
    xlog(2,"[%d] # load start => %lld",++nstat,count_cache_load_start);
    xlog(2,"[%d] # load no mshr => %lld",++nstat,count_cache_no_mshr);
    xlog(2,"[%d] # load continue => %lld",++nstat,count_cache_load_continue);
    xlog(2,"[%d] # load hit in l1 => %lld",++nstat,count_cache_load_hit_l1);
    xlog(2,"[%d] # load hit in l2 => %lld",++nstat,count_cache_load_hit_l2);
    xlog(2,"[%d] # load from memory => %lld",++nstat,count_cache_load_memory);
    xlog(2,"[%d] # load removed => %lld",++nstat,count_cache_load_removed);
    xlog(2,"[%d] # store start => %lld",++nstat,count_cache_store_start);
    xlog(2,"[%d] # speculative stores => %lld",++nstat,count_cache_store_spec);
    xlog(2,"[%d] # store no wbuf => %lld",++nstat,count_cache_no_wbuf);
    xlog(2,"[%d] # speculaitve store no wbuf => %lld",++nstat,count_cache_no_wbuf_spec);
    xlog(2,"[%d] # store commit => %lld",++nstat,count_cache_store_commit);
    xlog(2,"[%d] # store commit fail => %lld",++nstat,count_cache_store_commit_fail);
    xlog(2,"[%d] # store rollback => %lld",++nstat,count_cache_store_rollback);
    xlog(2,"[%d] # mem test failed => %lld",++nstat,count_cache_segfault);
    xlog(2,"[%d] # cache flush => %lld",++nstat,count_cache_flush);
#endif
    xstats();
    exit(0);
}