* cgen-asm.c: Include symcat.h.
* cgen-dis.c,cgen-opc.c,cgen-asm.in,cgen-dis.in: Ditto.
This commit is contained in:
parent
677c3439a7
commit
833d299073
|
@ -1,3 +1,8 @@
|
|||
Mon Feb 23 13:16:17 1998 Doug Evans <devans@seba.cygnus.com>
|
||||
|
||||
* cgen-asm.c: Include symcat.h.
|
||||
* cgen-dis.c,cgen-opc.c,cgen-asm.in,cgen-dis.in: Ditto.
|
||||
|
||||
start-sanitize-sky
|
||||
Mon Feb 23 09:51:39 1998 Doug Evans <devans@canuck.cygnus.com>
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
This file is used to generate @arch@-asm.c.
|
||||
|
||||
Copyright (C) 1996, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Binutils and GDB, the GNU debugger.
|
||||
|
||||
|
@ -26,6 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
|||
#include <stdio.h>
|
||||
#include "ansidecl.h"
|
||||
#include "bfd.h"
|
||||
#include "symcat.h"
|
||||
#include "@arch@-opc.h"
|
||||
|
||||
/* ??? The layout of this stuff is still work in progress.
|
||||
|
@ -37,31 +38,64 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
|||
|
||||
static const char * parse_insn_normal
|
||||
PARAMS ((const CGEN_INSN *, const char **, CGEN_FIELDS *));
|
||||
static void insert_insn_normal
|
||||
static const char * insert_insn_normal
|
||||
PARAMS ((const CGEN_INSN *, CGEN_FIELDS *, cgen_insn_t *));
|
||||
|
||||
/* Default insertion routine.
|
||||
|
||||
SHIFT is negative for left shifts, positive for right shifts.
|
||||
All bits of VALUE to be inserted must be valid as we don't handle
|
||||
signed vs unsigned shifts.
|
||||
ATTRS is a mask of the boolean attributes.
|
||||
LENGTH is the length of VALUE in bits.
|
||||
TOTAL_LENGTH is the total length of the insn (currently 8,16,32).
|
||||
|
||||
ATTRS is a mask of the boolean attributes. We don't need any at the
|
||||
moment, but for consistency with extract_normal we have them. */
|
||||
The result is an error message or NULL if success. */
|
||||
|
||||
/* FIXME: This duplicates functionality with bfd's howto table and
|
||||
/* ??? This duplicates functionality with bfd's howto table and
|
||||
bfd_install_relocation. */
|
||||
/* FIXME: For architectures where insns can be representable as ints,
|
||||
store insn in `field' struct and add registers, etc. while parsing. */
|
||||
/* ??? For architectures where insns can be representable as ints,
|
||||
store insn in `field' struct and add registers, etc. while parsing? */
|
||||
|
||||
static CGEN_INLINE void
|
||||
static const char *
|
||||
insert_normal (value, attrs, start, length, shift, total_length, buffer)
|
||||
long value;
|
||||
unsigned int attrs;
|
||||
int start, length, shift, total_length;
|
||||
int start;
|
||||
int length;
|
||||
int shift;
|
||||
int total_length;
|
||||
char * buffer;
|
||||
{
|
||||
bfd_vma x;
|
||||
static char buf[100];
|
||||
|
||||
if (shift < 0)
|
||||
value <<= -shift;
|
||||
else
|
||||
value >>= shift;
|
||||
|
||||
/* Ensure VALUE will fit. */
|
||||
if ((attrs & (1 << CGEN_OPERAND_UNSIGNED)) != 0)
|
||||
{
|
||||
unsigned long max = (1 << length) - 1;
|
||||
if ((unsigned long) value > max)
|
||||
{
|
||||
const char *err = "operand out of range (%lu not between 0 and %lu)";
|
||||
|
||||
sprintf (buf, err, value, max);
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
long min = - (1 << (length - 1));
|
||||
long max = (1 << (length - 1)) - 1;
|
||||
if (value < min || value > max)
|
||||
{
|
||||
const char *err = "operand out of range (%ld not between %ld and %ld)";
|
||||
|
||||
sprintf (buf, err, value, min, max);
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0 /*def CGEN_INT_INSN*/
|
||||
*buffer |= ((value & ((1 << length) - 1))
|
||||
|
@ -88,11 +122,6 @@ insert_normal (value, attrs, start, length, shift, total_length, buffer)
|
|||
abort ();
|
||||
}
|
||||
|
||||
if (shift < 0)
|
||||
value <<= -shift;
|
||||
else
|
||||
value >>= shift;
|
||||
|
||||
x |= ((value & ((1 << length) - 1))
|
||||
<< (total_length - (start + length)));
|
||||
|
||||
|
@ -117,6 +146,8 @@ insert_normal (value, attrs, start, length, shift, total_length, buffer)
|
|||
abort ();
|
||||
}
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* -- assembler routines inserted here */
|
||||
|
@ -167,10 +198,13 @@ parse_insn_normal (insn, strp, fields)
|
|||
/* We don't check for (*str != '\0') here because we want to parse
|
||||
any trailing fake arguments in the syntax string. */
|
||||
syn = CGEN_SYNTAX_STRING (CGEN_INSN_SYNTAX (insn));
|
||||
|
||||
/* Mnemonics come first for now, ensure valid string. */
|
||||
if (! CGEN_SYNTAX_MNEMONIC_P (* syn))
|
||||
abort ();
|
||||
|
||||
++syn;
|
||||
|
||||
while (* syn != 0)
|
||||
{
|
||||
/* Non operand chars must match exactly. */
|
||||
|
@ -189,7 +223,8 @@ parse_insn_normal (insn, strp, fields)
|
|||
else
|
||||
{
|
||||
/* Syntax char didn't match. Can't be this insn. */
|
||||
/* FIXME: would like to return "expected char `c'" */
|
||||
/* FIXME: would like to return something like
|
||||
"expected char `c'" */
|
||||
return "syntax error";
|
||||
}
|
||||
continue;
|
||||
|
@ -226,9 +261,11 @@ parse_insn_normal (insn, strp, fields)
|
|||
}
|
||||
|
||||
/* Default insn builder (insert handler).
|
||||
The instruction is recorded in target byte order. */
|
||||
The instruction is recorded in target byte order.
|
||||
The result is an error message or NULL if success. */
|
||||
/* FIXME: change buffer to char *? */
|
||||
|
||||
static void
|
||||
static const char *
|
||||
insert_insn_normal (insn, fields, buffer)
|
||||
const CGEN_INSN * insn;
|
||||
CGEN_FIELDS * fields;
|
||||
|
@ -275,11 +312,18 @@ insert_insn_normal (insn, fields, buffer)
|
|||
|
||||
for (syn = CGEN_SYNTAX_STRING (syntax); * syn != '\0'; ++ syn)
|
||||
{
|
||||
const char *errmsg;
|
||||
|
||||
if (CGEN_SYNTAX_CHAR_P (* syn))
|
||||
continue;
|
||||
|
||||
@arch@_cgen_insert_operand (CGEN_SYNTAX_FIELD (*syn), fields, buffer);
|
||||
errmsg = @arch@_cgen_insert_operand (CGEN_SYNTAX_FIELD (*syn), fields,
|
||||
(char *) buffer);
|
||||
if (errmsg)
|
||||
return errmsg;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Main entry point.
|
||||
|
@ -336,16 +380,10 @@ const CGEN_INSN *
|
|||
/* FIXME: wip */
|
||||
CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn);
|
||||
|
||||
/* ??? The extent to which moving the parse and insert handlers into
|
||||
this function (thus removing the function call) will speed things up
|
||||
is unclear. The simplicity and flexibility of the current scheme is
|
||||
appropriate for now. One could have the best of both worlds with
|
||||
inline functions but of course that would only work for gcc. Since
|
||||
we're machine generating some code we could do that here too. Maybe
|
||||
later. */
|
||||
if (! (*CGEN_PARSE_FN (insn)) (insn, &str, fields))
|
||||
if (! CGEN_PARSE_FN (insn) (insn, & str, fields))
|
||||
{
|
||||
(*CGEN_INSERT_FN (insn)) (insn, fields, buf);
|
||||
if (CGEN_INSERT_FN (insn) (insn, fields, buf) != NULL)
|
||||
continue;
|
||||
/* It is up to the caller to actually output the insn and any
|
||||
queued relocs. */
|
||||
return insn;
|
||||
|
|
|
@ -26,6 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
|||
#include "ansidecl.h"
|
||||
#include "dis-asm.h"
|
||||
#include "bfd.h"
|
||||
#include "symcat.h"
|
||||
#include "@arch@-opc.h"
|
||||
|
||||
/* ??? The layout of this stuff is still work in progress.
|
||||
|
@ -87,6 +88,8 @@ extract_normal (buf_ctrl, insn_value, attrs, start, length, shift, total_length,
|
|||
value <<= shift;
|
||||
|
||||
*valuep = value;
|
||||
|
||||
/* FIXME: for now */
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue