Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

212 lines
6.3 KiB

  1. #!/usr/local/bin/perl -w
  2. ##
  3. ## Copyright (c) 2000, Intel Corporation
  4. ## All rights reserved.
  5. ##
  6. ## WARRANTY DISCLAIMER
  7. ##
  8. ## THESE MATERIALS ARE PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  9. ## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  10. ## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  11. ## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS
  12. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  13. ## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  14. ## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  15. ## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  16. ## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING
  17. ## NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THESE
  18. ## MATERIALS, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  19. ##
  20. ## Intel Corporation is the author of the Materials, and requests that all
  21. ## problem reports or change requests be submitted to it directly at
  22. ## http://developer.intel.com/opensource.
  23. ##
  24. require "EM_perl.h";
  25. $GenDir = shift(@ARGV);
  26. $EmdbDir = shift(@ARGV);
  27. ########################################
  28. # STATIC DATA
  29. ########################################
  30. #formats pos value default
  31. @Ignored_insts_basic = (
  32. "{I21},20\.2,{0x3},0x1",
  33. "{M1,M2,M3,M6,M7,M8,M11,M12,M16,M17},28\.2,{0x2},0x0",
  34. "{M4,M5,M9,M10},28\.2,{0x1,0x2},0x0",
  35. "{B5},32\.3,{0x0,0x2,0x4,0x6},0x1",
  36. "{B7},3\.2,{0x1,0x3},0x0"
  37. );
  38. ###@Ignored_insts_merced = (
  39. ###"{M1},28\.2,{0x2,0x3},0x0",
  40. ###"{M4},28\.2,{0x1,0x2},0x0",
  41. ###);
  42. $Inst_cln = 0;
  43. $Format_cln = 10;
  44. $Exts_cln = 12;
  45. $ign_suffix = "IGN";
  46. ########################################
  47. open(EMDB, "$EmdbDir/emdb.txt") || die "Can't open emdb.txt\n";
  48. ###open(EMDB_MERCED, "$EmdbDir/emdb_merced.txt") || die "Can't open emdb_merced.txt\n";
  49. open(FORMAT, "$EmdbDir/emdb_formats.txt") || die "Can't open emdb_formats.txt\n";
  50. open(IGN_IDS_H, ">$GenDir/inst_ign_ids.h") || die "Can't open inst_ign_ids.h\n";
  51. open(IGN_TABLE, ">$GenDir/ign_inst.txt") || die "Can't open ign_inst.txt\n";
  52. select(IGN_TABLE);
  53. ### print the header of inst_ign_ids_ign.h
  54. ### ids with 'IGN' suffix
  55. print IGN_IDS_H "#ifndef _INST_IGN_IDS_H\n";
  56. print IGN_IDS_H "#define _INST_IGN_IDS_H\n\n";
  57. print IGN_IDS_H "typedef enum Inst_ign_id_e\n{\n";
  58. print IGN_IDS_H "EM_INST_EMDB_LAST = EM_INST_LAST-1,\n";
  59. ### print emdb like header in ign_inst.txt
  60. printf "\&inst_id mnemonic template_role op1 op2 op3 op4 op5 op6 flags format major_opcode extensions impls\n";
  61. printf "\?Inst_id_t Mnemonic_t Template_role_t Operand_t Operand_t Operand_t Operand_t Operand_t Operand_t Flags_t Format_t Major_opcode_t Extension_t Implementation_t\n";
  62. printf "\@--- --- EM_TROLE EM_OPROLE;EM_OPTYPE EM_OPROLE;EM_OPTYPE EM_OPROLE;EM_OPTYPE EM_OPROLE;EM_OPTYPE EM_OPROLE;EM_OPTYPE EM_OPROLE;EM_OPTYPE --- EM_FORMAT --- ---;---;---;---;---;---;---;--- ---\n\n";
  63. @inst_formats = <FORMAT>;
  64. @input = <EMDB>;
  65. &create_ignored_insts(@Ignored_insts_basic);
  66. ###@input = <EMDB_MERCED>;
  67. ###&create_ignored_insts(@Ignored_insts_merced);
  68. printf IGN_IDS_H "EM_INST_IGN_LAST\n} Inst_ign_id_t;\n\n";
  69. printf IGN_IDS_H "#endif \/* _INST_IGN_IDS_H *\/\n";
  70. close (EMDB);
  71. ###close (EMDB_MERCED);
  72. close (FORMAT);
  73. close (IGN_TABLE);
  74. close (IGN_IDS_H);
  75. sub create_ignored_insts
  76. {
  77. local(@Ignored_insts) = @_;
  78. local(%Frmt_pos);
  79. local(%Frmt_default);
  80. local(%Frmt_vals);
  81. local(%Frmt_ext_num);
  82. for ($i=0; $i<=$#Ignored_insts; $i++)
  83. {
  84. ($frmts, $place, $vals, $default) = $Ignored_insts[$i] =~ /^\{(\S+)\},(\S+),\{(\S+)\},(\S+)$/;
  85. @frmt = split(/,/, $frmts);
  86. # ($start, $size) = split(/\./, $place);
  87. @val = split(/,/, $vals);
  88. for ($j=0; $j<=$#frmt; $j++)
  89. {
  90. # $Frmt_start{$frmt[$j]} = $start;
  91. # $Frmt_size{$frmt[$j]} = $size;
  92. $Frmt_pos{$frmt[$j]} = $place;
  93. $Frmt_default{$frmt[$j]} = $default;
  94. for ($k=0; $k<=$#val; $k++)
  95. {
  96. $Frmt_vals{$frmt[$j], $k} = $val[$k];
  97. }
  98. }
  99. }
  100. for ($ln=0; $ln<=$#inst_formats; $ln++)
  101. {
  102. $line = $inst_formats[$ln];
  103. if ($line =~ /^EM_FORMAT_(\w+)/)
  104. {
  105. ###format number
  106. $frmt_name = $1;
  107. if ($Frmt_pos{$frmt_name})
  108. {
  109. ###the format has ignored fields values
  110. @format_line = split(/\s+/, $line);
  111. for ($i=1; $i<=$MAX_EXTENSION; $i++)
  112. {
  113. if ($format_line[$i] eq $Frmt_pos{$frmt_name})
  114. {
  115. $Frmt_ext_num{$frmt_name} = $i-1;
  116. last;
  117. }
  118. }
  119. die "Mismatch of formats $frmt_name and ignored extentions positions\n" if ($i>$MAX_EXTENSION);
  120. }
  121. }
  122. }
  123. for ($ln=0; $ln<=$#input; $ln++)
  124. {
  125. $line = $input[$ln];
  126. if ($line =~ /^EM_/)
  127. {
  128. ###$line = $_;
  129. @columns = split(/\s+/,$line);
  130. $format = $columns[$Format_cln];
  131. $old_exts = $columns[$Exts_cln];
  132. $inst_id = $columns[$Inst_cln];
  133. if ($Frmt_pos{$format})
  134. {
  135. @exts = split(/;/, $columns[$Exts_cln]);
  136. if ($exts[$Frmt_ext_num{$format}] eq $Frmt_default{$format})
  137. {
  138. for ($i=0; $Frmt_vals{$format, $i}; $i++)
  139. {
  140. $exts[$Frmt_ext_num{$format}] = $Frmt_vals{$format, $i};
  141. $new_exts = join(';', @exts);
  142. $new_line = $line;
  143. $new_line =~ s/$old_exts/$new_exts/;
  144. $ind = $i+1;
  145. $new_inst_id = $inst_id."\_".$ign_suffix.$ind;
  146. $new_line =~ s/$inst_id/$new_inst_id/;
  147. printf $new_line; ### print instruction with new 'ignore' id
  148. ###if (!$Inst_ign_ids{$new_inst_id})
  149. ###{
  150. printf IGN_IDS_H "$new_inst_id,\n";
  151. ### $Inst_ign_ids{$new_inst_id} = 1;
  152. ###}
  153. }
  154. }
  155. }
  156. }
  157. }
  158. }