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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [opcodes/] [s390-mkopc.c] - Diff between revs 157 and 225

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 157 Rev 225
Line 1... Line 1...
/* s390-mkopc.c -- Generates opcode table out of s390-opc.txt
/* s390-mkopc.c -- Generates opcode table out of s390-opc.txt
   Copyright 2000, 2001, 2003, 2007 Free Software Foundation, Inc.
   Copyright 2000, 2001, 2003, 2005, 2007, 2008 Free Software Foundation, Inc.
   Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
   Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
 
 
   This file is part of the GNU opcodes library.
   This file is part of the GNU opcodes library.
 
 
   This library is free software; you can redistribute it and/or modify
   This library is free software; you can redistribute it and/or modify
Line 35... Line 35...
    S390_OPCODE_G5 = 0,
    S390_OPCODE_G5 = 0,
    S390_OPCODE_G6,
    S390_OPCODE_G6,
    S390_OPCODE_Z900,
    S390_OPCODE_Z900,
    S390_OPCODE_Z990,
    S390_OPCODE_Z990,
    S390_OPCODE_Z9_109,
    S390_OPCODE_Z9_109,
    S390_OPCODE_Z9_EC
    S390_OPCODE_Z9_EC,
 
    S390_OPCODE_Z10
  };
  };
 
 
struct op_struct
struct op_struct
  {
  {
    char  opcode[16];
    char  opcode[16];
Line 119... Line 120...
{
{
  char nibble;
  char nibble;
  char extension[4];
  char extension[4];
};
};
 
 
 
/* The mnemonic extensions for conditional jumps used to replace
 
   the '*' tag.  */
#define NUM_COND_EXTENSIONS 20
#define NUM_COND_EXTENSIONS 20
 
 
const struct s390_cond_ext_format s390_cond_extensions[NUM_COND_EXTENSIONS] =
const struct s390_cond_ext_format s390_cond_extensions[NUM_COND_EXTENSIONS] =
  {
{ { '1', "o" },    /* jump on overflow / if ones */
    { '1', "o" },    /* jump on overflow / if ones */
 
    { '2', "h" },    /* jump on A high */
    { '2', "h" },    /* jump on A high */
    { '2', "p" },    /* jump on plus */
    { '2', "p" },    /* jump on plus */
    { '3', "nle" },  /* jump on not low or equal */
    { '3', "nle" },  /* jump on not low or equal */
    { '4', "l" },    /* jump on A low */
    { '4', "l" },    /* jump on A low */
    { '4', "m" },    /* jump on minus / if mixed */
    { '4', "m" },    /* jump on minus / if mixed */
Line 145... Line 146...
    { 'd', "nh" },   /* jump on A not high */
    { 'd', "nh" },   /* jump on A not high */
    { 'd', "np" },   /* jump on not plus */
    { 'd', "np" },   /* jump on not plus */
    { 'e', "no" },   /* jump on not overflow / if not ones */
    { 'e', "no" },   /* jump on not overflow / if not ones */
  };
  };
 
 
 
/* The mnemonic extensions for conditional branches used to replace
 
   the '$' tag.  */
 
#define NUM_CRB_EXTENSIONS 12
 
const struct s390_cond_ext_format s390_crb_extensions[NUM_CRB_EXTENSIONS] =
 
{ { '2', "h" },    /* jump on A high */
 
  { '2', "nle" },  /* jump on not low or equal */
 
  { '4', "l" },    /* jump on A low */
 
  { '4', "nhe" },  /* jump on not high or equal */
 
  { '6', "ne" },   /* jump on A not equal B */
 
  { '6', "lh" },   /* jump on low or high */
 
  { '8', "e" },    /* jump on A equal B */
 
  { '8', "nlh" },  /* jump on not low or high */
 
  { 'a', "nl" },   /* jump on A not low */
 
  { 'a', "he" },   /* jump on high or equal */
 
  { 'c', "nh" },   /* jump on A not high */
 
  { 'c', "le" },   /* jump on low or equal */
 
};
 
 
/* As with insertOpcode instructions are added to the sorted opcode
/* As with insertOpcode instructions are added to the sorted opcode
   array.  Additionally mnemonics containing the '*<number>' tag are
   array.  Additionally mnemonics containing the '*<number>' tag are
   expanded to the set of conditional instructions described by
   expanded to the set of conditional instructions described by
   s390_cond_extensions with the '*<number>' tag replaced by the
   s390_cond_extensions with the tag replaced by the respective
   respective mnemonic extensions.  */
   mnemonic extensions.  */
 
 
static void
static void
expandConditionalJump (char *opcode, char *mnemonic, char *format,
insertExpandedMnemonic (char *opcode, char *mnemonic, char *format,
                       int min_cpu, int mode_bits)
                       int min_cpu, int mode_bits)
{
{
  char prefix[5];
  char *tag;
  char suffix[5];
  char prefix[15];
  char number[5];
  char suffix[15];
  int mask_start, i = 0, star_found = 0, reading_number = 0;
  char number[15];
 
  int mask_start, i = 0, tag_found = 0, reading_number = 0;
  int number_p = 0, suffix_p = 0, prefix_p = 0;
  int number_p = 0, suffix_p = 0, prefix_p = 0;
 
  const struct s390_cond_ext_format *ext_table;
 
  int ext_table_length;
 
 
 
  if (!(tag = strpbrk (mnemonic, "*$")))
 
    {
 
      insertOpcode (opcode, mnemonic, format, min_cpu, mode_bits);
 
      return;
 
    }
 
 
  while (mnemonic[i] != '\0')
  while (mnemonic[i] != '\0')
    {
    {
      switch (mnemonic[i])
      if (mnemonic[i] == *tag)
        {
        {
        case '*':
          if (tag_found)
          if (star_found)
 
            goto malformed_mnemonic;
            goto malformed_mnemonic;
 
 
          star_found = 1;
          tag_found = 1;
          reading_number = 1;
          reading_number = 1;
          break;
        }
 
      else
 
        switch (mnemonic[i])
 
          {
        case '0': case '1': case '2': case '3': case '4':
        case '0': case '1': case '2': case '3': case '4':
        case '5': case '6': case '7': case '8': case '9':
        case '5': case '6': case '7': case '8': case '9':
          if (!star_found || !reading_number)
            if (!tag_found || !reading_number)
            goto malformed_mnemonic;
            goto malformed_mnemonic;
 
 
          number[number_p++] = mnemonic[i];
          number[number_p++] = mnemonic[i];
          break;
          break;
 
 
Line 190... Line 219...
                goto malformed_mnemonic;
                goto malformed_mnemonic;
              else
              else
                reading_number = 0;
                reading_number = 0;
            }
            }
 
 
          if (star_found)
            if (tag_found)
            suffix[suffix_p++] = mnemonic[i];
            suffix[suffix_p++] = mnemonic[i];
          else
          else
            prefix[prefix_p++] = mnemonic[i];
            prefix[prefix_p++] = mnemonic[i];
        }
        }
      i++;
      i++;
Line 214... Line 243...
      return;
      return;
    }
    }
 
 
  mask_start >>= 2;
  mask_start >>= 2;
 
 
  for (i = 0; i < NUM_COND_EXTENSIONS; i++)
  switch (*tag)
 
    {
 
    case '*':
 
      ext_table = s390_cond_extensions;
 
      ext_table_length = NUM_COND_EXTENSIONS;
 
      break;
 
    case '$':
 
      ext_table = s390_crb_extensions;
 
      ext_table_length = NUM_CRB_EXTENSIONS;
 
      break;
 
    default: fprintf (stderr, "Unknown tag char: %c\n", *tag);
 
    }
 
 
 
  for (i = 0; i < ext_table_length; i++)
    {
    {
      char new_mnemonic[15];
      char new_mnemonic[15];
 
 
      strcpy (new_mnemonic, prefix);
      strcpy (new_mnemonic, prefix);
      strcat (new_mnemonic, s390_cond_extensions[i].extension);
      opcode[mask_start] = ext_table[i].nibble;
 
      strcat (new_mnemonic, ext_table[i].extension);
      strcat (new_mnemonic, suffix);
      strcat (new_mnemonic, suffix);
      opcode[mask_start] = s390_cond_extensions[i].nibble;
 
      insertOpcode (opcode, new_mnemonic, format, min_cpu, mode_bits);
      insertOpcode (opcode, new_mnemonic, format, min_cpu, mode_bits);
    }
    }
  return;
  return;
 
 
 malformed_mnemonic:
 malformed_mnemonic:
Line 316... Line 358...
            min_cpu = S390_OPCODE_Z990;
            min_cpu = S390_OPCODE_Z990;
          else if (strcmp (cpu_string, "z9-109") == 0)
          else if (strcmp (cpu_string, "z9-109") == 0)
            min_cpu = S390_OPCODE_Z9_109;
            min_cpu = S390_OPCODE_Z9_109;
          else if (strcmp (cpu_string, "z9-ec") == 0)
          else if (strcmp (cpu_string, "z9-ec") == 0)
            min_cpu = S390_OPCODE_Z9_EC;
            min_cpu = S390_OPCODE_Z9_EC;
 
          else if (strcmp (cpu_string, "z10") == 0)
 
            min_cpu = S390_OPCODE_Z10;
          else {
          else {
            fprintf (stderr, "Couldn't parse cpu string %s\n", cpu_string);
            fprintf (stderr, "Couldn't parse cpu string %s\n", cpu_string);
            exit (1);
            exit (1);
          }
          }
 
 
Line 341... Line 385...
            }
            }
            if (*str == ',')
            if (*str == ',')
              str++;
              str++;
          } while (*str != 0);
          } while (*str != 0);
 
 
          if (!strchr (mnemonic, '*'))
          insertExpandedMnemonic (opcode, mnemonic, format, min_cpu, mode_bits);
            insertOpcode (opcode, mnemonic, format, min_cpu, mode_bits);
 
          else
 
            expandConditionalJump (opcode, mnemonic, format,
 
                                   min_cpu, mode_bits);
 
        }
        }
      else
      else
        fprintf (stderr, "Couldn't scan line %s\n", currentLine);
        fprintf (stderr, "Couldn't scan line %s\n", currentLine);
    }
    }
 
 

powered by: WebSVN 2.1.0

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