static void model_c_function(insn_table *table, lf *file, table_entry *function, const char *prefix) { if (function->fields[function_type] == NULL || function->fields[function_type][0] == '\0') { error("Model function return type not specified for %s", function->fields[function_name]); } else { lf_printf(file, "\n"); lf_print_function_type(file, function->fields[function_type], prefix, "\n"); lf_printf(file, "%s(%s)\n", function->fields[function_name], function->fields[function_param]); } table_entry_print_cpp_line_nr(file, function); lf_printf(file, "{\n"); if (function->annex) { lf_indent(file, +2); lf_print__c_code(file, function->annex); lf_indent(file, -2); } lf_printf(file, "}\n"); lf_print__internal_reference(file); lf_printf(file, "\n"); }
static void model_c_or_h_data (insn_table *table, lf *file, table_entry *data) { if (data->annex) { table_entry_print_cpp_line_nr (file, data->annex_line); lf_print__c_code (file, data->annex); lf_print__internal_reference (file); lf_printf (file, "\n"); } }
void print_semantic_body(lf *file, insn *instruction, insn_bits *expanded_bits, opcode_field *opcodes) { print_itrace(file, instruction->file_entry, 0/*put_value_in_cache*/); /* validate the instruction, if a cache this has already been done */ if (!(code & generate_with_icache)) print_idecode_validate(file, instruction, opcodes); /* generate the profiling call - this is delayed until after the instruction has been verified */ lf_printf(file, "\n"); lf_printf(file, "/* monitoring: */\n"); lf_printf(file, "if (WITH_MON & MONITOR_INSTRUCTION_ISSUE) {\n"); lf_printf(file, " mon_issue("); print_function_name(file, instruction->file_entry->fields[insn_name], NULL, function_name_prefix_itable); lf_printf(file, ", processor, cia);\n"); lf_printf(file, "}\n"); /* generate the code (or at least something */ lf_printf(file, "\n"); lf_printf(file, "/* semantics: */\n"); lf_printf(file, "nia = cia + %d;\n", insn_bit_size / 8); if (instruction->file_entry->annex != NULL) { /* true code */ table_entry_print_cpp_line_nr(file, instruction->file_entry); lf_printf(file, "{\n"); lf_indent(file, +2); lf_print__c_code(file, instruction->file_entry->annex); lf_indent(file, -2); lf_printf(file, "}\n"); lf_print__internal_reference(file); } else if (it_is("nop", instruction->file_entry->fields[insn_flags])) { lf_print__internal_reference(file); } else { /* abort so it is implemented now */ table_entry_print_cpp_line_nr(file, instruction->file_entry); lf_putstr(file, "error(\"%s:%d:0x%08lx:%s unimplemented\\n\",\n"); lf_printf(file, " itable[MY_INDEX].file, itable[MY_INDEX].line_nr, (long)cia, itable[MY_INDEX].name);\n"); lf_print__internal_reference(file); } }
void print_icache_internal_function_definition(insn_table *table, lf *file, void *data, table_entry *function) { ASSERT((code & generate_with_icache) != 0); if (it_is("internal", function->fields[insn_flags])) { lf_printf(file, "\n"); lf_print_function_type(file, ICACHE_FUNCTION_TYPE, "INLINE_ICACHE", "\n"); print_function_name(file, function->fields[insn_name], NULL, function_name_prefix_icache); lf_printf(file, "\n(%s)\n", ICACHE_FUNCTION_FORMAL); lf_printf(file, "{\n"); lf_indent(file, +2); lf_printf(file, "/* semantic routine */\n"); table_entry_print_cpp_line_nr(file, function); if ((code & generate_with_semantic_icache)) { lf_print__c_code(file, function->annex); lf_printf(file, "error(\"Internal function must longjump\\n\");\n"); lf_printf(file, "return 0;\n"); } else { lf_printf(file, "return "); print_function_name(file, function->fields[insn_name], NULL, function_name_prefix_semantics); lf_printf(file, ";\n"); } lf_print__internal_reference(file); lf_indent(file, -2); lf_printf(file, "}\n"); } }
static void support_c_function(insn_table *table, lf *file, void *data, table_entry *function) { ASSERT(function->fields[function_type] != NULL); print_support_function_name(file, function, 1/*!is_definition*/); table_entry_print_cpp_line_nr(file, function); lf_printf(file, "{\n"); lf_indent(file, +2); lf_print__c_code(file, function->annex); if (it_is("internal", function->fields[insn_flags])) { lf_printf(file, "error(\"Internal function must longjump\\n\");\n"); lf_printf(file, "return 0;\n"); } lf_indent(file, -2); lf_printf(file, "}\n"); lf_print__internal_reference(file); lf_printf(file, "\n"); }