X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmini%2Fgenmdesc.c;h=0c942afabafd3a8f47fb18c3352781254e16c441;hb=92d89b2b067df5ee75533d956b69d42a3dfac611;hp=7d34d3561a89e5460ba5b29a23ace680680025f2;hpb=2d23bfcbce7a3f7e54dcd5911adb88b244baca35;p=mono.git diff --git a/mono/mini/genmdesc.c b/mono/mini/genmdesc.c index 7d34d3561a8..0c942afabaf 100644 --- a/mono/mini/genmdesc.c +++ b/mono/mini/genmdesc.c @@ -43,6 +43,7 @@ typedef struct { char spec [MONO_INST_MAX]; } OpDesc; +static int nacl = 0; static GHashTable *table; static GHashTable *template_table; @@ -65,7 +66,7 @@ load_file (const char *name) { * The format of the lines are: * # comment * opcode: [dest:format] [src1:format] [src2:format] [flags:format] [clob:format] - * [cost:num] [res:format] [delay:num] [len:num] + * [cost:num] [res:format] [delay:num] [len:num] [nacl:num] * format is a single letter that depends on the field * NOTE: no space between the field name and the ':' * @@ -74,6 +75,8 @@ load_file (const char *name) { line = 0; while ((str = fgets (buf, sizeof (buf), f))) { gboolean is_template = FALSE; + gboolean nacl_length_set = FALSE; + ++line; eat_whitespace (str); if (!str [0]) @@ -131,8 +134,20 @@ load_file (const char *name) { p += 7; */ } else if (strncmp (p, "len:", 4) == 0) { + unsigned long size; p += 4; - desc->spec [MONO_INST_LEN] = strtoul (p, &p, 10); + size = strtoul (p, &p, 10); + if (!nacl_length_set) { + desc->spec [MONO_INST_LEN] = size; + } + } else if (strncmp (p, "nacl:", 5) == 0) { + unsigned long size; + p += 5; + size = strtoul (p, &p, 10); + if (nacl) { + desc->spec [MONO_INST_LEN] = size; + nacl_length_set = TRUE; + } } else if (strncmp (p, "template:", 9) == 0) { char *tname; int i; @@ -284,14 +299,22 @@ main (int argc, char* argv []) dump (); } else if (argc < 4) { g_print ("Usage: genmdesc arguments\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"); + g_print ("\tgenmdesc desc Output to stdout the description file.\n"); + g_print ("\tgenmdesc [--nacl] output name desc [desc1...]\n" + " Write to output the description in a table named 'name',\n" + " use --nacl to generate Google NativeClient code\n"); return 1; } else { - int i; - for (i = 3; i < argc; ++i) + int i = 3; + if (strcmp (argv [1], "--nacl") == 0) { + nacl = 1; + i++; + } + + for (; i < argc; ++i) load_file (argv [i]); - build_table (argv [1], argv [2]); + + build_table (argv [1 + nacl], argv [2 + nacl]); } return 0; }