00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef u64_lower_template_INCLUDED
00043 #define u64_lower_template_INCLUDED "u64_lower_template.h"
00044
00045
00046
00047 enum HIGH_ORDER_BITS {
00048 HOB_none,
00049 HOB_zero_xtd,
00050 HOB_sign_xtd,
00051 };
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 template <class NODE>
00067 NODE *
00068 U64_LOWER_expr(NODE *tree, INT &maxsize,
00069 HIGH_ORDER_BITS &hob_state, HIGH_ORDER_BITS &hob_to_do,
00070 BOOL leave_CVTL_at_leaf)
00071 {
00072 INT maxsize0, maxsize1, new_maxsize;
00073 HIGH_ORDER_BITS hob_state0, hob_state1;
00074 HIGH_ORDER_BITS hob_to_do0, hob_to_do1;
00075 INT i;
00076 NODE *nd;
00077 NODE *new_nd = U64_LOWER_alloc_stack(tree); U64_LOWER_copy_node(new_nd, tree);
00078 OPERATOR opr = U64_LOWER_operator(tree);
00079 TYPE_ID res = U64_LOWER_rtype(tree);
00080 TYPE_ID desc = U64_LOWER_desc(tree);
00081 if (desc == MTYPE_V || desc == MTYPE_UNKNOWN) desc = res;
00082
00083 if (opr == OPR_INTRINSIC_OP
00084 #ifdef KEY
00085 || opr == OPR_PURE_CALL_OP
00086 #endif
00087 ) {
00088 for (i = 0; i < U64_LOWER_kid_count(tree); i++) {
00089 U64_LOWER_set_kid(new_nd, i, U64_LOWER_expr(U64_LOWER_kid(tree,i),
00090 maxsize0, hob_state0, hob_to_do0, leave_CVTL_at_leaf));
00091 }
00092 if (MTYPE_is_integral(res) && res != MTYPE_B) {
00093 maxsize = MTYPE_bit_size(res);
00094 hob_state = HOB_none;
00095 hob_to_do = MTYPE_signed(res) ? HOB_sign_xtd : HOB_zero_xtd;
00096 }
00097 else maxsize = 0;
00098 return U64_LOWER_form_node(new_nd, tree);
00099 }
00100 if (opr == OPR_SELECT) {
00101 U64_LOWER_set_kid(new_nd, 0, U64_LOWER_expr(U64_LOWER_kid(tree,0), maxsize0,
00102 hob_state0, hob_to_do0, leave_CVTL_at_leaf));
00103 if (maxsize0 != 0 && maxsize0 != 64) {
00104 if (hob_state0 == HOB_none)
00105 U64_LOWER_insert_cvtl_for_kid(new_nd, HOB_zero_xtd, 0, maxsize0, hob_state0);
00106 #if 0
00107 U64_LOWER_set_kid0(new_nd, U64_LOWER_create_ne_0(Boolean_type, MTYPE_U8,
00108 U64_LOWER_kid0(new_nd)));
00109 #endif
00110 }
00111 U64_LOWER_set_kid1(new_nd, U64_LOWER_expr(U64_LOWER_kid1(tree), maxsize1,
00112 hob_state1, hob_to_do1, leave_CVTL_at_leaf));
00113 U64_LOWER_set_kid2(new_nd, U64_LOWER_expr(U64_LOWER_kid2(tree), maxsize,
00114 hob_state, hob_to_do, leave_CVTL_at_leaf));
00115 if (! MTYPE_is_integral(res) || res == MTYPE_B)
00116 return U64_LOWER_form_node(new_nd, tree);
00117 U64_LOWER_set_rtype(new_nd, Mtype_TransferSize(MTYPE_A8, res));
00118 if (maxsize == maxsize1 && hob_state == hob_state1 &&
00119 hob_to_do == hob_to_do1)
00120 return U64_LOWER_form_node(new_nd, tree);
00121 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do1, 1, maxsize1, hob_state1);
00122 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do, 2, maxsize, hob_state);
00123 maxsize = 64;
00124 return U64_LOWER_form_node(new_nd, tree);
00125 }
00126
00127 if (U64_LOWER_kid_count(tree) > 0) {
00128 U64_LOWER_set_kid0(new_nd, U64_LOWER_expr(U64_LOWER_kid0(tree), maxsize,
00129 hob_state, hob_to_do, leave_CVTL_at_leaf));
00130 if (U64_LOWER_kid_count(tree) > 1) {
00131 U64_LOWER_set_kid1(new_nd, U64_LOWER_expr(U64_LOWER_kid1(tree), maxsize1,
00132 hob_state1, hob_to_do1, leave_CVTL_at_leaf));
00133 if (U64_LOWER_kid_count(tree) > 2) {
00134 Is_True(! MTYPE_is_integral(desc), ("unhandled ternary operator"));
00135 U64_LOWER_set_kid2(new_nd, U64_LOWER_expr(U64_LOWER_kid2(tree), maxsize1,
00136 hob_state1, hob_to_do1, leave_CVTL_at_leaf));
00137 maxsize = 0;
00138 return U64_LOWER_form_node(new_nd, tree);
00139
00140 }
00141 }
00142 }
00143
00144
00145 switch (opr) {
00146
00147
00148
00149 case OPR_LDID:
00150 if (! MTYPE_is_integral(res) || res == MTYPE_B) {
00151 maxsize = 0;
00152 return tree;
00153 }
00154 if (U64_LOWER_class(tree) == CLASS_PREG) {
00155 maxsize = MTYPE_bit_size(res);
00156 hob_state = HOB_none;
00157 hob_to_do = MTYPE_signed(res) ? HOB_sign_xtd : HOB_zero_xtd;
00158 U64_LOWER_set_rtype(tree, Mtype_TransferSize(MTYPE_A8, res));
00159 #if 0
00160
00161
00162 U64_LOWER_set_desc(tree, Mtype_TransferSize(MTYPE_A8, res));
00163 #endif
00164 return tree;
00165 }
00166 maxsize = MTYPE_bit_size(desc);
00167 if (maxsize == 64)
00168 return tree;
00169 hob_state = HOB_zero_xtd;
00170 hob_to_do = MTYPE_signed(res) ? HOB_sign_xtd : HOB_zero_xtd;
00171 if (MTYPE_signed(desc)) {
00172 U64_LOWER_set_desc(tree, Mtype_TransferSign(MTYPE_U8, desc));
00173 }
00174 #if 0 // this is done in post-pass instead
00175 U64_LOWER_reset_sign_extd(tree);
00176 #endif
00177
00178 U64_LOWER_set_rtype(tree, Mtype_TransferSize(MTYPE_A8, U64_LOWER_desc(tree)));
00179
00180 if (! leave_CVTL_at_leaf)
00181 return tree;
00182 else if (maxsize < 64 && hob_to_do == HOB_sign_xtd) {
00183 hob_state = HOB_sign_xtd;
00184 return U64_LOWER_create_cvtl(MTYPE_I8, tree, maxsize);
00185 }
00186 else return tree;
00187
00188 case OPR_ILOAD:
00189 if (! MTYPE_is_integral(res) || res == MTYPE_B) {
00190 maxsize = 0;
00191 return U64_LOWER_form_node(new_nd, tree);
00192 }
00193 maxsize = MTYPE_bit_size(desc);
00194 if (maxsize == 64)
00195 return U64_LOWER_form_node(new_nd, tree);
00196 hob_state = HOB_zero_xtd;
00197 hob_to_do = MTYPE_signed(res) ? HOB_sign_xtd : HOB_zero_xtd;
00198 if (MTYPE_signed(desc)) {
00199 U64_LOWER_set_desc(new_nd, Mtype_TransferSign(MTYPE_U8, desc));
00200 }
00201 #if 0 // this is done in post-pass instead
00202 U64_LOWER_reset_sign_extd(new_nd);
00203 #endif
00204
00205 U64_LOWER_set_rtype(new_nd, Mtype_TransferSize(MTYPE_A8, U64_LOWER_desc(new_nd)));
00206
00207 if (! leave_CVTL_at_leaf)
00208 return U64_LOWER_form_node(new_nd, tree);
00209 else if (maxsize < 64 && hob_to_do == HOB_sign_xtd) {
00210 hob_state = HOB_sign_xtd;
00211 return U64_LOWER_create_cvtl(MTYPE_I8,
00212 U64_LOWER_form_node(new_nd, tree),
00213 maxsize);
00214 }
00215 else return U64_LOWER_form_node(new_nd, tree);
00216
00217 case OPR_LDBITS:
00218 maxsize = U64_LOWER_bit_size(tree);
00219 hob_state = MTYPE_signed(res) ? HOB_sign_xtd : HOB_zero_xtd;
00220 hob_to_do = HOB_none;
00221 return tree;
00222
00223 case OPR_ILDBITS:
00224 maxsize = U64_LOWER_bit_size(tree);
00225 hob_state = MTYPE_signed(res) ? HOB_sign_xtd : HOB_zero_xtd;
00226 hob_to_do = HOB_none;
00227 return U64_LOWER_form_node(new_nd, tree);
00228
00229 case OPR_MLOAD:
00230 Is_True(maxsize1 != 0, ("illegal type for kid 1 of MLOAD node"));
00231 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do, 1, maxsize1, hob_state1);
00232 maxsize = 0;
00233 return U64_LOWER_form_node(new_nd, tree);
00234
00235
00236
00237 case OPR_INTCONST:
00238 maxsize = MTYPE_bit_size(res);
00239 if (maxsize == 32) {
00240 if (MTYPE_signed(res)) {
00241 U64_LOWER_set_const_val(tree, (U64_LOWER_const_val(tree) << 32) >> 32);
00242 hob_state = HOB_sign_xtd;
00243 }
00244 else {
00245 U64_LOWER_set_const_val(tree, (UINT64) (U64_LOWER_const_val(tree) << 32) >> 32);
00246 hob_state = HOB_zero_xtd;
00247 }
00248 U64_LOWER_set_rtype(tree, Mtype_TransferSize(MTYPE_A8, res));
00249 hob_to_do = hob_state;
00250 }
00251 return tree;
00252
00253 case OPR_CONST:
00254 if (! MTYPE_is_integral(res)) {
00255 maxsize = 0;
00256 return tree;
00257 }
00258 maxsize = MTYPE_bit_size(res);
00259 hob_state = HOB_none;
00260 hob_to_do = MTYPE_signed(res) ? HOB_sign_xtd : HOB_zero_xtd;
00261 return tree;
00262
00263 case OPR_LDA: case OPR_LDA_LABEL:
00264 maxsize = MTYPE_bit_size(res);
00265 hob_state = HOB_zero_xtd;
00266 hob_to_do = HOB_none;
00267 return tree;
00268
00269
00270
00271 case OPR_SQRT: case OPR_RSQRT: case OPR_RECIP:
00272 case OPR_PAREN:
00273 case OPR_REALPART: case OPR_IMAGPART:
00274 case OPR_HIGHPART: case OPR_LOWPART:
00275 return U64_LOWER_form_node(new_nd, tree);
00276
00277 case OPR_LNOT:
00278 if (MTYPE_bit_size(res) > maxsize)
00279 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do, 0, maxsize, hob_state);
00280 maxsize = 1;
00281 hob_state = HOB_zero_xtd;
00282 hob_to_do = HOB_none;
00283 return U64_LOWER_form_node(new_nd, tree);
00284
00285 case OPR_ALLOCA:
00286 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do, 0, maxsize, hob_state);
00287 maxsize = MTYPE_bit_size(res);
00288 hob_state = HOB_zero_xtd;
00289 hob_to_do = HOB_none;
00290 return U64_LOWER_form_node(new_nd, tree);
00291
00292 case OPR_NEG:
00293 if (MTYPE_is_integral(res)) {
00294 if (maxsize < MTYPE_bit_size(res)) {
00295 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do, 0, maxsize, hob_state);
00296 }
00297 U64_LOWER_set_rtype(new_nd, Mtype_TransferSize(MTYPE_A8, res));
00298 }
00299 return U64_LOWER_form_node(new_nd, tree);
00300
00301 case OPR_EXTRACT_BITS:
00302 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do, 0, maxsize, hob_state);
00303
00304 U64_LOWER_set_rtype(new_nd, Mtype_TransferSize(MTYPE_A8, res));
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314 if (res == MTYPE_BS) {
00315 maxsize = U64_LOWER_bit_size(tree);
00316 }
00317 else {
00318 maxsize = MTYPE_bit_size(res);
00319 }
00320 hob_state = MTYPE_signed(res) ? HOB_sign_xtd : HOB_zero_xtd;
00321 hob_to_do = HOB_none;
00322 return U64_LOWER_form_node(new_nd, tree);
00323
00324 case OPR_BNOT:
00325 if (maxsize < MTYPE_bit_size(res))
00326 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do, 0, maxsize, hob_state);
00327 if (MTYPE_bit_size(res) == 64) {
00328 hob_to_do = HOB_none;
00329 maxsize = 64;
00330 }
00331 else {
00332 U64_LOWER_set_rtype(new_nd, Mtype_TransferSize(MTYPE_A8, res));
00333 hob_to_do = MTYPE_signed(res) ? HOB_sign_xtd : HOB_zero_xtd;
00334 maxsize = MTYPE_bit_size(res);
00335 hob_state = HOB_none;
00336 }
00337 return U64_LOWER_form_node(new_nd, tree);
00338
00339 case OPR_PARM:
00340 case OPR_TAS:
00341 if (MTYPE_bit_size(res) > maxsize)
00342 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do, 0, maxsize, hob_state);
00343 maxsize = MTYPE_is_integral(res) ? 64 : 0;
00344 return U64_LOWER_form_node(new_nd, tree);
00345
00346 case OPR_ABS:
00347 if (maxsize != 0 && maxsize != 64) {
00348 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do, 0, maxsize, hob_state);
00349 hob_state = HOB_zero_xtd;
00350 hob_to_do = HOB_zero_xtd;
00351
00352 }
00353 if (MTYPE_is_integral(res))
00354 U64_LOWER_set_rtype(new_nd, Mtype_TransferSize(MTYPE_A8, res));
00355 return U64_LOWER_form_node(new_nd, tree);
00356
00357 case OPR_CVTL:
00358 if (U64_LOWER_cvtl_bits(tree) > maxsize) {
00359 if (MTYPE_signed(res) &&
00360 (hob_to_do == HOB_sign_xtd ||
00361 hob_to_do == HOB_none && hob_state == HOB_sign_xtd) ||
00362 (hob_to_do == HOB_zero_xtd ||
00363 hob_to_do == HOB_none && hob_state == HOB_zero_xtd) ) {
00364
00365 }
00366 else {
00367 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do, 0, maxsize, hob_state);
00368 maxsize = U64_LOWER_cvtl_bits(tree);
00369 hob_state = MTYPE_signed(res) ? HOB_sign_xtd : HOB_zero_xtd;
00370 hob_to_do = HOB_none;
00371 return U64_LOWER_form_node(new_nd, tree);
00372 }
00373 }
00374 else {
00375 maxsize = U64_LOWER_cvtl_bits(tree);
00376 hob_state = HOB_none;
00377 hob_to_do = MTYPE_signed(res) ? HOB_sign_xtd : HOB_zero_xtd;
00378 }
00379
00380 nd = U64_LOWER_kid0(new_nd);
00381 U64_LOWER_delete(tree);
00382 return nd;
00383
00384 case OPR_CVT:
00385 if (! MTYPE_is_integral(res)) {
00386 hob_to_do = MTYPE_is_signed(desc) ? HOB_sign_xtd : HOB_zero_xtd;
00387 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do, 0, maxsize, hob_state);
00388 maxsize = 0;
00389 if (MTYPE_is_integral(desc))
00390 U64_LOWER_set_desc(new_nd, Mtype_TransferSize(MTYPE_A8, desc));
00391 return U64_LOWER_form_node(new_nd, tree);
00392 }
00393 if (! MTYPE_is_integral(desc) || desc == MTYPE_B) {
00394
00395 U64_LOWER_set_rtype(new_nd, Mtype_TransferSize(MTYPE_A8, res));
00396 maxsize = 64;
00397 return U64_LOWER_form_node(new_nd, tree);
00398 }
00399 if (MTYPE_bit_size(res) < maxsize) {
00400 maxsize = MTYPE_bit_size(res);
00401 hob_state = HOB_none;
00402 hob_to_do = MTYPE_signed(res) ? HOB_sign_xtd : HOB_zero_xtd;
00403 }
00404 else if (MTYPE_bit_size(desc) == maxsize) {
00405 if (MTYPE_bit_size(res) == MTYPE_bit_size(desc))
00406 hob_to_do = MTYPE_signed(res) ? HOB_sign_xtd : HOB_zero_xtd;
00407 else hob_to_do = MTYPE_signed(desc) ? HOB_sign_xtd : HOB_zero_xtd;
00408 }
00409
00410 nd = U64_LOWER_kid0(new_nd);
00411 U64_LOWER_delete(tree);
00412 return nd;
00413
00414 case OPR_MINPART: case OPR_MAXPART:
00415 if (! MTYPE_is_integral(res) || res == MTYPE_B)
00416 return U64_LOWER_form_node(new_nd, tree);
00417
00418 case OPR_RND: case OPR_TRUNC: case OPR_CEIL:
00419 U64_LOWER_set_rtype(new_nd, Mtype_TransferSize(MTYPE_A8, res));
00420 maxsize = 64;
00421
00422
00423
00424 case OPR_FLOOR:
00425 return U64_LOWER_form_node(new_nd, tree);
00426
00427
00428
00429 case OPR_ADD: case OPR_SUB:
00430 if (MTYPE_is_integral(res) && res != MTYPE_B) {
00431 if (maxsize < MTYPE_bit_size(res)) {
00432 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do, 0, maxsize, hob_state);
00433 }
00434 if (maxsize1 < MTYPE_bit_size(res)) {
00435 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do1, 1, maxsize1, hob_state1);
00436 }
00437 U64_LOWER_set_rtype(new_nd, Mtype_TransferSize(MTYPE_A8, res));
00438
00439
00440
00441
00442 if( maxsize != 0 || maxsize1 != 0 )
00443 maxsize = MIN(MAX(maxsize, maxsize1) + 1, 64);
00444
00445
00446 if (hob_state != HOB_none && hob_state == hob_state1 &&
00447 (hob_to_do == HOB_none || hob_to_do == hob_state) &&
00448 (hob_to_do1 == HOB_none || hob_to_do1 == hob_state1) &&
00449 maxsize <= MTYPE_bit_size(res))
00450 return U64_LOWER_form_node(new_nd, tree);
00451 if (maxsize > MTYPE_bit_size(res))
00452 maxsize = MTYPE_bit_size(res);
00453 hob_state = HOB_none;
00454 hob_to_do = MTYPE_signed(res) ? HOB_sign_xtd : HOB_zero_xtd;
00455 }
00456 return U64_LOWER_form_node(new_nd, tree);
00457
00458 case OPR_MPY:
00459 if (MTYPE_is_integral(res) && res != MTYPE_B) {
00460
00461
00462
00463 if (maxsize < maxsize1) {
00464 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do, 0, maxsize, hob_state);
00465 maxsize = maxsize1;
00466 }
00467 if (maxsize > maxsize1) {
00468 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do1, 1, maxsize1, hob_state1);
00469 }
00470
00471 if (MTYPE_bit_size(res) == 64 && maxsize > 16) {
00472 if (maxsize < 64) {
00473 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do, 0, maxsize, hob_state);
00474 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do1, 1, maxsize1, hob_state1);
00475 }
00476 U64_LOWER_set_rtype(new_nd, Mtype_TransferSize(MTYPE_A8, res));
00477 maxsize = 64;
00478 }
00479 #ifdef TARG_IA64
00480
00481 else {
00482 if (maxsize < 32) {
00483 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do, 0, maxsize, hob_state);
00484 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do1, 1, maxsize1, hob_state1);
00485 }
00486 U64_LOWER_set_rtype(new_nd, Mtype_TransferSize(MTYPE_A4, res));
00487 maxsize = 32;
00488 }
00489 #else
00490 else if (maxsize > 8) {
00491 if (maxsize < 32) {
00492 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do, 0, maxsize, hob_state);
00493 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do1, 1, maxsize1, hob_state1);
00494 }
00495 U64_LOWER_set_rtype(new_nd, Mtype_TransferSize(MTYPE_A4, res));
00496 maxsize = 32;
00497 }
00498 else if (maxsize > 4) {
00499 if (maxsize < 16) {
00500 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do, 0, maxsize, hob_state);
00501 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do1, 1, maxsize1, hob_state1);
00502 }
00503 U64_LOWER_set_rtype(new_nd, Mtype_TransferSize(MTYPE_I2, res));
00504 maxsize = 16;
00505 }
00506 else {
00507 if (maxsize < 8) {
00508 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do, 0, maxsize, hob_state);
00509 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do1, 1, maxsize1, hob_state1);
00510 }
00511 U64_LOWER_set_rtype(new_nd, Mtype_TransferSize(MTYPE_I1, res));
00512 maxsize = 8;
00513 }
00514 #endif //TARG_IA64
00515
00516 if (MTYPE_bit_size(res) == 32 && maxsize > 32)
00517 maxsize = 32;
00518 hob_state = HOB_none;
00519 hob_to_do = MTYPE_signed(res) ? HOB_sign_xtd : HOB_zero_xtd;
00520 }
00521 return U64_LOWER_form_node(new_nd, tree);
00522
00523 case OPR_DIV:
00524 case OPR_MOD: case OPR_REM:
00525 case OPR_DIVREM:
00526
00527
00528
00529
00530 if (MTYPE_is_integral(res) && res != MTYPE_B) {
00531 #if 0 // this has problem with pregs introduced by wopt of types I8/U8
00532 Is_True(MTYPE_bit_size(res) >= maxsize &&
00533 MTYPE_bit_size(res) >= maxsize1,
00534 ("size of operation smaller than size of operand"));
00535 #endif
00536 if (opr == OPR_DIV || opr == OPR_DIVREM)
00537 new_maxsize = maxsize;
00538 else new_maxsize = maxsize1;
00539
00540 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do, 0, maxsize, hob_state);
00541 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do1, 1, maxsize1, hob_state1);
00542
00543
00544 if (res == MTYPE_I4) {
00545 U64_LOWER_insert_cvtl_for_kid(new_nd, HOB_sign_xtd, 0, 32, hob_state);
00546 U64_LOWER_insert_cvtl_for_kid(new_nd, HOB_sign_xtd, 1, 32, hob_state1);
00547 }
00548 else if (res == MTYPE_U4) {
00549 U64_LOWER_insert_cvtl_for_kid(new_nd, HOB_zero_xtd, 0, 32, hob_state);
00550 U64_LOWER_insert_cvtl_for_kid(new_nd, HOB_zero_xtd, 1, 32, hob_state1);
00551 }
00552
00553 maxsize = new_maxsize;
00554
00555 hob_state = MTYPE_signed(res) ? HOB_sign_xtd : HOB_zero_xtd;
00556 hob_to_do = HOB_none;
00557 }
00558 return U64_LOWER_form_node(new_nd, tree);
00559
00560 case OPR_BAND: case OPR_BIOR: case OPR_BNOR: case OPR_BXOR:
00561
00562
00563 if (desc != MTYPE_B) {
00564 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do, 0, maxsize, hob_state);
00565 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do1, 1, maxsize1, hob_state1);
00566 maxsize = MAX(maxsize, maxsize1);
00567 U64_LOWER_set_rtype(new_nd, Mtype_TransferSize(MTYPE_A8, res));
00568 hob_state = HOB_none;
00569 hob_to_do = HOB_none;
00570 }
00571 return U64_LOWER_form_node(new_nd, tree);
00572
00573 case OPR_MAX: case OPR_MIN:
00574 if (MTYPE_is_integral(desc) && desc != MTYPE_B) {
00575
00576 if (maxsize < MTYPE_bit_size(desc))
00577 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do, 0, maxsize, hob_state);
00578 if (maxsize1 < MTYPE_bit_size(desc))
00579 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do1, 1, maxsize1, hob_state1);
00580 maxsize = MAX(maxsize, maxsize1);
00581 if (MTYPE_bit_size(desc) == 64) {
00582 hob_to_do = HOB_none;
00583 hob_state = MTYPE_signed(desc) ? HOB_sign_xtd : HOB_zero_xtd;
00584 }
00585 else {
00586 if (hob_to_do == hob_state && hob_to_do1 == hob_state1 ||
00587 hob_to_do == HOB_none && hob_to_do1 == HOB_none) {
00588 hob_to_do = HOB_none;
00589 hob_state = MTYPE_signed(desc) ? HOB_sign_xtd : HOB_zero_xtd;
00590 }
00591 else {
00592 hob_state = HOB_none;
00593 hob_to_do = MTYPE_signed(desc) ? HOB_sign_xtd : HOB_zero_xtd;
00594 }
00595 }
00596 }
00597 return U64_LOWER_form_node(new_nd, tree);
00598
00599 case OPR_MINMAX:
00600 if (MTYPE_is_integral(desc) && desc != MTYPE_B) {
00601 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do, 0, maxsize, hob_state);
00602 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do1, 1, maxsize1, hob_state1);
00603 maxsize = MAX(maxsize, maxsize1);
00604 U64_LOWER_set_rtype(new_nd, Mtype_TransferSize(MTYPE_A8, res));
00605 hob_state = MTYPE_signed(desc) ? HOB_sign_xtd : HOB_zero_xtd;
00606 hob_to_do = HOB_none;
00607 }
00608 return U64_LOWER_form_node(new_nd, tree);
00609
00610 case OPR_EQ: case OPR_NE:
00611 case OPR_GE: case OPR_GT: case OPR_LE: case OPR_LT:
00612 if (MTYPE_is_integral(desc) && desc != MTYPE_B) {
00613
00614 if (maxsize < MTYPE_bit_size(desc))
00615 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do, 0, maxsize, hob_state);
00616 if (maxsize1 < MTYPE_bit_size(desc))
00617 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do1, 1, maxsize1, hob_state1);
00618 }
00619 maxsize = 0;
00620 return U64_LOWER_form_node(new_nd, tree);
00621
00622 case OPR_ASHR: case OPR_LSHR:
00623 if (MTYPE_bit_size(res) == 64) {
00624 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do, 0, maxsize, hob_state);
00625 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do1, 1, maxsize1, hob_state1);
00626
00627 hob_state = (opr == OPR_ASHR) ? HOB_sign_xtd : HOB_zero_xtd;
00628 hob_to_do = HOB_none;
00629 return U64_LOWER_form_node(new_nd, tree);
00630 }
00631
00632 if (U64_LOWER_operator(U64_LOWER_kid1(tree)) == OPR_INTCONST) {
00633
00634 if (maxsize < 32) {
00635 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do, 0, maxsize, hob_state);
00636 }
00637 }
00638 else {
00639 if (maxsize < 32) {
00640 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do, 0, maxsize, hob_state);
00641 }
00642
00643 if (maxsize > 32) {
00644 nd = U64_LOWER_create_cvtl((opr == OPR_ASHR) ? MTYPE_I8 : MTYPE_U8,
00645 U64_LOWER_kid0(tree), 32);
00646 U64_LOWER_set_kid0(new_nd, nd);
00647 }
00648 else {
00649 if (opr == OPR_ASHR && hob_state != HOB_sign_xtd)
00650 U64_LOWER_insert_cvtl_for_kid(new_nd, HOB_sign_xtd, 0, 32, hob_state);
00651 else if (opr == OPR_LSHR && hob_state != HOB_zero_xtd)
00652 U64_LOWER_insert_cvtl_for_kid(new_nd, HOB_zero_xtd, 0, 32, hob_state);
00653 }
00654
00655 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do1, 1, maxsize1, hob_state1);
00656 U64_LOWER_set_rtype(new_nd, Mtype_TransferSize(MTYPE_A8, res));
00657 }
00658 maxsize = 32;
00659 hob_state = (opr == OPR_ASHR) ? HOB_sign_xtd : HOB_zero_xtd;
00660 hob_to_do = HOB_none;
00661 return U64_LOWER_form_node(new_nd, tree);
00662
00663 case OPR_SHL:
00664 if (MTYPE_bit_size(res) == 64) {
00665 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do, 0, maxsize, hob_state);
00666 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do1, 1, maxsize1, hob_state1);
00667 maxsize = 64;
00668 return U64_LOWER_form_node(new_nd, tree);
00669 }
00670
00671 if (maxsize < 32) {
00672 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do, 0, maxsize, hob_state);
00673 }
00674 maxsize = 32;
00675 hob_state = HOB_none;
00676 hob_to_do = MTYPE_signed(res) ? HOB_sign_xtd : HOB_zero_xtd;
00677 if (U64_LOWER_operator(U64_LOWER_kid1(tree)) == OPR_INTCONST) {
00678
00679 return U64_LOWER_form_node(new_nd, tree);
00680 }
00681 else {
00682 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do1, 1, maxsize1, hob_state1);
00683 U64_LOWER_set_rtype(new_nd, Mtype_TransferSize(MTYPE_A8, res));
00684 return U64_LOWER_form_node(new_nd, tree);
00685 }
00686
00687 case OPR_COMPOSE_BITS:
00688 if (maxsize <= (U64_LOWER_bit_size(tree) + U64_LOWER_bit_offset(tree)))
00689 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do, 0, maxsize, hob_state);
00690 if (maxsize1 < U64_LOWER_bit_size(tree))
00691 U64_LOWER_insert_cvtl_for_kid(new_nd, hob_to_do1, 1, maxsize1, hob_state1);
00692 U64_LOWER_set_rtype(new_nd, Mtype_TransferSize(MTYPE_A8, res));
00693 return U64_LOWER_form_node(new_nd, tree);
00694
00695 case OPR_LAND: case OPR_LIOR:
00696 case OPR_COMPLEX:
00697 return U64_LOWER_form_node(new_nd, tree);
00698
00699 default:
00700 Is_True(FALSE,("unexpected operator"));
00701 }
00702 return NULL;
00703 }
00704
00705 #endif