binutils-gdb/sim/d10v/gencode.c
Tom Tromey bdca5ee4bc remove PARAMS from sim
This removes the last uses of PARAMS from sim.

2014-01-06  Tom Tromey  <tromey@redhat.com>

	* README-HACKING: Don't use PARAMS.
	* arm/wrapper.c: Don't use PARAMS.
	* bfin/sim-main.h: Don't use PARAMS.
	* common/callback.c: Don't use PARAMS.
	* common/cgen-trace.c: Don't use PARAMS.
	* common/run-sim.h: Don't use PARAMS.
	* common/run.c: Don't use PARAMS.
	* common/sim-base.h: Don't use PARAMS.
	* common/sim-load.c: Don't use PARAMS.
	* common/sim-options.h: Don't use PARAMS.
	* common/sim-trace.c: Don't use PARAMS.
	* common/sim-trace.h: Don't use PARAMS.
	* common/sim-utils.h: Don't use PARAMS.
	* cr16/cr16_sim.h: Don't use PARAMS.
	* cr16/gencode.c: Don't use PARAMS.
	* cr16/interp.c: Don't use PARAMS.
	* cr16/simops.c: Don't use PARAMS.
	* d10v/d10v_sim.h: Don't use PARAMS.
	* d10v/gencode.c: Don't use PARAMS.
	* d10v/interp.c: Don't use PARAMS.
	* d10v/simops.c: Don't use PARAMS.
	* erc32/erc32.c: Don't use PARAMS.
	* erc32/exec.c: Don't use PARAMS.
	* erc32/float.c: Don't use PARAMS.
	* erc32/func.c: Don't use PARAMS.
	* erc32/sis.c: Don't use PARAMS.
	* erc32/sis.h: Don't use PARAMS.
	* mips/interp.c: Don't use PARAMS.
	* mips/sim-main.h: Don't use PARAMS.
	* sh/interp.c: Don't use PARAMS.
	* v850/sim-main.h: Don't use PARAMS.
	* v850/v850_sim.h: Don't use PARAMS.
2014-01-07 09:17:05 -07:00

156 lines
3.5 KiB
C

#include "config.h"
#include <stdio.h>
#include <ctype.h>
#include <limits.h>
#include "ansidecl.h"
#include "opcode/d10v.h"
static void write_header (void);
static void write_opcodes (void);
static void write_template (void);
int
main (argc, argv)
int argc;
char *argv[];
{
if ((argc > 1) && (strcmp (argv[1],"-h") == 0))
write_header();
else if ((argc > 1) && (strcmp (argv[1],"-t") == 0))
write_template ();
else
write_opcodes();
return 0;
}
static void
write_header ()
{
struct d10v_opcode *opcode;
for (opcode = (struct d10v_opcode *)d10v_opcodes; opcode->name; opcode++)
if (opcode->format != OPCODE_FAKE)
printf("void OP_%X (void);\t\t/* %s */\n",opcode->opcode, opcode->name);
}
/* write_template creates a file all required functions, ready */
/* to be filled out */
static void
write_template ()
{
struct d10v_opcode *opcode;
int i,j;
printf ("#include \"d10v_sim.h\"\n");
printf ("#include \"simops.h\"\n");
for (opcode = (struct d10v_opcode *)d10v_opcodes; opcode->name; opcode++)
{
if (opcode->format != OPCODE_FAKE)
{
printf("/* %s */\nvoid\nOP_%X ()\n{\n",opcode->name,opcode->opcode);
/* count operands */
j = 0;
for (i=0;i<6;i++)
{
int flags = d10v_operands[opcode->operands[i]].flags;
if ((flags & OPERAND_REG) || (flags & OPERAND_NUM) || (flags & OPERAND_ADDR))
j++;
}
switch (j)
{
case 0:
printf ("printf(\" %s\\n\");\n",opcode->name);
break;
case 1:
printf ("printf(\" %s\\t%%x\\n\",OP[0]);\n",opcode->name);
break;
case 2:
printf ("printf(\" %s\\t%%x,%%x\\n\",OP[0],OP[1]);\n",opcode->name);
break;
case 3:
printf ("printf(\" %s\\t%%x,%%x,%%x\\n\",OP[0],OP[1],OP[2]);\n",opcode->name);
break;
default:
fprintf (stderr,"Too many operands: %d\n",j);
}
printf ("}\n\n");
}
}
}
long Opcodes[512];
static int curop=0;
check_opcodes( long op)
{
int i;
for (i=0;i<curop;i++)
if (Opcodes[i] == op)
fprintf(stderr,"DUPLICATE OPCODES: %x\n",op);
}
static void
write_opcodes ()
{
struct d10v_opcode *opcode;
int i, j;
/* write out opcode table */
printf ("#include \"d10v_sim.h\"\n");
printf ("#include \"simops.h\"\n\n");
printf ("struct simops Simops[] = {\n");
for (opcode = (struct d10v_opcode *)d10v_opcodes; opcode->name; opcode++)
{
if (opcode->format != OPCODE_FAKE)
{
printf (" { %ld,%d,%ld,%d,%d,%d,%d,OP_%X,", opcode->opcode,
(opcode->format & LONG_OPCODE) ? 1 : 0, opcode->mask, opcode->format,
opcode->cycles, opcode->unit, opcode->exec_type, opcode->opcode);
/* REMOVE ME */
check_opcodes (opcode->opcode);
Opcodes[curop++] = opcode->opcode;
j = 0;
for (i=0;i<6;i++)
{
int flags = d10v_operands[opcode->operands[i]].flags;
if ((flags & OPERAND_REG) || (flags & OPERAND_NUM) || (flags & OPERAND_ADDR))
j++;
}
printf ("%d,",j);
j = 0;
for (i=0;i<6;i++)
{
int flags = d10v_operands[opcode->operands[i]].flags;
int shift = d10v_operands[opcode->operands[i]].shift;
if ((flags & OPERAND_REG) || (flags & OPERAND_NUM)|| (flags & OPERAND_ADDR))
{
if (j == 0)
printf ("{");
else
printf (", ");
if ((flags & OPERAND_REG) && (opcode->format == LONG_L))
shift += 15;
printf ("%d,%d,%d",shift,d10v_operands[opcode->operands[i]].bits,flags);
j = 1;
}
}
if (j)
printf ("}");
printf ("},\n");
}
}
printf ("{ 0,0,0,0,0,0,0,(void (*)(void))0,0,{0,0,0}},\n};\n");
}