📄 genmloop.sh
字号:
#endif#else @prefix@_sem_init_idesc_table (current_cpu);#endif CPU_IDESC_SEM_INIT_P (current_cpu) = 1; } do {/* begin full-exec-simple */EOF${SHELL} $infile full-exec-simplecat << EOF/* end full-exec-simple */ ++ CPU_INSN_COUNT (current_cpu); } while (0 /*CPU_RUNNING_P (current_cpu)*/);}#undef FAST_PEOF##################################### Simple engine: fast version.# ??? A somewhat dubious effort, but for completeness' sake.if [ x$fast = xyes ] ; then cat << EOF#define FAST_P 1FIXME: "fast simple version unimplemented, delete -fast arg to genmloop.sh."#undef FAST_PEOFfi # -fastfi # simple engine########################################################################### Non-parallel scache engine: lookup insn in scache, fetch if missing,# then execute it.if [ x$scache = xyes -a x$parallel = xno ] ; then cat << EOFstatic INLINE SCACHE *@prefix@_scache_lookup (SIM_CPU *current_cpu, PCADDR vpc, SCACHE *scache, unsigned int hash_mask, int FAST_P){ /* First step: look up current insn in hash table. */ SCACHE *sc = scache + SCACHE_HASH_PC (vpc, hash_mask); /* If the entry isn't the one we want (cache miss), fetch and decode the instruction. */ if (sc->argbuf.addr != vpc) { if (! FAST_P) PROFILE_COUNT_SCACHE_MISS (current_cpu);/* begin extract-scache */EOF${SHELL} $infile extract-scachecat << EOF/* end extract-scache */ } else if (! FAST_P) { PROFILE_COUNT_SCACHE_HIT (current_cpu); /* Make core access statistics come out right. The size is a guess, but it's currently not used either. */ PROFILE_COUNT_CORE (current_cpu, vpc, 2, exec_map); } return sc;}#define FAST_P 0void@prefix@_engine_run_full (SIM_CPU *current_cpu){ SIM_DESC current_state = CPU_STATE (current_cpu); SCACHE *scache = CPU_SCACHE_CACHE (current_cpu); unsigned int hash_mask = CPU_SCACHE_HASH_MASK (current_cpu); SEM_PC vpc;EOF# Any initialization code before looping starts.# Note that this code may declare some locals.${SHELL} $infile initcat << EOF if (! CPU_IDESC_SEM_INIT_P (current_cpu)) {#if ! WITH_SEM_SWITCH_FULL @prefix@_sem_init_idesc_table (current_cpu);#endif CPU_IDESC_SEM_INIT_P (current_cpu) = 1; } vpc = GET_H_PC (); do { SCACHE *sc; sc = @prefix@_scache_lookup (current_cpu, vpc, scache, hash_mask, FAST_P);/* begin full-exec-scache */EOF${SHELL} $infile full-exec-scachecat << EOF/* end full-exec-scache */ SET_H_PC (vpc); ++ CPU_INSN_COUNT (current_cpu); } while (0 /*CPU_RUNNING_P (current_cpu)*/);}#undef FAST_PEOF##################################### Non-parallel scache engine: fast version.if [ x$fast = xyes ] ; then cat << EOF#define FAST_P 1void@prefix@_engine_run_fast (SIM_CPU *current_cpu){ SIM_DESC current_state = CPU_STATE (current_cpu); SCACHE *scache = CPU_SCACHE_CACHE (current_cpu); unsigned int hash_mask = CPU_SCACHE_HASH_MASK (current_cpu); SEM_PC vpc;EOF# Any initialization code before looping starts.# Note that this code may declare some locals.${SHELL} $infile initcat << EOF if (! CPU_IDESC_SEM_INIT_P (current_cpu)) {#if WITH_SEM_SWITCH_FAST#if defined (__GNUC__)/* ??? Later maybe paste sem-switch.c in when building mainloop.c. */#define DEFINE_LABELS#include "$switch"#endif#else @prefix@_semf_init_idesc_table (current_cpu);#endif CPU_IDESC_SEM_INIT_P (current_cpu) = 1; } vpc = GET_H_PC (); do { SCACHE *sc; sc = @prefix@_scache_lookup (current_cpu, vpc, scache, hash_mask, FAST_P);/* begin fast-exec-scache */EOF${SHELL} $infile fast-exec-scachecat << EOF/* end fast-exec-scache */ SET_H_PC (vpc); ++ CPU_INSN_COUNT (current_cpu); } while (0 /*CPU_RUNNING_P (current_cpu)*/);}#undef FAST_PEOFfi # -fastfi # -scache && ! parallel########################################################################### Parallel scache engine: lookup insn in scache, fetch if missing,# then execute it.# For the parallel case we give the target more flexibility.if [ x$scache = xyes -a x$parallel != xno ] ; then cat << EOFstatic INLINE SCACHE *@prefix@_scache_lookup (SIM_CPU *current_cpu, PCADDR vpc, SCACHE *scache, unsigned int hash_mask, int FAST_P){ /* First step: look up current insn in hash table. */ SCACHE *sc = scache + SCACHE_HASH_PC (vpc, hash_mask); /* If the entry isn't the one we want (cache miss), fetch and decode the instruction. */ if (sc->argbuf.addr != vpc) { if (! FAST_P) PROFILE_COUNT_SCACHE_MISS (current_cpu);#define SET_LAST_INSN_P(last_p) do { sc->last_insn_p = (last_p); } while (0)/* begin extract-scache */EOF${SHELL} $infile extract-scachecat << EOF/* end extract-scache */#undef SET_LAST_INSN_P } else if (! FAST_P) { PROFILE_COUNT_SCACHE_HIT (current_cpu); /* Make core access statistics come out right. The size is a guess, but it's currently not used either. */ PROFILE_COUNT_CORE (current_cpu, vpc, 2, exec_map); } return sc;}#define FAST_P 0void@prefix@_engine_run_full (SIM_CPU *current_cpu){ SIM_DESC current_state = CPU_STATE (current_cpu); SCACHE *scache = CPU_SCACHE_CACHE (current_cpu); unsigned int hash_mask = CPU_SCACHE_HASH_MASK (current_cpu); SEM_PC vpc;EOF# Any initialization code before looping starts.# Note that this code may declare some locals.${SHELL} $infile initif [ x$parallel = xread ] ; thencat << EOF#if defined (__GNUC__) { if (! CPU_IDESC_READ_INIT_P (current_cpu)) {/* ??? Later maybe paste read.c in when building mainloop.c. */#define DEFINE_LABELS#include "readx.c" CPU_IDESC_READ_INIT_P (current_cpu) = 1; } }#endifEOFficat << EOF if (! CPU_IDESC_SEM_INIT_P (current_cpu)) {#if ! WITH_SEM_SWITCH_FULL @prefix@_sem_init_idesc_table (current_cpu);#endif CPU_IDESC_SEM_INIT_P (current_cpu) = 1; } vpc = GET_H_PC (); do {/* begin full-exec-scache */EOF${SHELL} $infile full-exec-scachecat << EOF/* end full-exec-scache */ } while (0 /*CPU_RUNNING_P (current_cpu)*/);}#undef FAST_PEOF##################################### Parallel scache engine: fast version.if [ x$fast = xyes ] ; then cat << EOF#define FAST_P 1void@prefix@_engine_run_fast (SIM_CPU *current_cpu){ SIM_DESC current_state = CPU_STATE (current_cpu); SCACHE *scache = CPU_SCACHE_CACHE (current_cpu); unsigned int hash_mask = CPU_SCACHE_HASH_MASK (current_cpu); SEM_PC vpc; PAREXEC pbufs[MAX_PARALLEL_INSNS]; PAREXEC *par_exec;EOF# Any initialization code before looping starts.# Note that this code may declare some locals.${SHELL} $infile initif [ x$parallel = xread ] ; thencat << EOF#if defined (__GNUC__) { if (! CPU_IDESC_READ_INIT_P (current_cpu)) {/* ??? Later maybe paste read.c in when building mainloop.c. */#define DEFINE_LABELS#include "readx.c" CPU_IDESC_READ_INIT_P (current_cpu) = 1; } }#endifEOFficat << EOF if (! CPU_IDESC_SEM_INIT_P (current_cpu)) {#if WITH_SEM_SWITCH_FAST#if defined (__GNUC__)/* ??? Later maybe paste sem-switch.c in when building mainloop.c. */#define DEFINE_LABELS#include "$switch"#endif#else @prefix@_semf_init_idesc_table (current_cpu);#endif CPU_IDESC_SEM_INIT_P (current_cpu) = 1; } vpc = GET_H_PC (); do {/* begin fast-exec-scache */EOF${SHELL} $infile fast-exec-scachecat << EOF/* end fast-exec-scache */ } while (0 /*CPU_RUNNING_P (current_cpu)*/);}#undef FAST_PEOFfi # -fastfi # -scache && parallel########################################################################### Compilation engine: lookup insn in scache, extract a pbb# (pseudo-basic-block) if missing, then execute the pbb.# A "pbb" is a sequence of insns up to the next cti insn or until# some prespecified maximum.# CTI: control transfer instruction.if [ x$pbb = xyes ] ; then cat << EOF/* Record address of cti terminating a pbb. */#define SET_CTI_VPC(sc) do { _cti_sc = (sc); } while (0)/* Record number of [real] insns in pbb. */#define SET_INSN_COUNT(n) do { _insn_count = (n); } while (0)/* Fetch and extract a pseudo-basic-block. FAST_P is non-zero if no tracing/profiling/etc. is wanted. */INLINE SEM_PC@prefix@_pbb_begin (SIM_CPU *current_cpu, int FAST_P){ SEM_PC new_vpc; PCADDR pc; SCACHE *sc; int max_insns = CPU_SCACHE_MAX_CHAIN_LENGTH (current_cpu); pc = GET_H_PC (); new_vpc = scache_lookup_or_alloc (current_cpu, pc, max_insns, &sc); if (! new_vpc) { /* Leading '_' to avoid collision with mainloop.in. */ int _insn_count = 0; SCACHE *orig_sc = sc; SCACHE *_cti_sc = NULL; int slice_insns = CPU_MAX_SLICE_INSNS (current_cpu); /* First figure out how many instructions to compile. MAX_INSNS is the size of the allocated buffer, which includes space for before/after handlers if they're being used.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -