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.

1033 lines
34 KiB

  1. #!/usr/local/bin/perl5
  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. # CONSTANTS
  29. ################################################
  30. $dst_2nd_role = $EMDB_LAST_FLAG << 1;
  31. $src_2nd_role = $EMDB_LAST_FLAG << 2;
  32. ################################################
  33. # VARIABLES
  34. ################################################
  35. $function_arguments = "(deccpu_EMDB_info_t *emdb_entry_p, \
  36. U64 inst_code, const U128 *bu_code, EM_Decoder_Info *decoder_info)";
  37. ################################################
  38. if (open(FRMT_FUNC,">$GenDir/frmt_func.c")!=1)
  39. {
  40. die "\nBuilder error - can't open frmt_func.c\n";
  41. };
  42. ################################################
  43. # read format table
  44. ################################################
  45. if (open(FRMT_TABLE,"$EmdbDir/emdb_formats.txt")!=1)
  46. {
  47. die "\nBuilder error - can't open emdb_formats.txt\n";
  48. };
  49. while(<FRMT_TABLE>)
  50. {
  51. /(\S+)(.*)/;
  52. $format_name = $1;
  53. $FT_info{$format_name} = $2;
  54. }
  55. close(FRMT_TABLE);
  56. ################################################
  57. # check redundand optypes
  58. ################################################
  59. open (ALL_OPTYPES, ">$GenDir/all_optypes.txt")||die "Can't open all_optypes.txt\n";
  60. ################################################
  61. # read EMDB format information
  62. ################################################
  63. if (open(EMDB_DEC_INFO,"$GenDir/dec_frmt.txt")!=1)
  64. {
  65. die "\nBuilder error - can't open dec_frmt.txt\n";
  66. };
  67. &Print_inc;
  68. LINE:
  69. while(<EMDB_DEC_INFO>)
  70. {
  71. ($format_name, $function_name, $emdb_format_info, $hard_coded_info) = split(/:/,$_);
  72. $format_name =~ /^(\w*)@?/;
  73. if (!$FT_info{$1} && ($1 ne EM_FORMAT_NONE))
  74. {
  75. die "\nBuilder error - tables mismatch: $1 \n";
  76. }
  77. &Open_function;
  78. if ($format_name ne EM_FORMAT_NONE)
  79. {
  80. &Put_operands_macros;
  81. }
  82. else
  83. {
  84. $check_macro = "";
  85. $check_equal_2dst = "";
  86. $set_macro = "";
  87. $check_hard_coded_macro = "";
  88. }
  89. print FRMT_FUNC $check_macro;
  90. print FRMT_FUNC $check_equal_2dst;
  91. print FRMT_FUNC $set_macro;
  92. print FRMT_FUNC $check_hard_coded_macro;
  93. &Close_function;
  94. }
  95. close(EMDB_DEC_INFO);
  96. sub Open_function
  97. {
  98. print FRMT_FUNC "EM_Decoder_Err ".$function_name;
  99. print FRMT_FUNC $function_arguments."\n\{\n";
  100. print FRMT_FUNC "\tint enc_value;\n";
  101. print FRMT_FUNC "\tEM_Decoder_Err dec_err = EM_DECODER_NO_ERROR;\n";
  102. }
  103. sub Put_operands_macros
  104. {
  105. $dst_no = 1;
  106. $src_no = 1;
  107. ($opers_info, $flags) = split(/\}\{/,$emdb_format_info);
  108. $opers_info =~ s/^\s*\{\s*//;
  109. $flags =~ s/^\s*//;
  110. $flags =~ s/\}//;
  111. &Check_flags;
  112. $hard_coded_info =~ s/^\s*\{\s*|\s*\}\s*$//g;
  113. &Check_hard_coded_fields($hard_coded_info);
  114. @opers_role_type = split(/\s+/,$opers_info);
  115. $format_info = $FT_info{$format_name};
  116. $format_info =~ s/^\s*//;
  117. ($ext0,$ext1,$ext2,$ext3,$ext4,$ext5,$ext6,$ext7,@opers_pos_size) =
  118. split(/\s+/,$format_info);
  119. for($op_no=0;$op_no<$MAX_OPERAND;$op_no++)
  120. {
  121. $put_imm_opers = "";
  122. $imm_size=0;
  123. &Get_pos_and_size($opers_pos_size[$op_no]);
  124. ($op_role,$op_type) = split(/@/,$opers_role_type[$op_no]);
  125. if ($op_role eq DST)
  126. {
  127. $di_op_role = "dst".$dst_no;
  128. $dst_no++;
  129. }
  130. else # SRC
  131. {
  132. $di_op_role = "src".$src_no;
  133. $src_no++;
  134. }
  135. if (($op_type eq EM_OPTYPE_IREG)||
  136. ($op_type eq EM_OPTYPE_IREG_R0_3))
  137. {
  138. print FRMT_FUNC
  139. "\tGET_REG_VALUE(enc_value,inst_code,".$op_pos[0].",".$op_size[0].");\n";
  140. print FRMT_FUNC
  141. "\tFILL_REG_INFO(EM_DECODER_INT_REG, EM_DECODER_REG_R0, enc_value, \
  142. EM_NUM_OF_GREGS, decoder_info->".$di_op_role.", dec_err);\n";
  143. }
  144. elsif ($op_type eq EM_OPTYPE_IREG_R0)
  145. {
  146. print FRMT_FUNC
  147. "\tFILL_REG_INFO(EM_DECODER_INT_REG, EM_DECODER_REG_R0, 0, 1,\
  148. decoder_info->".$di_op_role.", dec_err);\n";
  149. }
  150. elsif ($op_type eq EM_OPTYPE_IREG_R1_127)
  151. {
  152. print FRMT_FUNC
  153. "\tGET_REG_VALUE(enc_value,inst_code,".$op_pos[0].",".$op_size[0].");\n";
  154. print FRMT_FUNC
  155. "\tFILL_REG_INFO(EM_DECODER_INT_REG, EM_DECODER_REG_R0, enc_value, \
  156. EM_NUM_OF_GREGS, decoder_info->".$di_op_role.", dec_err);\n";
  157. print FRMT_FUNC
  158. "\tCHECK_REG_VALUE_0(enc_value, decoder_info->".$di_op_role.", dec_err);\n";
  159. }
  160. elsif ($op_type eq EM_OPTYPE_PREGS_ROT)
  161. {
  162. print FRMT_FUNC
  163. "\tFILL_REG_INFO(EM_DECODER_PR_ROT_REG, EM_DECODER_REG_PR_ROT, 0,1,\
  164. decoder_info->".$di_op_role.", dec_err);\n";
  165. }
  166. elsif ($op_type eq EM_OPTYPE_PSR_L)
  167. {
  168. print FRMT_FUNC
  169. "\tFILL_REG_INFO(EM_DECODER_PSR_L_REG, EM_DECODER_REG_PSR_L, 0,1,\
  170. decoder_info->".$di_op_role.", dec_err);\n";
  171. }
  172. elsif ($op_type eq EM_OPTYPE_PSR_UM)
  173. {
  174. print FRMT_FUNC
  175. "\tFILL_REG_INFO(EM_DECODER_PSR_UM_REG, EM_DECODER_REG_PSR_UM, 0,1,\
  176. decoder_info->".$di_op_role.", dec_err);\n";
  177. }
  178. elsif ($op_type eq EM_OPTYPE_PSR)
  179. {
  180. print FRMT_FUNC
  181. "\tFILL_REG_INFO(EM_DECODER_PSR_REG, EM_DECODER_REG_PSR, 0,1,\
  182. decoder_info->".$di_op_role.", dec_err);\n";
  183. }
  184. elsif ($op_type eq EM_OPTYPE_PREGS_ALL)
  185. {
  186. print FRMT_FUNC
  187. "\tFILL_REG_INFO(EM_DECODER_PR_REG, EM_DECODER_REG_PR, 0,1,\
  188. decoder_info->".$di_op_role.", dec_err);\n";
  189. }
  190. elsif ($op_type eq EM_OPTYPE_APP_CCV)
  191. {
  192. print FRMT_FUNC
  193. "\tFILL_REG_INFO(EM_DECODER_APP_CCV_REG, EM_DECODER_REG_AR0,EM_AR_CCV, \
  194. EM_NUM_OF_AREGS, decoder_info->".$di_op_role.", dec_err);\n";
  195. }
  196. elsif ($op_type eq EM_OPTYPE_APP_PFS)
  197. {
  198. print FRMT_FUNC
  199. "\tFILL_REG_INFO(EM_DECODER_APP_PFS_REG, EM_DECODER_REG_AR0,EM_AR_PFS,\
  200. EM_NUM_OF_AREGS, decoder_info->".$di_op_role.", dec_err);\n";
  201. }
  202. elsif (($op_type eq EM_OPTYPE_DTR)||
  203. ($op_type eq EM_OPTYPE_CPUID))
  204. {
  205. $op_type =~ /EM_OPTYPE_(\w+)/;
  206. $regfile = $1;
  207. print FRMT_FUNC
  208. "\tGET_REG_VALUE(enc_value,inst_code,".$op_pos[0].",".$op_size[0].");\n";
  209. print FRMT_FUNC
  210. "\tFILL_REGFILE_INFO(EM_DECODER_REGFILE_$regfile, enc_value, \
  211. decoder_info->".$di_op_role.", dec_err);\n";
  212. }
  213. elsif ($op_type eq EM_OPTYPE_DBR)
  214. {
  215. print FRMT_FUNC
  216. "\tGET_REG_VALUE(enc_value,inst_code,".$op_pos[0].",".$op_size[0].");\n";
  217. print FRMT_FUNC
  218. "\tFILL_REGFILE_INFO(EM_DECODER_REGFILE_DBR, enc_value, \
  219. decoder_info->".$di_op_role.", dec_err);\n";
  220. }
  221. elsif ($op_type eq EM_OPTYPE_IBR)
  222. {
  223. print FRMT_FUNC
  224. "\tGET_REG_VALUE(enc_value,inst_code,".$op_pos[0].",".$op_size[0].");\n";
  225. print FRMT_FUNC
  226. "\tFILL_REGFILE_INFO(EM_DECODER_REGFILE_IBR, enc_value, \
  227. decoder_info->".$di_op_role.", dec_err);\n";
  228. }
  229. elsif ($op_type eq EM_OPTYPE_PKR)
  230. {
  231. print FRMT_FUNC
  232. "\tGET_REG_VALUE(enc_value,inst_code,".$op_pos[0].",".$op_size[0].");\n";
  233. print FRMT_FUNC
  234. "\tFILL_REGFILE_INFO(EM_DECODER_REGFILE_PKR, enc_value, \
  235. decoder_info->".$di_op_role.", dec_err);\n";
  236. }
  237. elsif ($op_type eq EM_OPTYPE_PMC)
  238. {
  239. print FRMT_FUNC
  240. "\tGET_REG_VALUE(enc_value,inst_code,".$op_pos[0].",".$op_size[0].");\n";
  241. print FRMT_FUNC
  242. "\tFILL_REGFILE_INFO(EM_DECODER_REGFILE_PMC, enc_value, \
  243. decoder_info->".$di_op_role.", dec_err);\n";
  244. }
  245. elsif ($op_type eq EM_OPTYPE_PMD)
  246. {
  247. print FRMT_FUNC
  248. "\tGET_REG_VALUE(enc_value,inst_code,".$op_pos[0].",".$op_size[0].");\n";
  249. print FRMT_FUNC
  250. "\tFILL_REGFILE_INFO(EM_DECODER_REGFILE_PMD, enc_value, \
  251. decoder_info->".$di_op_role.", dec_err);\n";
  252. }
  253. elsif ($op_type eq EM_OPTYPE_DTR)
  254. {
  255. print FRMT_FUNC
  256. "\tGET_REG_VALUE(enc_value,inst_code,".$op_pos[0].",".$op_size[0].");\n";
  257. print FRMT_FUNC
  258. "\tFILL_REGFILE_INFO(EM_DECODER_REGFILE_DTR, enc_value, \
  259. decoder_info->".$di_op_role.", dec_err);\n";
  260. }
  261. elsif ($op_type eq EM_OPTYPE_ITR)
  262. {
  263. print FRMT_FUNC
  264. "\tGET_REG_VALUE(enc_value,inst_code,".$op_pos[0].",".$op_size[0].");\n";
  265. print FRMT_FUNC
  266. "\tFILL_REGFILE_INFO(EM_DECODER_REGFILE_ITR, enc_value, \
  267. decoder_info->".$di_op_role.", dec_err);\n";
  268. }
  269. elsif ($op_type eq EM_OPTYPE_RR)
  270. {
  271. print FRMT_FUNC
  272. "\tGET_REG_VALUE(enc_value,inst_code,".$op_pos[0].",".$op_size[0].");\n";
  273. print FRMT_FUNC
  274. "\tFILL_REGFILE_INFO(EM_DECODER_REGFILE_RR, enc_value, \
  275. decoder_info->".$di_op_role.", dec_err);\n";
  276. }
  277. elsif ($op_type eq EM_OPTYPE_MSR)
  278. {
  279. print FRMT_FUNC
  280. "\tGET_REG_VALUE(enc_value,inst_code,".$op_pos[0].",".$op_size[0].");\n";
  281. print FRMT_FUNC
  282. "\tFILL_REGFILE_INFO(EM_DECODER_REGFILE_MSR, enc_value, \
  283. decoder_info->".$di_op_role.", dec_err);\n";
  284. }
  285. elsif ($op_type eq EM_OPTYPE_FREG)
  286. {
  287. print FRMT_FUNC
  288. "\tGET_REG_VALUE(enc_value,inst_code,".$op_pos[0].",".$op_size[0].");\n";
  289. print FRMT_FUNC
  290. "\tFILL_REG_INFO(EM_DECODER_FP_REG, EM_DECODER_REG_F0, enc_value, EM_NUM_OF_FPREGS, \
  291. decoder_info->".$di_op_role.", dec_err);\n";
  292. }
  293. elsif ($op_type eq EM_OPTYPE_FREG_F2_127)
  294. {
  295. print FRMT_FUNC
  296. "\tGET_REG_VALUE(enc_value,inst_code,".$op_pos[0].",".$op_size[0].");\n";
  297. print FRMT_FUNC
  298. "\tFILL_REG_INFO(EM_DECODER_FP_REG, EM_DECODER_REG_F0, enc_value, EM_NUM_OF_FPREGS, \
  299. decoder_info->".$di_op_role.", dec_err);\n";
  300. print FRMT_FUNC
  301. "\tCHECK_FP_REG_VALUE_0_1(enc_value, decoder_info->".$di_op_role.", dec_err);\n";
  302. }
  303. elsif ($op_type eq EM_OPTYPE_CR)
  304. {
  305. print FRMT_FUNC
  306. "\tGET_REG_VALUE(enc_value,inst_code,".$op_pos[0].",".$op_size[0].");\n";
  307. print FRMT_FUNC
  308. "\tFILL_REG_INFO(EM_DECODER_CR_REG, EM_DECODER_REG_CR0, enc_value, EM_NUM_OF_CREGS, \
  309. decoder_info->".$di_op_role.", dec_err);\n";
  310. print FRMT_FUNC
  311. "\tCHECK_REG_CR(enc_value, decoder_info->".$di_op_role.", dec_err);\n";
  312. }
  313. elsif ($op_type eq EM_OPTYPE_IP)
  314. {
  315. print FRMT_FUNC
  316. "\tFILL_REG_INFO(EM_DECODER_IP_REG, EM_DECODER_REG_IP, 0, 1,\
  317. decoder_info->".$di_op_role.", dec_err);\n";
  318. }
  319. elsif ($op_type eq EM_OPTYPE_APP_REG_GRP_HIGH)
  320. {
  321. print FRMT_FUNC
  322. "\tGET_REG_VALUE(enc_value,inst_code,".$op_pos[0].",".$op_size[0].");\n";
  323. print FRMT_FUNC
  324. "\tFILL_REG_INFO(EM_DECODER_APP_REG, EM_DECODER_REG_AR0, enc_value, EM_NUM_OF_AREGS, \
  325. decoder_info->".$di_op_role.", dec_err);\n";
  326. print FRMT_FUNC
  327. "\tCHECK_REG_APP_GRP_HIGH(enc_value, decoder_info->".$di_op_role.", dec_err);\n";
  328. }
  329. elsif ($op_type eq EM_OPTYPE_APP_REG_GRP_LOW)
  330. {
  331. print FRMT_FUNC
  332. "\tGET_REG_VALUE(enc_value,inst_code,".$op_pos[0].",".$op_size[0].");\n";
  333. print FRMT_FUNC
  334. "\tFILL_REG_INFO(EM_DECODER_APP_REG, EM_DECODER_REG_AR0, enc_value, EM_NUM_OF_AREGS, \
  335. decoder_info->".$di_op_role.", dec_err);\n";
  336. print FRMT_FUNC
  337. "\tCHECK_REG_APP_GRP_LOW(enc_value, decoder_info->".$di_op_role.", dec_err);\n";
  338. }
  339. elsif ($op_type eq EM_OPTYPE_PREG)
  340. {
  341. print FRMT_FUNC
  342. "\tGET_REG_VALUE(enc_value,inst_code,".$op_pos[0].",".$op_size[0].");\n";
  343. print FRMT_FUNC
  344. "\tFILL_REG_INFO(EM_DECODER_PRED_REG, EM_DECODER_REG_P0, enc_value, EM_NUM_OF_PREGS, \
  345. decoder_info->".$di_op_role.", dec_err);\n";
  346. }
  347. elsif ($op_type eq EM_OPTYPE_BR)
  348. {
  349. print FRMT_FUNC
  350. "\tGET_REG_VALUE(enc_value,inst_code,".$op_pos[0].",".$op_size[0].");\n";
  351. print FRMT_FUNC
  352. "\tFILL_REG_INFO(EM_DECODER_BR_REG, EM_DECODER_REG_BR0, enc_value, EM_NUM_OF_BREGS, \
  353. decoder_info->".$di_op_role.", dec_err);\n";
  354. }
  355. elsif ($op_type eq EM_OPTYPE_IREG_NUM)
  356. {
  357. for ($j=0;$j<$num_of_parts;$j++)
  358. {
  359. $put_imm_opers .= ($op_pos[$j]-($EM_PREDICATE_BITS*(!$not_predicatable))).",".$op_size[$j].",";
  360. $imm_size += $op_size[$j];
  361. }
  362. print FRMT_FUNC
  363. "\tGET_UIMM_VALUE".$np_suffix.$num_of_parts."(enc_value,".$put_imm_opers."inst_code);\n";
  364. print FRMT_FUNC
  365. "\tFILL_IMM_INFO(EM_DECODER_IMM_UNSIGNED,enc_value, ".$imm_size.", \
  366. decoder_info->".$di_op_role.");\n";
  367. print FRMT_FUNC
  368. "\tdecoder_info->".$di_op_role."\.oper_flags |= EM_DECODER_OPER_IMM_IREG_BIT;\n";
  369. }
  370. elsif ($op_type eq EM_OPTYPE_FREG_NUM)
  371. {
  372. for ($j=0;$j<$num_of_parts;$j++)
  373. {
  374. $put_imm_opers .= ($op_pos[$j]-($EM_PREDICATE_BITS*(!$not_predicatable))).",".$op_size[$j].",";
  375. $imm_size += $op_size[$j];
  376. }
  377. print FRMT_FUNC
  378. "\tGET_UIMM_VALUE".$np_suffix.$num_of_parts."(enc_value,".$put_imm_opers."inst_code);\n";
  379. print FRMT_FUNC
  380. "\tFILL_IMM_INFO(EM_DECODER_IMM_UNSIGNED,enc_value, ".$imm_size.", \
  381. decoder_info->".$di_op_role.");\n";
  382. print FRMT_FUNC
  383. "\tdecoder_info->".$di_op_role."\.oper_flags |= EM_DECODER_OPER_IMM_FREG_BIT;\n";
  384. }
  385. elsif ($op_type eq EM_OPTYPE_BR_VEC)
  386. {
  387. for ($j=0;$j<$num_of_parts;$j++)
  388. {
  389. $put_imm_opers .= ($op_pos[$j]-($EM_PREDICATE_BITS*(!$not_predicatable))).",".$op_size[$j].",";
  390. $imm_size += $op_size[$j];
  391. }
  392. print FRMT_FUNC
  393. "\tGET_UIMM_VALUE".$np_suffix.$num_of_parts."(enc_value,".$put_imm_opers."inst_code);\n";
  394. print FRMT_FUNC
  395. "\tREJECT_0(enc_value);\n";
  396. print FRMT_FUNC
  397. "\tFILL_IMM_INFO(EM_DECODER_IMM_BR_VEC,enc_value, ".$imm_size.", \
  398. decoder_info->".$di_op_role.");\n";
  399. }
  400. elsif ($op_type eq EM_OPTYPE_MEM)
  401. {
  402. print FRMT_FUNC
  403. "\tGET_REG_VALUE(enc_value,inst_code,".$op_pos[0].",".$op_size[0].");\n";
  404. print FRMT_FUNC
  405. "\tFILL_MEM_INFO(enc_value,emdb_entry_p->mem_size,decoder_info->".$di_op_role.",dec_err);\n";
  406. }
  407. elsif (($op_type eq EM_OPTYPE_UIMM)||($op_type eq EM_OPTYPE_MUX2))
  408. {
  409. for ($j=0;$j<$num_of_parts;$j++)
  410. {
  411. $put_imm_opers .= ($op_pos[$j]-($EM_PREDICATE_BITS*(!$not_predicatable))).",".$op_size[$j].",";
  412. $imm_size += $op_size[$j];
  413. }
  414. print FRMT_FUNC
  415. "\tGET_UIMM_VALUE".$np_suffix.$num_of_parts."(enc_value,".$put_imm_opers."inst_code);\n";
  416. print FRMT_FUNC
  417. "\tFILL_IMM_INFO(EM_DECODER_IMM_UNSIGNED,enc_value, ".$imm_size.", \
  418. decoder_info->".$di_op_role.");\n";
  419. }
  420. elsif ($op_type eq EM_OPTYPE_ALLOC_IOL)
  421. {
  422. for ($j=0;$j<$num_of_parts;$j++)
  423. {
  424. $put_imm_opers .= ($op_pos[$j]-($EM_PREDICATE_BITS*(!$not_predicatable))).",".$op_size[$j].",";
  425. $imm_size += $op_size[$j];
  426. }
  427. if ($op_no != 2)
  428. {
  429. print FRMT_FUNC
  430. "\t\tGET_UIMM_VALUE".$np_suffix.$num_of_parts."(enc_value,".$put_imm_opers."inst_code);\n";
  431. }
  432. else
  433. {
  434. print FRMT_FUNC
  435. "\tGET_UIMM_VALUE".$np_suffix.$num_of_parts."(enc_value,".$put_imm_opers."inst_code);\n";
  436. print FRMT_FUNC
  437. "\n\t{\n\t\tint check_val = enc_value;\n\n";
  438. }
  439. if ($op_no==4)
  440. {
  441. print FRMT_FUNC
  442. "\t\tif ((enc_value>EM_REGISTER_STACK_SIZE) && (!dec_err))\n\t\t\tdec_err = \
  443. (EM_DECODER_STACK_FRAME_SIZE_OUT_OF_RANGE);\n";
  444. print FRMT_FUNC
  445. "\t\tif ((enc_value<check_val) && (!dec_err))\n\t\t\tdec_err = \
  446. (EM_DECODER_LOCALS_SIZE_LARGER_STACK_FRAME);\n";
  447. print FRMT_FUNC
  448. "\t\tcheck_val = enc_value;\n";
  449. print FRMT_FUNC
  450. "\t\tFILL_IMM_INFO(EM_DECODER_IMM_UNSIGNED,enc_value-(int)\
  451. IEL_GETDW0\(decoder_info->src2\.imm_info\.val64\), ".$imm_size.", \
  452. decoder_info->".$di_op_role.");\n";
  453. }
  454. else
  455. {
  456. print FRMT_FUNC
  457. "\t\tFILL_IMM_INFO(EM_DECODER_IMM_UNSIGNED,enc_value, ".$imm_size.", \
  458. decoder_info->".$di_op_role.");\n";
  459. }
  460. }
  461. elsif ($op_type eq EM_OPTYPE_CPOS)
  462. {
  463. for ($j=0;$j<$num_of_parts;$j++)
  464. {
  465. $put_imm_opers .= ($op_pos[$j]-($EM_PREDICATE_BITS*(!$not_predicatable))).",".$op_size[$j].",";
  466. $imm_size += $op_size[$j];
  467. }
  468. print FRMT_FUNC
  469. "\tGET_UIMM_VALUE".$np_suffix.$num_of_parts."(enc_value,".$put_imm_opers."inst_code);\n";
  470. print FRMT_FUNC "\tenc_value = 63-enc_value;\n";
  471. print FRMT_FUNC
  472. "\tFILL_IMM_INFO(EM_DECODER_IMM_UNSIGNED,enc_value, ".$imm_size.", \
  473. decoder_info->".$di_op_role.");\n";
  474. }
  475. elsif ($op_type eq EM_OPTYPE_LDFP_BASE_UPDATE)
  476. {
  477. for ($j=0;$j<$num_of_parts;$j++)
  478. {
  479. $put_imm_opers .= ($op_pos[$j]-($EM_PREDICATE_BITS*(!$not_predicatable))).",".$op_size[$j].",";
  480. $imm_size += $op_size[$j];
  481. }
  482. print FRMT_FUNC
  483. "\tGET_UIMM_VALUE".$np_suffix.$num_of_parts."(enc_value,".$put_imm_opers."inst_code);\n";
  484. }
  485. elsif ($op_type eq EM_OPTYPE_SSHIFT_16)
  486. {
  487. for ($j=0;$j<$num_of_parts;$j++)
  488. {
  489. $put_imm_opers .= ($op_pos[$j]-($EM_PREDICATE_BITS*(!$not_predicatable))).",".$op_size[$j].",";
  490. $imm_size += $op_size[$j];
  491. }
  492. print FRMT_FUNC "\t\{\n";
  493. print FRMT_FUNC "\t\tU64 imm_value64;\n";
  494. print FRMT_FUNC
  495. "\t\tGET_SIMM_VALUE".$np_suffix.$num_of_parts."(enc_value,".$put_imm_opers."inst_code);\n";
  496. print FRMT_FUNC "\t\tIEL_CONVERT2(imm_value64,enc_value,(((unsigned)enc_value>>31)*(-1)));\n";
  497. print FRMT_FUNC "\t\tIEL_SHL(imm_value64,imm_value64,16);\n";
  498. print FRMT_FUNC
  499. "\t\tFILL_LONG_IMM_INFO(EM_DECODER_IMM_SIGNED,imm_value64, ".($imm_size+16).", \
  500. decoder_info->".$di_op_role.");\n\t}\n";
  501. }
  502. elsif ($op_type eq EM_OPTYPE_SSHIFT_1)
  503. {
  504. for ($j=0;$j<$num_of_parts;$j++)
  505. {
  506. $put_imm_opers .= ($op_pos[$j]-($EM_PREDICATE_BITS*(!$not_predicatable))).",".$op_size[$j].",";
  507. $imm_size += $op_size[$j];
  508. }
  509. print FRMT_FUNC
  510. "\tGET_SIMM_VALUE".$np_suffix.$num_of_parts."(enc_value,".$put_imm_opers."inst_code);\n";
  511. print FRMT_FUNC "\tenc_value = enc_value<<1;\n";
  512. print FRMT_FUNC
  513. "\tFILL_IMM_INFO(EM_DECODER_IMM_SIGNED,enc_value, ".($imm_size+1).", \
  514. decoder_info->".$di_op_role.");\n";
  515. }
  516. elsif ($op_type eq EM_OPTYPE_ALLOC_ROT)
  517. {
  518. for ($j=0;$j<$num_of_parts;$j++)
  519. {
  520. $put_imm_opers .= ($op_pos[$j]-($EM_PREDICATE_BITS*(!$not_predicatable))).",".$op_size[$j].",";
  521. $imm_size += $op_size[$j];
  522. }
  523. print FRMT_FUNC
  524. "\t\tGET_UIMM_VALUE".$np_suffix.$num_of_parts."(enc_value,".$put_imm_opers."inst_code);\n";
  525. print FRMT_FUNC "\t\tenc_value = enc_value<<3;\n";
  526. print FRMT_FUNC
  527. "\t\tif ((enc_value>check_val) && (!dec_err))\n\t\t\tdec_err = \
  528. (EM_DECODER_ROTATING_SIZE_LARGER_STACK_FRAME);\n\t}\n\n";
  529. print FRMT_FUNC
  530. "\tFILL_IMM_INFO(EM_DECODER_IMM_UNSIGNED,enc_value, ".($imm_size+3).", \
  531. decoder_info->".$di_op_role.");\n";
  532. }
  533. elsif ($op_type eq EM_OPTYPE_CCOUNT)
  534. {
  535. for ($j=0;$j<$num_of_parts;$j++)
  536. {
  537. $put_imm_opers .= ($op_pos[$j]-($EM_PREDICATE_BITS*(!$not_predicatable))).",".$op_size[$j].",";
  538. $imm_size += $op_size[$j];
  539. }
  540. print FRMT_FUNC
  541. "\tGET_UIMM_VALUE".$np_suffix.$num_of_parts."(enc_value,".$put_imm_opers."inst_code);\n";
  542. print FRMT_FUNC "\tenc_value = 31-enc_value;\n";
  543. print FRMT_FUNC
  544. "\tFILL_IMM_INFO(EM_DECODER_IMM_UNSIGNED,enc_value, ".$imm_size.", \
  545. decoder_info->".$di_op_role.");\n";
  546. }
  547. elsif ($op_type eq EM_OPTYPE_UDEC)
  548. {
  549. for ($j=0;$j<$num_of_parts;$j++)
  550. {
  551. $put_imm_opers .= ($op_pos[$j]-($EM_PREDICATE_BITS*(!$not_predicatable))).",".$op_size[$j].",";
  552. $imm_size += $op_size[$j];
  553. }
  554. print FRMT_FUNC
  555. "\tGET_UIMM_VALUE".$np_suffix.$num_of_parts."(enc_value,".$put_imm_opers."inst_code);\n";
  556. print FRMT_FUNC "\tenc_value++;\n";
  557. print FRMT_FUNC
  558. "\tFILL_IMM_INFO(EM_DECODER_IMM_UNSIGNED,enc_value, ".$imm_size.", \
  559. decoder_info->".$di_op_role.");\n";
  560. }
  561. elsif ($op_type eq EM_OPTYPE_FCLASS)
  562. {
  563. for ($j=0;$j<$num_of_parts;$j++)
  564. {
  565. $put_imm_opers .= ($op_pos[$j]-($EM_PREDICATE_BITS*(!$not_predicatable))).",".$op_size[$j].",";
  566. $imm_size += $op_size[$j];
  567. }
  568. print FRMT_FUNC
  569. "\tGET_UIMM_VALUE".$np_suffix.$num_of_parts."(enc_value,".$put_imm_opers."inst_code);\n";
  570. print FRMT_FUNC
  571. "\tFILL_IMM_INFO(EM_DECODER_IMM_FCLASS,enc_value, ".$imm_size.", \
  572. decoder_info->".$di_op_role.");\n";
  573. }
  574. elsif ($op_type eq EM_OPTYPE_SEMAPHORE_INC)
  575. {
  576. for ($j=0;$j<$num_of_parts;$j++)
  577. {
  578. $put_imm_opers .= ($op_pos[$j]-($EM_PREDICATE_BITS*(!$not_predicatable))).",".$op_size[$j].",";
  579. $imm_size += $op_size[$j];
  580. }
  581. print FRMT_FUNC
  582. "\tGET_SIMM_VALUE".$np_suffix.$num_of_parts."(enc_value,".$put_imm_opers."inst_code);\n";
  583. print FRMT_FUNC
  584. "\tCONVERT_IMM_SEMAPHORE_INC(enc_value, dec_err);\n";
  585. print FRMT_FUNC
  586. "\tFILL_IMM_INFO(EM_DECODER_IMM_SIGNED,enc_value, ".$imm_size.", \
  587. decoder_info->".$di_op_role.");\n";
  588. }
  589. elsif ($op_type eq EM_OPTYPE_CMP_UIMM)
  590. {
  591. for ($j=0;$j<$num_of_parts;$j++)
  592. {
  593. $put_imm_opers .= ($op_pos[$j]-($EM_PREDICATE_BITS*(!$not_predicatable))).",".$op_size[$j].",";
  594. $imm_size += $op_size[$j];
  595. }
  596. print FRMT_FUNC "\t\{\n";
  597. print FRMT_FUNC "\t\t U64 enc_value64;\n";
  598. print FRMT_FUNC
  599. "\t\tGET_CMP_UIMM_VALUE".$np_suffix.$num_of_parts."(enc_value64,".$put_imm_opers."inst_code);\n";
  600. print FRMT_FUNC
  601. "\t\tFILL_LONG_IMM_INFO(EM_DECODER_IMM_UNSIGNED,enc_value64, ".$imm_size.", \
  602. decoder_info->".$di_op_role.");\n";
  603. print FRMT_FUNC "\t\}\n";
  604. }
  605. elsif ($op_type eq EM_OPTYPE_CMP4_UIMM)
  606. {
  607. for ($j=0;$j<$num_of_parts;$j++)
  608. {
  609. $put_imm_opers .= ($op_pos[$j]-($EM_PREDICATE_BITS*(!$not_predicatable))).",".$op_size[$j].",";
  610. $imm_size += $op_size[$j];
  611. }
  612. print FRMT_FUNC
  613. "\tGET_CMP4_UIMM_VALUE".$np_suffix.$num_of_parts."(enc_value,".$put_imm_opers."inst_code);\n";
  614. print FRMT_FUNC
  615. "\tFILL_IMM_INFO(EM_DECODER_IMM_UNSIGNED,enc_value, ".$imm_size.", \
  616. decoder_info->".$di_op_role.");\n";
  617. }
  618. elsif ($op_type eq EM_OPTYPE_MUX1)
  619. {
  620. for ($j=0;$j<$num_of_parts;$j++)
  621. {
  622. $put_imm_opers .= ($op_pos[$j]-($EM_PREDICATE_BITS*(!$not_predicatable))).",".$op_size[$j].",";
  623. $imm_size += $op_size[$j];
  624. }
  625. print FRMT_FUNC
  626. "\tGET_UIMM_VALUE".$np_suffix.$num_of_parts."(enc_value,".$put_imm_opers."inst_code);\n";
  627. print FRMT_FUNC
  628. "\tCHECK_IMM_MUX1(enc_value, dec_err);\n";
  629. print FRMT_FUNC
  630. "\tFILL_IMM_INFO(EM_DECODER_IMM_MUX1,enc_value, ".$imm_size.", \
  631. decoder_info->".$di_op_role.");\n";
  632. }
  633. elsif ($op_type eq EM_OPTYPE_SIMM)
  634. {
  635. for ($j=0;$j<$num_of_parts;$j++)
  636. {
  637. $put_imm_opers .= ($op_pos[$j]-($EM_PREDICATE_BITS*(!$not_predicatable))).",".$op_size[$j].",";
  638. $imm_size += $op_size[$j];
  639. }
  640. print FRMT_FUNC
  641. "\tGET_SIMM_VALUE".$np_suffix.$num_of_parts."(enc_value,".$put_imm_opers."inst_code);\n";
  642. print FRMT_FUNC
  643. "\tFILL_IMM_INFO(EM_DECODER_IMM_SIGNED,enc_value, ".$imm_size.", \
  644. decoder_info->".$di_op_role.");\n";
  645. }
  646. elsif ($op_type eq EM_OPTYPE_UIMM64 || $op_type eq EM_OPTYPE_SSHIFT_REL64)
  647. {
  648. if ($not_predicatable)
  649. {
  650. die "ERROR! Assumption broken: IMM64 operand appears in non-predicatable instruction\n";
  651. }
  652. print FRMT_FUNC "\t\{\n";
  653. print FRMT_FUNC "\t\t U64 imm_value64;\n";
  654. $put_imm_opers1 = "";
  655. $put_imm_opers2 = "";
  656. $put_imm_opers3 = "";
  657. $num_of_parts1 = 0;
  658. $num_of_parts2 = 0;
  659. $num_of_parts3 = 0;
  660. $pos_in_oper = 0;
  661. for ($j=0;$j<$num_of_parts;$j++)
  662. {
  663. if ($op_pos[$j]>=0 && $num_of_parts2==0)
  664. {
  665. ### encoding of this operand part can be taken from the instruction slot
  666. ### and does not slip out of the 32-bit integer operand
  667. $num_of_parts1++;
  668. $put_imm_opers1 .= ($op_pos[$j]-($EM_PREDICATE_BITS*(!$not_predicatable))).",".$op_size[$j].",";
  669. }
  670. elsif ($op_pos[$j]<0)
  671. {
  672. ### operand part is located in the non-instruction slot
  673. $num_of_parts2++;
  674. $put_imm_opers2 .= $pos_in_oper.",".(41+$op_pos[$j]).",".$op_size[$j].",";
  675. }
  676. else
  677. {
  678. ### encoding of this operand part can be taken from the instruction slot
  679. ### but slip out of the 32-bit integer operand
  680. $num_of_parts3++;
  681. $put_imm_opers3 .= $pos_in_oper.",".($op_pos[$j]-($EM_PREDICATE_BITS*(!$not_predicatable))).",".$op_size[$j].",";
  682. }
  683. $pos_in_oper += $op_size[$j];
  684. }
  685. print FRMT_FUNC
  686. "\t\tGET_UIMM_VALUE".$num_of_parts1."(enc_value,".$put_imm_opers1."inst_code);\n";
  687. print FRMT_FUNC "\t\tIEL_CONVERT2(imm_value64,enc_value,0);\n";
  688. if ($num_of_parts2 > 0)
  689. {
  690. print FRMT_FUNC
  691. "\t\tGET_UIMM64_VALUE".$num_of_parts2."(imm_value64,".$put_imm_opers2."*bu_code);\n";
  692. }
  693. if ($num_of_parts3 > 0)
  694. {
  695. print FRMT_FUNC
  696. "\t\tGET_UIMM_2_U64_VALUE".$num_of_parts3."(imm_value64,".$put_imm_opers3."inst_code);\n";
  697. }
  698. if ($op_type eq EM_OPTYPE_UIMM64)
  699. {
  700. print FRMT_FUNC
  701. "\t\tFILL_LONG_IMM_INFO(EM_DECODER_IMM_UNSIGNED,imm_value64, ".$pos_in_oper.", \
  702. decoder_info->".$di_op_role.");\n";
  703. }
  704. else
  705. {
  706. ### shift_rel64
  707. print FRMT_FUNC "\tIEL_SHL(imm_value64, imm_value64, EM_IPREL_TARGET_SHIFT_AMOUNT);\n";
  708. print FRMT_FUNC
  709. "\tFILL_LONG_IPREL_INFO(imm_value64, $pos_in_oper+4, decoder_info->".$di_op_role.");\n";
  710. }
  711. print FRMT_FUNC "\t\}\n";
  712. }
  713. elsif ($op_type eq EM_OPTYPE_SSHIFT_REL || $op_type eq EM_OPTYPE_TAG)
  714. {
  715. for ($j=0;$j<$num_of_parts;$j++)
  716. {
  717. $put_imm_opers .= ($op_pos[$j]-($EM_PREDICATE_BITS*(!$not_predicatable))).",".$op_size[$j].",";
  718. $imm_size += $op_size[$j];
  719. }
  720. print FRMT_FUNC
  721. "\tGET_SIMM_VALUE".$np_suffix.$num_of_parts."(enc_value,".$put_imm_opers."inst_code);\n";
  722. print FRMT_FUNC "\tenc_value = enc_value<<EM_IPREL_TARGET_SHIFT_AMOUNT;\n";
  723. print FRMT_FUNC
  724. "\tFILL_IPREL_INFO(enc_value, ".($imm_size+4).", decoder_info->".$di_op_role.");\n";
  725. }
  726. elsif ($op_type eq EM_OPTYPE_COUNT_123)
  727. {
  728. for ($j=0;$j<$num_of_parts;$j++)
  729. {
  730. $put_imm_opers .= ($op_pos[$j]-($EM_PREDICATE_BITS*(!$not_predicatable))).",".$op_size[$j].",";
  731. $imm_size += $op_size[$j];
  732. }
  733. print FRMT_FUNC
  734. "\tGET_UIMM_VALUE".$np_suffix.$num_of_parts."(enc_value,".$put_imm_opers."inst_code);\n";
  735. print FRMT_FUNC "\tenc_value++;\n";
  736. print FRMT_FUNC
  737. "\tCHECK_IMM_COUNT_123(enc_value, dec_err);\n";
  738. print FRMT_FUNC
  739. "\tFILL_IMM_INFO(EM_DECODER_IMM_UNSIGNED,enc_value, ".$imm_size.", \
  740. decoder_info->".$di_op_role.");\n";
  741. }
  742. elsif ($op_type eq EM_OPTYPE_COUNT_PACK)
  743. {
  744. for ($j=0;$j<$num_of_parts;$j++)
  745. {
  746. $put_imm_opers .= ($op_pos[$j]-($EM_PREDICATE_BITS*(!$not_predicatable))).",".$op_size[$j].",";
  747. $imm_size += $op_size[$j];
  748. }
  749. print FRMT_FUNC
  750. "\tGET_UIMM_VALUE".$np_suffix.$num_of_parts."(enc_value,".$put_imm_opers."inst_code);\n";
  751. print FRMT_FUNC
  752. "\tCONVERT_IMM_COUNT_PACK(enc_value);\n";
  753. print FRMT_FUNC
  754. "\tFILL_IMM_INFO(EM_DECODER_IMM_UNSIGNED,enc_value, ".$imm_size.", \
  755. decoder_info->".$di_op_role.");\n";
  756. }
  757. elsif ($op_type eq EM_OPTYPE_COUNT_1234)
  758. {
  759. for ($j=0;$j<$num_of_parts;$j++)
  760. {
  761. $put_imm_opers .= ($op_pos[$j]-($EM_PREDICATE_BITS*(!$not_predicatable))).",".$op_size[$j].",";
  762. $imm_size += $op_size[$j];
  763. }
  764. print FRMT_FUNC
  765. "\tGET_UIMM_VALUE".$np_suffix.$num_of_parts."(enc_value,".$put_imm_opers."inst_code);\n";
  766. print FRMT_FUNC "\tenc_value++;\n";
  767. print FRMT_FUNC
  768. "\tCHECK_IMM_COUNT_1234(enc_value, dec_err);\n";
  769. print FRMT_FUNC
  770. "\tFILL_IMM_INFO(EM_DECODER_IMM_UNSIGNED,enc_value, ".$imm_size.", \
  771. decoder_info->".$di_op_role.");\n";
  772. }
  773. elsif ($op_type eq EM_OPTYPE_ONE)
  774. {
  775. print FRMT_FUNC
  776. "\tFILL_IMM_INFO(EM_DECODER_IMM_UNSIGNED,1,1,decoder_info->".$di_op_role.");\n";
  777. }
  778. elsif ($op_type eq EM_OPTYPE_EIGHT)
  779. {
  780. print FRMT_FUNC
  781. "\tFILL_IMM_INFO(EM_DECODER_IMM_UNSIGNED,8,4,decoder_info->".$di_op_role.");\n";
  782. }
  783. elsif ($op_type eq EM_OPTYPE_SIXTEEN)
  784. {
  785. print FRMT_FUNC
  786. "\tFILL_IMM_INFO(EM_DECODER_IMM_UNSIGNED,16,5,decoder_info->".$di_op_role.");\n";
  787. }
  788. elsif ($op_type ne EM_OPTYPE_NONE)
  789. {
  790. die "\nERROR! ".$op_type." is not covered\n";
  791. }
  792. if ($op_type ne EM_OPTYPE_NONE)
  793. {
  794. print FRMT_FUNC "\n";
  795. }
  796. if (!$ALL_optypes{$op_type})
  797. {
  798. $ALL_optypes{$op_type} = 1;
  799. print ALL_OPTYPES "$op_type \n";
  800. }
  801. }
  802. }
  803. sub Close_function
  804. {
  805. print FRMT_FUNC "\treturn(dec_err);\n";
  806. print FRMT_FUNC "\}\n\n";
  807. }
  808. sub Get_pos_and_size
  809. {
  810. local($ps) = @_;
  811. $i = 0;
  812. while($ps =~ /\d/)
  813. {
  814. ($op_pos[$i],$op_size[$i]) = $ps =~
  815. /^\s*\+*(\-?\d+)\.(\d+)/;
  816. $ps =~ s/^\s*(\+*\-?\d+\.\d+)//;
  817. $i++;
  818. $op_size[$i] = 0;
  819. }
  820. $num_of_parts = $i;
  821. }
  822. sub Check_flags
  823. {
  824. ### $chk_db=0;
  825. ### $no_chk_db=0;
  826. $check_macro="";
  827. $not_predicatable = 0;
  828. $np_suffix = "";
  829. @flag = split(/\s+/,$flags);
  830. $total_flag_num = $#flag+1;
  831. $set_macro = "";
  832. if ($total_flag_num == 1)
  833. {
  834. if (!(hex($flag[0]) & $EM_FLAG_PRED))
  835. {
  836. $not_predicatable = 1;
  837. $np_suffix = "_NP";
  838. }
  839. if (hex($flag[0]) & $EM_FLAG_CHECK_BASE_EQ_DST)
  840. {
  841. $check_macro = "\tCHECK_DEST_AND_BASE(decoder_info->dst1,decoder_info->src1,dec_err);\n";
  842. }
  843. if (hex($flag[0]) & $dst_2nd_role)
  844. {
  845. $set_macro = "\tSET_2ND_ROLE_TO_DEST(decoder_info->src1);\n";
  846. }
  847. elsif (hex($flag[0]) & $src_2nd_role)
  848. {
  849. $set_macro = "\tSET_2ND_ROLE_TO_SRC(decoder_info->dst1);\n";
  850. }
  851. if (hex($flag[0]) & $EM_FLAG_CHECK_SAME_DSTS)
  852. {
  853. $check_equal_2dst = "\tCHECK_DEST_AND_DEST(decoder_info,dec_err);\n";
  854. }
  855. else
  856. {
  857. $check_equal_2dst = "";
  858. }
  859. if (hex($flag[0]) & $EM_FLAG_CHECK_EVEN_ODD_FREGS)
  860. {
  861. $check_macro =
  862. "\tCHECK_ODD_EVEN_DSTS(decoder_info->dst1,decoder_info->dst2,dec_err);\n";
  863. }
  864. }
  865. elsif ($total_flag_num > 1)
  866. {
  867. $predicatable = 0;
  868. $chk_base_dst = 1;
  869. $src_is_dst = 1;
  870. $dst_is_src = 1;
  871. $no_2nd_role = 1;
  872. $dst_eq_dst = 1;
  873. $dst_ne_dst = 1;
  874. for($fl_no=0;$fl_no<$total_flag_num;$fl_no++)
  875. {
  876. if (hex($flag[$fl_no]) & $EM_FLAG_PRED)
  877. {
  878. die "ERROR! Handler contains both predicatable and non-predicatable instructions\n" if ($not_predicatable == 1);
  879. $predicatable = 1;
  880. }
  881. else
  882. {
  883. die "ERROR! Handler contains both predicatable and non-predicatable instructions\n" if ($predicatable == 1);
  884. $not_predicatable = 1;
  885. $np_suffix = "_NP";
  886. }
  887. if (hex($flag[0]) & $EM_FLAG_CHECK_BASE_EQ_DST)
  888. {
  889. die "ERROR! Handler contains both instructions with FLAG_CHECK_BASE_EQ_DST on and off\n" if ($chk_base_dst == 0);
  890. $check_macro = "\tCHECK_DEST_AND_BASE(decoder_info->dst1,decoder_info->src1,dec_err);\n";
  891. }
  892. else
  893. {
  894. die "ERROR! Handler contains both instructions with CHECK_BASE_EQ_DST on and off\n" if ($check_macro ne "");
  895. $chk_base_dst = 0;
  896. }
  897. if (hex($flag[0]) & $dst_2nd_role)
  898. {
  899. die "ERROR! Handler contains instructions with different 2nd role property\n" if ($src_is_dst == 0);
  900. $dst_is_src = 0;
  901. $no_2nd_role = 0;
  902. $set_macro = "\tSET_2ND_ROLE_TO_DEST(decoder_info->src1);\n";
  903. }
  904. elsif (hex($flag[0]) & $src_2nd_role)
  905. {
  906. die "ERROR! Handler contains instructions with different 2nd role property\n" if ($dst_is_src == 0);
  907. $src_is_dst = 0;
  908. $no_2nd_role = 0;
  909. $set_macro = "\tSET_2ND_ROLE_TO_SRC(decoder_info->dst1);\n";
  910. }
  911. else
  912. {
  913. die "ERROR! Handler contains instructions with different 2nd role property\n" if ($no_2nd_role == 0);
  914. $src_is_dst = 0;
  915. $dst_is_src = 0;
  916. }
  917. if (hex($flag[0]) & $EM_FLAG_CHECK_SAME_DSTS)
  918. {
  919. die "ERROR! Handler contains both instructions with FLAG_CHECK_SAME_DSTS on and off\n" if ($dst_eq_dst == 0);
  920. $check_equal_2dst = "\tCHECK_DEST_AND_DEST(decoder_info,dec_err);\n";
  921. $dst_ne_dst = 0;
  922. }
  923. else
  924. {
  925. die "ERROR! Handler contains both instructions with FLAG_CHECK_SAME_DSTS on and off\n" if ($dst_ne_dst == 0);
  926. $dst_eq_dst = 0;
  927. $check_equal_2dst = "";
  928. }
  929. }
  930. }
  931. }
  932. sub Check_hard_coded_fields
  933. {
  934. local($hard_coded_info) = @_;
  935. local($pos, $val, $start, $end, $size);
  936. $check_hard_coded_macro = "\n";
  937. @hard_coded_flds = split(/\s+/, $hard_coded_info);
  938. for ($fld_no=0; $fld_no<=$#hard_coded_flds; $fld_no++)
  939. {
  940. ($pos, $val) = split(/,/, $hard_coded_flds[$fld_no]);
  941. ($start, $end) = split(/-/, $pos);
  942. if ($pos eq "0-5")
  943. {
  944. ### hard-coded predicate
  945. $check_hard_coded_macro .= "\tGET_PREDICATE_HARD_CODED_VALUE(enc_value, inst_code);\n";
  946. $check_hard_coded_macro .= "\tCHECK_PREDICATE_HARD_CODED(enc_value, ".$val.", dec_err);\n";
  947. }
  948. else
  949. {
  950. ### hard-coded predicate
  951. $size = $end - $start + 1;
  952. $check_hard_coded_macro .= "\tGET_FIELD_HARD_CODED_VALUE(enc_value, ".$start.", ".$size.", inst_code);\n";
  953. $check_hard_coded_macro .= "\tCHECK_FIELD_HARD_CODED(enc_value, ".$val.", dec_err);\n";
  954. }
  955. }
  956. }
  957. sub Print_inc
  958. {
  959. print FRMT_FUNC "#include <stdio.h>\n";
  960. print FRMT_FUNC "#include <stdlib.h>\n";
  961. print FRMT_FUNC "#include \"decfn_emdb.h\"\n";
  962. print FRMT_FUNC "#include \"frmt_mac.h\"\n";
  963. }