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 #include "wn.h"
00037 #include "stab.h"
00038 #include "strtab.h"
00039 #include "mtypes.h"
00040 #include "targ_const.h"
00041 #include "config_targ.h"
00042 #include "wn_util.h"
00043 #include "region_util.h"
00044 #include <alloca.h>
00045 #include "data_layout.h"
00046
00047 extern "C" {
00048 void Rewrite_Pragmas_On_Structs (WN* block_wn, WN* wn);
00049 }
00050
00051 static void Rewrite_Structs_In_MPRegion (WN* wn,
00052 WN* parent_wn,
00053 INT count,
00054 WN** rewrite_pwn,
00055 ST** rewrite_st,
00056 TYPE_ID* rewrite_rtype,
00057 TYPE_ID* rewrite_desc);
00058 static BOOL Tree_Equiv (WN *wn1, WN* wn2);
00059
00060
00061
00062
00063
00064
00065 static BOOL Is_Mp_Region(WN *wn)
00066 {
00067 if (WN_opcode(wn) == OPC_REGION) {
00068 RID *rid = REGION_get_rid(wn);
00069 if (RID_TYPE_mp(rid)) return TRUE;
00070 }
00071 return FALSE;
00072 }
00073
00074
00075
00076
00077
00078
00079
00080
00081 static BOOL Weird_Array_Element (WN *pwn) {
00082 Is_True (pwn &&
00083 WN_operator(pwn) == OPR_XPRAGMA &&
00084 WN_pragma(pwn) == WN_PRAGMA_REDUCTION,
00085 ("Weird_Array_Element called weirdly"));
00086
00087 if (WN_operator(WN_kid0(pwn)) != OPR_ARRAY) return FALSE;
00088
00089 WN *array_base = WN_array_base(WN_kid0(pwn));
00090 OPERATOR opr = WN_operator(array_base);
00091 if ((opr == OPR_LDA &&
00092 TY_kind(ST_type(WN_st(array_base))) == KIND_ARRAY) ||
00093 (opr == OPR_LDID &&
00094 TY_kind(ST_type(WN_st(array_base))) == KIND_POINTER &&
00095 TY_kind(TY_pointed(ST_type(WN_st(array_base)))) == KIND_ARRAY))
00096 {
00097
00098 return FALSE;
00099 }
00100 return TRUE;
00101 }
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123 static BOOL Array_Element_Then_Struct (WN *pwn) {
00124
00125 Is_True (pwn &&
00126 WN_operator(pwn) == OPR_XPRAGMA &&
00127 WN_pragma(pwn) == WN_PRAGMA_REDUCTION,
00128 ("Array_Element_Then_Struct called weirdly"));
00129
00130 if (WN_operator(WN_kid0(pwn)) != OPR_ARRAY) return FALSE;
00131
00132 WN *array_base = WN_array_base(WN_kid0(pwn));
00133 OPERATOR opr = WN_operator(array_base);
00134
00135 if (opr == OPR_LDA) {
00136 TY_IDX ty = ST_type(WN_st(array_base));
00137
00138 if (TY_kind(ty) == KIND_ARRAY && TY_kind(TY_etype(ty)) == KIND_STRUCT)
00139 return TRUE;
00140
00141 if (TY_kind(ty) == KIND_STRUCT)
00142 return TRUE;
00143
00144 } else if (opr == OPR_LDID) {
00145 TY_IDX ty = ST_type(WN_st(array_base));
00146
00147 if (TY_kind(ty) == KIND_POINTER) {
00148 if (TY_kind(TY_pointed(ty)) == KIND_STRUCT)
00149 return TRUE;
00150 else if (TY_kind(TY_pointed(ty)) == KIND_ARRAY &&
00151 TY_kind(TY_etype(TY_pointed(ty))) == KIND_STRUCT)
00152 return TRUE;
00153 }
00154 }
00155
00156 return FALSE;
00157 }
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172 extern void Rewrite_Pragmas_On_Structs (WN* block_wn, WN* wn) {
00173 if (!wn) return;
00174
00175 if (Is_Mp_Region (wn)) {
00176
00177 FmtAssert (block_wn, ("Rewrite_Pragmas: missing BLOCK node"));
00178
00179
00180
00181 WN* pwn = WN_first(WN_region_pragmas(wn));
00182 INT count = 0;
00183 while (pwn) {
00184 Is_True (WN_operator(pwn) == OPR_PRAGMA ||
00185 WN_operator(pwn) == OPR_XPRAGMA,
00186 ("Rewrite_Pragmas: Expected a pragma/xpragma node"));
00187
00188 ST* st = NULL;
00189 if (WN_operator(pwn) == OPR_PRAGMA) st = WN_st(pwn);
00190
00191 if (WN_operator(pwn) == OPR_PRAGMA &&
00192 WN_pragma_compiler_generated(pwn) &&
00193 (WN_pragma(pwn) == WN_PRAGMA_REDUCTION ||
00194 WN_pragma(pwn) == WN_PRAGMA_LOCAL ||
00195 WN_pragma(pwn) == WN_PRAGMA_FIRSTPRIVATE ||
00196 WN_pragma(pwn) == WN_PRAGMA_LASTLOCAL) &&
00197 (TY_kind(ST_type(st)) == KIND_STRUCT)) {
00198
00199
00200
00201 count++;
00202 }
00203 else if (WN_operator(pwn) == OPR_XPRAGMA &&
00204 WN_pragma_compiler_generated(pwn) &&
00205 WN_pragma(pwn) == WN_PRAGMA_REDUCTION &&
00206 WN_operator(WN_kid0(pwn)) == OPR_ARRAY) {
00207
00208
00209
00210
00211
00212 WN* array_base = WN_array_base(WN_kid0(pwn));
00213 OPERATOR opr = WN_operator(array_base);
00214
00215 if (Array_Element_Then_Struct(pwn)) {
00216
00217
00218 count++;
00219
00220 } else if (Weird_Array_Element(pwn)) {
00221
00222
00223 count++;
00224 }
00225
00226 }
00227 pwn = WN_next(pwn);
00228 }
00229
00230 if (count) {
00231
00232 WN** rewrite_pwn = (WN**) alloca (count*sizeof(WN*));
00233 ST** rewrite_st = (ST**) alloca (count*sizeof(ST*));
00234 TYPE_ID* rewrite_rtype = (TYPE_ID*) alloca (count*sizeof(TYPE_ID));
00235 TYPE_ID* rewrite_desc = (TYPE_ID*) alloca (count*sizeof(TYPE_ID));
00236 INT i = 0;
00237 pwn = WN_first(WN_region_pragmas(wn));
00238 while (pwn) {
00239 ST* st = NULL;
00240 if (WN_operator(pwn) == OPR_PRAGMA) st = WN_st(pwn);
00241
00242 if (WN_operator(pwn) == OPR_PRAGMA &&
00243 WN_pragma_compiler_generated(pwn) &&
00244 (WN_pragma(pwn) == WN_PRAGMA_REDUCTION ||
00245 WN_pragma(pwn) == WN_PRAGMA_LOCAL ||
00246 WN_pragma(pwn) == WN_PRAGMA_FIRSTPRIVATE ||
00247 WN_pragma(pwn) == WN_PRAGMA_LASTLOCAL) &&
00248 (TY_kind(ST_type(st)) == KIND_STRUCT)) {
00249
00250
00251
00252
00253
00254
00255
00256 FmtAssert (i<count, ("Rewrite_STs. counting error"));
00257
00258 BOOL duplicate = FALSE;
00259 for (INT j=0; j<i; j++) {
00260 if (WN_st(rewrite_pwn[j]) == WN_st(pwn) &&
00261 WN_pragma_arg1(rewrite_pwn[j]) == WN_pragma_arg1(pwn)) {
00262 if (WN_pragma(rewrite_pwn[j]) == WN_pragma(pwn)) {
00263 duplicate = TRUE;
00264
00265 WN* tmp_wn = pwn;
00266 pwn = WN_prev(pwn);
00267 WN_DELETE_FromBlock (WN_region_pragmas(wn), tmp_wn);
00268 break;
00269 }
00270 else {
00271 FmtAssert (FALSE, ("Rewrite_Pragmas: contradictory pragmas"));
00272 }
00273 }
00274 }
00275 if (!duplicate) {
00276 rewrite_pwn[i] = pwn;
00277 rewrite_st[i] = NULL;
00278 i++;
00279 }
00280 }
00281 else if (WN_operator(pwn) == OPR_XPRAGMA &&
00282 WN_pragma_compiler_generated(pwn) &&
00283 WN_pragma(pwn) == WN_PRAGMA_REDUCTION &&
00284 WN_operator(WN_kid0(pwn)) == OPR_ARRAY) {
00285
00286 WN* array_base = WN_array_base(WN_kid0(pwn));
00287 OPERATOR opr = WN_operator(array_base);
00288
00289 if (Array_Element_Then_Struct(pwn) ||
00290 Weird_Array_Element(pwn)) {
00291
00292
00293 BOOL duplicate = FALSE;
00294 for (INT j=0; j<i; j++) {
00295 if (Tree_Equiv(rewrite_pwn[j], pwn)) {
00296 duplicate = TRUE;
00297
00298 WN* tmp_wn = pwn;
00299 pwn = WN_prev(pwn);
00300 WN_DELETE_FromBlock (WN_region_pragmas(wn), tmp_wn);
00301 break;
00302 }
00303 }
00304 if (!duplicate) {
00305 rewrite_pwn[i] = pwn;
00306 rewrite_st[i] = NULL;
00307 i++;
00308 }
00309 }
00310 }
00311 pwn = WN_next(pwn);
00312 }
00313
00314 count = i;
00315
00316 Rewrite_Structs_In_MPRegion (WN_region_body(wn),
00317 wn,
00318 count,
00319 rewrite_pwn,
00320 rewrite_st,
00321 rewrite_rtype,
00322 rewrite_desc);
00323
00324
00325 for (i=0; i<count; i++) {
00326
00327
00328
00329 if (rewrite_st[i] == NULL) continue;
00330
00331 pwn = rewrite_pwn[i];
00332
00333 if (WN_operator(pwn) == OPR_XPRAGMA) {
00334
00335
00336
00337 OPCODE opc = OPCODE_make_op(OPR_ILOAD,
00338 rewrite_rtype[i],
00339 rewrite_desc[i]);
00340 WN* iload_wn = WN_CreateIload (opc, WN_prefetch_flag(pwn),
00341 ST_type(rewrite_st[i]),
00342 Make_Pointer_Type(ST_type
00343 (rewrite_st[i]),
00344 FALSE),
00345 WN_COPY_Tree(WN_kid0(pwn)));
00346
00347 opc = OPCODE_make_op (OPR_STID, MTYPE_V, rewrite_desc[i]);
00348 WN* stid_wn = WN_CreateStid (opc, 0, rewrite_st[i],
00349 ST_type(rewrite_st[i]),
00350 iload_wn);
00351 WN_INSERT_BlockBefore (block_wn, wn, stid_wn);
00352
00353
00354 opc = OPCODE_make_op(OPR_LDID,
00355 rewrite_rtype[i],
00356 rewrite_desc[i]);
00357 WN *ldid_wn = WN_CreateLdid (opc,
00358 0,
00359 rewrite_st[i],
00360 ST_type(rewrite_st[i]));
00361 opc = OPCODE_make_op (OPR_ISTORE, MTYPE_V, rewrite_desc[i]);
00362 WN* istore_wn = WN_CreateIstore (opc, WN_prefetch_flag(pwn),
00363 Make_Pointer_Type(ST_type
00364 (rewrite_st[i]),
00365 FALSE),
00366 ldid_wn,
00367 WN_COPY_Tree(WN_kid0(pwn)));
00368 WN_INSERT_BlockAfter (block_wn, wn, istore_wn);
00369
00370
00371 WN* pragma_wn = WN_CreatePragma (WN_PRAGMA_REDUCTION,
00372 rewrite_st[i], 0, 0);
00373
00374 WN_pragma_arg2(pragma_wn) = WN_pragma_arg2(pwn);
00375 WN_INSERT_BlockBefore (WN_region_pragmas(wn), pwn, pragma_wn);
00376 WN_DELETE_FromBlock (WN_region_pragmas(wn), pwn);
00377 continue;
00378 }
00379 else {
00380 ST* st = WN_st(pwn);
00381
00382 switch (WN_pragma(pwn)) {
00383 case WN_PRAGMA_REDUCTION:
00384 {
00385
00386 OPCODE opc = OPCODE_make_op(OPR_LDID,
00387 rewrite_rtype[i],
00388 rewrite_desc[i]);
00389 WN* ldid_wn = WN_CreateLdid (opc,
00390 WN_pragma_arg1(pwn),
00391 st,
00392 ST_type(rewrite_st[i]));
00393 opc = OPCODE_make_op (OPR_STID, MTYPE_V, rewrite_desc[i]);
00394 WN* stid_wn = WN_CreateStid (opc, 0, rewrite_st[i],
00395 ST_type(rewrite_st[i]),
00396 ldid_wn);
00397 WN_INSERT_BlockBefore (block_wn, wn, stid_wn);
00398
00399
00400 opc = OPCODE_make_op(OPR_LDID,
00401 rewrite_rtype[i],
00402 rewrite_desc[i]);
00403 ldid_wn = WN_CreateLdid (opc,
00404 0,
00405 rewrite_st[i],
00406 ST_type(rewrite_st[i]));
00407 opc = OPCODE_make_op (OPR_STID, MTYPE_V, rewrite_desc[i]);
00408 stid_wn = WN_CreateStid (opc, WN_pragma_arg1(pwn),
00409 st,
00410 ST_type(rewrite_st[i]),
00411 ldid_wn);
00412 WN_INSERT_BlockAfter (block_wn, wn, stid_wn);
00413
00414
00415 WN_st_idx(pwn) = ST_st_idx(rewrite_st[i]);
00416 WN_pragma_arg1(pwn) = 0;
00417 break;
00418 }
00419 case WN_PRAGMA_LOCAL:
00420 {
00421
00422 WN_st_idx(pwn) = ST_st_idx(rewrite_st[i]);
00423 WN_pragma_arg1(pwn) = 0;
00424 break;
00425 }
00426 case WN_PRAGMA_FIRSTPRIVATE:
00427 {
00428
00429
00430
00431
00432
00433
00434
00435 OPCODE opc = OPCODE_make_op(OPR_LDID,
00436 (rewrite_rtype[i] != MTYPE_V ?
00437 rewrite_rtype[i] : rewrite_desc[i]),
00438 rewrite_desc[i]);
00439 WN *ldid_wn = WN_CreateLdid (opc,
00440 WN_pragma_arg1(pwn),
00441 WN_st(pwn),
00442 ST_type(rewrite_st[i]));
00443 opc = OPCODE_make_op (OPR_STID, MTYPE_V, rewrite_desc[i]);
00444 WN* stid_wn = WN_CreateStid (opc,
00445 0,
00446 rewrite_st[i],
00447 ST_type(rewrite_st[i]),
00448 ldid_wn);
00449
00450 WN_INSERT_BlockFirst (WN_region_body(wn), stid_wn);
00451
00452
00453 WN_st_idx(pwn) = ST_st_idx (rewrite_st[i]);
00454 WN_pragma_arg1(pwn) = 0;
00455 break;
00456 }
00457 case WN_PRAGMA_LASTLOCAL:
00458 {
00459
00460
00461
00462
00463
00464
00465
00466 OPCODE opc = OPCODE_make_op(OPR_LDID,
00467 (rewrite_rtype[i] != MTYPE_V ?
00468 rewrite_rtype[i] : rewrite_desc[i]),
00469 rewrite_desc[i]);
00470 WN* ldid_wn = WN_CreateLdid (opc,
00471 0,
00472 rewrite_st[i],
00473 ST_type(rewrite_st[i]));
00474 opc = OPCODE_make_op (OPR_STID, MTYPE_V, rewrite_desc[i]);
00475 WN* stid_wn = WN_CreateStid (opc, WN_pragma_arg1(pwn),
00476 st,
00477 ST_type(rewrite_st[i]),
00478 ldid_wn);
00479 WN_INSERT_BlockAfter (block_wn, wn, stid_wn);
00480
00481
00482 WN_st_idx(pwn) = ST_st_idx(rewrite_st[i]);
00483 WN_pragma_arg1(pwn) = 0;
00484 break;
00485 }
00486 default:
00487 {
00488 FmtAssert (FALSE, ("Rewrite_Pragmas: Unknown pragma type"));
00489 }
00490 }
00491 }
00492 }
00493 }
00494 }
00495
00496 if (WN_opcode(wn) == OPC_BLOCK) {
00497 WN* kid = WN_first(wn);
00498 while (kid) {
00499 Rewrite_Pragmas_On_Structs (wn, kid);
00500 kid = WN_next(kid);
00501 }
00502 }
00503 else {
00504 for (INT i=0; i<WN_kid_count(wn); i++) {
00505 Rewrite_Pragmas_On_Structs (NULL, WN_kid(wn,i));
00506 }
00507 }
00508 }
00509
00510
00511
00512
00513
00514
00515
00516 static INT Find_Symbol (WN** rewrite_pwn, INT count, ST* st, WN_OFFSET ofst) {
00517
00518 for (INT i=0; i<count; i++) {
00519 ST* this_st = NULL;
00520 if (WN_operator(rewrite_pwn[i]) == OPR_PRAGMA) {
00521 this_st = WN_st(rewrite_pwn[i]);
00522 }
00523
00524 if (this_st == st && WN_pragma_arg1(rewrite_pwn[i]) == ofst)
00525 return i;
00526 }
00527 return -1;
00528 }
00529
00530
00531
00532
00533
00534
00535
00536 static BOOL Tree_Equiv (WN *wn1, WN* wn2) {
00537
00538 if (!wn1 && !wn2) return TRUE;
00539 if (!wn1 || !wn2) return FALSE;
00540 if (!WN_Equiv (wn1, wn2)) return FALSE;
00541
00542
00543 if (WN_opcode(wn1) == OPC_BLOCK) {
00544 WN *kid1 = WN_first(wn1);
00545 WN *kid2 = WN_first(wn2);
00546 while (1) {
00547 if (!Tree_Equiv (kid1, kid2)) return FALSE;
00548 if (kid1 == NULL) break;
00549 kid1 = WN_next (kid1);
00550 kid2 = WN_next (kid2);
00551 };
00552 return TRUE;
00553 }
00554 else {
00555
00556 for (INT i=0; i<WN_kid_count(wn1); i++)
00557 if (!Tree_Equiv (WN_kid(wn1,i), WN_kid(wn2,i))) return FALSE;
00558 return TRUE;
00559 }
00560 }
00561
00562
00563
00564
00565
00566
00567
00568 static INT Find_Reduction_Symbol (WN** rewrite_pwn,
00569 INT count,
00570 WN* array_wn,
00571 INT64 ofst) {
00572
00573 for (INT i=0; i<count; i++) {
00574 WN* pwn = rewrite_pwn[i];
00575 if ((WN_operator(pwn) == OPR_XPRAGMA) &&
00576 Tree_Equiv (WN_kid0(pwn), array_wn) &&
00577 ofst == WN_prefetch_flag(pwn)) {
00578 return i;
00579 }
00580 }
00581 return -1;
00582 }
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593 static void Rewrite_Structs_In_MPRegion (WN* wn,
00594 WN* parent_wn,
00595 INT count,
00596 WN** rewrite_pwn,
00597 ST** rewrite_st,
00598 TYPE_ID* rewrite_rtype,
00599 TYPE_ID* rewrite_desc) {
00600
00601 if (!wn) return;
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612 OPERATOR opr = WN_operator(wn);
00613
00614 if (opr == OPR_LDID || opr == OPR_STID) {
00615 ST* st = WN_st(wn);
00616
00617 INT idx = Find_Symbol (rewrite_pwn, count, st, WN_offset(wn));
00618 if (idx != -1) {
00619 if (rewrite_st[idx] == NULL) {
00620
00621
00622 char* name = (char*) alloca(strlen(ST_name(st))+10);
00623 sprintf (name, "rewrite_%s", ST_name(st));
00624
00625 ST* new_st = New_ST(CURRENT_SYMTAB);
00626 ST_Init (new_st,
00627 Save_Str(name),
00628 ST_class(st),
00629 SCLASS_AUTO,
00630 EXPORT_LOCAL,
00631 WN_ty(wn));
00632
00633 rewrite_st[idx] = new_st;
00634 rewrite_desc[idx] = WN_desc(wn);
00635 rewrite_rtype[idx] = WN_rtype(wn);
00636 }
00637
00638 if (opr == OPR_LDID && rewrite_rtype[idx] == MTYPE_V) {
00639 rewrite_rtype[idx] = WN_rtype(wn);
00640
00641 rewrite_desc[idx] = WN_desc(wn);
00642 }
00643
00644 WN_st_idx(wn) = ST_st_idx(rewrite_st[idx]);
00645 WN_offset(wn) = 0;
00646 }
00647 }
00648
00649
00650
00651
00652
00653
00654 if (opr == OPR_ILOAD || opr == OPR_ISTORE ||
00655 (opr == OPR_ARRAY &&
00656 WN_operator(parent_wn) != OPR_ILOAD &&
00657 WN_operator(parent_wn) != OPR_ISTORE)) {
00658
00659 WN* array_wn = (opr == OPR_ARRAY ? wn :
00660 (opr == OPR_ILOAD ? WN_kid0(wn) :
00661 WN_kid1(wn)));
00662
00663 if (WN_operator(array_wn) == OPR_ARRAY) {
00664
00665 INT idx = Find_Reduction_Symbol (rewrite_pwn,
00666 count,
00667 array_wn,
00668 ((opr == OPR_ILOAD || OPR_ISTORE) ?
00669 WN_offset(wn) : 0));
00670 if (idx != -1) {
00671
00672 #ifdef Is_True_On
00673 if (opr == OPR_ARRAY) {
00674
00675
00676 Is_True(WN_operator(parent_wn) == OPR_PARM,
00677 ("Rewrite_Structs_In_MPRegion(): bad parent opr == %d",
00678 (INT) WN_operator(parent_wn)));
00679 }
00680 #endif
00681
00682 if (rewrite_st[idx] == NULL) {
00683
00684
00685 char* name = (char*) alloca(20);
00686 sprintf (name, "rewrite_xreducn");
00687
00688 ST* new_st = New_ST(CURRENT_SYMTAB);
00689
00690 TY_IDX new_ty_idx;
00691 if (opr == OPR_ISTORE)
00692 new_ty_idx = TY_pointed(WN_ty(wn));
00693 else if (opr == OPR_ARRAY)
00694 new_ty_idx = WN_ty(parent_wn);
00695 else
00696 new_ty_idx = WN_ty(wn);
00697
00698 ST_Init (new_st,
00699 Save_Str(name),
00700 CLASS_VAR,
00701 SCLASS_AUTO,
00702 EXPORT_LOCAL,
00703 new_ty_idx);
00704
00705 rewrite_st[idx] = new_st;
00706 rewrite_desc[idx] = WN_desc(wn);
00707 rewrite_rtype[idx] = WN_rtype(wn);
00708 }
00709 if (opr == OPR_ILOAD && rewrite_rtype[idx] == MTYPE_V) {
00710 rewrite_rtype[idx] = WN_rtype(wn);
00711 }
00712
00713
00714 switch (opr) {
00715
00716 case OPR_ILOAD: {
00717 OPCODE opc = OPCODE_make_op(OPR_LDID,
00718 rewrite_rtype[idx],
00719 rewrite_desc[idx]);
00720 WN *ldid_wn = WN_CreateLdid (opc, 0, rewrite_st[idx],
00721 ST_type(rewrite_st[idx]));
00722 FmtAssert (WN_opcode(parent_wn) != OPC_BLOCK,
00723 ("Rewrite_pragmas: iload under a BLOCK node"));
00724 INT kidno;
00725 for (kidno=0; kidno<WN_kid_count(parent_wn); kidno++) {
00726 if (WN_kid(parent_wn,kidno) == wn) break;
00727 }
00728 FmtAssert (kidno < WN_kid_count(parent_wn),
00729 ("Rewrite_Pragmas: Could not find kid in parent"));
00730 WN_DELETE_Tree (WN_kid(parent_wn, kidno));
00731 WN_kid(parent_wn, kidno) = ldid_wn;
00732 wn = ldid_wn;
00733 break;
00734 }
00735
00736 case OPR_ISTORE: {
00737 OPCODE opc = OPCODE_make_op (OPR_STID, MTYPE_V, rewrite_desc[idx]);
00738 WN* stid_wn = WN_CreateStid (opc, 0, rewrite_st[idx],
00739 ST_type(rewrite_st[idx]),
00740 WN_COPY_Tree(WN_kid0(wn)));
00741 FmtAssert (WN_opcode(parent_wn) == OPC_BLOCK,
00742 ("Rewrite_pragmas: istore not under a BLOCK node"));
00743 WN_INSERT_BlockBefore (parent_wn, wn, stid_wn);
00744 WN_DELETE_FromBlock (parent_wn, wn);
00745 wn = stid_wn;
00746 break;
00747 }
00748
00749 case OPR_ARRAY: {
00750 OPCODE opc = OPCODE_make_op (OPR_LDA, Pointer_type, MTYPE_V);
00751 WN* lda_wn =
00752 WN_CreateLda (opc, 0,
00753 Make_Pointer_Type(ST_type(rewrite_st[idx]), FALSE),
00754 rewrite_st[idx]);
00755 FmtAssert (WN_opcode(parent_wn) != OPC_BLOCK,
00756 ("Rewrite_pragmas: array under a BLOCK node"));
00757 INT kidno;
00758 for (kidno=0; kidno<WN_kid_count(parent_wn); kidno++) {
00759 if (WN_kid(parent_wn,kidno) == wn) break;
00760 }
00761 FmtAssert (kidno < WN_kid_count(parent_wn),
00762 ("Rewrite_Pragmas: Could not find kid in parent"));
00763 WN_DELETE_Tree (WN_kid(parent_wn, kidno));
00764 WN_kid(parent_wn, kidno) = lda_wn;
00765 wn = lda_wn;
00766 break;
00767 }
00768 }
00769 }
00770 }
00771 }
00772
00773 if (WN_opcode(wn) == OPC_BLOCK) {
00774 WN* kid = WN_first(wn);
00775 while (kid) {
00776 Rewrite_Structs_In_MPRegion (kid,
00777 wn,
00778 count,
00779 rewrite_pwn,
00780 rewrite_st,
00781 rewrite_rtype,
00782 rewrite_desc);
00783 kid = WN_next(kid);
00784 }
00785 }
00786 else {
00787 for (INT i=0; i<WN_kid_count(wn); i++) {
00788 Rewrite_Structs_In_MPRegion (WN_kid(wn,i),
00789 wn,
00790 count,
00791 rewrite_pwn,
00792 rewrite_st,
00793 rewrite_rtype,
00794 rewrite_desc);
00795 }
00796 }
00797 }