7 #include "opcode/d10v.h"
9 static void write_header (void);
10 static void write_opcodes (void);
11 static void write_template (void);
14 main (int argc, char *argv[])
16 if ((argc > 1) && (strcmp (argv[1],"-h") == 0))
18 else if ((argc > 1) && (strcmp (argv[1],"-t") == 0))
29 struct d10v_opcode *opcode;
31 for (opcode = (struct d10v_opcode *)d10v_opcodes; opcode->name; opcode++)
32 if (opcode->format != OPCODE_FAKE)
33 printf("void OP_%lX (void);\t\t/* %s */\n", opcode->opcode, opcode->name);
37 /* write_template creates a file all required functions, ready */
38 /* to be filled out */
43 struct d10v_opcode *opcode;
46 printf ("#include \"d10v_sim.h\"\n");
47 printf ("#include \"simops.h\"\n");
49 for (opcode = (struct d10v_opcode *)d10v_opcodes; opcode->name; opcode++)
51 if (opcode->format != OPCODE_FAKE)
53 printf("/* %s */\nvoid\nOP_%lX ()\n{\n", opcode->name, opcode->opcode);
59 int flags = d10v_operands[opcode->operands[i]].flags;
60 if ((flags & OPERAND_REG) || (flags & OPERAND_NUM) || (flags & OPERAND_ADDR))
66 printf ("printf(\" %s\\n\");\n",opcode->name);
69 printf ("printf(\" %s\\t%%x\\n\",OP[0]);\n",opcode->name);
72 printf ("printf(\" %s\\t%%x,%%x\\n\",OP[0],OP[1]);\n",opcode->name);
75 printf ("printf(\" %s\\t%%x,%%x,%%x\\n\",OP[0],OP[1],OP[2]);\n",opcode->name);
78 fprintf (stderr,"Too many operands: %d\n",j);
90 check_opcodes( long op)
96 fprintf(stderr,"DUPLICATE OPCODES: %lx\n", op);
102 struct d10v_opcode *opcode;
105 /* write out opcode table */
106 printf ("#include \"d10v_sim.h\"\n");
107 printf ("#include \"simops.h\"\n\n");
108 printf ("struct simops Simops[] = {\n");
110 for (opcode = (struct d10v_opcode *)d10v_opcodes; opcode->name; opcode++)
112 if (opcode->format != OPCODE_FAKE)
114 printf (" { %ld,%d,%ld,%d,%d,%d,%d,OP_%lX,", opcode->opcode,
115 (opcode->format & LONG_OPCODE) ? 1 : 0, opcode->mask, opcode->format,
116 opcode->cycles, opcode->unit, opcode->exec_type, opcode->opcode);
119 check_opcodes (opcode->opcode);
120 Opcodes[curop++] = opcode->opcode;
125 int flags = d10v_operands[opcode->operands[i]].flags;
126 if ((flags & OPERAND_REG) || (flags & OPERAND_NUM) || (flags & OPERAND_ADDR))
134 int flags = d10v_operands[opcode->operands[i]].flags;
135 int shift = d10v_operands[opcode->operands[i]].shift;
136 if ((flags & OPERAND_REG) || (flags & OPERAND_NUM)|| (flags & OPERAND_ADDR))
142 if ((flags & OPERAND_REG) && (opcode->format == LONG_L))
144 printf ("%d,%d,%d",shift,d10v_operands[opcode->operands[i]].bits,flags);
153 printf ("{ 0,0,0,0,0,0,0,(void (*)(void))0,0,{0,0,0}},\n};\n");