summaryrefslogtreecommitdiff
path: root/src/inc/genrops.pl
diff options
context:
space:
mode:
authorJiyoung Yun <jy910.yun@samsung.com>2016-11-23 10:09:09 (GMT)
committerJiyoung Yun <jy910.yun@samsung.com>2016-11-23 10:09:09 (GMT)
commit4b4aad7217d3292650e77eec2cf4c198ea9c3b4b (patch)
tree98110734c91668dfdbb126fcc0e15ddbd93738ca /src/inc/genrops.pl
parentfa45f57ed55137c75ac870356a1b8f76c84b229c (diff)
downloadcoreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.zip
coreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.tar.gz
coreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.tar.bz2
Imported Upstream version 1.1.0upstream/1.1.0
Diffstat (limited to 'src/inc/genrops.pl')
-rw-r--r--src/inc/genrops.pl91
1 files changed, 91 insertions, 0 deletions
diff --git a/src/inc/genrops.pl b/src/inc/genrops.pl
new file mode 100644
index 0000000..415eea7
--- /dev/null
+++ b/src/inc/genrops.pl
@@ -0,0 +1,91 @@
+# Licensed to the .NET Foundation under one or more agreements.
+# The .NET Foundation licenses this file to you under the MIT license.
+# See the LICENSE file in the project root for more information.
+#
+# GENREFOPS.PL
+#
+# PERL script used to generate the numbering of the reference opcodes
+#
+#use strict 'vars';
+#use strict 'subs';
+#use strict 'refs';
+
+print "Reference opcodes\n";
+print "This file is presently only for human consumption\n";
+print "This file is generated from opcode.def using the genrops.pl script\n\n";
+print "Name String Name refop encode\n";
+print "-----------------------------------------------------------------\n";
+
+my $ret = 0;
+my %oneByte;
+my %twoByte;
+$count = 0;
+while (<>)
+{
+ # Process only OPDEF(....) lines
+ if (/OPDEF\(\s*/)
+ {
+ chop; # Strip off trailing CR
+ s/^OPDEF\(\s*//; # Strip off "OP("
+ s/\)$//; # Strip off ")" at end
+ s/,\s*/,/g; # Remove whitespace
+
+ # Split the line up into its basic parts
+ ($enumname, $stringname, $pop, $push, $operand, $type, $size, $s1, $s2, $ctrl) = split(/,/);
+ $s1 =~ s/0x//;
+ $s1 = hex($s1);
+ $s2 =~ s/0x//;
+ $s2 = hex($s2);
+
+
+ my $line = sprintf("%-24s %-24s 0x%03x",
+ $enumname, $stringname, $count);
+ if ($size == 1) {
+ $line .= sprintf(" 0x%02x\n", $s2);
+ if ($oneByte{$s2}) {
+ printf("Error opcode 0x%x already defined!\n", $s2);
+ print " Old = $oneByte{$s2}";
+ print " New = $line";
+ $ret = -1;
+ }
+ $oneByte{$s2} = $line;
+ }
+ elsif ($size == 2) {
+ if ($twoByte{$s2}) {
+ printf("Error opcode 0x%x 0x%x already defined!\n", $s1, $s2);
+ print " Old = $twoByte{$s2}";
+ print " New = $line";
+ $ret = -1;
+ }
+ $line .= sprintf(" 0x%02x 0x%02x\n", $s1, $s2);
+ $twoByte{$s2 + 256 * $s1} = $line;
+ }
+ else {
+ $line .= "\n";
+ push(@deprecated, $line);
+ }
+ $count++;
+ }
+}
+
+my $opcode;
+my $lastOp = -1;
+foreach $opcode (sort {$a <=> $b} keys(%oneByte)) {
+ printf("***** GAP %d instrs ****\n", $opcode - $lastOp) if ($lastOp + 1 != $opcode && $lastOp > 0);
+ print $oneByte{$opcode};
+ $lastOp = $opcode;
+}
+
+$lastOp = -1;
+foreach $opcode (sort {$a <=> $b} keys(%twoByte)) {
+ printf("***** GAP %d instrs ****\n", $opcode - $lastOp) if ($lastOp + 1 != $opcode && $lastOp > 0);
+ print $twoByte{$opcode};
+ $lastOp = $opcode;
+}
+
+print @deprecated;
+
+exit($ret);
+
+
+