OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-binutils/] [binutils-2.19.1/] [cgen/] [sim-model.scm] - Rev 26

Go to most recent revision | Compare with Previous | Blame | View Log

; Simulator model support, plus misc. things associated with a cpu family.
; Copyright (C) 2000, 2003, 2009 Red Hat, Inc.
; This file is part of CGEN.
; Return C code to define cpu implementation properties.
"UNIT_""_""\
/* The properties of this cpu's implementation.  */
 
static const MACH_IMP_PROPERTIES @cpu@_imp_properties =
{
  sizeof (SIM_CPU),
#if WITH_SCACHE
  sizeof (SCACHE)
#else
  0
#endif
};\n\n"; Insn modeling support.
; Generate code to profile hardware elements.
; ??? Not currently used.
; Fetch profilable input and output operands of the semantic code.
; For each operand, record its being get/set.
; Return decls of hardware element profilers.
; ??? Not currently used.
"/* Hardware profiling handlers.  */\n\n""extern void @cpu@_model_mark_get_"" (SIM_CPU *"""", int"; FIXME: get index type
");\n""extern void @cpu@_model_mark_set_"" (SIM_CPU *"""", int"; FIXME: get index type
");\n""\n"; Return name of profiling handler for MODEL, UNIT.
; Also called by sim.scm.
"@cpu@_model_""_"; Return decls of all insn model handlers.
; This is called from sim-decode.scm.
" /*""*/"; Indices of scalars not passed.
; -gen-hw-profile-decls
"/* Function unit handlers (user written).  */\n\n""extern int "" (SIM_CPU *, const IDESC *,"" int /*unit_num*/, int /*referenced*/"");\n""\n""/* Profiling before/after handlers (user written) */\n\n""extern void @cpu@_model_insn_before (SIM_CPU *, int /*first_p*/);\n""extern void @cpu@_model_insn_after (SIM_CPU *, int /*last_p*/, int /*cycles*/);\n""\n"; Return name of profile handler for INSN, MODEL.
"model_""_"; Return function to model INSN.
"Processing modeling for "": \"""\" ...\n""static int\n"; sem_arg is a void * to keep cgen specific stuff out of sim-model.h
" (SIM_CPU *current_cpu, void *sem_arg)\n""{\n""""  const ARGBUF * UNUSED abuf = SEM_ARGBUF ((SEM_ARG) sem_arg);\n""  const IDESC * UNUSED idesc = abuf->idesc;\n"; or: idesc = & CPU_IDESC (current_cpu) ["
; (gen-cpu-insn-enum (mach-cpu (model:mach model)) insn)
; "];\n"
"  int cycles = 0;\n""""  IADDR UNUSED pc = GET_H_PC ();\n""  CGEN_INSN_INT insn = abuf->insn;\n""  ""  "; Emit code to model the insn.  Function units are handled here.
"cycles""  return cycles;\n""""}\n\n"; Return insn modeling handlers.
; ??? Might wish to reduce the amount of output by combining identical cases.
; ??? Modelling of insns could be table driven, but that puts constraints on
; generality.
"/* Model handlers for each insn.  */\n\n"; Generate timing table entry for function unit U while executing INSN.
; U is a <unit> object.
; ARGS is a list of overriding arguments from INSN.
"{ ""(int) "", "", "" }, "; Generate timing table entry for MODEL for INSN.
; Instruction timing is stored as an associative list based on the model.
;(display timing) (newline)
"  { "", ""0"", { "" } },\n"; Generate model timing table for MODEL.
"/* Model timing data for `""'.  */\n\n""static const INSN_TIMING ""_timing[] = {\n""};\n\n"; Return C code to define model profiling support stuff.
"/* We assume UNIT_NONE == 0 because the tables don't always terminate\n""   entries with it.  */\n\n"; Return C code to define the model table for MACH.
"\
static const MODEL ""_models[] =\n{\n""  { ""\"""\", ""& ""_mach, "", ""TIMING_DATA (& ""_timing[0]), ""_model_init"" },\n""  { 0 }\n""};\n\n"; Return C code to define model init fn.
"\
static void\n""_model_init (SIM_CPU *cpu)
{
  CPU_MODEL_DATA (cpu) = (void *) zalloc (sizeof (MODEL_""_DATA));
}\n\n"; Return C code to define model data and support fns.
"#if WITH_PROFILE_MODEL_P
#define TIMING_DATA(td) td
#else
#define TIMING_DATA(td) 0
#endif\n\n"; Return C definitions for this cpu family variant.
"\
 
static void
@cpu@_prepare_run (SIM_CPU *cpu)
{
  if (CPU_IDESC (cpu) == NULL)
    @cpu@_init_idesc_table (cpu);
}
 
static const CGEN_INSN *
@cpu@_get_idata (SIM_CPU *cpu, int inum)
{
  return CPU_IDESC (cpu) [inum].idata;
}
 
"; Return C code to define the machine data.
"\
static void\n""_init_cpu (SIM_CPU *cpu)
{
  CPU_REG_FETCH (cpu) = ""_fetch_register;
  CPU_REG_STORE (cpu) = ""_store_register;
  CPU_PC_FETCH (cpu) = ""_h_pc_get;
  CPU_PC_STORE (cpu) = ""_h_pc_set;
  CPU_GET_IDATA (cpu) = @cpu@_get_idata;
  CPU_MAX_INSNS (cpu) = @PREFIX@_INSN__MAX;
  CPU_INSN_NAME (cpu) = cgen_insn_name;
  CPU_FULL_ENGINE_FN (cpu) = @prefix@_engine_run_full;
#if WITH_FAST
  CPU_FAST_ENGINE_FN (cpu) = @prefix@_engine_run_fast;
#else
  CPU_FAST_ENGINE_FN (cpu) = @prefix@_engine_run_full;
#endif
}
 
const MACH ""_mach =
{
  \"""\", ""\"""\", "",\n""  "", "; FIXME: addr-bitsize: delete
", ""& ""_models[0], ""& ""_imp_properties,
  ""_init_cpu,
  @cpu@_prepare_run
};
 
"; Top level file generators.
; Generate model.c
"Generating ""'s model.c ...\n"; Turn parallel execution support on if cpu needs it.
"Simulator model support for @cpu@.""\
#define WANT_CPU @cpu@
#define WANT_CPU_@CPU@
 
#include \"sim-main.h\"
 
/* The profiling data is recorded here, but is accessed via the profiling
   mechanism.  After all, this is information for profiling.  */
 
#if WITH_PROFILE_MODEL_P
 
""#endif /* WITH_PROFILE_MODEL_P */\n\n"

Go to most recent revision | Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.