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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-binutils/] [binutils-2.19.1/] [cgen/] [sid-model.scm] - Rev 6

Compare with Previous | Blame | View Log

; Simulator model support, plus misc. things associated with a cpu family.
; Copyright (C) 2000, 2002, 2003, 2006, 2009 Red Hat, Inc.
; This file is part of CGEN.
"UNIT_"; Return C code to define cpu implementation properties.
"\
/* The properties of this cpu's implementation.  */
 
static const MACH_IMP_PROPERTIES @cpu@_imp_properties =
{
  sizeof (@cpu@_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 @prefix@_model_mark_get_"" (@cpu@_cpu *"""", int"; FIXME: get index type
");\n""extern void @prefix@_model_mark_set_"" (@cpu@_cpu *"""", int"; FIXME: get index type
");\n""\n"; Return the name of the class representing the given MODEL.
"@prefix@_""_model"; Return name of profiling handler for MODEL, UNIT.
; Also called by sim.scm.
"model_""_"" /*""*/"; Indices of scalars not passed.
"  virtual UINT "" (@cpu@_cpu *cpu, const struct @prefix@_idesc *idesc,"" int unit_num"", unsigned long long referenced"""")\n"; Return decls of all insn model handlers.
"\n""// Function unit handlers\n""// To be overridden as needed.\n""    {\n""      return 0;\n""    }\n""    {\n""      return timing[idesc->sem_index].units[unit_num].done;\n""    }\n"; Return name of profile handler for INSN, MODEL.
"model_""_""::"; Return declaration of function to model INSN.
"UINT "" (@cpu@_cpu *current_cpu, @prefix@_scache *sem);\n""  // These methods call the appropriate unit modeller(s) for each insn.\n""  ""  "; Return function to model INSN.
"Processing modeling for "": \"""\" ...\n""UINT\n"" (@cpu@_cpu *current_cpu, @prefix@_scache *sem)\n""{\n""""  const @prefix@_scache* abuf = sem;\n""  const @prefix@_idesc* 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""""  PCADDR UNUSED pc = current_cpu->hardware.h_pc;\n""  @prefix@_insn_word 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 the model constructor.
"::"" (@cpu@_cpu *cpu)\n""  : cgen_model (cpu)\n""{\n""}\n""\n""\n""  ""unit types""UNIT_"; "apply append" squeezes out nils.
; create <model_name>-<unit-name> for each unit
"  struct unit {\n""    unit_number unit;\n""    UINT issue;\n""    UINT done;\n""  };\n\n"; FIXME: revisit MAX_UNITS
"  static const int MAX_UNITS = "";\n"; Return the C++ class representing the given model.
"\
class "" : public cgen_model
{
public:
  "" (@cpu@_cpu *cpu);
 
  // Call the proper unit modelling function for the given insn.
  UINT model_before (@cpu@_cpu *current_cpu, @prefix@_scache* sem)
    {
      return (this->*(timing[sem->idesc->sem_index].model_before)) (current_cpu, sem);
    } 
  UINT model_after (@cpu@_cpu *current_cpu, @prefix@_scache* sem)
    {
      return (this->*(timing[sem->idesc->sem_index].model_after)) (current_cpu, sem);
    } 
""\
 
protected:
""\
 
  typedef UINT (""::*model_function) (@cpu@_cpu* current_cpu, @prefix@_scache* sem);
 
  struct insn_timing {
    // This is an integer that identifies this insn.
    UINT num;
    // Functions to handle insn-specific profiling.
    model_function model_before;
    model_function model_after;
    // Array of function units used by this insn.
    unit units[MAX_UNITS];
  };
 
  static const insn_timing timing[];
};
"; Return the C++ classes representing the current list of models.
"\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.
"{ ""::"", "", "" }, "; Generate timing table entry for MODEL for INSN.
; Instruction timing is stored as an associative list based on the model.
;(display timing) (newline)
"  { "", ""0, 0""& "", ""& "", { "" } },\n"; Generate model timing table for MODEL.
"/* Model timing data for `""'.  */\n\n""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 (@cpu@_cpu *cpu)
{
  cpu->model_data = new @PREFIX@_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.
""; Return C code to define the machine data.
"\
static void\n""_init_cpu (@cpu@_cpu *cpu)
{
  @prefix@_init_idesc_table (cpu);
}
 
const MACH ""_mach =
{
  \"""\", ""\"""\",
  "", "; FIXME: addr-bitsize: delete
", ""& ""_models[0], ""& ""_imp_properties,
  ""_init_cpu
};
 
"; Top level file generators.
; Generate model.cxx
"Generating ""-model.cxx ...\n"; Turn parallel execution support on if cpu needs it.
"Simulator model support for @prefix@.""\
 
#if HAVE_CONFIG_H
#include \"config.h\"
#endif
#include \"@cpu@.h\"
 
using namespace @cpu@; // FIXME: namespace organization still wip
 
/* The profiling data is recorded here, but is accessed via the profiling
   mechanism.  After all, this is information for profiling.  */
 
";  not adapted for sid yet
;   -gen-model-defns
;   -gen-cpu-imp-properties
;   -gen-cpu-defns
;   -gen-mach-defns
"Generating ""-model.h ...\n""Simulator model support for @prefix@.""\
#ifndef @PREFIX@_MODEL_H
#define @PREFIX@_MODEL_H
 
#include \"cgen-cpu.h\"
#include \"cgen-model.h\"
 
namespace @cpu@
{
using namespace cgen;
""\
 
} // namespace @cpu@
 
#endif // @PREFIX@_MODEL_H
"

Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

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