# This shell script emits a C file. -*- C -*- # Generate the main loop of the simulator. # Syntax: genmloop.sh /bin/sh [options] cpu mainloop.in # Options: [-mono|-multi] -scache -fast -parallel # # -scache: use the scache # -fast: include support for fast execution in addition to full featured mode # -parallel: cpu can execute multiple instructions parallely # # FIXME: "multi" support is wip. # TODO # - move this C code to mainloop.in # - keep genmloop.sh # - build exec.in from .cpu file # - have each cpu provide handwritten cycle.in # - integrate with common/sim-engine.[ch] # - for sparc, have two main loops, outer one handles delay slot when npc != 0 # - inner loop does not handle delay slots, pc = pc + 4 type=mono #scache= #fast= #parallel= shell=$1 ; shift while true do case $1 in -mono) type=mono ;; -multi) type=multi ;; -no-scache) ;; -scache) scache=yes ;; -no-fast) ;; -fast) fast=yes ;; -no-parallel) ;; -parallel) parallel=yes ;; *) break ;; esac shift done cpu=$1 file=$2 cat <jmpbuf = &buf; sim_engine_set_run_state (sd, sim_running, 0); pending_reason = sim_running; pending_sigrc = 0; /* ??? Restart support to be added in time. */ if (setjmp (buf)) { /* Account for the last insn executed. */ ++insn_count; TRACE_INSN_FINI ((sim_cpu *) cpu, 1); } else { /* The computed goto switch can be used, and while the number of blocks may swamp the relatively few that this function contains, when running with the scache we put the actual semantic code in their own functions. */ EOF if [ x$fast = xyes ] ; then cat <jmpbuf = NULL; PROFILE_EXEC_TIME (CPU_PROFILE_DATA (cpu)) += sim_elapsed_time_since (start_time); PROFILE_TOTAL_INSN_COUNT (CPU_PROFILE_DATA (cpu)) += insn_count; } EOF ########################################################################## if [ x$scache = xyes ] ; then cat <argbuf.addr != pc) { insn_t insn; PROFILE_COUNT_SCACHE_MISS (current_cpu); /* begin full-extract-scache */ EOF ${SHELL} $file full-extract-scache cat <argbuf.addr != pc) { insn_t insn; /* begin fast-extract-scache */ EOF ${SHELL} $file fast-extract-scache cat <