/* This file is part of the program psim.
- Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>
+ Copyright (C) 1994-1997, Andrew Cagney <cagney@highland.com.au>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
insn_field *cur_field,
insn_bits *bits,
icache_decl_type what_to_declare,
- icache_body_type what_to_do)
+ icache_body_type what_to_do,
+ const char *reason)
{
+ const char *expression;
ASSERT(entry_name != NULL);
/* Define a storage area for the cache element */
&& strcmp(entry_name, cur_field->val_string) == 0
&& ((bits->opcode->is_boolean && bits->value == 0)
|| (!bits->opcode->is_boolean))) {
- /* The field has been made constant (as a result of expanding
- instructions or similar). Remember that for a boolean field,
- value is either 0 (implying the required boolean_constant) or
- nonzero (implying some other value) - Define the variable
- accordingly */
+ /* The simple field has been made constant (as a result of
+ expanding instructions or similar). Remember that for a
+ boolean field, value is either 0 (implying the required
+ boolean_constant) or nonzero (implying some other value and
+ handled later below) - Define the variable accordingly */
+ expression = "constant field";
ASSERT(bits->field == cur_field);
ASSERT(entry_type == NULL);
if (bits->opcode->is_boolean)
lf_printf(file, "%d", bits->value);
}
else if (bits != NULL
- && bits->opcode->is_boolean
&& original_name != NULL
&& strncmp(entry_name,
original_name, strlen(original_name)) == 0
&& strncmp(entry_name + strlen(original_name),
"_is_", strlen("_is_")) == 0
- && (atol(entry_name + strlen(original_name) + strlen("_is_"))
- == bits->opcode->boolean_constant)) {
+ && ((bits->opcode->is_boolean
+ && (atol(entry_name + strlen(original_name) + strlen("_is_"))
+ == bits->opcode->boolean_constant))
+ || (!bits->opcode->is_boolean))) {
+ expression = "constant compare";
/* An entry, derived from ORIGINAL_NAME, is testing to see of the
ORIGINAL_NAME has a specific constant value. That value
- matching a boolean bit field */
- lf_printf(file, "%d /* %s == %d */",
- bits->value == 0, original_name, bits->opcode->boolean_constant);
+ matching a boolean or constant field */
+ if (bits->opcode->is_boolean)
+ lf_printf(file, "%d /* %s == %d */",
+ bits->value == 0,
+ original_name,
+ bits->opcode->boolean_constant);
+ else if (bits->opcode->last < bits->field->last)
+ lf_printf(file, "%d /* %s == %d */",
+ (atol(entry_name + strlen(original_name) + strlen("_is_"))
+ == (bits->value << (bits->field->last - bits->opcode->last))),
+ original_name,
+ (bits->value << (bits->field->last - bits->opcode->last)));
+ else
+ lf_printf(file, "%d /* %s == %d */",
+ (atol(entry_name + strlen(original_name) + strlen("_is_"))
+ == bits->value),
+ original_name,
+ bits->value);
}
else {
/* put the field in the local variable, possibly also enter it
into the cache */
+ expression = "extraction";
/* handle the cache */
if ((what_to_do & get_values_from_icache)
|| (what_to_do & put_values_in_icache)) {
}
}
- if ((what_to_declare == define_variables)
- || (what_to_declare == undef_variables))
- lf_printf(file, "\n");
- else
- lf_printf(file, ";\n");
+ if (!((what_to_declare == define_variables)
+ || (what_to_declare == undef_variables)))
+ lf_printf(file, ";");
+ if (reason != NULL)
+ lf_printf(file, " /* %s - %s */", reason, expression);
+ lf_printf(file, "\n");
}
cur_field,
bits,
what_to_declare,
- do_not_use_icache);
+ do_not_use_icache,
+ "icache scratch");
else if (cache_rule->type == compute_value
&& ((what_to_do & get_values_from_icache)
|| what_to_do == do_not_use_icache))
cur_field,
bits,
what_to_declare,
- do_not_use_icache);
+ do_not_use_icache,
+ "semantic compute");
else if (cache_rule->type == cache_value
&& ((what_to_declare != undef_variables)
|| !(what_to_do & put_values_in_icache)))
((what_to_do & put_values_in_icache)
? declare_variables
: what_to_declare),
- what_to_do);
+ what_to_do,
+ "in icache");
}
}
}
- /* No rule at all, assume that it should go into the cache */
+ /* No rule at all, assume that this is needed in the semantic
+ function (when values are extracted from the icache) and
+ hence must be put into the cache */
if (found_rule == 0
&& ((what_to_declare != undef_variables)
|| !(what_to_do & put_values_in_icache)))
((what_to_do & put_values_in_icache)
? declare_variables
: what_to_declare),
- what_to_do);
+ what_to_do,
+ "default in icache");
/* any thing else ... */
}
}
NULL, 0, /* file_name & line_nr */
NULL, NULL,
what_to_declare,
- what_to_do);
+ what_to_do,
+ NULL);
}
}
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",
+ lf_print_function_type(file, ICACHE_FUNCTION_TYPE, "PSIM_INLINE_ICACHE",
"\n");
print_function_name(file,
function->fields[insn_name],
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",
+ lf_print_function_type(file, ICACHE_FUNCTION_TYPE, "PSIM_INLINE_ICACHE",
"\n");
print_function_name(file,
function->fields[insn_name],