⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 genmloop.sh

📁 这个是LINUX下的GDB调度工具的源码
💻 SH
📖 第 1 页 / 共 3 页
字号:
	 SLICE_INSNS is the maxinum number of real insns that can be	 executed.  Zero means "as many as we want".  */      /* ??? max_insns is serving two incompatible roles.	 1) Number of slots available in scache buffer.	 2) Number of real insns to execute.	 They're incompatible because there are virtual insns emitted too	 (chain,cti-chain,before,after handlers).  */      if (slice_insns == 1)	{	  /* No need to worry about extra slots required for virtual insns	     and parallel exec support because MAX_CHAIN_LENGTH is	     guaranteed to be big enough to execute at least 1 insn!  */	  max_insns = 1;	}      else	{	  /* Allow enough slop so that while compiling insns, if max_insns > 0	     then there's guaranteed to be enough space to emit one real insn.	     MAX_CHAIN_LENGTH is typically much longer than	     the normal number of insns between cti's anyway.  */	  max_insns -= (1 /* one for the trailing chain insn */			+ (FAST_P			   ? 0			   : (1 + MAX_PARALLEL_INSNS) /* before+after */)			+ (MAX_PARALLEL_INSNS > 1			   ? (MAX_PARALLEL_INSNS * 2)			   : 0));	  /* Account for before/after handlers.  */	  if (! FAST_P)	    slice_insns *= 3;	  if (slice_insns > 0	      && slice_insns < max_insns)	    max_insns = slice_insns;	}      new_vpc = sc;      /* SC,PC must be updated to point passed the last entry used.	 SET_CTI_VPC must be called if pbb is terminated by a cti.	 SET_INSN_COUNT must be called to record number of real insns in	 pbb [could be computed by us of course, extra cpu but perhaps	 negligible enough].  *//* begin extract-pbb */EOF${SHELL} $infile extract-pbbcat << EOF/* end extract-pbb */      /* The last one is a pseudo-insn to link to the next chain.	 It is also used to record the insn count for this chain.  */      {	const IDESC *id;	/* Was pbb terminated by a cti?  */	if (_cti_sc)	  {	    id = & CPU_IDESC (current_cpu) [@PREFIX@_INSN_X_CTI_CHAIN];	  }	else	  {	    id = & CPU_IDESC (current_cpu) [@PREFIX@_INSN_X_CHAIN];	  }	SEM_SET_CODE (&sc->argbuf, id, FAST_P);	sc->argbuf.idesc = id;	sc->argbuf.addr = pc;	sc->argbuf.fields.chain.insn_count = _insn_count;	sc->argbuf.fields.chain.next = 0;	sc->argbuf.fields.chain.branch_target = 0;	++sc;      }      /* Update the pointer to the next free entry, may not have used as	 many entries as was asked for.  */      CPU_SCACHE_NEXT_FREE (current_cpu) = sc;      /* Record length of chain if profiling.	 This includes virtual insns since they count against	 max_insns too.  */      if (! FAST_P)	PROFILE_COUNT_SCACHE_CHAIN_LENGTH (current_cpu, sc - orig_sc);    }  return new_vpc;}/* Chain to the next block from a non-cti terminated previous block.  */INLINE SEM_PC@prefix@_pbb_chain (SIM_CPU *current_cpu, SEM_ARG sem_arg){  ARGBUF *abuf = SEM_ARGBUF (sem_arg);  PBB_UPDATE_INSN_COUNT (current_cpu, sem_arg);  SET_H_PC (abuf->addr);  /* If not running forever, exit back to main loop.  */  if (CPU_MAX_SLICE_INSNS (current_cpu) != 0      /* Also exit back to main loop if there's an event.         Note that if CPU_MAX_SLICE_INSNS != 1, events won't get processed	 at the "right" time, but then that was what was asked for.	 There is no silver bullet for simulator engines.         ??? Clearly this needs a cleaner interface.	 At present it's just so Ctrl-C works.  */      || STATE_EVENTS (CPU_STATE (current_cpu))->work_pending)    CPU_RUNNING_P (current_cpu) = 0;  /* If chained to next block, go straight to it.  */  if (abuf->fields.chain.next)    return abuf->fields.chain.next;  /* See if next block has already been compiled.  */  abuf->fields.chain.next = scache_lookup (current_cpu, abuf->addr);  if (abuf->fields.chain.next)    return abuf->fields.chain.next;  /* Nope, so next insn is a virtual insn to invoke the compiler     (begin a pbb).  */  return CPU_SCACHE_PBB_BEGIN (current_cpu);}/* Chain to the next block from a cti terminated previous block.   BR_TYPE indicates whether the branch was taken and whether we can cache   the vpc of the branch target.   NEW_PC is the target's branch address, and is only valid if   BR_TYPE != SEM_BRANCH_UNTAKEN.  */INLINE SEM_PC@prefix@_pbb_cti_chain (SIM_CPU *current_cpu, SEM_ARG sem_arg,		     SEM_BRANCH_TYPE br_type, PCADDR new_pc){  SEM_PC *new_vpc_ptr;  PBB_UPDATE_INSN_COUNT (current_cpu, sem_arg);  /* If not running forever, exit back to main loop.  */  if (CPU_MAX_SLICE_INSNS (current_cpu) != 0      /* Also exit back to main loop if there's an event.         Note that if CPU_MAX_SLICE_INSNS != 1, events won't get processed	 at the "right" time, but then that was what was asked for.	 There is no silver bullet for simulator engines.         ??? Clearly this needs a cleaner interface.	 At present it's just so Ctrl-C works.  */      || STATE_EVENTS (CPU_STATE (current_cpu))->work_pending)    CPU_RUNNING_P (current_cpu) = 0;  /* Restart compiler if we branched to an uncacheable address     (e.g. "j reg").  */  if (br_type == SEM_BRANCH_UNCACHEABLE)    {      SET_H_PC (new_pc);      return CPU_SCACHE_PBB_BEGIN (current_cpu);    }  /* If branch wasn't taken, update the pc and set BR_ADDR_PTR to our     next chain ptr.  */  if (br_type == SEM_BRANCH_UNTAKEN)    {      ARGBUF *abuf = SEM_ARGBUF (sem_arg);      new_pc = abuf->addr;      SET_H_PC (new_pc);      new_vpc_ptr = &abuf->fields.chain.next;    }  else    {      ARGBUF *abuf = SEM_ARGBUF (sem_arg);      SET_H_PC (new_pc);      new_vpc_ptr = &abuf->fields.chain.branch_target;    }  /* If chained to next block, go straight to it.  */  if (*new_vpc_ptr)    return *new_vpc_ptr;  /* See if next block has already been compiled.  */  *new_vpc_ptr = scache_lookup (current_cpu, new_pc);  if (*new_vpc_ptr)    return *new_vpc_ptr;  /* Nope, so next insn is a virtual insn to invoke the compiler     (begin a pbb).  */  return CPU_SCACHE_PBB_BEGIN (current_cpu);}/* x-before handler.   This is called before each insn.  */void@prefix@_pbb_before (SIM_CPU *current_cpu, SCACHE *sc){  SEM_ARG sem_arg = sc;  const ARGBUF *abuf = SEM_ARGBUF (sem_arg);  int first_p = abuf->fields.before.first_p;  const ARGBUF *cur_abuf = SEM_ARGBUF (sc + 1);  const IDESC *cur_idesc = cur_abuf->idesc;  PCADDR pc = cur_abuf->addr;  if (ARGBUF_PROFILE_P (cur_abuf))    PROFILE_COUNT_INSN (current_cpu, pc, cur_idesc->num);  /* If this isn't the first insn, finish up the previous one.  */  if (! first_p)    {      if (PROFILE_MODEL_P (current_cpu))	{	  const SEM_ARG prev_sem_arg = sc - 1;	  const ARGBUF *prev_abuf = SEM_ARGBUF (prev_sem_arg);	  const IDESC *prev_idesc = prev_abuf->idesc;	  int cycles;	  /* ??? May want to measure all insns if doing insn tracing.  */	  if (ARGBUF_PROFILE_P (prev_abuf))	    {	      cycles = (*prev_idesc->timing->model_fn) (current_cpu, prev_sem_arg);	      @prefix@_model_insn_after (current_cpu, 0 /*last_p*/, cycles);	    }	}      TRACE_INSN_FINI (current_cpu, cur_abuf, 0 /*last_p*/);    }  /* FIXME: Later make cover macros: PROFILE_INSN_{INIT,FINI}.  */  if (PROFILE_MODEL_P (current_cpu)      && ARGBUF_PROFILE_P (cur_abuf))    @prefix@_model_insn_before (current_cpu, first_p);  TRACE_INSN_INIT (current_cpu, cur_abuf, first_p);  TRACE_INSN (current_cpu, cur_idesc->idata, cur_abuf, pc);}/* x-after handler.   This is called after a serial insn or at the end of a group of parallel   insns.  */void@prefix@_pbb_after (SIM_CPU *current_cpu, SCACHE *sc){  SEM_ARG sem_arg = sc;  const ARGBUF *abuf = SEM_ARGBUF (sem_arg);  const SEM_ARG prev_sem_arg = sc - 1;  const ARGBUF *prev_abuf = SEM_ARGBUF (prev_sem_arg);  /* ??? May want to measure all insns if doing insn tracing.  */  if (PROFILE_MODEL_P (current_cpu)      && ARGBUF_PROFILE_P (prev_abuf))    {      const IDESC *prev_idesc = prev_abuf->idesc;      int cycles;      cycles = (*prev_idesc->timing->model_fn) (current_cpu, prev_sem_arg);      @prefix@_model_insn_after (current_cpu, 1 /*last_p*/, cycles);    }  TRACE_INSN_FINI (current_cpu, prev_abuf, 1 /*last_p*/);}#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);  /* virtual program counter */  SEM_PC vpc;#if WITH_SEM_SWITCH_FULL  /* For communication between cti's and cti-chain.  */  SEM_BRANCH_TYPE pbb_br_type;  PCADDR pbb_br_npc;#endifEOFcase x$parallel inxread | xwrite)    cat << EOF  PAREXEC pbufs[MAX_PARALLEL_INSNS];  PAREXEC *par_exec = &pbufs[0];EOF    ;;esac# 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))    {      /* ??? 'twould be nice to move this up a level and only call it once.	 On the other hand, in the "let's go fast" case the test is only done	 once per pbb (since we only return to the main loop at the end of	 a pbb).  And in the "let's run until we're done" case we don't return	 until the program exits.  */#if WITH_SEM_SWITCH_FULL#if defined (__GNUC__)/* ??? Later maybe paste sem-switch.c in when building mainloop.c.  */#define DEFINE_LABELS#include "$switch"#endif#else      @prefix@_sem_init_idesc_table (current_cpu);#endif      /* Initialize the "begin (compile) a pbb" virtual insn.  */      vpc = CPU_SCACHE_PBB_BEGIN (current_cpu);      SEM_SET_FULL_CODE (SEM_ARGBUF (vpc),			 & CPU_IDESC (current_cpu) [@PREFIX@_INSN_X_BEGIN]);      vpc->argbuf.idesc = & CPU_IDESC (current_cpu) [@PREFIX@_INSN_X_BEGIN];      CPU_IDESC_SEM_INIT_P (current_cpu) = 1;    }  CPU_RUNNING_P (current_cpu) = 1;  /* ??? In the case where we're returning to the main loop after every     pbb we don't want to call pbb_begin each time (which hashes on the pc     and does a table lookup).  A way to speed this up is to save vpc     between calls.  */  vpc = @prefix@_pbb_begin (current_cpu, FAST_P);  do    {/* begin full-exec-pbb */EOF${SHELL} $infile full-exec-pbbcat << EOF/* end full-exec-pbb */    }  while (CPU_RUNNING_P (current_cpu));}#undef FAST_PEOF##################################### Compile 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);  /* virtual program counter */  SEM_PC vpc;#if WITH_SEM_SWITCH_FAST  /* For communication between cti's and cti-chain.  */  SEM_BRANCH_TYPE pbb_br_type;  PCADDR pbb_br_npc;#endifEOFcase x$parallel inxread | xwrite)    cat << EOF  PAREXEC pbufs[MAX_PARALLEL_INSNS];  PAREXEC *par_exec = &pbufs[0];EOF    ;;esac# 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))    {      /* ??? 'twould be nice to move this up a level and only call it once.	 On the other hand, in the "let's go fast" case the test is only done	 once per pbb (since we only return to the main loop at the end of	 a pbb).  And in the "let's run until we're done" case we don't return	 until the program exits.  */#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      /* Initialize the "begin (compile) a pbb" virtual insn.  */      vpc = CPU_SCACHE_PBB_BEGIN (current_cpu);      SEM_SET_FAST_CODE (SEM_ARGBUF (vpc),			 & CPU_IDESC (current_cpu) [@PREFIX@_INSN_X_BEGIN]);      vpc->argbuf.idesc = & CPU_IDESC (current_cpu) [@PREFIX@_INSN_X_BEGIN];      CPU_IDESC_SEM_INIT_P (current_cpu) = 1;    }  CPU_RUNNING_P (current_cpu) = 1;  /* ??? In the case where we're returning to the main loop after every     pbb we don't want to call pbb_begin each time (which hashes on the pc     and does a table lookup).  A way to speed this up is to save vpc     between calls.  */  vpc = @prefix@_pbb_begin (current_cpu, FAST_P);  do    {/* begin fast-exec-pbb */EOF${SHELL} $infile fast-exec-pbbcat << EOF/* end fast-exec-pbb */    }  while (CPU_RUNNING_P (current_cpu));}#undef FAST_PEOFfi # -fastfi # -pbb# Expand @..@ macros appearing in tmp-mloop-{pid}.cin.sed \  -e "s/@cpu@/$cpu/g" -e "s/@CPU@/$CPU/g" \  -e "s/@prefix@/$prefix/g" -e "s/@PREFIX@/$PREFIX/g" < tmp-mloop-$$.cin > mloop${outsuffix}.cinrc=$?rm -f tmp-mloop-$$.cinexit $rc

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -