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

📄 gen-engine.c

📁 这个是LINUX下的GDB调度工具的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
}#endif#if 0static voidprint_jump_insn (lf *file,		 insn_entry * instruction,		 opcode_bits *expanded_bits,		 opcode_field *opcodes, cache_entry *cache_rules){  insn_opcodes opcode_path;  memset (&opcode_path, 0, sizeof (opcode_path));  opcode_path.opcode = opcodes;  /* what we are for the moment */  lf_printf (file, "\n");  print_my_defines (file,		    instruction->name,		    instruction->format_name, expanded_bits);  /* output the icache entry */  if (options.gen.icache)    {      lf_printf (file, "\n");      lf_indent (file, -1);      print_function_name (file,			   instruction->name,			   instruction->format_name,			   NULL, expanded_bits, function_name_prefix_icache);      lf_printf (file, ":\n");      lf_indent (file, +1);      lf_printf (file, "{\n");      lf_indent (file, +2);      lf_putstr (file, "const unsigned_word cia = nia;\n");      print_itrace (file, instruction, 1 /*putting-value-in-cache */ );      print_idecode_validate (file, instruction, &opcode_path);      lf_printf (file, "\n");      lf_printf (file, "{\n");      lf_indent (file, +2);      print_icache_body (file, instruction, expanded_bits, cache_rules, 0,	/*use_defines */			 put_values_in_icache);      lf_printf (file, "cache_entry->address = nia;\n");      lf_printf (file, "cache_entry->semantic = &&");      print_function_name (file,			   instruction->name,			   instruction->format_name,			   NULL,			   expanded_bits, function_name_prefix_semantics);      lf_printf (file, ";\n");      if (options.gen.semantic_icache)	{	  print_semantic_body (file,			       instruction, expanded_bits, &opcode_path);	  print_jump (file, 1 /*is-tail */ );	}      else	{	  lf_printf (file, "/* goto ");	  print_function_name (file,			       instruction->name,			       instruction->format_name,			       NULL,			       expanded_bits, function_name_prefix_semantics);	  lf_printf (file, "; */\n");	}      lf_indent (file, -2);      lf_putstr (file, "}\n");      lf_indent (file, -2);      lf_printf (file, "}\n");    }  /* print the semantics */  lf_printf (file, "\n");  lf_indent (file, -1);  print_function_name (file,		       instruction->name,		       instruction->format_name,		       NULL, expanded_bits, function_name_prefix_semantics);  lf_printf (file, ":\n");  lf_indent (file, +1);  lf_printf (file, "{\n");  lf_indent (file, +2);  lf_putstr (file, "const unsigned_word cia = nia;\n");  print_icache_body (file,		     instruction,		     expanded_bits,		     cache_rules,		     (options.gen.direct_access		      ? define_variables		      : declare_variables),		     (options.gen.icache		      ? get_values_from_icache : do_not_use_icache));  print_semantic_body (file, instruction, expanded_bits, &opcode_path);  if (options.gen.direct_access)    print_icache_body (file,		       instruction,		       expanded_bits,		       cache_rules,		       undef_variables,		       (options.gen.icache			? get_values_from_icache : do_not_use_icache));  print_jump (file, 1 /*is tail */ );  lf_indent (file, -2);  lf_printf (file, "}\n");}#endif#if 0static voidprint_jump_definition (lf *file, gen_entry *entry, int depth, void *data){  cache_entry *cache_rules = (cache_entry *) data;  if (entry->opcode_rule->with_duplicates)    {      ASSERT (entry->nr_insns == 1	      && entry->opcode == NULL	      && entry->parent != NULL && entry->parent->opcode != NULL);      ASSERT (entry->nr_insns == 1	      && entry->opcode == NULL	      && entry->parent != NULL	      && entry->parent->opcode != NULL	      && entry->parent->opcode_rule != NULL);      print_jump_insn (file,		       entry->insns->insn,		       entry->expanded_bits, entry->opcode, cache_rules);    }  else    {      print_jump_insn (file, entry->insns->insn, NULL, NULL, cache_rules);    }}#endif#if 0static voidprint_jump_internal_function (lf *file, function_entry * function, void *data){  if (function->is_internal)    {      lf_printf (file, "\n");      lf_print__line_ref (file, function->line);      lf_indent (file, -1);      print_function_name (file,			   function->name,			   NULL,			   NULL,			   NULL,			   (options.gen.icache			    ? function_name_prefix_icache			    : function_name_prefix_semantics));      lf_printf (file, ":\n");      lf_indent (file, +1);      lf_printf (file, "{\n");      lf_indent (file, +2);      lf_printf (file, "const unsigned_word cia = nia;\n");      table_print_code (file, function->code);      lf_print__internal_ref (file);      lf_printf (file, "error(\"Internal function must longjump\\n\");\n");      lf_indent (file, -2);      lf_printf (file, "}\n");    }}#endif#if 0static voidprint_jump_body (lf *file,		 gen_entry *entry, insn_table *isa, cache_entry *cache_rules){  lf_printf (file, "{\n");  lf_indent (file, +2);  lf_putstr (file, "jmp_buf halt;\n");  lf_putstr (file, "jmp_buf restart;\n");  lf_putstr (file, "cpu *processor = NULL;\n");  lf_putstr (file, "unsigned_word nia = -1;\n");  lf_putstr (file, "instruction_word instruction = 0;\n");  if (options.gen.icache)    {      lf_putstr (file, "engine_cache *cache_entry = NULL;\n");    }  if (options.gen.smp)    {      lf_putstr (file, "int current_cpu = -1;\n");    }  /* all the switches and tables - they know about jumping */  print_idecode_lookups (file, entry, cache_rules);  /* start the simulation up */  if (options.gen.icache)    {      lf_putstr (file, "\n");      lf_putstr (file, "{\n");      lf_putstr (file, "  int cpu_nr;\n");      lf_putstr (file, "  for (cpu_nr = 0; cpu_nr < nr_cpus; cpu_nr++)\n");      lf_putstr (file, "    cpu_flush_icache(processors[cpu_nr]);\n");      lf_putstr (file, "}\n");    }  lf_putstr (file, "\n");  lf_putstr (file, "psim_set_halt_and_restart(system, &halt, &restart);\n");  lf_putstr (file, "\n");  lf_putstr (file, "if (setjmp(halt))\n");  lf_putstr (file, "  return;\n");  lf_putstr (file, "\n");  lf_putstr (file, "setjmp(restart);\n");  lf_putstr (file, "\n");  if (!options.gen.smp)    {      lf_putstr (file, "processor = processors[0];\n");      lf_putstr (file, "nia = cpu_get_program_counter(processor);\n");    }  else    {      lf_putstr (file, "current_cpu = psim_last_cpu(system);\n");    }  if (!options.gen.icache)    {      lf_printf (file, "\n");      lf_indent (file, -1);      lf_printf (file, "engine:\n");      lf_indent (file, +1);    }  print_jump (file, 0 /*is_tail */ );  if (options.gen.icache)    {      lf_indent (file, -1);      lf_printf (file, "cache_miss:\n");      lf_indent (file, +1);    }  print_engine_issue_prefix_hook (file);  lf_putstr (file, "instruction\n");  lf_putstr (file,	     "  = vm_instruction_map_read(cpu_instruction_map(processor),\n");  lf_putstr (file, "                            processor, nia);\n");  print_engine_issue_prefix_hook (file);  print_idecode_body (file, entry, "/*IGORE*/");  print_engine_issue_postfix_hook (file);  /* print out a table of all the internals functions */  function_entry_traverse (file, isa->functions,			   print_jump_internal_function, NULL);  /* print out a table of all the instructions */  ERROR ("Use the list of semantic functions, not travere_tree");  gen_entry_traverse_tree (file, entry, 1, NULL,	/* start */			   print_jump_definition,	/* leaf */			   NULL,	/* end */			   cache_rules);  lf_indent (file, -2);  lf_printf (file, "}\n");}#endif/****************************************************************/voidprint_engine_run_function_header (lf *file,				  char *processor,				  function_decl_type decl_type){  int indent;  lf_printf (file, "\n");  switch (decl_type)    {    case is_function_declaration:      lf_print__function_type (file, "void", "INLINE_ENGINE", "\n");      break;    case is_function_definition:      lf_print__function_type (file, "void", "INLINE_ENGINE", " ");      break;    case is_function_variable:      lf_printf (file, "void (*");      break;    }  indent = print_function_name (file, "run", NULL,	/* format name */				processor, NULL,	/* expanded bits */				function_name_prefix_engine);  switch (decl_type)    {    case is_function_definition:      lf_putstr (file, "\n(");      indent = 1;      break;    case is_function_declaration:      indent += lf_printf (file, " (");      break;    case is_function_variable:      lf_putstr (file, ")\n(");      indent = 1;      break;    }  lf_indent (file, +indent);  lf_printf (file, "SIM_DESC sd,\n");  lf_printf (file, "int next_cpu_nr,\n");  lf_printf (file, "int nr_cpus,\n");  lf_printf (file, "int siggnal)");  lf_indent (file, -indent);  switch (decl_type)    {    case is_function_definition:      lf_putstr (file, "\n");      break;    case is_function_variable:    case is_function_declaration:      lf_putstr (file, ";\n");      break;    }}voidgen_engine_h (lf *file,	      gen_table *gen, insn_table *isa, cache_entry *cache_rules){  gen_list *entry;  for (entry = gen->tables; entry != NULL; entry = entry->next)    {      print_engine_run_function_header (file,					(options.gen.multi_sim					 ? entry->model->name					 : NULL), is_function_declaration);    }}voidgen_engine_c (lf *file,	      gen_table *gen, insn_table *isa, cache_entry *cache_rules){  gen_list *entry;  /* the intro */  print_includes (file);  print_include_inline (file, options.module.semantics);  print_include (file, options.module.engine);  lf_printf (file, "\n");  lf_printf (file, "#include \"sim-assert.h\"\n");  lf_printf (file, "\n");  print_idecode_globals (file);  lf_printf (file, "\n");  for (entry = gen->tables; entry != NULL; entry = entry->next)    {      switch (options.gen.code)	{	case generate_calls:	  print_idecode_lookups (file, entry->table, cache_rules);	  /* output the main engine routine */	  print_engine_run_function_header (file,					    (options.gen.multi_sim					     ? entry->model->name					     : NULL), is_function_definition);	  print_run_body (file, entry->table);	  break;	case generate_jumps:	  ERROR ("Jumps currently unimplemented");#if 0	  print_engine_run_function_header (file,					    entry->processor,					    is_function_definition);	  print_jump_body (file, entry->table, isa, cache_rules);#endif	  break;	}    }}

⌨️ 快捷键说明

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