6 #include "opcode/d10v.h"
8 static void write_header PARAMS ((void));
9 static void write_opcodes PARAMS ((void));
10 static void write_template PARAMS ((void));
17 if ((argc > 1) && (strcmp (argv[1],"-h") == 0))
19 else if ((argc > 1) && (strcmp (argv[1],"-t") == 0))
30 struct d10v_opcode *opcode;
32 for (opcode = (struct d10v_opcode *)d10v_opcodes; opcode->name; opcode++)
33 if (opcode->format != OPCODE_FAKE)
34 printf("void OP_%X PARAMS ((void));\t\t/* %s */\n",opcode->opcode, opcode->name);
38 /* write_template creates a file all required functions, ready */
39 /* to be filled out */
44 struct d10v_opcode *opcode;
47 printf ("#include \"d10v_sim.h\"\n");
48 printf ("#include \"simops.h\"\n");
50 for (opcode = (struct d10v_opcode *)d10v_opcodes; opcode->name; opcode++)
52 if (opcode->format != OPCODE_FAKE)
54 printf("/* %s */\nvoid\nOP_%X ()\n{\n",opcode->name,opcode->opcode);
60 int flags = d10v_operands[opcode->operands[i]].flags;
61 if ((flags & OPERAND_REG) || (flags & OPERAND_NUM) || (flags & OPERAND_ADDR))
67 printf ("printf(\" %s\\n\");\n",opcode->name);
70 printf ("printf(\" %s\\t%%x\\n\",OP[0]);\n",opcode->name);
73 printf ("printf(\" %s\\t%%x,%%x\\n\",OP[0],OP[1]);\n",opcode->name);
76 printf ("printf(\" %s\\t%%x,%%x,%%x\\n\",OP[0],OP[1],OP[2]);\n",opcode->name);
79 fprintf (stderr,"Too many operands: %d\n",j);
90 check_opcodes( long op)
96 fprintf(stderr,"DUPLICATE OPCODES: %x\n",op);
103 struct d10v_opcode *opcode;
106 /* write out opcode table */
107 printf ("#include \"d10v_sim.h\"\n");
108 printf ("#include \"simops.h\"\n\n");
109 printf ("struct simops Simops[] = {\n");
111 for (opcode = (struct d10v_opcode *)d10v_opcodes; opcode->name; opcode++)
113 if (opcode->format != OPCODE_FAKE)
115 printf (" { %ld,%d,%ld,%d,%d,%d,%d,OP_%X,", opcode->opcode,
116 (opcode->format & LONG_OPCODE) ? 1 : 0, opcode->mask, opcode->format,
117 opcode->cycles, opcode->unit, opcode->exec_type, opcode->opcode);
120 check_opcodes (opcode->opcode);
121 Opcodes[curop++] = opcode->opcode;
126 int flags = d10v_operands[opcode->operands[i]].flags;
127 if ((flags & OPERAND_REG) || (flags & OPERAND_NUM) || (flags & OPERAND_ADDR))
135 int flags = d10v_operands[opcode->operands[i]].flags;
136 int shift = d10v_operands[opcode->operands[i]].shift;
137 if ((flags & OPERAND_REG) || (flags & OPERAND_NUM)|| (flags & OPERAND_ADDR))
143 if ((flags & OPERAND_REG) && (opcode->format == LONG_L))
145 printf ("%d,%d,%d",shift,d10v_operands[opcode->operands[i]].bits,flags);
154 printf ("{ 0,0,0,0,0,0,0,(void (*)(void))0,0,{0,0,0}},\n};\n");