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
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 static const char *source_file = __FILE__;
00075
00076 #ifdef _KEEP_RCS_ID
00077 static char *rcs_id = "$Source: /home/bos/bk/kpro64-pending/crayf90/sgi/SCCS/s.cwh_expr.cxx $ $Revision: 1.5 $";
00078 #endif
00079
00080
00081
00082
00083 #include "defs.h"
00084 #include "glob.h"
00085 #include "stab.h"
00086 #include "strtab.h"
00087 #include "errors.h"
00088 #include "config_targ.h"
00089 #include "targ_const.h"
00090 #include "wn.h"
00091 #include "wn_util.h"
00092 #include "const.h"
00093 #include "f90_utils.h"
00094 #include "sgi_cmd_line.h"
00095
00096
00097
00098 #include "i_cvrt.h"
00099
00100
00101
00102 #include "cwh_defines.h"
00103 #include "cwh_addr.h"
00104 #include "cwh_expr.h"
00105 #include "cwh_block.h"
00106 #include "cwh_types.h"
00107 #include "cwh_preg.h"
00108 #include "cwh_stab.h"
00109 #include "cwh_auxst.h"
00110 #include "cwh_stmt.h"
00111 #include "cwh_stk.h"
00112 #include "cwh_expr.h"
00113 #include "cwh_intrin.h"
00114 #include "cwh_preg.h"
00115
00116 static void cwh_expr_binop(OPERATOR op, TY_IDX result_ty) ;
00117 static void cwh_expr_unop(OPERATOR op,TY_IDX result_ty) ;
00118 static WN * cwh_expr_compare_char(OPERATOR op, TY_IDX ty) ;
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131 extern WN *
00132 cwh_expr_extract_arrayexp(WN *wn, WN **arrayexp)
00133 {
00134 WN * ae;
00135 INT i;
00136 if (Full_arrayexp) {
00137 if (WNOPR(wn) == OPR_ARRAYEXP && arrayexp != NULL) {
00138 ae = wn;
00139 wn = WN_kid0(wn);
00140
00141
00142 if (arrayexp != DELETE_ARRAYEXP_WN && *arrayexp == NULL) {
00143 *arrayexp = ae;
00144 } else {
00145 for (i = 1; i < WN_kid_count(ae); i++) {
00146 WN_DELETE_Tree(WN_kid(ae,i));
00147 }
00148 WN_Delete(ae);
00149 }
00150 }
00151 }
00152
00153 return (wn);
00154 }
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165 extern WN *
00166 cwh_expr_restore_arrayexp(WN *wn, WN *arrayexp)
00167 {
00168 OPCODE opc;
00169
00170 if (Full_arrayexp && arrayexp) {
00171 WN_kid0(arrayexp) = wn;
00172 opc = cwh_make_typed_opcode(OPR_ARRAYEXP,WN_rtype(wn),MTYPE_V);
00173 WN_set_opcode(arrayexp,opc);
00174 return (arrayexp);
00175 } else {
00176 return (wn);
00177 }
00178 }
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188 extern WN *
00189 cwh_wrap_cvtl(WN * wn, TYPE_ID ty)
00190 {
00191 return F90_wrap_cvtl(wn,ty);
00192 }
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204 extern WN *
00205 cwh_convert_to_ty(WN * wn, TYPE_ID ty)
00206 {
00207 TYPE_ID old_ty,real_ty,new_real_ty;
00208 OPCODE cvt_op;
00209 OPCODE realpart,imagpart;
00210 WN *r;
00211 WN *ri,*rr;
00212
00213 old_ty = WNRTY(wn);
00214 if (old_ty == ty) return (wn);
00215
00216 if (old_ty == MTYPE_I1 || old_ty == MTYPE_I2) {
00217
00218 old_ty = MTYPE_I4;
00219 }
00220
00221 r = wn;
00222 cvt_op = OPCODE_UNKNOWN;
00223
00224
00225
00226 if (WNOPR(wn) == OPR_TAS) {
00227 WN_set_opcode(wn,OPCODE_make_op(OPR_TAS,ty,MTYPE_V));
00228 return (wn);
00229 }
00230
00231 if (MTYPE_is_complex(old_ty)) {
00232 real_ty = Mtype_complex_to_real(old_ty);
00233 realpart = OPCODE_make_op(OPR_REALPART,real_ty,MTYPE_V);
00234 imagpart = OPCODE_make_op(OPR_IMAGPART,real_ty,MTYPE_V);
00235
00236
00237
00238 if (!MTYPE_is_complex(ty)) {
00239 r = WN_CreateExp1(realpart,r);
00240 r = cwh_convert_to_ty(r,ty);
00241
00242 } else {
00243
00244 new_real_ty = Mtype_complex_to_real(ty);
00245 rr = WN_CreateExp1(realpart,WN_COPY_Tree(r));
00246 rr = cwh_convert_to_ty(rr,new_real_ty);
00247 ri = WN_CreateExp1(imagpart,r);
00248 ri = cwh_convert_to_ty(ri,new_real_ty);
00249 r = WN_CreateExp2(OPCODE_make_op(OPR_COMPLEX,ty,MTYPE_V),rr,ri);
00250 }
00251 return (r);
00252
00253 } else if (MTYPE_is_complex(ty)) {
00254 real_ty = Mtype_complex_to_real(ty);
00255 cvt_op = OPCODE_make_op(OPR_COMPLEX,ty,MTYPE_V);
00256 r = cwh_convert_to_ty(r,real_ty);
00257 r = WN_CreateExp2(cvt_op,r,Make_Zerocon(real_ty));
00258 return (r);
00259 }
00260
00261
00262 if (ty == MTYPE_I1 || ty == MTYPE_I2) {
00263
00264 r = cwh_convert_to_ty(wn,MTYPE_I4);
00265 r = cwh_wrap_cvtl(r,ty);
00266 return (r);
00267 }
00268
00269 if (ty == MTYPE_U1 || ty == MTYPE_U2) {
00270
00271 r = cwh_convert_to_ty(wn,MTYPE_U4);
00272 r = cwh_wrap_cvtl(r,ty);
00273 return (r);
00274 }
00275
00276
00277 if (MTYPE_is_float(ty)) {
00278
00279 cvt_op = OPCODE_make_op(OPR_CVT,ty,old_ty);
00280 } else if (MTYPE_is_float(old_ty)) {
00281
00282 cvt_op = OPCODE_make_op(OPR_TRUNC,ty,old_ty);
00283 } else {
00284
00285 if (MTYPE_size_reg(ty) != MTYPE_size_reg(old_ty)) {
00286 cvt_op = OPCODE_make_op(OPR_CVT,ty,old_ty);
00287 }
00288 }
00289
00290
00291 if (cvt_op != 0) {
00292 r = WN_CreateExp1(cvt_op,r);
00293 }
00294
00295 return (r);
00296 }
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309 extern TYPE_ID
00310 cwh_get_highest_type(WN *lhs, WN *rhs)
00311 {
00312 TYPE_ID t1,t2,r;
00313 t1 = WN_rtype(lhs);
00314 t2 = WN_rtype(rhs);
00315
00316
00317 if (t1 == t2) return (t1);
00318
00319 if (MTYPE_is_complex(t1) && !MTYPE_is_complex(t2)) {
00320 t1 = Mtype_complex_to_real(t1);
00321 if (MTYPE_type_order(t2) > MTYPE_type_order(t1)) {
00322 r = t2;
00323 } else {
00324 r = t1;
00325 }
00326
00327 switch (r) {
00328 case MTYPE_F4: r = MTYPE_C4; break;
00329 case MTYPE_F8: r = MTYPE_C8; break;
00330 case MTYPE_FQ: r = MTYPE_CQ; break;
00331 }
00332 } else if (MTYPE_is_complex(t2) && !MTYPE_is_complex(t1)) {
00333 t2 = Mtype_complex_to_real(t2);
00334 if (MTYPE_type_order(t2) > MTYPE_type_order(t1)) {
00335 r = t2;
00336 } else {
00337 r = t1;
00338 }
00339
00340 switch (r) {
00341 case MTYPE_F4: r = MTYPE_C4; break;
00342 case MTYPE_F8: r = MTYPE_C8; break;
00343 case MTYPE_FQ: r = MTYPE_CQ; break;
00344 }
00345 } else {
00346
00347 if (MTYPE_type_order(t2) > MTYPE_type_order(t1)) {
00348 r = t2;
00349 } else {
00350 r = t1;
00351 }
00352 }
00353 return (r);
00354 }
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369 extern WN *
00370 cwh_get_typed_operand(TYPE_ID ty, WN **arrexp)
00371 {
00372 WN *r;
00373
00374 r = cwh_expr_operand(arrexp);
00375 r = cwh_convert_to_ty(r,ty);
00376 return (r);
00377 }
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388 extern OPCODE
00389 cwh_make_typed_opcode(OPERATOR op, TYPE_ID ty1, TYPE_ID ty2)
00390 {
00391 OPCODE opc;
00392 TYPE_ID ti ;
00393
00394 switch (ty1) {
00395 case MTYPE_B:
00396 case MTYPE_I1:
00397 case MTYPE_I2:
00398 ti = MTYPE_I4;
00399 break ;
00400
00401 case MTYPE_U1:
00402 case MTYPE_U2:
00403 ti = MTYPE_U4;
00404 break ;
00405
00406 default:
00407 ti = ty1;
00408 break;
00409 }
00410 opc = OPCODE_make_op(op,ti,ty2);
00411 return (opc);
00412 }
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424 static void
00425 cwh_expr_binop(OPERATOR op,TY_IDX result_ty)
00426 {
00427
00428 WN *rhs ;
00429 WN *lhs ;
00430 WN *wn ;
00431 TYPE_ID bt ;
00432 OPCODE opc ;
00433 TYPE_ID ot;
00434 WN *ae=NULL;
00435
00436
00437 rhs = cwh_expr_operand(&ae);
00438 lhs = cwh_expr_operand(&ae);
00439
00440 ot = cwh_get_highest_type(rhs,lhs);
00441 if (result_ty) {
00442 bt = TY_mtype(result_ty) ;
00443 } else {
00444 bt = ot;
00445 }
00446 opc = cwh_make_typed_opcode(op, ot, MTYPE_V);
00447 lhs = cwh_convert_to_ty(lhs,ot);
00448 rhs = cwh_convert_to_ty(rhs,ot);
00449
00450 wn = WN_CreateExp2 ( opc, lhs, rhs) ;
00451
00452
00453 wn = cwh_wrap_cvtl(wn,bt);
00454
00455 wn = cwh_expr_restore_arrayexp(wn,ae);
00456 cwh_stk_push_typed(wn,WN_item,result_ty) ;
00457 }
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470 static void
00471 cwh_expr_binop_shift(OPERATOR op, TY_IDX result_ty)
00472 {
00473
00474 WN *arg ;
00475 WN *shft ;
00476 WN *wn ;
00477 WN *temp ;
00478 WN *ae=NULL;
00479
00480 TYPE_ID bt ;
00481 TYPE_ID ret_t;
00482 TYPE_ID br ;
00483 TYPE_ID ba ;
00484 OPCODE opc ;
00485 INT bitlen;
00486 INT reslen;
00487
00488 br = TY_mtype(result_ty) ;
00489 ret_t = br;
00490 reslen = MTYPE_size_best(br);
00491 shft = cwh_expr_operand(&ae);
00492 arg = cwh_expr_operand(&ae);
00493
00494 bt = WNRTY(arg);
00495 bitlen = MTYPE_size_best(bt);
00496
00497 if (reslen < 32 && op == OPR_LSHR) {
00498
00499 arg = WN_Band(bt,arg,WN_Intconst(bt,(1<<reslen)-1));
00500 }
00501
00502 if (bitlen <= MTYPE_size_best(MTYPE_U4))
00503 ba = MTYPE_I4 ;
00504 else
00505 ba = MTYPE_I8 ;
00506
00507 if (reslen > 32) {
00508 br = MTYPE_I8;
00509 } else {
00510 br = MTYPE_I4;
00511 }
00512
00513 if (!MTYPE_is_integral(bt))
00514 arg = WN_Tas(ba,Be_Type_Tbl(bt),arg) ;
00515
00516 opc = cwh_make_typed_opcode(op, br, MTYPE_V);
00517 if (op == OPR_ASHR) {
00518
00519 if (ARCH_mask_shift_counts) {
00520 temp = WN_GT(br,WN_COPY_Tree(shft),WN_Intconst(br,reslen-1));
00521 temp = cwh_convert_to_ty(temp,br);
00522 temp = WN_Neg(br,temp);
00523 shft = WN_Bior(br,temp,shft);
00524 }
00525 wn = WN_CreateExp2 (opc, arg, shft);
00526 } else {
00527 if (ARCH_mask_shift_counts) {
00528
00529 temp = WN_LT(br,WN_COPY_Tree(shft),WN_Intconst(br,reslen));
00530 temp = cwh_convert_to_ty(temp,br);
00531 temp = WN_Neg(br,temp);
00532 wn = WN_CreateExp2 (opc, arg, shft);
00533 wn = WN_Band(br,wn,temp);
00534 } else {
00535 wn = WN_CreateExp2 (opc, arg, shft);
00536 }
00537 }
00538
00539 wn = cwh_wrap_cvtl(wn,ret_t);
00540
00541 wn = cwh_expr_restore_arrayexp(wn,ae);
00542 cwh_stk_push_typed(wn,WN_item,result_ty);
00543 }
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559 extern void
00560 cwh_expr_compare(OPERATOR op,TY_IDX ty)
00561 {
00562
00563 WN *rhs ;
00564 WN *lhs ;
00565 WN *wn ;
00566 WN *ae=NULL;
00567
00568 TYPE_ID bt ;
00569 OPCODE opc ;
00570
00571 if (cwh_stk_get_class() == STR_item)
00572 wn = cwh_expr_compare_char(op,ty);
00573
00574 else {
00575
00576 rhs = cwh_expr_operand(&ae);
00577 lhs = cwh_expr_operand(&ae);
00578
00579 bt = cwh_get_highest_type(rhs,lhs);
00580 opc = cwh_make_typed_opcode(op, MTYPE_I4, Mtype_comparison(bt));
00581 lhs = cwh_convert_to_ty(lhs,bt);
00582 rhs = cwh_convert_to_ty(rhs,bt);
00583
00584 wn = WN_CreateExp2 ( opc, lhs, rhs) ;
00585 wn = cwh_expr_restore_arrayexp(wn,ae);
00586 }
00587
00588 cwh_stk_push_typed(wn,WN_item,ty);
00589 }
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601 static WN *
00602 cwh_expr_compare_char(OPERATOR op, TY_IDX ty)
00603 {
00604 WN * ar[4];
00605 WN * sz[4];
00606 BOOL va[4];
00607 WN * wn ;
00608 #ifdef KEY
00609 INTRINSIC intr = INTRN_CLTEXPR;
00610 #else
00611 INTRINSIC intr;
00612 #endif
00613
00614 cwh_stk_pop_STR();
00615 ar[3] = cwh_expr_operand(NULL);
00616 ar[1] = cwh_expr_address(f_NONE);
00617
00618 sz[3] = NULL;
00619 sz[1] = WN_COPY_Tree(ar[3]);
00620 va[3] = TRUE;
00621 va[1] = FALSE;
00622
00623 cwh_stk_pop_STR();
00624 ar[2] = cwh_expr_operand(NULL);
00625 ar[0] = cwh_expr_address(f_NONE);
00626
00627 sz[2] = NULL;
00628 sz[0] = WN_COPY_Tree(ar[2]);
00629 va[2] = TRUE;
00630 va[0] = FALSE;
00631
00632 switch(op) {
00633 case OPR_LT:
00634 intr = INTRN_CLTEXPR;
00635 break ;
00636 case OPR_LE:
00637 intr = INTRN_CLEEXPR;
00638 break ;
00639 case OPR_GE:
00640 intr = INTRN_CGEEXPR;
00641 break ;
00642 case OPR_GT:
00643 intr = INTRN_CGTEXPR;
00644 break ;
00645 case OPR_EQ:
00646 intr = INTRN_CEQEXPR;
00647 break ;
00648 case OPR_NE:
00649 intr = INTRN_CNEEXPR;
00650 break ;
00651
00652 default:
00653 DevAssert((0),("Missing char comp"));
00654
00655 }
00656 wn = cwh_intrin_op(intr,4,ar,sz,va,TY_mtype(ty));
00657 wn = F90_Wrap_ARREXP(wn);
00658 return (wn);
00659 }
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671 static void
00672 cwh_expr_compare_logical(OPCODE opc,TY_IDX ty)
00673 {
00674 WN * rhs;
00675 WN * lhs;
00676 WN * wn ;
00677 WN *ae=NULL;
00678
00679 rhs = cwh_expr_operand(&ae);
00680 lhs = cwh_expr_operand(&ae);
00681 wn = WN_CreateExp2 ( opc, lhs, rhs) ;
00682 wn = cwh_expr_restore_arrayexp(wn,ae);
00683
00684 cwh_stk_push_typed(wn,WN_item,ty);
00685 }
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698 static void
00699 cwh_expr_compare_bitwise(OPERATOR op,TY_IDX ty)
00700 {
00701 WN * rhs;
00702 WN * lhs;
00703 WN * wn ;
00704 TY_IDX ta ;
00705
00706 TYPE_ID bt;
00707 TYPE_ID br;
00708 TYPE_ID ba;
00709 TYPE_ID rhs_t,lhs_t;
00710 OPCODE opc;
00711 WN *ae=NULL;
00712
00713 bt = br = TY_mtype(ty);
00714 if (bt == MTYPE_U4) br = MTYPE_I4 ;
00715 if (bt == MTYPE_U8) br = MTYPE_I8 ;
00716
00717 rhs = cwh_expr_operand(&ae) ;
00718 lhs = cwh_expr_operand(&ae) ;
00719 rhs_t = WN_rtype(rhs);
00720 lhs_t = WN_rtype(lhs);
00721
00722 ta = cwh_types_scalar_TY(cwh_types_WN_TY(rhs,FALSE));
00723 ba = TY_mtype(ta);
00724
00725 if (!MTYPE_is_integral(rhs_t)) {
00726 rhs = WN_Tas(br,ta,rhs) ;
00727 }
00728 if (!MTYPE_is_integral(lhs_t)) {
00729 lhs = WN_Tas(br,ta,lhs) ;
00730 }
00731 opc = cwh_make_typed_opcode(op,br,MTYPE_V);
00732 wn = WN_CreateExp2 ( opc, lhs, rhs) ;
00733
00734 wn = cwh_expr_restore_arrayexp(wn,ae);
00735 cwh_stk_push(wn,WN_item);
00736 }
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747 extern void
00748 fei_lneg(TYPE result)
00749 {
00750 WN * lhs;
00751 WN * wn ;
00752 WN *ae=NULL;
00753
00754 lhs = cwh_expr_operand(&ae);
00755 wn = WN_CreateExp1(OPC_I4LNOT, lhs) ;
00756
00757 wn = cwh_expr_restore_arrayexp(wn,ae);
00758 cwh_stk_push_typed(wn,WN_item,(INTPTR)cast_to_TY(t_TY(result)));
00759 }
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772 static void
00773 cwh_expr_unop(OPERATOR op,TY_IDX result_ty)
00774 {
00775
00776 WN *lhs ;
00777 WN *wn ;
00778 WN *ae=NULL;
00779
00780 TYPE_ID bt ;
00781 OPCODE opc ;
00782
00783 bt = TY_mtype(result_ty) ;
00784 opc = cwh_make_typed_opcode(op, bt, MTYPE_V);
00785 lhs = cwh_get_typed_operand(bt,&ae);
00786
00787 wn = WN_CreateExp1 ( opc, lhs) ;
00788 wn = cwh_wrap_cvtl(wn,bt);
00789
00790 wn = cwh_expr_restore_arrayexp(wn,ae);
00791 cwh_stk_push(wn,WN_item);
00792 }
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805 extern WN *
00806 cwh_expr_bincalc(OPERATOR op, WN * wn1, WN * wn2)
00807 {
00808 TYPE_ID bt ;
00809
00810 bt = cwh_get_highest_type(wn1,wn2);
00811 wn1 = cwh_convert_to_ty(wn1,bt);
00812 wn2 = cwh_convert_to_ty(wn2,bt);
00813
00814 return WN_CreateExp2 (OPCODE_make_op(op,bt,MTYPE_V),
00815 wn1,
00816 wn2) ;
00817 }
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835 extern WN *
00836 cwh_expr_operand(WN **arrexp)
00837 {
00838 WN * wn ;
00839 ST * st ;
00840 TY_IDX ts ;
00841
00842 FLD_det det;
00843
00844 ts = cwh_stk_get_TY();
00845
00846 switch(cwh_stk_get_class()) {
00847 case WN_item:
00848 case WN_item_whole_array:
00849 wn = cwh_stk_pop_WN();
00850 if (wn == NULL)
00851 return(wn);
00852
00853 if (cwh_addr_is_array(wn)) {
00854 wn = cwh_addr_load_WN(wn,0,ts);
00855 } else if (cwh_addr_is_section(wn)) {
00856 wn = cwh_addr_load_WN(wn,0,ts);
00857 if (Full_arrayexp) {
00858 wn = F90_Wrap_ARREXP(wn);
00859 }
00860 }
00861 wn = cwh_expr_extract_arrayexp(wn,arrexp);
00862 break ;
00863
00864 case ADDR_item:
00865 wn = cwh_stk_pop_ADDR();
00866 break ;
00867
00868 case DEREF_item:
00869 wn = cwh_stk_pop_DEREF();
00870 wn = cwh_addr_load_WN(wn,0,0);
00871 break ;
00872
00873 case ST_item:
00874 case ST_item_whole_array:
00875 st = cwh_stk_pop_ST();
00876 wn = cwh_addr_load_ST(st,0,0);
00877 break ;
00878
00879 case FLD_item:
00880 det = cwh_addr_offset();
00881
00882 if (cwh_stk_get_class() == ST_item || cwh_stk_get_class() == ST_item_whole_array) {
00883 st = cwh_stk_pop_ST();
00884 wn = cwh_addr_load_ST(st,det.off,det.type);
00885
00886 } else {
00887
00888 wn = cwh_stk_pop_WHIRL();
00889 wn = cwh_expr_extract_arrayexp(wn,DELETE_ARRAYEXP_WN);
00890 wn = cwh_addr_load_WN(wn,det.off,det.type);
00891 if (Full_arrayexp) {
00892 wn = F90_Wrap_ARREXP(wn);
00893 }
00894 wn = cwh_expr_extract_arrayexp(wn,arrexp);
00895 }
00896 break ;
00897
00898 case PCONST_item:
00899 st = (ST *) cwh_stk_pop_PCONST();
00900 wn = cwh_addr_address_ST(st);
00901 break;
00902
00903 default:
00904 DevAssert((0),("Bad operand"));
00905 }
00906 return (wn);
00907 }
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928 extern WN *
00929 cwh_expr_address(FLAG flag)
00930 {
00931 WN * wn ;
00932 ST * st ;
00933
00934 FLD_det det ;
00935
00936 switch(cwh_stk_get_class()) {
00937 case WN_item:
00938 case WN_item_whole_array:
00939 case ADDR_item:
00940 case DEREF_item:
00941 wn = cwh_stk_pop_WHIRL();
00942
00943 if (wn) {
00944 if (flag) {
00945 st = cwh_addr_WN_ST(wn);
00946 cwh_expr_set_flags(st, flag);
00947 }
00948 }
00949 break;
00950
00951 case ST_item:
00952 case ST_item_whole_array:
00953 st = cwh_stk_pop_ST();
00954 wn = cwh_addr_address_ST(st);
00955 if (flag)
00956 cwh_expr_set_flags(st, flag);
00957 break;
00958
00959 case STR_item:
00960 cwh_stk_pop_STR();
00961 WN_Delete(cwh_expr_operand(NULL));
00962 wn = cwh_expr_address(flag);
00963 break;
00964
00965 case FLD_item:
00966 det = cwh_addr_offset();
00967
00968 if (cwh_stk_get_class() == ST_item ||
00969 cwh_stk_get_class() == ST_item_whole_array) {
00970
00971 st = cwh_stk_pop_ST();
00972 wn = cwh_addr_address_ST(st,det.off,det.type);
00973 if (flag)
00974 cwh_expr_set_flags(st, flag);
00975
00976 } else {
00977 wn = cwh_expr_address(flag);
00978 wn = cwh_expr_bincalc(OPR_ADD,wn,WN_Intconst(Pointer_Mtype,det.off));
00979 }
00980 break ;
00981
00982 default:
00983 DevAssert((0),("Odd address"));
00984 }
00985
00986 return (wn);
00987 }
00988
00989
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002 #define binop_routine(name,opr) \
01003 extern void name (TYPE type) \
01004 { \
01005 cwh_expr_binop(opr,cast_to_TY(t_TY(type))); \
01006 }
01007
01008 #define binop_shift_routine(name,opr) \
01009 extern void name (TYPE type) \
01010 { \
01011 cwh_expr_binop_shift(opr,cast_to_TY(t_TY(type))); \
01012 }
01013
01014 #define compare_routine(name,opr) \
01015 extern void name (TYPE type) \
01016 { \
01017 cwh_expr_compare(opr,cast_to_TY(t_TY(type))); \
01018 }
01019
01020 #define compare_logical(name,opr_l,opr_c) \
01021 extern void name (TYPE type) \
01022 { \
01023 cwh_expr_compare_logical(FTN_Short_Circuit_On ? opr_c : opr_l,cast_to_TY(t_TY(type))); \
01024 }
01025
01026 #define compare_bitwise(name,opr) \
01027 extern void name (TYPE type) \
01028 { \
01029 cwh_expr_compare_bitwise(opr,cast_to_TY(t_TY(type))); \
01030 }
01031 binop_routine(fei_plus,OPR_ADD)
01032 binop_routine(fei_minus,OPR_SUB)
01033 binop_routine(fei_mult,OPR_MPY)
01034 binop_routine(fei_div,OPR_DIV)
01035 compare_routine(fei_gt,OPR_GT)
01036 compare_routine(fei_ge,OPR_GE)
01037 compare_routine(fei_lt,OPR_LT)
01038 compare_routine(fei_le,OPR_LE)
01039 compare_routine(fei_eq,OPR_EQ)
01040 compare_routine(fei_ne,OPR_NE)
01041 compare_bitwise(fei_and,OPR_BAND)
01042 compare_bitwise(fei_xor,OPR_BXOR)
01043 compare_logical(fei_land ,OPC_I4LAND, OPC_I4CAND)
01044 compare_routine(fei_leqv ,OPR_EQ)
01045 compare_logical(fei_lor ,OPC_I4LIOR, OPC_I4CIOR)
01046 binop_shift_routine(fei_lshift ,OPR_SHL)
01047 binop_shift_routine(fei_rshift ,OPR_LSHR)
01048 binop_shift_routine(fei_ashift ,OPR_ASHR)
01049 compare_routine(fei_lxor ,OPR_NE)
01050 compare_bitwise(fei_or ,OPR_BIOR)
01051
01052
01053
01054 extern void
01055 fei_eqv(TYPE type)
01056 {
01057 fei_xor(type);
01058 fei_bneg(type);
01059 }
01060
01061
01062
01063
01064
01065
01066
01067
01068
01069
01070 extern void
01071 fei_islg(TYPE type)
01072 {
01073 WN *arg1, *arg2, *r1, *r2;
01074
01075 arg1 = cwh_expr_operand(NULL);
01076 arg2 = cwh_expr_operand(NULL);
01077 cwh_stk_push(WN_COPY_Tree(arg2),WN_item);
01078 cwh_stk_push(WN_COPY_Tree(arg1),WN_item);
01079 cwh_expr_compare(OPR_LT,0);
01080
01081 r1 = cwh_expr_operand(NULL);
01082 cwh_stk_push(arg2,WN_item);
01083 cwh_stk_push(arg1,WN_item);
01084 cwh_expr_compare(OPR_GT,0);
01085
01086 r2 = cwh_expr_operand(NULL);
01087 cwh_stk_push(r1,WN_item);
01088 cwh_stk_push(r2,WN_item);
01089 fei_lor(type);
01090 }
01091
01092 extern void
01093 fei_multiply_high(TYPE type)
01094 {
01095
01096 WN *rhs ;
01097 WN *lhs ;
01098 WN *wn ;
01099 OPCODE opc ;
01100 TYPE_ID ot;
01101 WN *ae=NULL;
01102
01103 rhs = cwh_expr_operand(&ae);
01104 lhs = cwh_expr_operand(&ae);
01105
01106 ot = cwh_get_highest_type(rhs,lhs);
01107 if (ot == MTYPE_I8) {
01108 opc = OPC_U8HIGHMPY;
01109 ot = MTYPE_U8;
01110 } else {
01111 opc = OPC_U4HIGHMPY;
01112 ot = MTYPE_U4;
01113 }
01114
01115 lhs = cwh_convert_to_ty(lhs,ot);
01116 rhs = cwh_convert_to_ty(rhs,ot);
01117
01118 wn = WN_CreateExp2 ( opc, lhs, rhs) ;
01119
01120 wn = cwh_expr_restore_arrayexp(wn,ae);
01121 cwh_stk_push(wn,WN_item);
01122 }
01123
01124
01125
01126
01127
01128
01129
01130
01131
01132 #define unop_routine(name,opr) \
01133 extern void name (TYPE type) \
01134 { \
01135 cwh_expr_unop(opr,cast_to_TY(t_TY(type))); \
01136 }
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146 extern void
01147 fei_imag(TYPE type)
01148 {
01149 WN *rhs, *wn;
01150 TY_IDX ty;
01151 TYPE_ID t,rt;
01152 WN *ae=NULL;
01153
01154 ty = cast_to_TY(t_TY(type));
01155 t = TY_mtype(ty) ;
01156 rhs = cwh_expr_operand(&ae);
01157 rt = Mtype_complex_to_real(WN_rtype(rhs));
01158 wn = WN_CreateExp1(cwh_make_typed_opcode(OPR_IMAGPART,rt,MTYPE_V),rhs);
01159
01160 wn = cwh_convert_to_ty(wn,t);
01161 wn = cwh_expr_restore_arrayexp(wn,ae);
01162 cwh_stk_push(wn,WN_item);
01163 }
01164
01165
01166
01167
01168
01169
01170
01171
01172
01173 extern void
01174 fei_bneg(TYPE type)
01175 {
01176
01177 WN *lhs ;
01178 WN *wn ;
01179 WN *ae=NULL;
01180
01181 TYPE_ID bt, lhs_t ;
01182 OPCODE opc ;
01183 TY_IDX ta, result_ty;
01184
01185 result_ty = cast_to_TY(t_TY(type));
01186 bt = TY_mtype(result_ty) ;
01187
01188 if (MTYPE_is_unsigned(bt)) {
01189 bt = MTYPE_complement(bt);
01190 }
01191
01192 lhs = cwh_expr_operand(&ae) ;
01193 lhs_t = WN_rtype(lhs);
01194
01195 ta = cwh_types_scalar_TY(cwh_types_WN_TY(lhs,FALSE));
01196 if (!MTYPE_is_integral(lhs_t)) {
01197 lhs = WN_Tas(bt,ta,lhs) ;
01198 }
01199
01200 opc = cwh_make_typed_opcode(OPR_BNOT, bt, MTYPE_V);
01201
01202 wn = WN_CreateExp1 ( opc, lhs) ;
01203 wn = cwh_wrap_cvtl(wn,bt);
01204
01205 wn = cwh_expr_restore_arrayexp(wn,ae);
01206 cwh_stk_push_typed(wn,WN_item,Be_Type_Tbl(bt));
01207 }
01208
01209 unop_routine(fei_uminus,OPR_NEG)
01210
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220
01221 extern void
01222 fei_paren(TYPE type)
01223 {
01224
01225 TY_IDX ty ;
01226 TYPE_ID t;
01227
01228 ty = cast_to_TY(t_TY(type));
01229 ty = cwh_types_scalar_TY(ty);
01230 t = TY_mtype(ty);
01231
01232 if (MTYPE_is_float(t) || MTYPE_is_complex(t)) {
01233 cwh_expr_unop(OPR_PAREN,ty);
01234 }
01235 }
01236
01237
01238
01239
01240
01241
01242
01243
01244
01245 extern void
01246 fei_max(INT count, TYPE type)
01247 {
01248 INT i;
01249 for (i = 1; i < count; i++) {
01250 cwh_expr_binop(OPR_MAX,cast_to_TY(t_TY(type)));
01251 }
01252
01253 }
01254 extern void
01255 fei_min(INT count, TYPE type)
01256 {
01257 INT i;
01258 for (i = 1; i < count; i++) {
01259 cwh_expr_binop(OPR_MIN,cast_to_TY(t_TY(type)));
01260 }
01261 }
01262
01263
01264
01265
01266
01267
01268
01269
01270
01271
01272
01273
01274
01275
01276
01277
01278
01279
01280 extern void
01281 #ifdef KEY
01282 fei_select(TYPE type, int cselect)
01283 #else
01284 fei_select(TYPE type)
01285 #endif
01286 {
01287 WN *t_case,*f_case,*condition;
01288 WN * wn;
01289 TY_IDX ty;
01290 WN *strlen;
01291 WN *addr;
01292 TYPE_ID bt;
01293 TYPE_ID rt;
01294 WN *args[3];
01295 WN *ae=NULL;
01296
01297 ty = cast_to_TY(t_TY(type));
01298
01299 condition = cwh_expr_operand(&ae);
01300
01301 if (TY_is_character(ty)) {
01302 cwh_stk_pop_STR();
01303 strlen = cwh_expr_operand(NULL);
01304 addr = cwh_expr_address(f_NONE);
01305 f_case = cwh_addr_mload(addr,0,ty,strlen);
01306
01307 cwh_stk_pop_STR();
01308 strlen = cwh_expr_operand(NULL);
01309 addr = cwh_expr_address(f_NONE);
01310 t_case = cwh_addr_mload(addr,0,ty,strlen);
01311
01312 } else {
01313 f_case = cwh_expr_operand(&ae);
01314 t_case = cwh_expr_operand(&ae);
01315 }
01316
01317 bt = WN_rtype(t_case);
01318
01319 if (bt == MTYPE_M) {
01320
01321
01322
01323 args[0] = cwh_intrin_wrap_value_parm(condition);
01324 args[1] = cwh_intrin_wrap_value_parm(t_case);
01325 args[2] = cwh_intrin_wrap_value_parm(f_case);
01326 if (TY_is_character(ty)) {
01327 wn = WN_Create_Intrinsic(OPC_U4INTRINSIC_OP,INTRN_MERGE,3,args);
01328 cwh_stk_push_STR(WN_COPY_Tree(strlen),wn,ty,WN_item);
01329 } else {
01330 wn = WN_Create_Intrinsic(OPC_MINTRINSIC_OP,INTRN_MERGE,3,args);
01331 wn = cwh_expr_restore_arrayexp(wn,ae);
01332 cwh_stk_push(wn,WN_item);
01333 }
01334 } else {
01335
01336
01337
01338
01339 rt = TY_mtype(ty);
01340 if (MTYPE_is_integral(rt)) {
01341 if (!MTYPE_is_integral(WNRTY(t_case))) {
01342 t_case = WN_Tas(rt,Be_Type_Tbl(WNRTY(t_case)),t_case) ;
01343 }
01344 if (!MTYPE_is_integral(WNRTY(f_case))) {
01345 f_case = WN_Tas(rt,Be_Type_Tbl(WNRTY(f_case)),f_case) ;
01346 }
01347 }
01348
01349 #ifdef KEY
01350 wn = WN_CreateExp3(
01351 cwh_make_typed_opcode((cselect ? OPR_CSELECT : OPR_SELECT),rt,MTYPE_V),
01352 condition,t_case,f_case);
01353 #else
01354 wn = WN_CreateExp3(cwh_make_typed_opcode(OPR_SELECT,rt,MTYPE_V),condition,t_case,f_case);
01355 #endif
01356 wn = cwh_wrap_cvtl(wn,rt);
01357 wn = cwh_expr_restore_arrayexp(wn,ae);
01358 cwh_stk_push_typed(wn,WN_item,Be_Type_Tbl(rt));
01359 }
01360 }
01361
01362
01363
01364
01365
01366
01367
01368
01369
01370
01371 extern void
01372 fei_cvtop(TYPE type)
01373 {
01374 WN *wn ;
01375 TYPE_ID bt ;
01376 TYPE_ID ot ;
01377 WN *addr;
01378 TY_IDX ty;
01379 WN *ival;
01380 WN *icall;
01381 WN *ae=NULL;
01382
01383 ty = cast_to_TY(t_TY(type));
01384
01385
01386
01387 if (type.basic_type == T_ypeless) {
01388 wn = cwh_expr_operand(&ae);
01389 ot = WNRTY(wn) ;
01390
01391 if (!MTYPE_is_integral(ot)) {
01392 wn = WN_Tas(TY_mtype(ty),Be_Type_Tbl(ot),wn) ;
01393 }
01394
01395 wn = cwh_expr_restore_arrayexp(wn,ae);
01396 cwh_stk_push_typed(wn,WN_item,ty);
01397
01398 } else if (TY_is_character(ty)) {
01399
01400 ival = cwh_intrin_wrap_value_parm(cwh_expr_operand(&ae));
01401 icall = WN_Create_Intrinsic(OPC_U4INTRINSIC_OP,INTRN_CHAR,1,&ival);
01402 icall = cwh_expr_restore_arrayexp(icall,ae);
01403 cwh_stk_push_STR(WN_Intconst(MTYPE_I4,1),icall,ty,WN_item);
01404
01405 } else {
01406
01407 bt = TY_mtype(ty);
01408
01409 if (cwh_stk_get_class() == STR_item) {
01410 cwh_stk_pop_STR();
01411 WN_Delete(cwh_expr_operand(NULL));
01412 addr = cwh_expr_address(f_NONE);
01413
01414 if (WN_opcode(addr) == OPC_U4INTRINSIC_OP &&
01415 WN_intrinsic(addr) == INTRN_CHAR) {
01416
01417 addr = cwh_expr_dispose_of_char(addr);
01418
01419
01420 wn = WN_Band(MTYPE_I4,addr,WN_Intconst(MTYPE_I4,255));
01421 wn = F90_Wrap_ARREXP(wn);
01422 } else {
01423
01424 wn = cwh_addr_load_WN(addr,0,Be_Type_Tbl(MTYPE_U1));
01425 wn = WN_Band(MTYPE_I4,wn,WN_Intconst(MTYPE_I4,255));
01426
01427 wn = cwh_convert_to_ty(wn,bt);
01428 }
01429 } else {
01430 wn = cwh_get_typed_operand(bt,&ae);
01431 }
01432
01433 if (WNOPR(wn) == OPR_INTCONST) {
01434 wn = cwh_expr_restore_arrayexp(wn,ae);
01435 cwh_stk_push_typed(wn,WN_item,ty);
01436 } else {
01437 wn = cwh_expr_restore_arrayexp(wn,ae);
01438 cwh_stk_push_typed(wn,WN_item,ty);
01439 }
01440
01441 }
01442
01443 }
01444
01445
01446
01447
01448
01449
01450
01451
01452
01453
01454
01455
01456
01457
01458
01459
01460
01461
01462
01463
01464
01465 extern void
01466 fei_len(TYPE type)
01467 {
01468 ST * st ;
01469 ST * ln ;
01470 WN * wn ;
01471
01472
01473 switch(cwh_stk_get_class()) {
01474 case ST_item:
01475 case ST_item_whole_array:
01476 st = cwh_stk_pop_ST();
01477 ln = cwh_auxst_find_dummy_len(st);
01478 if (ln == NULL) {
01479 if (ST_sclass(st) == SCLASS_FORMAL)
01480 Fatal_Error ("Unsupported LEN on character dummy : %s",ST_name(st));
01481 else
01482 Fatal_Error ("No LEN type parameter: %s", ST_name(st));
01483
01484 }
01485 cwh_stk_push(ln,ST_item);
01486 break;
01487
01488 case STR_item:
01489 cwh_stk_pop_STR();
01490 wn = cwh_expr_operand(NULL);
01491 cwh_stk_pop_whatever();
01492 cwh_stk_push(wn,WN_item);
01493 break;
01494
01495 default:
01496 DevAssert((0),("Odd LEN"));
01497
01498 }
01499 }
01500
01501
01502
01503
01504
01505
01506
01507
01508
01509 extern void
01510 fei_null_expr (void)
01511 {
01512 WN *null_wn = NULL;
01513 cwh_stk_push(null_wn,WN_item);
01514 }
01515
01516
01517
01518
01519
01520
01521 extern
01522 WN * cwh_generate_bitmask(WN *len, TYPE_ID ty)
01523 {
01524 WN *mask;
01525 if (MTYPE_size_reg(ty) != 64 || !ARCH_mask_shift_counts) {
01526
01527 mask = WN_Intconst(MTYPE_I8,1);
01528 } else {
01529
01530 mask = WN_NE(ty,WN_Intconst(MTYPE_I8,64),WN_COPY_Tree(len));
01531 mask = cwh_convert_to_ty(mask,MTYPE_I8);
01532 }
01533
01534 mask = WN_Shl(MTYPE_I8,mask,len);
01535 mask = cwh_expr_bincalc(OPR_SUB,mask,WN_Intconst(MTYPE_I8,1));
01536 mask = cwh_convert_to_ty(mask,ty);
01537 return (mask);
01538 }
01539
01540
01541
01542
01543
01544
01545
01546
01547
01548
01549
01550
01551 extern void
01552 fei_mask (TYPE type)
01553 {
01554 #ifdef KEY
01555 WN *wn = 0;
01556 WN *arg,*t1,*t2;
01557 #else
01558 WN *wn,*arg,*t1,*t2;
01559 #endif
01560 TYPE_ID t;
01561 WN *ae=NULL;
01562
01563 t = TY_mtype(cast_to_TY(t_TY(type)));
01564
01565 arg = cwh_expr_operand(&ae);
01566
01567 switch (t) {
01568
01569 case MTYPE_U1:
01570 case MTYPE_I1:
01571
01572 wn = WN_CreateExp2(OPC_I4LSHR,WN_Intconst(MTYPE_I4,0xff00LL),arg);
01573 wn = cwh_convert_to_ty(wn,MTYPE_I1);
01574 break;
01575
01576 case MTYPE_U2:
01577 case MTYPE_I2:
01578
01579 wn = WN_CreateExp2(OPC_I4LSHR,WN_Intconst(MTYPE_U4,0xffff0000LL),arg);
01580 wn = cwh_convert_to_ty(wn,MTYPE_I2);
01581 break;
01582
01583 case MTYPE_U4:
01584 case MTYPE_I4:
01585
01586 wn = WN_CreateExp2(OPC_I8LSHR,WN_Intconst(MTYPE_I8,0xffffffff00000000LL),arg);
01587 wn = cwh_convert_to_ty(wn,MTYPE_I4);
01588 break;
01589 case MTYPE_U8:
01590 case MTYPE_I8:
01591
01592
01593
01594
01595 t1 = cwh_expr_bincalc(OPR_LSHR,WN_Intconst(MTYPE_I8,-1),WN_COPY_Tree(arg));
01596 t1 = WN_CreateExp1(OPC_I8BNOT,t1);
01597 t2 = cwh_expr_bincalc(OPR_SUB,WN_Intconst(MTYPE_I8,128),WN_COPY_Tree(arg));
01598 t2 = cwh_generate_bitmask(t2,MTYPE_I8);
01599 wn = WN_CreateExp2(OPC_I4I8LT,arg,WN_Intconst(t,64));
01600 wn = WN_CreateExp3(OPC_I8SELECT,wn,t1,t2);
01601 }
01602
01603 wn = cwh_expr_restore_arrayexp(wn,ae);
01604 cwh_stk_push_typed(wn,WN_item,Be_Type_Tbl(t));
01605 }
01606
01607
01608
01609
01610
01611
01612
01613
01614
01615
01616
01617
01618
01619
01620
01621 extern void
01622 fei_mbits (TYPE type)
01623 {
01624 WN *wn,*a1,*a2,*mask;
01625 WN *ae=NULL;
01626
01627 mask = cwh_expr_operand(&ae);
01628 a2 = cwh_expr_operand(&ae);
01629 a1 = cwh_expr_operand(&ae);
01630
01631 cwh_stk_push(a1,WN_item);
01632 cwh_stk_push(WN_COPY_Tree(mask),WN_item);
01633 fei_and(type);
01634
01635
01636 cwh_stk_push(mask,WN_item);
01637 fei_bneg(type);
01638
01639
01640 cwh_stk_push(a2,WN_item);
01641 fei_and(type);
01642 fei_or(type);
01643
01644 wn = cwh_expr_operand(NULL);
01645 wn = cwh_expr_restore_arrayexp(wn,ae);
01646 cwh_stk_push(wn,WN_item);
01647 }
01648
01649
01650
01651
01652
01653
01654
01655
01656
01657
01658
01659
01660
01661 extern void
01662 fei_new_binop_cshift (TYPE type)
01663 {
01664 WN *wn,*shift,*arg;
01665 WN *t1;
01666 WN *ae=NULL;
01667 INT64 bitlen;
01668 TYPE_ID bt ;
01669 TYPE_ID br ;
01670
01671 shift = cwh_expr_operand(&ae);
01672 arg = cwh_expr_operand(&ae);
01673
01674 bt = WNRTY(arg);
01675 bitlen = MTYPE_size_best(bt);
01676
01677 if (bitlen <= MTYPE_size_best(MTYPE_U4))
01678 br = MTYPE_I4 ;
01679 else
01680 br = MTYPE_I8 ;
01681
01682 if (!MTYPE_is_integral(bt))
01683 arg = WN_Tas(br,Be_Type_Tbl(bt),arg) ;
01684
01685 t1 = cwh_expr_bincalc(OPR_SUB,WN_Intconst(MTYPE_I4,bitlen),WN_COPY_Tree(shift));
01686 t1 = cwh_expr_bincalc(OPR_LSHR,WN_COPY_Tree(arg),t1);
01687
01688 wn = cwh_expr_bincalc(OPR_SHL,arg,shift);
01689 wn = cwh_expr_bincalc(OPR_BIOR,wn,t1);
01690 wn = cwh_wrap_cvtl(wn,bt);
01691
01692 wn = cwh_expr_restore_arrayexp(wn,ae);
01693 cwh_stk_push(wn,WN_item);
01694 }
01695
01696
01697
01698
01699
01700
01701
01702
01703
01704
01705
01706
01707
01708
01709
01710
01711
01712
01713
01714
01715
01716
01717
01718 extern WN *
01719 cwh_expr_temp(TY_IDX ty, WN * e_sz, FLAG flag)
01720 {
01721 ST * st ;
01722 TY_IDX tp ;
01723 WN * wr ;
01724 WN * nl[1] ;
01725 WN * wn[1] ;
01726 BOOL va[1] ;
01727 WN *free_stmt;
01728
01729 PREG_det det;
01730
01731 if (e_sz == NULL && TY_size(ty) != 0) {
01732
01733 st = cwh_stab_temp_ST(ty,TY_name(ty));
01734 cwh_expr_set_flags(st,flag);
01735 wr = cwh_addr_address_ST(st);
01736
01737
01738 } else if (WNOPR(e_sz) == OPR_INTCONST && TY_size(ty) != 0) {
01739
01740 st = cwh_stab_temp_ST(ty,TY_name(ty));
01741 cwh_expr_set_flags(st,flag);
01742 wr = cwh_addr_address_ST(st);
01743
01744 } else {
01745 DevAssert((e_sz!=NULL),("NULL element size in cwh_expr_temp"));
01746
01747 if (TY_kind(ty) == KIND_ARRAY)
01748 wn[0] = cwh_types_size_WN(ty,e_sz);
01749 else
01750 wn[0] = e_sz ;
01751
01752 nl[0] = NULL;
01753 va[0] = TRUE;
01754
01755
01756
01757 det = cwh_preg_next_preg(Pointer_Mtype,"concat_temp",NULL);
01758 wr = cwh_intrin_op(INTRN_F90_STACKTEMPALLOC,1,wn,nl,va,Pointer_Mtype);
01759
01760 tp = cwh_types_make_pointer_type(ty, FALSE);
01761
01762 cwh_addr_store_ST(det.preg_st,det.preg,tp,wr);
01763
01764 wr = cwh_addr_load_ST(det.preg_st,det.preg,tp);
01765
01766
01767
01768 wn[0] = cwh_intrin_wrap_value_parm(WN_COPY_Tree(wr));
01769 free_stmt = WN_Create_Intrinsic(OPC_VINTRINSIC_CALL,INTRN_F90_STACKTEMPFREE,1,wn);
01770 WN_Set_Call_Non_Parm_Ref(free_stmt);
01771 WN_Set_Call_Non_Parm_Mod(free_stmt);
01772 cwh_block_append_given_id(free_stmt,Defer_Block,FALSE);
01773 }
01774
01775 return(wr);
01776 }
01777
01778
01779
01780
01781
01782
01783
01784
01785
01786
01787
01788 extern void
01789 cwh_expr_temp_set_pragma(ST *st)
01790 {
01791 cwh_block_add_to_enclosing_regions(WN_PRAGMA_LOCAL,st);
01792 }
01793
01794
01795
01796
01797
01798
01799
01800
01801
01802
01803
01804
01805
01806 extern void
01807 cwh_expr_str_operand(W_node expr[2])
01808 {
01809 WN * wn;
01810
01811 cwh_stk_pop_STR();
01812
01813 wn = cwh_expr_operand(NULL);
01814 W_ty(expr[0]) = cwh_types_WN_TY(wn,FALSE);
01815 W_wn(expr[0]) = wn;
01816
01817 W_ty(expr[1]) = cwh_stk_get_TY();
01818 W_wn(expr[1]) = cwh_expr_address(f_NONE);
01819
01820 }
01821
01822
01823
01824
01825
01826
01827
01828
01829
01830
01831
01832 extern void
01833 cwh_expr_set_flags(ST *st, FLAG flag)
01834 {
01835 if (st != NULL)
01836 if ((ST_class(st) == CLASS_VAR) ||
01837 (ST_class(st) == CLASS_FUNC)) {
01838 if (flag & f_T_SAVED) Set_ST_addr_saved(st);
01839 }
01840 }
01841
01842
01843
01844
01845
01846
01847
01848
01849
01850
01851
01852
01853
01854
01855
01856
01857 extern WN *
01858 cwh_expr_dispose_of_char(WN * src)
01859 {
01860 WN * wn;
01861 WN * wn1;
01862
01863 if (WN_operator(src) == OPR_ARRAYEXP) {
01864 wn = WN_kid0(src);
01865 wn1 = cwh_expr_dispose_of_char(wn);
01866 if (wn != wn1)
01867 WN_kid0(src) = wn1;
01868
01869 } else if (WN_operator(src) == OPR_INTRINSIC_OP &&
01870 WN_intrinsic(src) == INTRN_CHAR) {
01871
01872 wn = WN_kid0(src);
01873 WN_Delete(src);
01874 src = WN_kid0(wn);
01875 WN_Delete(wn);
01876 }
01877 return src;
01878 }