2010-01-16 Zoltan Varga <vargaz@gmail.com>
[mono.git] / mono / mini / genmdesc.c
index f0ec807d6b39c02960e70cff9107b2eabcaafad5..aad714566b9969ef59a5f8d12f792f6d661dab32 100644 (file)
@@ -79,6 +79,9 @@ load_file (const char *name) {
                        } else if (strncmp (p, "src2:", 5) == 0) {
                                desc->spec [MONO_INST_SRC2] = p [5];
                                p += 6;
+                       } else if (strncmp (p, "src3:", 5) == 0) {
+                               desc->spec [MONO_INST_SRC3] = p [5];
+                               p += 6;
                        } else if (strncmp (p, "clob:", 5) == 0) {
                                desc->spec [MONO_INST_CLOB] = p [5];
                                p += 6;
@@ -119,12 +122,6 @@ init_table (void) {
        table = g_hash_table_new (g_str_hash, g_str_equal);
 
        opcodes = g_new0 (OpDesc, OP_LAST);
-       for (i = 0; i < MONO_CEE_LAST; ++i) {
-               desc = opcodes + i;
-               desc->num = i;
-               desc->name = mono_inst_name (i);
-               g_hash_table_insert (table, (char *)desc->name, desc);
-       }
        for (i = OP_LOAD; i < OP_LAST; ++i) {
                desc = opcodes + i;
                desc->num = i;
@@ -161,10 +158,10 @@ build_table (const char *fname, const char *name) {
        idx = 1;
        g_string_append_printf (idx_array, "const guint16 %s_idx [] = {\n", name);
 
-       for (i = 0; i < OP_LAST; ++i) {
+       for (i = OP_LOAD; i < OP_LAST; ++i) {
                desc = opcodes + i;
                if (!desc->desc)
-                       g_string_append_printf (idx_array, "\t0,\t/* %s */\n", desc->name);
+                       g_string_append_printf (idx_array, "\t0,\t/* %s */\n", desc->name ? desc->name : "");
                else {
                        fprintf (f, "\t\"");
                        for (j = 0; j < MONO_INST_MAX; ++j)
@@ -217,21 +214,20 @@ int
 main (int argc, char* argv [])
 {
        init_table ();
-       switch (argc) {
-       case 2:
+       if (argc == 2) {
                /* useful to get a new file when some opcodes are added: looses the comments, though */
                load_file (argv [1]);
                dump ();
-               break;
-       case 4:
-               load_file (argv [1]);
-               build_table (argv [2], argv [3]);
-               break;
-       default:
+       } else if (argc < 4) {
                g_print ("Usage: genmdesc arguments\n");
-               g_print ("\tgenmdesc desc             Output to stdout the description file.\n");
-               g_print ("\tgenmdesc desc output name Write to output the description in a table named 'name'.\n");
+               g_print ("\tgenmdesc desc                        Output to stdout the description file.\n");
+               g_print ("\tgenmdesc output name desc [desc1...] Write to output the description in a table named 'name'.\n");
                return 1;
+       } else {
+               int i;
+               for (i = 3; i < argc; ++i)
+                       load_file (argv [i]);
+               build_table (argv [1], argv [2]);
        }
        return 0;
 }