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
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316 #ifndef lwn_util_INCLUDED
00317 #define lwn_util_INCLUDED
00318
00319 #ifndef wn_INCLUDED
00320 #include "wn.h"
00321 #endif
00322 #ifndef wn_util_INCLUDED
00323 #include "wn_util.h"
00324 #endif
00325
00326 #include "fb_whirl.h"
00327
00328 extern WN_MAP Parent_Map;
00329
00330 #define LWN_Get_Parent(wn) ((WN*)WN_MAP_Get(Parent_Map, (WN*)wn))
00331 #define LWN_Set_Parent(wn, p) (WN_MAP_Set(Parent_Map, wn, (void *)p))
00332
00333 inline void LWN_Copy_Linenumber(const WN* from, WN* to)
00334 {
00335 if (OPCODE_has_next_prev(WN_opcode(from)) &&
00336 OPCODE_has_next_prev(WN_opcode(to))) {
00337 WN_linenum(to) = WN_linenum(from);
00338 }
00339 }
00340
00341 #ifdef _USE_OLD_FEEDBACK
00342 inline void LWN_Set_Frequency(const WN* wn, const INT32 count)
00343 {
00344 if (Cur_PU_Feedback && WN_opcode(wn) != OPC_BLOCK)
00345 WN_MAP32_Set(WN_MAP_FEEDBACK, (WN *) wn, count);
00346 }
00347
00348 inline void LWN_Copy_Frequency(const WN* wn, const WN* wn_from)
00349 {
00350 if (Cur_PU_Feedback && WN_opcode(wn) != OPC_BLOCK)
00351 WN_MAP32_Set(WN_MAP_FEEDBACK, (WN *) wn, WN_MAP32_Get(WN_MAP_FEEDBACK, wn_from));
00352 }
00353
00354 inline void LWN_Scale_Frequency(const WN* wn, const float ratio)
00355 {
00356 if (Cur_PU_Feedback && WN_opcode(wn) != OPC_BLOCK)
00357 WN_MAP32_Set(WN_MAP_FEEDBACK, (WN *) wn, (INT32) ratio*WN_MAP32_Get(WN_MAP_FEEDBACK, wn));
00358 }
00359
00360 inline void LWN_Adjust_Frequency(const WN* wn, const INT32 count)
00361 {
00362 if (Cur_PU_Feedback && WN_opcode(wn) != OPC_BLOCK)
00363 WN_MAP32_Set(WN_MAP_FEEDBACK, (WN *) wn, WN_MAP32_Get(WN_MAP_FEEDBACK, wn) - count);
00364 }
00365
00366 extern void LWN_Set_Frequency_Tree(const WN* wn, const INT32 count);
00367 extern void LWN_Copy_Frequency_Tree(const WN* wn, const WN *wn_from);
00368 extern void LWN_Adjust_Frequency_Tree(const WN* wn, const INT32 count);
00369 extern void LWN_Scale_Frequency_Tree(const WN* wn, const float ratio);
00370
00371 #else
00372
00373
00374 inline void LWN_Set_Frequency(const WN*, const INT32) {}
00375 inline void LWN_Copy_Frequency(const WN*, const WN*) {}
00376 inline void LWN_Scale_Frequency(const WN*, const float) {}
00377 inline void LWN_Adjust_Frequency(const WN*, const INT32) {}
00378
00379 extern void LWN_Set_Frequency_Tree(const WN*, const INT32);
00380 extern void LWN_Copy_Frequency_Tree(const WN*, const WN *);
00381 extern void LWN_Adjust_Frequency_Tree(const WN*, const INT32);
00382 extern void LWN_Scale_Frequency_Tree(const WN*, const float);
00383
00384 #endif // _USE_OLD_FEEDBACK
00385
00386
00387
00388 #define LWN_ITER WN_ITER
00389 #define LWN_WALK_TreeIter WN_WALK_TreeIter
00390 #define LWN_WALK_TreeNext WN_WALK_TreeNext
00391 #define LWN_WALK_SCFIter WN_WALK_SCFIter
00392 #define LWN_WALK_SCFNext WN_WALK_SCFNext
00393 #define LWN_WALK_StmtIter WN_WALK_StmtIter
00394 #define LWN_WALK_StmtNext WN_WALK_StmtNext
00395 #define LWN_WALK_Abort WN_WALK_Abort
00396
00397 extern WN* LWN_Get_Next_Tree_Node (const WN*);
00398 extern WN* LWN_Get_Statement(WN *wn);
00399
00400 extern WN* LWN_Get_Next_Stmt_Node (const WN*);
00401
00402 extern WN* LWN_Get_Next_SCF_Node (const WN*);
00403
00404 extern void LWN_Insert_Block_Before(
00405 WN* block,
00406 WN* wn,
00407 WN* in
00408 );
00409
00410 extern void LWN_Insert_Block_After(
00411 WN* block,
00412 WN* wn,
00413 WN* in
00414 );
00415
00416 extern void LWN_Delete_From_Block
00417 (WN *block, WN* wn);
00418
00419 extern void LWN_Delete_Tree_From_Block (WN* wn);
00420
00421
00422 extern WN* LWN_Extract_From_Block(WN* item);
00423 extern WN* LWN_Extract_From_Block(WN* parent, WN* item);
00424
00425 extern WN* LWN_Copy_Tree(
00426 WN *wn,
00427 BOOL copy_access=FALSE,
00428 WN_MAP access_map=0,
00429 BOOL copy_version=FALSE,
00430 WN_MAP version_map=0,
00431 BOOL copy_all_nodes=FALSE
00432 );
00433
00434 extern void LWN_Parentize (WN* wn);
00435
00436 extern BOOL LWN_Check_Parentize (const WN* wn);
00437
00438 extern BOOL inside_parallelizable_loop( WN *wn );
00439
00440 extern void LWN_Delete_Tree(WN *wn);
00441
00442 #ifdef LNO
00443 class DU_MANAGER;
00444 class ARRAY_DIRECTED_GRAPH16;
00445
00446 extern void LWN_Copy_Def_Use_Node(WN*, WN*, DU_MANAGER*);
00447 extern void LWN_Copy_Def_Use(WN*, WN*, DU_MANAGER*);
00448 extern void LWN_Delete_DU(WN *wn);
00449 extern void LWN_Delete_LNO_dep_graph(WN *wn);
00450 extern void LWN_Delete_CG_dep_graph(WN *wn);
00451 extern void LWN_Delete_Name_Manager(WN *wn);
00452 extern void LWN_Update_Def_Use_Delete_Tree(WN *wn, DU_MANAGER* = NULL);
00453 extern void LWN_Update_Dg_Delete_Tree(WN *wn, ARRAY_DIRECTED_GRAPH16*);
00454 #endif
00455
00456 #define Block_is_empty(b) (WN_first(b) == NULL)
00457
00458
00459
00460 extern WN *LWN_CreateStid(OPCODE opc, WN *orig_op, WN *value);
00461
00462 extern WN *LWN_CreateLdid(OPCODE opc, WN *orig_op);
00463
00464 extern WN *LWN_CreateDivfloor(TYPE_ID type, WN *kid0, WN *kid1);
00465
00466 extern WN *LWN_CreateDivceil(TYPE_ID type, WN *kid0, WN *kid1);
00467
00468 extern WN *LWN_CreateDO(WN *index,
00469 WN *start,
00470 WN *end,
00471 WN *step,
00472 WN *body);
00473
00474 extern WN *LWN_CreateLoopInfo(WN *induction,
00475 WN *trip,
00476 UINT16 trip_est,
00477 UINT16 depth,
00478 INT32 flags);
00479
00480 extern WN *LWN_CreateDoWhile(WN *test,
00481 WN *body);
00482
00483 extern WN *LWN_CreateWhileDo(WN *test,
00484 WN *body);
00485
00486 extern WN *LWN_CreateIf(WN *test,
00487 WN *if_then,
00488 WN *if_else);
00489
00490 extern WN *LWN_CreateCondbr( INT32 label_number,
00491 WN *exp);
00492
00493 extern WN *LWN_CreateReturn();
00494
00495 extern WN *LWN_CreateCompgoto(INT32 num_entries,
00496 WN *value,
00497 WN *block,
00498 WN *deflt);
00499
00500 #ifndef KEY
00501 extern WN *LWN_CreateIstore(OPCODE opc,
00502 WN_OFFSET offset,
00503 TY_IDX ty,
00504 WN *value,
00505 WN *addr);
00506 #else
00507 extern WN *LWN_CreateIstore(OPCODE opc,
00508 WN_OFFSET offset,
00509 TY_IDX ty,
00510 WN *value,
00511 WN *addr,
00512 UINT field_id = 0);
00513 #endif
00514
00515 extern WN *LWN_CreateMstore(WN_OFFSET offset,
00516 TY_IDX ty,
00517 WN *value,
00518 WN *addr,
00519 WN *num_bytes);
00520
00521 extern WN *LWN_CreateStid(OPCODE opc,
00522 WN_OFFSET offset,
00523 ST* st,
00524 TY_IDX ty,
00525 WN *value);
00526
00527 extern WN *LWN_CreateEval(WN *exp);
00528
00529 extern WN *LWN_CreateExp1(OPCODE opc,
00530 WN *kid0);
00531
00532 extern WN *LWN_CreateExp2(OPCODE opc,
00533 WN *kid0,
00534 WN *kid1);
00535
00536 #ifndef KEY
00537 extern WN *LWN_CreateIload(OPCODE opc,
00538 WN_OFFSET offset,
00539 TY_IDX ty1,
00540 TY_IDX ty2,
00541 WN *addr);
00542 #else
00543 extern WN *LWN_CreateIload(OPCODE opc,
00544 WN_OFFSET offset,
00545 TY_IDX ty1,
00546 TY_IDX ty2,
00547 WN *addr,
00548 UINT field_id = 0);
00549 #endif
00550
00551 extern WN *LWN_CreateMload(WN_OFFSET offset,
00552 TY_IDX ty,
00553 WN *addr,
00554 WN *num_bytes);
00555
00556 extern WN *LWN_CreateCvtl(OPCODE opc,
00557 INT16 cvtl_bits,
00558 WN *kid0);
00559
00560 #ifdef KEY
00561
00562 extern INT Num_Prefetches;
00563 #endif
00564 extern WN *LWN_CreatePrefetch (WN_OFFSET offset,
00565 UINT32 flag,
00566 WN* addr);
00567 extern WN *LWN_CreateParm(TYPE_ID rtype,
00568 WN *parm_node,
00569 TY_IDX ty,
00570 UINT32 flag);
00571
00572 extern BOOL Is_Descendent(WN *low, WN *high);
00573
00574 extern WN *LWN_Int_Type_Conversion(WN *wn, TYPE_ID to_type);
00575 extern TYPE_ID Promote_Type(TYPE_ID mtype);
00576
00577 extern BOOL Tree_Equiv (WN *wn1, WN* wn2);
00578
00579 #ifdef LNO
00580 extern WN *LWN_Loop_Trip_Count(const WN *loop);
00581
00582 extern BOOL Inside_Loop_With_Goto(WN *wn);
00583 #endif
00584
00585 extern WN* LWN_Simplify_Tree(WN* wn);
00586
00587 #endif