Add model-functions support

This commit is contained in:
Michael Meissner 1995-11-13 01:27:21 +00:00
parent d101d7bf06
commit eb4ef19775
3 changed files with 119 additions and 14 deletions

View File

@ -1,4 +1,15 @@
Sun Nov 12 07:58:09 1995 Michael Meissner <meissner@wogglebug.tiac.net>
Sun Nov 12 07:58:09 1995 Michael Meissner <meissner@tiktok.cygnus.com>
* igen.c (model_table_insert_{macro,function}): New functions.
(insn_table_load_insns): Call them.
(gen_model_h): Move section emiting model-macros to be first.
(model_{c,h}_function): New functions cloned from semantic
functions to print out the prototype and function for
model-functions.
(gen_model_{c,h}): Print out model-functions.
* ppc-instructions (model_{start,halt,print_info}): Add dummy
model-functions.
* options.c (print_options): Print out WITH_{,DEFAULT_}MODEL, not
WITH_PPC_{,DEFAULT_}_MODEL.

View File

@ -651,6 +651,9 @@ static model *last_model;
static insn *model_macros;
static insn *last_model_macro;
static insn *model_functions;
static insn *last_model_function;
static void
insn_table_insert_function(insn_table *table,
table_entry *file_entry)
@ -793,6 +796,32 @@ model_table_insert(insn_table *table,
strcpy(name + name_len, "_SENTINEL");
}
static void
model_table_insert_macro(insn_table *table,
table_entry *file_entry)
{
insn *macro = ZALLOC(insn);
macro->file_entry = file_entry;
if (last_model_macro)
last_model_macro->next = macro;
else
model_macros = macro;
last_model_macro = macro;
}
static void
model_table_insert_function(insn_table *table,
table_entry *file_entry)
{
insn *func = ZALLOC(insn);
func->file_entry = file_entry;
if (last_model_function)
last_model_function->next = func;
else
model_functions = func;
last_model_function = func;
}
static void
insn_table_insert_insn(insn_table *table,
@ -1110,13 +1139,10 @@ insn_table_load_insns(char *file_name)
model_table_insert(table, file_entry);
}
else if (it_is("model-macro", file_entry->fields[insn_flags])) {
insn *macro = ZALLOC(insn);
macro->file_entry = file_entry;
if (last_model_macro)
last_model_macro->next = macro;
else
model_macros = macro;
last_model_macro = macro;
model_table_insert_macro(table, file_entry);
}
else if (it_is("model-function", file_entry->fields[insn_flags])) {
model_table_insert_function(table, file_entry);
}
else {
insn_fields *fields;
@ -2940,9 +2966,30 @@ gen_itable_c(insn_table *table, lf *file)
/****************************************************************/
static void
model_h_function(insn_table *entry,
lf *file,
table_entry *function)
{
if (function->fields[function_type] == NULL
|| function->fields[function_type][0] == '\0') {
semantics_h_print_function(file,
function->fields[function_name],
NULL);
}
else {
lf_printf(file, "\n");
lf_printf(file, "INLINE_MODEL %s %s\n(%s);\n",
function->fields[function_type],
function->fields[function_name],
function->fields[function_param]);
}
}
static void
gen_model_h(insn_table *table, lf *file)
{
insn *insn_ptr;
model *model_ptr;
model_func_unit *func_unit_ptr;
insn *macro;
@ -2953,6 +3000,13 @@ gen_model_h(insn_table *table, lf *file)
lf_printf(file, "#ifndef _MODEL_H_\n");
lf_printf(file, "#define _MODEL_H_\n");
lf_printf(file, "\n");
if (model_macros) {
for(macro = model_macros; macro; macro = macro->next)
lf_printf(file, "%s\n", macro->file_entry->fields[insn_comment]);
lf_printf(file, "\n");
}
lf_printf(file, "#ifndef INLINE_MODEL\n");
lf_printf(file, "#define INLINE_MODEL\n");
lf_printf(file, "#endif\n");
@ -3027,12 +3081,6 @@ gen_model_h(insn_table *table, lf *file)
lf_printf(file, "\n");
}
if (model_macros) {
for(macro = model_macros; macro; macro = macro->next)
lf_printf(file, "%s\n", macro->file_entry->fields[insn_comment]);
lf_printf(file, "\n");
}
lf_printf(file, "extern model_enum current_model;\n");
lf_printf(file, "extern const char *model_name[ (int)nr_models ];\n");
lf_printf(file, "extern const char *const *const model_func_unit_name[ (int)nr_models ];\n");
@ -3040,6 +3088,12 @@ gen_model_h(insn_table *table, lf *file)
lf_printf(file, "\n");
lf_printf(file, "INLINE_MODEL void model_set\n");
lf_printf(file, "(const char *name);\n");
for(insn_ptr = model_functions; insn_ptr; insn_ptr = insn_ptr->next) {
model_h_function(table, file, insn_ptr->file_entry);
lf_printf(file, "\n");
}
lf_printf(file, "\n");
lf_printf(file, "#endif /* _MODEL_H_ */\n");
}
@ -3079,9 +3133,39 @@ model_c_insn(insn_table *entry,
lf_printf(file, " { %s_SENTINEL },\n", current_name);
}
static void
model_c_function(insn_table *table,
lf *file,
table_entry *function)
{
if (function->fields[function_type] == NULL
|| function->fields[function_type][0] == '\0') {
lf_print_c_semantic_function_header(file,
function->fields[function_name],
NULL);
}
else {
lf_printf(file, "\n");
lf_printf(file, "INLINE_MODEL %s\n%s(%s)\n",
function->fields[function_type],
function->fields[function_name],
function->fields[function_param]);
}
table_entry_lf_c_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_lf_c_line_nr(file);
}
static void
gen_model_c(insn_table *table, lf *file)
{
insn *insn_ptr;
model *model_ptr;
model_func_unit *func_unit_ptr;
int i;
@ -3142,6 +3226,7 @@ gen_model_c(insn_table *table, lf *file)
}
lf_printf(file, "};\n");
lf_printf(file, "\n");
lf_printf(file, "\f\n");
lf_printf(file, "/* Insn functional unit info */\n");
for(model_ptr = models; model_ptr; model_ptr = model_ptr->next) {
@ -3156,6 +3241,7 @@ gen_model_c(insn_table *table, lf *file)
lf_printf(file, "};\n");
lf_printf(file, "\n");
lf_printf(file, "\f\n");
}
lf_printf(file, "const model_time *const model_time_mapping[ (int)nr_models ] = {\n");
@ -3166,6 +3252,11 @@ gen_model_c(insn_table *table, lf *file)
lf_printf(file, "};\n");
lf_printf(file, "\n");
for(insn_ptr = model_functions; insn_ptr; insn_ptr = insn_ptr->next) {
model_c_function(table, file, insn_ptr->file_entry);
lf_printf(file, "\n");
}
lf_printf(file, "INLINE_MODEL void\n");
lf_printf(file, "model_set(const char *name)\n");
lf_printf(file, "{\n");

View File

@ -75,6 +75,9 @@
::model:603e:PPC603e:IU=1 integer,FPU=1 floating point,LSU=1 memory,SRU=1 system register,BPU=1 branch
::model:603:PPC603:IU=1 integer,FPU=1 floating point,LSU=1 memory,SRU=1 system register,BPU=1 branch
void::model-function::model_init:void
void::model-function::model_halt:void
void::model-function::model_print_info:void
# The following (illegal) instruction is `known' by gen and is
# called when ever an illegal instruction is encountered