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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gdb-7.2/] [sim/] [ppc/] [igen.c] - Diff between revs 835 and 841

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 835 Rev 841
/*  This file is part of the program psim.
/*  This file is part of the program psim.
 
 
    Copyright 1994, 1995, 1996, 1997, 2003 Andrew Cagney
    Copyright 1994, 1995, 1996, 1997, 2003 Andrew Cagney
 
 
    This program is free software; you can redistribute it and/or modify
    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
    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 2 of the License, or
    (at your option) any later version.
    (at your option) any later version.
 
 
    This program is distributed in the hope that it will be useful,
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    GNU General Public License for more details.
 
 
    You should have received a copy of the GNU General Public License
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 
    */
    */
 
 
 
 
 
 
#include <getopt.h>
#include <getopt.h>
 
 
#include "misc.h"
#include "misc.h"
#include "lf.h"
#include "lf.h"
#include "table.h"
#include "table.h"
#include "build-config.h"
#include "build-config.h"
 
 
#include "filter.h"
#include "filter.h"
 
 
#include "ld-cache.h"
#include "ld-cache.h"
#include "ld-decode.h"
#include "ld-decode.h"
#include "ld-insn.h"
#include "ld-insn.h"
 
 
#include "igen.h"
#include "igen.h"
 
 
#include "gen-model.h"
#include "gen-model.h"
#include "gen-icache.h"
#include "gen-icache.h"
#include "gen-itable.h"
#include "gen-itable.h"
#include "gen-idecode.h"
#include "gen-idecode.h"
#include "gen-semantics.h"
#include "gen-semantics.h"
#include "gen-support.h"
#include "gen-support.h"
 
 
int hi_bit_nr;
int hi_bit_nr;
int insn_bit_size = max_insn_bit_size;
int insn_bit_size = max_insn_bit_size;
 
 
igen_code code = generate_calls;
igen_code code = generate_calls;
 
 
int generate_expanded_instructions;
int generate_expanded_instructions;
int icache_size = 1024;
int icache_size = 1024;
int generate_smp;
int generate_smp;
 
 
/****************************************************************/
/****************************************************************/
 
 
static int
static int
print_insn_bits(lf *file, insn_bits *bits)
print_insn_bits(lf *file, insn_bits *bits)
{
{
  int nr = 0;
  int nr = 0;
  if (bits == NULL)
  if (bits == NULL)
    return nr;
    return nr;
  nr += print_insn_bits(file, bits->last);
  nr += print_insn_bits(file, bits->last);
  nr += lf_putchr(file, '_');
  nr += lf_putchr(file, '_');
  nr += lf_putstr(file, bits->field->val_string);
  nr += lf_putstr(file, bits->field->val_string);
  if (bits->opcode->is_boolean && bits->value == 0)
  if (bits->opcode->is_boolean && bits->value == 0)
    nr += lf_putint(file, bits->opcode->boolean_constant);
    nr += lf_putint(file, bits->opcode->boolean_constant);
  else if (!bits->opcode->is_boolean) {
  else if (!bits->opcode->is_boolean) {
    if (bits->opcode->last < bits->field->last)
    if (bits->opcode->last < bits->field->last)
      nr += lf_putint(file, bits->value << (bits->field->last - bits->opcode->last));
      nr += lf_putint(file, bits->value << (bits->field->last - bits->opcode->last));
    else
    else
      nr += lf_putint(file, bits->value);
      nr += lf_putint(file, bits->value);
  }
  }
  return nr;
  return nr;
}
}
 
 
extern int
extern int
print_function_name(lf *file,
print_function_name(lf *file,
                    const char *basename,
                    const char *basename,
                    insn_bits *expanded_bits,
                    insn_bits *expanded_bits,
                    lf_function_name_prefixes prefix)
                    lf_function_name_prefixes prefix)
{
{
  int nr = 0;
  int nr = 0;
  /* the prefix */
  /* the prefix */
  switch (prefix) {
  switch (prefix) {
  case function_name_prefix_semantics:
  case function_name_prefix_semantics:
    nr += lf_putstr(file, "semantic_");
    nr += lf_putstr(file, "semantic_");
    break;
    break;
  case function_name_prefix_idecode:
  case function_name_prefix_idecode:
    nr += lf_printf(file, "idecode_");
    nr += lf_printf(file, "idecode_");
    break;
    break;
  case function_name_prefix_itable:
  case function_name_prefix_itable:
    nr += lf_putstr(file, "itable_");
    nr += lf_putstr(file, "itable_");
    break;
    break;
  case function_name_prefix_icache:
  case function_name_prefix_icache:
    nr += lf_putstr(file, "icache_");
    nr += lf_putstr(file, "icache_");
    break;
    break;
  default:
  default:
    break;
    break;
  }
  }
 
 
  /* the function name */
  /* the function name */
  {
  {
    const char *pos;
    const char *pos;
    for (pos = basename;
    for (pos = basename;
         *pos != '\0';
         *pos != '\0';
         pos++) {
         pos++) {
      switch (*pos) {
      switch (*pos) {
      case '/':
      case '/':
      case '-':
      case '-':
      case '(':
      case '(':
      case ')':
      case ')':
        break;
        break;
      case ' ':
      case ' ':
        nr += lf_putchr(file, '_');
        nr += lf_putchr(file, '_');
        break;
        break;
      default:
      default:
        nr += lf_putchr(file, *pos);
        nr += lf_putchr(file, *pos);
        break;
        break;
      }
      }
    }
    }
  }
  }
 
 
  /* the suffix */
  /* the suffix */
  if (generate_expanded_instructions)
  if (generate_expanded_instructions)
    nr += print_insn_bits(file, expanded_bits);
    nr += print_insn_bits(file, expanded_bits);
 
 
  return nr;
  return nr;
}
}
 
 
 
 
void
void
print_my_defines(lf *file,
print_my_defines(lf *file,
                 insn_bits *expanded_bits,
                 insn_bits *expanded_bits,
                 table_entry *file_entry)
                 table_entry *file_entry)
{
{
  /* #define MY_INDEX xxxxx */
  /* #define MY_INDEX xxxxx */
  lf_indent_suppress(file);
  lf_indent_suppress(file);
  lf_printf(file, "#undef MY_INDEX\n");
  lf_printf(file, "#undef MY_INDEX\n");
  lf_indent_suppress(file);
  lf_indent_suppress(file);
  lf_printf(file, "#define MY_INDEX ");
  lf_printf(file, "#define MY_INDEX ");
  print_function_name(file,
  print_function_name(file,
                      file_entry->fields[insn_name],
                      file_entry->fields[insn_name],
                      NULL,
                      NULL,
                      function_name_prefix_itable);
                      function_name_prefix_itable);
  lf_printf(file, "\n");
  lf_printf(file, "\n");
  /* #define MY_PREFIX xxxxxx */
  /* #define MY_PREFIX xxxxxx */
  lf_indent_suppress(file);
  lf_indent_suppress(file);
  lf_printf(file, "#undef MY_PREFIX\n");
  lf_printf(file, "#undef MY_PREFIX\n");
  lf_indent_suppress(file);
  lf_indent_suppress(file);
  lf_printf(file, "#define MY_PREFIX ");
  lf_printf(file, "#define MY_PREFIX ");
  print_function_name(file,
  print_function_name(file,
                      file_entry->fields[insn_name],
                      file_entry->fields[insn_name],
                      expanded_bits,
                      expanded_bits,
                      function_name_prefix_none);
                      function_name_prefix_none);
  lf_printf(file, "\n");
  lf_printf(file, "\n");
}
}
 
 
 
 
void
void
print_itrace(lf *file,
print_itrace(lf *file,
             table_entry *file_entry,
             table_entry *file_entry,
             int idecode)
             int idecode)
{
{
  lf_print__external_reference(file, file_entry->line_nr, file_entry->file_name);
  lf_print__external_reference(file, file_entry->line_nr, file_entry->file_name);
  lf_printf(file, "ITRACE(trace_%s, (\"%s %s\\n\"));\n",
  lf_printf(file, "ITRACE(trace_%s, (\"%s %s\\n\"));\n",
            (idecode ? "idecode" : "semantics"),
            (idecode ? "idecode" : "semantics"),
            (idecode ? "idecode" : "semantics"),
            (idecode ? "idecode" : "semantics"),
            file_entry->fields[insn_name]);
            file_entry->fields[insn_name]);
  lf_print__internal_reference(file);
  lf_print__internal_reference(file);
}
}
 
 
 
 
/****************************************************************/
/****************************************************************/
 
 
 
 
static void
static void
gen_semantics_h(insn_table *table,
gen_semantics_h(insn_table *table,
                lf *file,
                lf *file,
                igen_code generate)
                igen_code generate)
{
{
  lf_printf(file, "typedef %s idecode_semantic\n(%s);\n",
  lf_printf(file, "typedef %s idecode_semantic\n(%s);\n",
            SEMANTIC_FUNCTION_TYPE,
            SEMANTIC_FUNCTION_TYPE,
            SEMANTIC_FUNCTION_FORMAL);
            SEMANTIC_FUNCTION_FORMAL);
  lf_printf(file, "\n");
  lf_printf(file, "\n");
  if ((code & generate_calls)) {
  if ((code & generate_calls)) {
    lf_printf(file, "extern int option_mpc860c0;\n");
    lf_printf(file, "extern int option_mpc860c0;\n");
    lf_printf(file, "#define PAGE_SIZE 0x1000\n");
    lf_printf(file, "#define PAGE_SIZE 0x1000\n");
    lf_printf(file, "\n");
    lf_printf(file, "\n");
    lf_printf(file, "PSIM_EXTERN_SEMANTICS(void)\n");
    lf_printf(file, "PSIM_EXTERN_SEMANTICS(void)\n");
    lf_printf(file, "semantic_init(device* root);\n");
    lf_printf(file, "semantic_init(device* root);\n");
    lf_printf(file, "\n");
    lf_printf(file, "\n");
    if (generate_expanded_instructions)
    if (generate_expanded_instructions)
      insn_table_traverse_tree(table,
      insn_table_traverse_tree(table,
                               file, NULL,
                               file, NULL,
                               1,
                               1,
                               NULL, /* start */
                               NULL, /* start */
                               print_semantic_declaration, /* leaf */
                               print_semantic_declaration, /* leaf */
                               NULL, /* end */
                               NULL, /* end */
                               NULL); /* padding */
                               NULL); /* padding */
    else
    else
      insn_table_traverse_insn(table,
      insn_table_traverse_insn(table,
                               file, NULL,
                               file, NULL,
                               print_semantic_declaration);
                               print_semantic_declaration);
 
 
  }
  }
  else {
  else {
    lf_print__this_file_is_empty(file);
    lf_print__this_file_is_empty(file);
  }
  }
}
}
 
 
 
 
static void
static void
gen_semantics_c(insn_table *table,
gen_semantics_c(insn_table *table,
                cache_table *cache_rules,
                cache_table *cache_rules,
                lf *file,
                lf *file,
                igen_code generate)
                igen_code generate)
{
{
  if ((code & generate_calls)) {
  if ((code & generate_calls)) {
    lf_printf(file, "\n");
    lf_printf(file, "\n");
    lf_printf(file, "#include \"cpu.h\"\n");
    lf_printf(file, "#include \"cpu.h\"\n");
    lf_printf(file, "#include \"idecode.h\"\n");
    lf_printf(file, "#include \"idecode.h\"\n");
    lf_printf(file, "#include \"semantics.h\"\n");
    lf_printf(file, "#include \"semantics.h\"\n");
    lf_printf(file, "#ifdef HAVE_COMMON_FPU\n");
    lf_printf(file, "#ifdef HAVE_COMMON_FPU\n");
    lf_printf(file, "#include \"sim-inline.h\"\n");
    lf_printf(file, "#include \"sim-inline.h\"\n");
    lf_printf(file, "#include \"sim-fpu.h\"\n");
    lf_printf(file, "#include \"sim-fpu.h\"\n");
    lf_printf(file, "#endif\n");
    lf_printf(file, "#endif\n");
    lf_printf(file, "#include \"support.h\"\n");
    lf_printf(file, "#include \"support.h\"\n");
    lf_printf(file, "\n");
    lf_printf(file, "\n");
    lf_printf(file, "int option_mpc860c0 = 0;\n");
    lf_printf(file, "int option_mpc860c0 = 0;\n");
    lf_printf(file, "\n");
    lf_printf(file, "\n");
    lf_printf(file, "PSIM_EXTERN_SEMANTICS(void)\n");
    lf_printf(file, "PSIM_EXTERN_SEMANTICS(void)\n");
    lf_printf(file, "semantic_init(device* root)\n");
    lf_printf(file, "semantic_init(device* root)\n");
    lf_printf(file, "{\n");
    lf_printf(file, "{\n");
    lf_printf(file, "  option_mpc860c0 = 0;\n");
    lf_printf(file, "  option_mpc860c0 = 0;\n");
    lf_printf(file, "  if (tree_find_property(root, \"/options/mpc860c0\"))\n");
    lf_printf(file, "  if (tree_find_property(root, \"/options/mpc860c0\"))\n");
    lf_printf(file, "    option_mpc860c0 = tree_find_integer_property(root, \"/options/mpc860c0\");\n");
    lf_printf(file, "    option_mpc860c0 = tree_find_integer_property(root, \"/options/mpc860c0\");\n");
    lf_printf(file, "    option_mpc860c0 *= 4;   /* convert word count to byte count */\n");
    lf_printf(file, "    option_mpc860c0 *= 4;   /* convert word count to byte count */\n");
    lf_printf(file, "}\n");
    lf_printf(file, "}\n");
    lf_printf(file, "\n");
    lf_printf(file, "\n");
    if (generate_expanded_instructions)
    if (generate_expanded_instructions)
      insn_table_traverse_tree(table,
      insn_table_traverse_tree(table,
                               file, cache_rules,
                               file, cache_rules,
                               1,
                               1,
                               NULL, /* start */
                               NULL, /* start */
                               print_semantic_definition, /* leaf */
                               print_semantic_definition, /* leaf */
                               NULL, /* end */
                               NULL, /* end */
                               NULL); /* padding */
                               NULL); /* padding */
    else
    else
      insn_table_traverse_insn(table,
      insn_table_traverse_insn(table,
                               file, cache_rules,
                               file, cache_rules,
                               print_semantic_definition);
                               print_semantic_definition);
 
 
  }
  }
  else {
  else {
    lf_print__this_file_is_empty(file);
    lf_print__this_file_is_empty(file);
  }
  }
}
}
 
 
 
 
/****************************************************************/
/****************************************************************/
 
 
 
 
static void
static void
gen_icache_h(insn_table *table,
gen_icache_h(insn_table *table,
             lf *file,
             lf *file,
             igen_code generate)
             igen_code generate)
{
{
  lf_printf(file, "typedef %s idecode_icache\n(%s);\n",
  lf_printf(file, "typedef %s idecode_icache\n(%s);\n",
            ICACHE_FUNCTION_TYPE,
            ICACHE_FUNCTION_TYPE,
            ICACHE_FUNCTION_FORMAL);
            ICACHE_FUNCTION_FORMAL);
  lf_printf(file, "\n");
  lf_printf(file, "\n");
  if ((code & generate_calls)
  if ((code & generate_calls)
      && (code & generate_with_icache)) {
      && (code & generate_with_icache)) {
    insn_table_traverse_function(table,
    insn_table_traverse_function(table,
                                 file, NULL,
                                 file, NULL,
                                 print_icache_internal_function_declaration);
                                 print_icache_internal_function_declaration);
    if (generate_expanded_instructions)
    if (generate_expanded_instructions)
      insn_table_traverse_tree(table,
      insn_table_traverse_tree(table,
                               file, NULL,
                               file, NULL,
                               1,
                               1,
                               NULL, /* start */
                               NULL, /* start */
                               print_icache_declaration, /* leaf */
                               print_icache_declaration, /* leaf */
                               NULL, /* end */
                               NULL, /* end */
                               NULL); /* padding */
                               NULL); /* padding */
    else
    else
      insn_table_traverse_insn(table,
      insn_table_traverse_insn(table,
                               file, NULL,
                               file, NULL,
                               print_icache_declaration);
                               print_icache_declaration);
 
 
  }
  }
  else {
  else {
    lf_print__this_file_is_empty(file);
    lf_print__this_file_is_empty(file);
  }
  }
}
}
 
 
static void
static void
gen_icache_c(insn_table *table,
gen_icache_c(insn_table *table,
             cache_table *cache_rules,
             cache_table *cache_rules,
             lf *file,
             lf *file,
             igen_code generate)
             igen_code generate)
{
{
  /* output `internal' invalid/floating-point unavailable functions
  /* output `internal' invalid/floating-point unavailable functions
     where needed */
     where needed */
  if ((code & generate_calls)
  if ((code & generate_calls)
      && (code & generate_with_icache)) {
      && (code & generate_with_icache)) {
    lf_printf(file, "\n");
    lf_printf(file, "\n");
    lf_printf(file, "#include \"cpu.h\"\n");
    lf_printf(file, "#include \"cpu.h\"\n");
    lf_printf(file, "#include \"idecode.h\"\n");
    lf_printf(file, "#include \"idecode.h\"\n");
    lf_printf(file, "#include \"semantics.h\"\n");
    lf_printf(file, "#include \"semantics.h\"\n");
    lf_printf(file, "#include \"icache.h\"\n");
    lf_printf(file, "#include \"icache.h\"\n");
    lf_printf(file, "#ifdef HAVE_COMMON_FPU\n");
    lf_printf(file, "#ifdef HAVE_COMMON_FPU\n");
    lf_printf(file, "#include \"sim-inline.h\"\n");
    lf_printf(file, "#include \"sim-inline.h\"\n");
    lf_printf(file, "#include \"sim-fpu.h\"\n");
    lf_printf(file, "#include \"sim-fpu.h\"\n");
    lf_printf(file, "#endif\n");
    lf_printf(file, "#endif\n");
    lf_printf(file, "#include \"support.h\"\n");
    lf_printf(file, "#include \"support.h\"\n");
    lf_printf(file, "\n");
    lf_printf(file, "\n");
    insn_table_traverse_function(table,
    insn_table_traverse_function(table,
                                 file, NULL,
                                 file, NULL,
                                 print_icache_internal_function_definition);
                                 print_icache_internal_function_definition);
    lf_printf(file, "\n");
    lf_printf(file, "\n");
    if (generate_expanded_instructions)
    if (generate_expanded_instructions)
      insn_table_traverse_tree(table,
      insn_table_traverse_tree(table,
                               file, cache_rules,
                               file, cache_rules,
                               1,
                               1,
                               NULL, /* start */
                               NULL, /* start */
                               print_icache_definition, /* leaf */
                               print_icache_definition, /* leaf */
                               NULL, /* end */
                               NULL, /* end */
                               NULL); /* padding */
                               NULL); /* padding */
    else
    else
      insn_table_traverse_insn(table,
      insn_table_traverse_insn(table,
                               file, cache_rules,
                               file, cache_rules,
                               print_icache_definition);
                               print_icache_definition);
 
 
  }
  }
  else {
  else {
    lf_print__this_file_is_empty(file);
    lf_print__this_file_is_empty(file);
  }
  }
}
}
 
 
 
 
/****************************************************************/
/****************************************************************/
 
 
 
 
int
int
main(int argc,
main(int argc,
     char **argv,
     char **argv,
     char **envp)
     char **envp)
{
{
  cache_table *cache_rules = NULL;
  cache_table *cache_rules = NULL;
  lf_file_references file_references = lf_include_references;
  lf_file_references file_references = lf_include_references;
  decode_table *decode_rules = NULL;
  decode_table *decode_rules = NULL;
  filter *filters = NULL;
  filter *filters = NULL;
  insn_table *instructions = NULL;
  insn_table *instructions = NULL;
  table_include *includes = NULL;
  table_include *includes = NULL;
  char *real_file_name = NULL;
  char *real_file_name = NULL;
  int is_header = 0;
  int is_header = 0;
  int ch;
  int ch;
 
 
  if (argc == 1) {
  if (argc == 1) {
    printf("Usage:\n");
    printf("Usage:\n");
    printf("  igen <config-opts> ... <input-opts>... <output-opts>...\n");
    printf("  igen <config-opts> ... <input-opts>... <output-opts>...\n");
    printf("Config options:\n");
    printf("Config options:\n");
    printf("  -F <filter-out-flag>  eg -F 64 to skip 64bit instructions\n");
    printf("  -F <filter-out-flag>  eg -F 64 to skip 64bit instructions\n");
    printf("  -E                    Expand (duplicate) semantic functions\n");
    printf("  -E                    Expand (duplicate) semantic functions\n");
    printf("  -I <icache-size>      Generate cracking cache version\n");
    printf("  -I <icache-size>      Generate cracking cache version\n");
    printf("  -C                    Include semantics in cache functions\n");
    printf("  -C                    Include semantics in cache functions\n");
    printf("  -S                    Include insn (instruction) in icache\n");
    printf("  -S                    Include insn (instruction) in icache\n");
    printf("  -R                    Use defines to reference cache vars\n");
    printf("  -R                    Use defines to reference cache vars\n");
    printf("  -L                    Supress line numbering in output files\n");
    printf("  -L                    Supress line numbering in output files\n");
    printf("  -B <bit-size>         Set the number of bits in an instruction\n");
    printf("  -B <bit-size>         Set the number of bits in an instruction\n");
    printf("  -H <high-bit>         Set the nr of the high (msb bit)\n");
    printf("  -H <high-bit>         Set the nr of the high (msb bit)\n");
    printf("  -N <nr-cpus>          Specify the max number of cpus the simulation will support\n");
    printf("  -N <nr-cpus>          Specify the max number of cpus the simulation will support\n");
    printf("  -J                    Use jumps instead of function calls\n");
    printf("  -J                    Use jumps instead of function calls\n");
    printf("  -T <mechanism>        Override the mechanism used to decode an instruction\n");
    printf("  -T <mechanism>        Override the mechanism used to decode an instruction\n");
    printf("                        using <mechanism> instead of what was specified in the\n");
    printf("                        using <mechanism> instead of what was specified in the\n");
    printf("                        decode-rules input file\n");
    printf("                        decode-rules input file\n");
    printf("\n");
    printf("\n");
    printf("Input options (ucase version also dumps loaded table):\n");
    printf("Input options (ucase version also dumps loaded table):\n");
    printf("  -o <decode-rules>\n");
    printf("  -o <decode-rules>\n");
    printf("  -k <cache-rules>\n");
    printf("  -k <cache-rules>\n");
    printf("  -i <instruction-table>\n");
    printf("  -i <instruction-table>\n");
    printf("\n");
    printf("\n");
    printf("Output options:\n");
    printf("Output options:\n");
    printf("  -n <real-name>        Specify the real name of for the next output file\n");
    printf("  -n <real-name>        Specify the real name of for the next output file\n");
    printf("  -h                    Generate header file\n");
    printf("  -h                    Generate header file\n");
    printf("  -c <output-file>      output icache\n");
    printf("  -c <output-file>      output icache\n");
    printf("  -d <output-file>      output idecode\n");
    printf("  -d <output-file>      output idecode\n");
    printf("  -m <output-file>      output model\n");
    printf("  -m <output-file>      output model\n");
    printf("  -s <output-file>      output schematic\n");
    printf("  -s <output-file>      output schematic\n");
    printf("  -t <output-file>      output itable\n");
    printf("  -t <output-file>      output itable\n");
    printf("  -f <output-file>      output support functions\n");
    printf("  -f <output-file>      output support functions\n");
  }
  }
 
 
  while ((ch = getopt(argc, argv,
  while ((ch = getopt(argc, argv,
                      "F:EI:RSLJT:CB:H:N:o:k:i:n:hc:d:m:s:t:f:"))
                      "F:EI:RSLJT:CB:H:N:o:k:i:n:hc:d:m:s:t:f:"))
         != -1) {
         != -1) {
    fprintf(stderr, "\t-%c %s\n", ch, (optarg ? optarg : ""));
    fprintf(stderr, "\t-%c %s\n", ch, (optarg ? optarg : ""));
    switch(ch) {
    switch(ch) {
    case 'C':
    case 'C':
      code |= generate_with_icache;
      code |= generate_with_icache;
      code |= generate_with_semantic_icache;
      code |= generate_with_semantic_icache;
      break;
      break;
    case 'S':
    case 'S':
      code |= generate_with_icache;
      code |= generate_with_icache;
      code |= generate_with_insn_in_icache;
      code |= generate_with_insn_in_icache;
      break;
      break;
    case 'L':
    case 'L':
      file_references = lf_omit_references;
      file_references = lf_omit_references;
      break;
      break;
    case 'E':
    case 'E':
      generate_expanded_instructions = 1;
      generate_expanded_instructions = 1;
      break;
      break;
    case 'G':
    case 'G':
      {
      {
        int enable_p;
        int enable_p;
        char *argp;
        char *argp;
        if (strncmp (optarg, "no-", strlen ("no-")) == 0)
        if (strncmp (optarg, "no-", strlen ("no-")) == 0)
          {
          {
            argp = optarg + strlen ("no-");
            argp = optarg + strlen ("no-");
            enable_p = 0;
            enable_p = 0;
          }
          }
        else if (strncmp (optarg, "!", strlen ("!")) == 0)
        else if (strncmp (optarg, "!", strlen ("!")) == 0)
          {
          {
            argp = optarg + strlen ("no-");
            argp = optarg + strlen ("no-");
            enable_p = 0;
            enable_p = 0;
          }
          }
        else
        else
          {
          {
            argp = optarg;
            argp = optarg;
            enable_p = 1;
            enable_p = 1;
          }
          }
        if (strncmp (argp, "gen-icache", strlen ("gen-icache")) == 0)
        if (strncmp (argp, "gen-icache", strlen ("gen-icache")) == 0)
          {
          {
            switch (argp[strlen ("gen-icache")])
            switch (argp[strlen ("gen-icache")])
              {
              {
              case '=':
              case '=':
                icache_size = atoi (argp + strlen ("gen-icache") + 1);
                icache_size = atoi (argp + strlen ("gen-icache") + 1);
                code |= generate_with_icache;
                code |= generate_with_icache;
                break;
                break;
              case '\0':
              case '\0':
                code |= generate_with_icache;
                code |= generate_with_icache;
                break;
                break;
              default:
              default:
                error (NULL, "Expecting -Ggen-icache or -Ggen-icache=<N>\n");
                error (NULL, "Expecting -Ggen-icache or -Ggen-icache=<N>\n");
              }
              }
          }
          }
        }
        }
    case 'I':
    case 'I':
      {
      {
        table_include **dir = &includes;
        table_include **dir = &includes;
        while ((*dir) != NULL)
        while ((*dir) != NULL)
          dir = &(*dir)->next;
          dir = &(*dir)->next;
        (*dir) = ZALLOC (table_include);
        (*dir) = ZALLOC (table_include);
        (*dir)->dir = strdup (optarg);
        (*dir)->dir = strdup (optarg);
      }
      }
      break;
      break;
    case 'N':
    case 'N':
      generate_smp = a2i(optarg);
      generate_smp = a2i(optarg);
      break;
      break;
    case 'R':
    case 'R':
      code |= generate_with_direct_access;
      code |= generate_with_direct_access;
      break;
      break;
    case 'B':
    case 'B':
      insn_bit_size = a2i(optarg);
      insn_bit_size = a2i(optarg);
      ASSERT(insn_bit_size > 0 && insn_bit_size <= max_insn_bit_size
      ASSERT(insn_bit_size > 0 && insn_bit_size <= max_insn_bit_size
             && (hi_bit_nr == insn_bit_size-1 || hi_bit_nr == 0));
             && (hi_bit_nr == insn_bit_size-1 || hi_bit_nr == 0));
      break;
      break;
    case 'H':
    case 'H':
      hi_bit_nr = a2i(optarg);
      hi_bit_nr = a2i(optarg);
      ASSERT(hi_bit_nr == insn_bit_size-1 || hi_bit_nr == 0);
      ASSERT(hi_bit_nr == insn_bit_size-1 || hi_bit_nr == 0);
      break;
      break;
    case 'F':
    case 'F':
      filters = new_filter(optarg, filters);
      filters = new_filter(optarg, filters);
      break;
      break;
    case 'J':
    case 'J':
      code &= ~generate_calls;
      code &= ~generate_calls;
      code |= generate_jumps;
      code |= generate_jumps;
      break;
      break;
    case 'T':
    case 'T':
      force_decode_gen_type(optarg);
      force_decode_gen_type(optarg);
      break;
      break;
    case 'i':
    case 'i':
      if (decode_rules == NULL) {
      if (decode_rules == NULL) {
        fprintf(stderr, "Must specify decode tables\n");
        fprintf(stderr, "Must specify decode tables\n");
        exit (1);
        exit (1);
      }
      }
      instructions = load_insn_table(optarg, decode_rules, filters, includes,
      instructions = load_insn_table(optarg, decode_rules, filters, includes,
                                     &cache_rules);
                                     &cache_rules);
      fprintf(stderr, "\texpanding ...\n");
      fprintf(stderr, "\texpanding ...\n");
      insn_table_expand_insns(instructions);
      insn_table_expand_insns(instructions);
      break;
      break;
    case 'o':
    case 'o':
      decode_rules = load_decode_table(optarg, hi_bit_nr);
      decode_rules = load_decode_table(optarg, hi_bit_nr);
      break;
      break;
    case 'k':
    case 'k':
      cache_rules = load_cache_table(optarg, hi_bit_nr);
      cache_rules = load_cache_table(optarg, hi_bit_nr);
      break;
      break;
    case 'n':
    case 'n':
      real_file_name = strdup(optarg);
      real_file_name = strdup(optarg);
      break;
      break;
    case 'h':
    case 'h':
      is_header = 1;
      is_header = 1;
      break;
      break;
    case 's':
    case 's':
    case 'd':
    case 'd':
    case 'm':
    case 'm':
    case 't':
    case 't':
    case 'f':
    case 'f':
    case 'c':
    case 'c':
      {
      {
        lf *file = lf_open(optarg, real_file_name, file_references,
        lf *file = lf_open(optarg, real_file_name, file_references,
                           (is_header ? lf_is_h : lf_is_c),
                           (is_header ? lf_is_h : lf_is_c),
                           argv[0]);
                           argv[0]);
        lf_print__file_start(file);
        lf_print__file_start(file);
        ASSERT(instructions != NULL);
        ASSERT(instructions != NULL);
        switch (ch) {
        switch (ch) {
        case 's':
        case 's':
          if(is_header)
          if(is_header)
            gen_semantics_h(instructions, file, code);
            gen_semantics_h(instructions, file, code);
          else
          else
            gen_semantics_c(instructions, cache_rules, file, code);
            gen_semantics_c(instructions, cache_rules, file, code);
          break;
          break;
        case 'd':
        case 'd':
          if (is_header)
          if (is_header)
            gen_idecode_h(file, instructions, cache_rules);
            gen_idecode_h(file, instructions, cache_rules);
          else
          else
            gen_idecode_c(file, instructions, cache_rules);
            gen_idecode_c(file, instructions, cache_rules);
          break;
          break;
        case 'm':
        case 'm':
          if (is_header)
          if (is_header)
            gen_model_h(instructions, file);
            gen_model_h(instructions, file);
          else
          else
            gen_model_c(instructions, file);
            gen_model_c(instructions, file);
          break;
          break;
        case 't':
        case 't':
          if (is_header)
          if (is_header)
            gen_itable_h(instructions, file);
            gen_itable_h(instructions, file);
          else
          else
            gen_itable_c(instructions, file);
            gen_itable_c(instructions, file);
          break;
          break;
        case 'f':
        case 'f':
          if (is_header)
          if (is_header)
            gen_support_h(instructions, file);
            gen_support_h(instructions, file);
          else
          else
            gen_support_c(instructions, file);
            gen_support_c(instructions, file);
          break;
          break;
        case 'c':
        case 'c':
          if (is_header)
          if (is_header)
            gen_icache_h(instructions, file, code);
            gen_icache_h(instructions, file, code);
          else
          else
            gen_icache_c(instructions, cache_rules, file, code);
            gen_icache_c(instructions, cache_rules, file, code);
          break;
          break;
        }
        }
        lf_print__file_finish(file);
        lf_print__file_finish(file);
        lf_close(file);
        lf_close(file);
        is_header = 0;
        is_header = 0;
      }
      }
      real_file_name = NULL;
      real_file_name = NULL;
      break;
      break;
    default:
    default:
      error("unknown option\n");
      error("unknown option\n");
    }
    }
  }
  }
  return 0;
  return 0;
}
}
 
 

powered by: WebSVN 2.1.0

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