Fix sorting of ulong[] arrays among others when using the non-generic Sort() overloads.
[mono-project/dkf.git] / mono / cil / make-opcodes-def.pl
bloba94c15778cac608d1f83d9d1e23421d0de139da9
1 #!/usr/bin/perl
3 # make-opcodes-def.pl: Loads the opcodes from the CIL-opcodes.xml and
4 # generates a spec compliant opcodes.def file
6 # Author:
7 # Miguel de Icaza (miguel@ximian.com)
9 # (C) 2001 Ximian, Inc.
11 # We should really be doing this with XSLT, but I know nothing about XSLT
12 # ;-)
13 # or maybe just an XML::Parser... - lupus
15 use strict;
16 use XML::Parser;
18 my %valid_flow;
19 # the XML file also includes "throw"
20 @valid_flow{qw(next call return branch meta cond-branch)} = ();
22 open OUTPUT, ">$ARGV[1]" || die "Can not create $ARGV[1] file: $!";
24 my $parser = new XML::Parser (Handlers => {Start => \&handle_opcode});
25 $parser->parsefile($ARGV[0]);
26 print_trailer();
27 close(OUTPUT) || die "Can not close file: $!";
29 sub handle_opcode {
30 my ($parser, $elem, %attrs) = @_;
31 my ($name, $input, $output, $args, $o1, $o2, $flow, $uname, $count, $ff);
33 return if ($elem ne 'opcode');
35 ($name, $input, $output, $args, $o1, $o2, $flow) =
36 @attrs{qw(name input output args o1 o2 flow)};
38 $uname = uc $name;
39 $uname =~ tr/./_/;
40 if (hex($o1) == 0xff){
41 $count = 1;
42 } else {
43 $count = 2;
46 $ff = "ERROR";
47 if (exists $valid_flow{$flow}) {
48 $ff = uc $flow;
49 $ff =~ tr/-/_/;
52 print OUTPUT "OPDEF(CEE_$uname, \"$name\", $input, $output, $args, X, $count, $o1, $o2, $ff)\n";
56 sub print_trailer {
57 print OUTPUT<<EOF;
58 #ifndef OPALIAS
59 #define _MONO_CIL_OPALIAS_DEFINED_
60 #define OPALIAS(a,s,r)
61 #endif
63 OPALIAS(CEE_BRNULL, "brnull", CEE_BRFALSE)
64 OPALIAS(CEE_BRNULL_S, "brnull.s", CEE_BRFALSE_S)
65 OPALIAS(CEE_BRZERO, "brzero", CEE_BRFALSE)
66 OPALIAS(CEE_BRZERO_S, "brzero.s", CEE_BRFALSE_S)
67 OPALIAS(CEE_BRINST, "brinst", CEE_BRTRUE)
68 OPALIAS(CEE_BRINST_S, "brinst.s", CEE_BRTRUE_S)
69 OPALIAS(CEE_LDIND_U8, "ldind.u8", CEE_LDIND_I8)
70 OPALIAS(CEE_LDELEM_U8, "ldelem.u8", CEE_LDELEM_I8)
71 OPALIAS(CEE_LDX_I4_MIX, "ldc.i4.M1", CEE_LDC_I4_M1)
72 OPALIAS(CEE_ENDFAULT, "endfault", CEE_ENDFINALLY)
74 #ifdef _MONO_CIL_OPALIAS_DEFINED_
75 #undef OPALIAS
76 #undef _MONO_CIL_OPALIAS_DEFINED_
77 #endif
78 EOF