Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
wn_core.h
Go to the documentation of this file.
00001 /*
00002 
00003   Copyright (C) 2000, 2001 Silicon Graphics, Inc.  All Rights Reserved.
00004 
00005   This program is free software; you can redistribute it and/or modify it
00006   under the terms of version 2 of the GNU General Public License as
00007   published by the Free Software Foundation.
00008 
00009   This program is distributed in the hope that it would be useful, but
00010   WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00012 
00013   Further, this software is distributed without any warranty that it is
00014   free of the rightful claim of any third person regarding infringement 
00015   or the like.  Any license provided herein, whether implied or 
00016   otherwise, applies only to this software file.  Patent licenses, if 
00017   any, provided herein do not apply to combinations of this program with 
00018   other software, or any other product whatsoever.  
00019 
00020   You should have received a copy of the GNU General Public License along
00021   with this program; if not, write the Free Software Foundation, Inc., 59
00022   Temple Place - Suite 330, Boston MA 02111-1307, USA.
00023 
00024   Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pky,
00025   Mountain View, CA 94043, or:
00026 
00027   http://www.sgi.com
00028 
00029   For further information regarding this notice, see:
00030 
00031   http://oss.sgi.com/projects/GenInfo/NoticeExplan
00032 
00033 */
00034 
00035 
00036 #ifndef wn_core_INCLUDED
00037 #define wn_core_INCLUDED
00038 
00039 #ifndef symtab_INCLUDED
00040 #include "symtab.h"
00041 #endif 
00042 
00043 #ifndef irbdata_INCLUDED
00044 #include "irbdata.h"
00045 #endif
00046 
00047 #ifndef wintrinsic_INCLUDED 
00048 #include "wintrinsic.h"
00049 #endif
00050 #ifndef wio_INCLUDED
00051 #include "wio.h"
00052 #endif
00053 
00376 #define MAX_FIELD_ID 0x3ffe
00377 #define UNKNOWN_FIELD_ID 0x3fff
00378 
00379 class WN;
00380 class STMT_WN;
00381 
00382 typedef INT32           WN_OFFSET;
00383 typedef INT64           WN_ESIZE;
00384 typedef INT32           WN_MAP_ID;
00385 
00386 typedef enum REGION_KIND {
00387   REGION_KIND_PRAGMA     = 0x0,
00388   REGION_KIND_FUNC_ENTRY = 0x1,
00389   REGION_KIND_LOOP       = 0x2,
00390   REGION_KIND_OLIMIT     = 0x3,
00391   REGION_KIND_MP         = 0x4,
00392   REGION_KIND_RPI        = 0x5,
00393   REGION_KIND_COLD       = 0x6,
00394   REGION_KIND_SWP        = 0x7,
00395 
00396   REGION_KIND_EH         = 0x8, /* any kind with bit 3 set is EH */
00397   REGION_KIND_TRY        = 0x8,
00398   REGION_KIND_CLEANUP    = 0x9,
00399   REGION_KIND_EXC_SPEC   = 0xa,
00400   REGION_KIND_MASK       = 0xb,
00401   REGION_KIND_GUARD      = 0xc,
00402   REGION_KIND_NULL_CLEANUP = 0xd  /* cleanup with empty destructor */
00403 } REGION_KIND;
00404 
00405 class WN {
00406 public:
00407    union {
00408       struct {
00409          union {
00410             WN_OFFSET       load_offset; 
00411             WN_OFFSET       lda_offset; 
00412             WN_OFFSET       store_offset;
00413             WN_OFFSET       idname_offset;
00414             INT32           num_entries; /* used by computed goto statements; may be used by regions */
00415             TY_IDX          loadx_addr_ty; /* for OPR_ILOADX */
00416             INT16           cvtl_bits;
00417             INT32           label_number;
00418             UINT32          call_flag;
00419             UINT32          if_flag;
00420             UINT32          io_flag;
00421             UINT32          asm_flag;
00422             UINT32          asm_operand_num;
00423             UINT32          eq_logical_flag;
00424             struct {
00425                 mUINT16     trip_est;
00426                 mUINT16     loop_depth;
00427             } li;
00428             struct {
00429                 mUINT16     pragma_flags;
00430                 mUINT16     pragma_id;
00431             } pragma;
00432             TY_IDX          io_item_ty;  /* for IO_ITEM */
00433             struct {
00434                 REGION_KIND region_kind: 4;
00435                 mUINT32     region_id  :28;
00436             } region;
00437          } ua;
00438          union {
00439             ST_IDX          st_idx;     /* for ldid/stid/lda */
00440             TY_IDX          ty;         /* for all types except lda,ldid,stid */
00441                                         /*  and io_item */
00442             INT32           id;
00443             INTRINSIC       intrinsic;
00444             IOSTATEMENT     iostatement;
00445             IOITEM          ioitem;
00446             UINT32          prefetch_flag;
00447             UINT32          loop_flag;
00448             INT32           last_label; /* end of switch */
00449             INITO_IDX       ereg_supp;
00450             UINT32          label_level; /* nest level for target of goto_outer_block */
00451          } ub;
00452       } uu;
00453       WN_ESIZE      element_size;
00454    } u1u2;
00455 
00456    // the following layout was used to minimize aliasing as 
00457    // kid_count is not used in most of the WHIRL nodes.
00458    // this permits loading of wn_operator, rtype and desc as bytes
00459    struct {
00460       OPERATOR          wn_operator : 8;  /* 8 bits of operator       */
00461       TYPE_ID           rtype       : 5;  /* result */
00462       mINT16            kid_count   :14; /* gives kid_count for free */
00463       TYPE_ID           desc        : 5;  /* descriptor type */
00464       INT32             map_id;
00465    } common;
00466 
00467    union {
00468      struct {
00469        WN          *dummy1;
00470        TY_IDX       ty;         /* ty used for lda,ldid,stid,iload */
00471      } ty_fields;
00472      WN            *kids[2];
00473      INT64          const_val;
00474      struct {
00475        UINT32       num_inputs;
00476        UINT32       num_clobbers;
00477      } asm_fields;
00478      struct {
00479        WN          *dummy2;
00480        UINT32       label_flag;
00481      } label_flag_fields;
00482      struct {
00483        WN          *first;
00484        WN          *last;
00485      } block;
00486 
00487       union {
00488         INT64       pragma_arg64;
00489         struct {
00490            INT32    pragma_arg1;
00491            union {
00492              INT32    pragma_arg2;
00493              struct {
00494                mUINT32  pragma_asm_opnd_num : 8;
00495                PREG_NUM pragma_asm_copyout_preg : 24;
00496              } asm_pragma;
00497            };
00498         } up1;
00499         struct {
00500            mINT16   pragma_pad1;
00501            mINT8    pragma_distr_type;
00502            mINT8    pragma_index;
00503            INT32    pragma_preg;
00504         } up2;
00505       } pragma;
00506    } u3;
00507 
00508 #ifndef WN_NO_ACCESSOR_FUNCTIONS
00509 
00510   WN () {}
00511   WN (const WN& wn) { }
00512   WN (const WN* wn) { }
00513   WN& operator= (const WN& wn) { return *this;}
00514   ~WN () {}
00515 
00516 public:
00517 
00518   friend inline WN_OFFSET   WN_load_offset (const WN *);
00519   friend inline WN_OFFSET&  WN_load_offset (WN *);
00520   friend inline WN_OFFSET   WN_lda_offset (const WN *);
00521   friend inline WN_OFFSET&  WN_lda_offset (WN *);
00522   friend inline WN_OFFSET   WN_store_offset (const WN *);
00523   friend inline WN_OFFSET&  WN_store_offset (WN *);
00524   friend inline WN_OFFSET   WN_idname_offset (const WN *);
00525   friend inline WN_OFFSET&  WN_idname_offset (WN *);
00526   friend inline WN_OFFSET   WN_offset (const WN *);
00527   friend inline WN_OFFSET&  WN_offset (WN *);
00528   friend inline INT32       WN_num_entries (const WN *);
00529   friend inline INT32&      WN_num_entries (WN *);
00530 //friend inline TY_IDX      WN_loadx_addr_ty (const WN *);
00531 //friend inline TY_IDX&     WN_loadx_addr_ty (WN *);
00532   friend inline INT16       WN_cvtl_bits (const WN *);
00533   friend inline INT16&      WN_cvtl_bits (WN *);
00534   friend inline INT32&      WN_label_number (WN *);
00535   friend inline INT32       WN_label_number (const WN *);
00536   friend inline UINT32&     WN_call_flag (WN *);
00537   friend inline UINT32      WN_call_flag (const WN *);
00538 
00539   friend inline UINT32&     WN_eq_logical_flag (WN *);
00540   friend inline UINT32      WN_eq_logical_flag (const WN *);
00541 
00542   friend inline UINT32&     WN_if_flag (WN *);
00543   friend inline UINT32      WN_if_flag (const WN *);
00544   friend inline UINT32&     WN_io_flag (WN *);
00545   friend inline UINT32      WN_io_flag (const WN *);
00546   friend inline UINT32&     WN_asm_flag (WN *);
00547   friend inline UINT32      WN_asm_flag (const WN *);
00548   friend inline UINT32&     WN_asm_num_inputs (WN *);
00549   friend inline UINT32      WN_asm_num_inputs (const WN *);
00550   friend inline UINT32&     WN_asm_num_clobbers (WN *);
00551   friend inline UINT32      WN_asm_num_clobbers (const WN *);
00552   friend inline char *      WN_asm_string (const WN *);
00553   friend inline char *      WN_asm_input_constraint (const WN *);
00554   friend inline UINT32      WN_asm_opnd_num(const WN *);
00555   friend inline UINT32&     WN_label_level (WN *);
00556   friend inline UINT32      WN_label_level (const WN *);
00557 
00558   friend inline mUINT16     WN_loop_trip_est (const WN *);
00559   friend inline mUINT16&    WN_loop_trip_est (WN *);
00560   friend inline mUINT16     WN_loop_depth (const WN *);
00561   friend inline mUINT16&    WN_loop_depth (WN *);
00562 
00563   friend inline mUINT16     WN_pragma_flags (const WN *);
00564   friend inline mUINT16&    WN_pragma_flags (WN *);
00565   friend inline mUINT16     WN_pragma (const WN *);
00566   friend inline mUINT16&    WN_pragma (WN *);
00567   friend inline UINT32      WN_pragma_asm_opnd_num (const WN *);
00568   friend inline void        WN_set_pragma_asm_opnd_num (WN *, UINT32);
00569 
00570 //friend inline TY_IDX      WN_io_item_ty (const WN *);
00571 //friend inline TY_IDX&     WN_io_item_ty (WN *);
00572 
00573   friend inline REGION_KIND WN_region_kind (const WN *);
00574   friend inline void        WN_set_region_kind (WN *, REGION_KIND);
00575   friend inline mUINT32     WN_region_id (const WN *);
00576   friend inline void        WN_set_region_id (WN *, mUINT32);
00577 
00578   friend inline ST_IDX      WN_st_idx (const WN *);
00579   friend inline ST_IDX&     WN_st_idx (WN *);
00580 //friend inline TY_IDX      WN_ty (const WN *);
00581 //friend inline TY_IDX&     WN_ty (WN *);
00582   friend inline INTRINSIC   WN_intrinsic (const WN *);
00583   friend inline INTRINSIC&  WN_intrinsic (WN *);
00584   friend inline IOSTATEMENT WN_io_statement(const WN *);
00585   friend inline IOSTATEMENT&  WN_io_statement(WN *);
00586   friend inline IOITEM      WN_io_item(const WN *);
00587   friend inline IOITEM&     WN_io_item(WN *);
00588 //friend inline INT32       WN_num_dim (const WN *);
00589 //friend inline INT32&      WN_num_dim (WN *);
00590   friend inline UINT32      WN_prefetch_flag (const WN *);
00591   friend inline UINT32&     WN_prefetch_flag (WN *);
00592   friend inline UINT32      WN_loop_flag (const WN *);
00593   friend inline UINT32&     WN_loop_flag (WN *);
00594   friend inline INT32       WN_last_label (const WN *);
00595   friend inline INT32&      WN_last_label (WN *);
00596   friend inline INITO_IDX   WN_ereg_supp (const WN *);
00597   friend inline INITO_IDX&  WN_ereg_supp (WN *);
00598 
00599   friend inline WN_ESIZE    WN_element_size (const WN *);
00600   friend inline WN_ESIZE&   WN_element_size (WN *);
00601 
00602   friend inline OPERATOR    WN_operator (const WN *);
00603   friend inline void        WN_set_operator (WN *, OPERATOR);
00604   friend inline TYPE_ID     WN_rtype (const WN *);
00605   friend inline void        WN_set_rtype (WN *, TYPE_ID);
00606   friend inline INT         WN_kid_count (const WN *);
00607   friend inline void        WN_set_kid_count (WN *, UINT);
00608   friend inline UINT        WN_field_id (const WN *);
00609   friend inline void        WN_set_field_id (WN *, UINT);
00610   friend inline UINT        WN_bit_offset (const WN *);
00611   friend inline void        WN_set_bit_offset (WN *, UINT);
00612   friend inline UINT        WN_bit_size (const WN *);
00613   friend inline void        WN_set_bit_size (WN *, UINT);
00614   friend inline TYPE_ID     WN_desc (const WN *);
00615   friend inline void        WN_set_desc (WN *, TYPE_ID);
00616   friend inline INT32       WN_map_id (const WN *);
00617   friend inline INT32&      WN_map_id (WN *);
00618 
00619   friend inline TY_IDX      WN_ty (const WN *, const int);
00620   friend inline TY_IDX&     WN_ty (WN *, const int);
00621   friend inline WN*         WN_kid (const WN *, const int);
00622   friend inline WN*&        WN_kid (WN *, const int);
00623   friend inline WN*         WN_kid0 (const WN *);
00624   friend inline WN*&        WN_kid0 (WN *);
00625   friend inline WN*         WN_kid1 (const WN *);
00626   friend inline WN*&        WN_kid1 (WN *);
00627   friend inline WN*         WN_kid2 (const WN *);
00628   friend inline WN*&        WN_kid2 (WN *);
00629   friend inline WN*         WN_kid3 (const WN *);
00630   friend inline WN*&        WN_kid3 (WN *);
00631   friend inline INT64       WN_const_val (const WN *);
00632   friend inline INT64&      WN_const_val (WN *);
00633   friend inline UINT32      WN_label_flag (const WN *);
00634   friend inline UINT32&     WN_label_flag (WN *);
00635 
00636   friend inline WN*         WN_first (const WN *);
00637   friend inline WN*&        WN_first (WN *);
00638   friend inline WN*         WN_last (const WN *);
00639   friend inline WN*&        WN_last (WN *);
00640 
00641   friend inline INT64       WN_pragma_arg64 (const WN *);
00642   friend inline INT64&      WN_pragma_arg64 (WN *);
00643   friend inline INT32       WN_pragma_arg1 (const WN *);
00644   friend inline INT32&      WN_pragma_arg1 (WN *);
00645   friend inline INT32       WN_pragma_arg2 (const WN *);
00646   friend inline INT32&      WN_pragma_arg2 (WN *);
00647   friend inline mINT8       WN_pragma_distr_type (const WN *);
00648   friend inline mINT8&      WN_pragma_distr_type (WN *);
00649   friend inline mINT8       WN_pragma_index (const WN *);
00650   friend inline mINT8&      WN_pragma_index (WN *);
00651   friend inline INT32       WN_pragma_preg (const WN *);
00652   friend inline INT32&      WN_pragma_preg (WN *);
00653 
00654   friend inline char *      WN_pragma_asm_constraint (const WN *);
00655   friend inline PREG_NUM    WN_pragma_asm_copyout_preg (const WN *);
00656   friend inline void        WN_set_pragma_asm_copyout_preg (WN *, PREG_NUM);
00657 
00658   friend inline OPCODE      WN_opcode (const WN*);
00659   friend inline void        WN_set_opcode (WN*, OPCODE);
00660   friend inline TY_IDX      WN_ty (const WN*);
00661   friend inline void        WN_set_ty (WN*, TY_IDX);
00662   friend inline TY_IDX      WN_load_addr_ty (const WN *);
00663   friend inline void        WN_set_load_addr_ty (WN*, TY_IDX);
00664 
00665   friend inline void        WN_Copy_u1u2 (WN*, const WN*);
00666   friend inline void        WN_Copy_u3 (WN*, const WN*);
00667 
00668 #endif /* WN_NO_ACCESSOR_FUNCTIONS */
00669 };
00670 
00671 #ifndef WN_NO_ACCESSOR_FUNCTIONS
00672 
00673 inline WN_OFFSET  WN_load_offset (const WN* wn) { return wn->u1u2.uu.ua.load_offset; }
00674 inline WN_OFFSET& WN_load_offset (WN* wn) { return wn->u1u2.uu.ua.load_offset; }
00675 inline WN_OFFSET  WN_lda_offset (const WN* wn) { return wn->u1u2.uu.ua.lda_offset; }
00676 inline WN_OFFSET& WN_lda_offset (WN* wn) { return wn->u1u2.uu.ua.lda_offset; }
00677 inline WN_OFFSET  WN_store_offset (const WN* wn) { return wn->u1u2.uu.ua.store_offset; }
00678 inline WN_OFFSET& WN_store_offset (WN* wn) { return wn->u1u2.uu.ua.store_offset; }
00679 inline WN_OFFSET  WN_idname_offset (const WN* wn) { return wn->u1u2.uu.ua.idname_offset; }
00680 inline WN_OFFSET& WN_idname_offset (WN* wn) { return wn->u1u2.uu.ua.idname_offset; }
00681 inline WN_OFFSET  WN_offset (const WN* wn) { return wn->u1u2.uu.ua.idname_offset; }
00682 inline WN_OFFSET& WN_offset (WN* wn) { return wn->u1u2.uu.ua.idname_offset; }
00683 inline INT32  WN_num_entries (const WN* wn) { return wn->u1u2.uu.ua.num_entries; }
00684 inline INT32& WN_num_entries (WN* wn) { return wn->u1u2.uu.ua.num_entries; }
00685 inline INT16 WN_cvtl_bits (const WN* wn) { return wn->u1u2.uu.ua.cvtl_bits; }
00686 inline INT16& WN_cvtl_bits (WN* wn) { return wn->u1u2.uu.ua.cvtl_bits; }
00687 inline INT32 WN_label_number (const WN* wn) { return wn->u1u2.uu.ua.label_number; }
00688 inline INT32& WN_label_number (WN* wn) { return wn->u1u2.uu.ua.label_number; }
00689 inline UINT32 WN_call_flag (const WN* wn) { return wn->u1u2.uu.ua.call_flag; }
00690 inline UINT32& WN_call_flag (WN* wn) { return wn->u1u2.uu.ua.call_flag; }
00691 
00692 inline UINT32 WN_eq_logical_flag (const WN* wn) { return wn->u1u2.uu.ua.eq_logical_flag; }
00693 inline UINT32& WN_eq_logical_flag (WN* wn) { return wn->u1u2.uu.ua.eq_logical_flag; }
00694 
00695 inline UINT32 WN_if_flag (const WN* wn) { return wn->u1u2.uu.ua.if_flag; }
00696 inline UINT32& WN_if_flag (WN* wn) { return wn->u1u2.uu.ua.if_flag; }
00697 inline UINT32 WN_io_flag (const WN* wn) { return wn->u1u2.uu.ua.io_flag; }
00698 inline UINT32& WN_io_flag (WN* wn) { return wn->u1u2.uu.ua.io_flag; }
00699 inline UINT32 WN_asm_flag (const WN *wn) { return wn->u1u2.uu.ua.asm_flag; }
00700 inline UINT32& WN_asm_flag (WN *wn) { return wn->u1u2.uu.ua.asm_flag; }
00701 inline UINT32 WN_label_level (const WN *wn) { return wn->u1u2.uu.ub.label_level; }
00702 inline UINT32& WN_label_level (WN *wn) { return wn->u1u2.uu.ub.label_level; }
00703 inline mUINT16 WN_loop_trip_est (const WN* wn) { return wn->u1u2.uu.ua.li.trip_est; }
00704 inline mUINT16& WN_loop_trip_est (WN* wn) { return wn->u1u2.uu.ua.li.trip_est; }
00705 inline mUINT16 WN_loop_depth (const WN* wn) { return wn->u1u2.uu.ua.li.loop_depth; }
00706 inline mUINT16& WN_loop_depth (WN* wn) { return wn->u1u2.uu.ua.li.loop_depth; }
00707 inline mUINT16 WN_pragma_flags (const WN* wn) { return wn->u1u2.uu.ua.pragma.pragma_flags; }
00708 inline mUINT16& WN_pragma_flags (WN* wn) { return wn->u1u2.uu.ua.pragma.pragma_flags; }
00709 inline mUINT16 WN_pragma (const WN* wn) { return wn->u1u2.uu.ua.pragma.pragma_id; }
00710 inline mUINT16& WN_pragma (WN* wn) { return wn->u1u2.uu.ua.pragma.pragma_id; }
00711 
00712 inline char *WN_pragma_asm_constraint(const WN *wn) { return ST_name(&St_Table[(ST_IDX) WN_pragma_arg1(wn)]); }
00713 inline PREG_NUM WN_pragma_asm_copyout_preg(const WN *wn) { return wn->u3.pragma.up1.asm_pragma.pragma_asm_copyout_preg; }
00714 inline void WN_set_pragma_asm_copyout_preg(WN *wn, PREG_NUM r) { wn->u3.pragma.up1.asm_pragma.pragma_asm_copyout_preg = r; }
00715 inline UINT32 WN_pragma_asm_opnd_num(const WN *wn) { return wn->u3.pragma.up1.asm_pragma.pragma_asm_opnd_num; }
00716 inline void WN_set_pragma_asm_opnd_num(WN *wn, UINT32 i) { wn->u3.pragma.up1.asm_pragma.pragma_asm_opnd_num = i; }
00717 
00718 inline REGION_KIND WN_region_kind (const WN* wn) { return wn->u1u2.uu.ua.region.region_kind; }
00719 inline void WN_set_region_kind (WN* wn, REGION_KIND k) { wn->u1u2.uu.ua.region.region_kind = k; }
00720 inline mUINT32 WN_region_id (const WN* wn) { return wn->u1u2.uu.ua.region.region_id; }
00721 inline void WN_set_region_id (WN* wn, mUINT32 i) { wn->u1u2.uu.ua.region.region_id = i; }
00722 
00723 inline ST_IDX WN_st_idx (const WN* wn) { return wn->u1u2.uu.ub.st_idx; }
00724 inline ST_IDX& WN_st_idx (WN* wn) { return wn->u1u2.uu.ub.st_idx; }
00725 inline INTRINSIC WN_intrinsic (const WN* wn) { return wn->u1u2.uu.ub.intrinsic; }
00726 inline INTRINSIC& WN_intrinsic (WN* wn) { return wn->u1u2.uu.ub.intrinsic; }
00727 inline IOSTATEMENT WN_io_statement(const WN* wn) { return wn->u1u2.uu.ub.iostatement; }
00728 inline IOSTATEMENT& WN_io_statement(WN* wn) { return wn->u1u2.uu.ub.iostatement; }
00729 inline IOITEM WN_io_item(const WN* wn) { return wn->u1u2.uu.ub.ioitem; }
00730 inline IOITEM & WN_io_item(WN* wn) { return wn->u1u2.uu.ub.ioitem; }
00731 inline UINT32 WN_prefetch_flag (const WN* wn) { return wn->u1u2.uu.ub.prefetch_flag; }
00732 inline UINT32& WN_prefetch_flag (WN* wn) { return wn->u1u2.uu.ub.prefetch_flag; }
00733 inline UINT32 WN_loop_flag (const WN* wn) { return wn->u1u2.uu.ub.loop_flag; }
00734 inline UINT32& WN_loop_flag (WN* wn) { return wn->u1u2.uu.ub.loop_flag; }
00735 inline INT32 WN_last_label (const WN* wn) { return wn->u1u2.uu.ub.last_label; }
00736 inline INT32& WN_last_label (WN* wn) { return wn->u1u2.uu.ub.last_label; }
00737 inline INITO_IDX WN_ereg_supp (const WN* wn) { return wn->u1u2.uu.ub.ereg_supp; }
00738 inline INITO_IDX& WN_ereg_supp (WN* wn) { return wn->u1u2.uu.ub.ereg_supp; }
00739 inline WN_ESIZE WN_element_size (const WN* wn) { return wn->u1u2.element_size; }
00740 inline WN_ESIZE& WN_element_size (WN* wn) { return wn->u1u2.element_size; }
00741 
00742 inline OPERATOR   WN_operator (const WN* wn) { return wn->common.wn_operator; }
00743 inline void       WN_set_operator (WN* wn, OPERATOR opr) { wn->common.wn_operator = opr; }
00744 inline TYPE_ID    WN_rtype (const WN* wn) { return wn->common.rtype; }
00745 inline void       WN_set_rtype (WN* wn, TYPE_ID ty) { wn->common.rtype = ty; }
00746 inline INT        WN_kid_count (const WN* wn) { return OPERATOR_nkids(WN_operator(wn)) == -1 ? wn->common.kid_count : OPERATOR_nkids(WN_operator(wn)); }
00747 inline void       WN_set_kid_count (WN* wn, UINT n) { if (OPERATOR_nkids(WN_operator(wn)) == -1) wn->common.kid_count = n; }
00748 inline UINT       WN_field_id (const WN* wn) { return wn->common.kid_count; }
00749 inline void       WN_set_field_id (WN* wn, UINT n) { wn->common.kid_count = (n > MAX_FIELD_ID) ? UNKNOWN_FIELD_ID : n; }
00750 inline UINT       WN_bit_offset (const WN* wn) { return wn->common.kid_count >> 7; }
00751 inline UINT       WN_bit_size (const WN* wn) { return wn->common.kid_count & 0x7f; }
00752 inline void       WN_set_bit_offset_size (WN* wn, UINT ofst, UINT siz) { wn->common.kid_count = ((ofst << 7) + siz); }
00753 inline TYPE_ID    WN_desc (const WN* wn) { return wn->common.desc; }
00754 inline void       WN_set_desc (WN* wn, TYPE_ID ty) { wn->common.desc = ty; }
00755 inline INT32      WN_map_id (const WN* wn) { return wn->common.map_id; }
00756 inline INT32&     WN_map_id (WN* wn) { return wn->common.map_id; }
00757 
00758 inline WN* WN_kid (const WN* wn, const int i) { return wn->u3.kids [i]; }
00759 inline WN*& WN_kid (WN* wn, const int i) { return wn->u3.kids [i]; }
00760 inline WN* WN_kid0 (const WN* wn) { return wn->u3.kids [0]; }
00761 inline WN*& WN_kid0 (WN* wn) { return wn->u3.kids [0]; }
00762 inline WN* WN_kid1 (const WN* wn) { return wn->u3.kids [1]; }
00763 inline WN*& WN_kid1 (WN* wn) { return wn->u3.kids [1]; }
00764 inline WN* WN_kid2 (const WN* wn) { return wn->u3.kids [2]; }
00765 inline WN*& WN_kid2 (WN* wn) { return wn->u3.kids [2]; }
00766 inline WN* WN_kid3 (const WN* wn) { return wn->u3.kids [3]; }
00767 inline WN*& WN_kid3 (WN* wn) { return wn->u3.kids [3]; }
00768 
00769 inline INT64 WN_const_val (const WN* wn) { return wn->u3.const_val; }
00770 inline INT64& WN_const_val (WN* wn) { return wn->u3.const_val; }
00771 inline UINT32 WN_label_flag (const WN* wn) { return wn->u3.label_flag_fields.label_flag; }
00772 inline UINT32& WN_label_flag (WN* wn) { return wn->u3.label_flag_fields.label_flag; }
00773 inline WN* WN_first (const WN* wn) { return wn->u3.block.first; }
00774 inline WN*& WN_first (WN* wn) { return wn->u3.block.first; }
00775 inline WN* WN_last (const WN* wn) { return wn->u3.block.last; }
00776 inline WN*& WN_last (WN* wn) { return wn->u3.block.last; }
00777 inline UINT32 WN_asm_num_inputs (const WN *wn) { return wn->u3.asm_fields.num_inputs; }
00778 inline UINT32& WN_asm_num_inputs (WN *wn) { return wn->u3.asm_fields.num_inputs; }
00779 inline UINT32 WN_asm_opnd_num (const WN *wn) { return wn->u1u2.uu.ua.asm_operand_num; }
00780 inline UINT32& WN_asm_opnd_num (WN *wn) { return wn->u1u2.uu.ua.asm_operand_num; }
00781 inline UINT32 WN_asm_num_clobbers (const WN *wn) { return wn->u3.asm_fields.num_clobbers; }
00782 inline UINT32& WN_asm_num_clobbers (WN *wn) { return wn->u3.asm_fields.num_clobbers; }
00783 inline INT64 WN_pragma_arg64 (const WN* wn) { return wn->u3.pragma.pragma_arg64; }
00784 inline INT64& WN_pragma_arg64 (WN* wn) { return wn->u3.pragma.pragma_arg64; }
00785 inline INT32 WN_pragma_arg1 (const WN* wn) { return wn->u3.pragma.up1.pragma_arg1; }
00786 inline INT32& WN_pragma_arg1 (WN* wn) { return wn->u3.pragma.up1.pragma_arg1; }
00787 inline INT32 WN_pragma_arg2 (const WN* wn) { return wn->u3.pragma.up1.pragma_arg2; }
00788 inline INT32& WN_pragma_arg2 (WN* wn) { return wn->u3.pragma.up1.pragma_arg2; }
00789 inline mINT8 WN_pragma_distr_type (const WN* wn) { return wn->u3.pragma.up2.pragma_distr_type; }
00790 inline mINT8& WN_pragma_distr_type (WN* wn) { return wn->u3.pragma.up2.pragma_distr_type; }
00791 inline mINT8 WN_pragma_index (const WN* wn) { return wn->u3.pragma.up2.pragma_index; }
00792 inline mINT8& WN_pragma_index (WN* wn) { return wn->u3.pragma.up2.pragma_index; }
00793 inline INT32 WN_pragma_preg (const WN* wn) { return wn->u3.pragma.up2.pragma_preg; }
00794 inline INT32& WN_pragma_preg (WN* wn) { return wn->u3.pragma.up2.pragma_preg; }
00795 
00796 
00797 
00798 inline void WN_Copy_u1u2 (WN* dst, const WN* src) { dst->u1u2 = src->u1u2; }
00799 inline void WN_Copy_u3 (WN* dst, const WN* src) { dst->u3 = src->u3; }
00800 
00801 #else
00802 
00803 #define WN_load_offset(x)       ((x)->u1u2.uu.ua.load_offset)
00804 #define WN_lda_offset(x)        ((x)->u1u2.uu.ua.lda_offset)
00805 #define WN_store_offset(x)      ((x)->u1u2.uu.ua.store_offset)
00806 #define WN_idname_offset(x)     ((x)->u1u2.uu.ua.idname_offset)
00807 #define WN_offset(x)            ((x)->u1u2.uu.ua.idname_offset)
00808 #define WN_num_entries(x)       ((x)->u1u2.uu.ua.num_entries)
00809 #define WN_cvtl_bits(x)         ((x)->u1u2.uu.ua.cvtl_bits)
00810 #define WN_label_number(x)      ((x)->u1u2.uu.ua.label_number)
00811 #define WN_call_flag(x)         ((x)->u1u2.uu.ua.call_flag)
00812 
00813 #define WN_eq_logical_flag(x)   ((x)->u1u2.uu.ua.eq_logical_flag)
00814 
00815 #define WN_if_flag(x)           ((x)->u1u2.uu.ua.if_flag)
00816 #define WN_io_flag(x)           ((x)->u1u2.uu.ua.io_flag)
00817 #define WN_asm_flag(x)          ((x)->u1u2.uu.ua.asm_flag)
00818 #define WN_asm_string(x)        (ST_name(WN_st(x)))
00819 #define WN_asm_input_constraint(x) (ST_name(WN_st(x)))
00820 #define WN_loop_trip_est(x)     ((x)->u1u2.uu.ua.li.trip_est)
00821 #define WN_loop_depth(x)        ((x)->u1u2.uu.ua.li.loop_depth)
00822 #define WN_pragma_flags(x)      ((x)->u1u2.uu.ua.pragma.pragma_flags)
00823 #define WN_pragma(x)            ((x)->u1u2.uu.ua.pragma.pragma_id)
00824 #define WN_pragma_asm_constraint(x) (ST_name(&St_Table[(ST_IDX) WN_pragma_arg1(wn)]))
00825 #define WN_pragma_asm_copyout_preg(x) ((PREG_NUM) (x)->u3.pragma.up1.asm_pragma.pragma_asm_copyout_preg)
00826 #define WN_pragma_asm_opnd_num(x) ((x)->u3.pragma.up1.asm_pragma.pragma_asm_opnd_num)
00827 #define WN_region_kind(x)       ((REGION_KIND)((x)->u1u2.uu.ua.region.region_kind))
00828 #define WN_set_region_kind(x,y) ((x)->u1u2.uu.ua.region.region_kind = y)
00829 #define WN_region_id(x)         ((mUINT32)((x)->u1u2.uu.ua.region.region_id))
00830 #define WN_st_idx(x)            ((x)->u1u2.uu.ub.st_idx)
00831 #define WN_intrinsic(x)         ((x)->u1u2.uu.ub.intrinsic)
00832 #define WN_io_statement(x)      ((x)->u1u2.uu.ub.iostatement)
00833 #define WN_io_item(x)           ((x)->u1u2.uu.ub.ioitem)
00834 #define WN_prefetch_flag(x)     ((x)->u1u2.uu.ub.prefetch_flag)
00835 #define WN_loop_flag(x)         ((x)->u1u2.uu.ub.loop_flag)
00836 #define WN_last_label(x)        ((x)->u1u2.uu.ub.last_label)
00837 #define WN_ereg_supp(x)         ((x)->u1u2.uu.ub.ereg_supp)
00838 
00839 #define WN_asm_num_inputs(x)    ((x)->u3.asm_fields.num_inputs)
00840 #define WN_asm_num_clobbers(x)  ((x)->u3.asm_fields.num_clobbers)
00841 
00842 #define WN_asm_opnd_num(x)      ((x)->u1u2.uu.ua.asm_operand_num)
00843 
00844 #define WN_element_size(x)      ((x)->u1u2.element_size)
00845 
00846 #define WN_operator(x)          ((OPERATOR) (x)->common.wn_operator)
00847 #define WN_set_operator(x,y)    ((x)->common.wn_operator = y)
00848 #define WN_rtype(x)             ((TYPE_ID) (x)->common.rtype)
00849 #define WN_set_rtype(x,y)       ((x)->common.rtype = y)
00850 #define WN_kid_count(x)         (OPERATOR_nkids(WN_operator(x)) == -1 ? (x)->common.kid_count : OPERATOR_nkids(WN_operator(x)))
00851 #define WN_set_kid_count(x,y)   if (OPERATOR_nkids(WN_operator(x)) == -1) (x)->common.kid_count = y; else
00852 #define WN_field_id(x)          ((x)->common.kid_count)
00853 #define WN_set_field_id(x,y)    ((x)->common.kid_count = (y > MAX_FIELD_ID) ? UNKNOWN_FIELD_ID : y)
00854 #define WN_bit_offset(x)        ((x)->common.kid_count >> 7)
00855 #define WN_bit_size(x)          ((x)->common.kid_count & 0x7f)
00856 #define WN_set_bit_offset_size(x,y,z) ((x)->common.kid_count = ((y << 7) + z))
00857 #define WN_desc(x)              ((TYPE_ID) (x)->common.desc)
00858 #define WN_set_desc(x,y)        ((x)->common.desc = y)
00859 #define WN_map_id(x)            ((x)->common.map_id)
00860 
00861 #define WN_kid(x,i)             ((x)->u3.kids[i])
00862 #define WN_kid0(x)              WN_kid((x),0)
00863 #define WN_kid1(x)              WN_kid((x),1)
00864 #define WN_kid2(x)              WN_kid((x),2)
00865 #define WN_kid3(x)              WN_kid((x),3)
00866 #define WN_const_val(x)         ((x)->u3.const_val)
00867 #define WN_label_flag(x)        ((x)->u3.label_flag_fields.label_flag)
00868 #define WN_first(x)             ((x)->u3.block.first)
00869 #define WN_last(x)              ((x)->u3.block.last)
00870 #define WN_pragma_arg64(x)      ((x)->u3.pragma.pragma_arg64)
00871 #define WN_pragma_arg1(x)       ((x)->u3.pragma.up1.pragma_arg1)
00872 #define WN_pragma_arg2(x)       ((x)->u3.pragma.up1.pragma_arg2)
00873 #define WN_pragma_distr_type(x) ((x)->u3.pragma.up2.pragma_distr_type)
00874 #define WN_pragma_index(x)      ((x)->u3.pragma.up2.pragma_index)
00875 #define WN_pragma_preg(x)       ((x)->u3.pragma.up2.pragma_preg)
00876 
00877 #define WN_Copy_u1u2(x,y)       ((x)->u1u2 = (y)->u1u2)
00878 #define WN_Copy_u3(x,y)         ((x)->u3 = (y)->u3)
00879 
00880 #endif /* WN_NO_ACCESSOR_FUNCTIONS */
00881 
00882 #define WN_num_dim(x)           (WN_kid_count(x)>>1)
00883 
00884 #define WN_asm_clobbers(x)      (WN_kid0(x))
00885 #define WN_asm_constraints(x)   (WN_kid1(x))
00886 
00887 inline OPCODE
00888 WN_opcode (const WN *wn) {
00889    return OPCODE_make_op (wn->common.wn_operator,
00890                           wn->common.rtype,
00891                           wn->common.desc);
00892 }
00893 
00894 inline void
00895 WN_set_opcode (WN *wn, OPCODE opc) {
00896   wn->common.wn_operator = OPCODE_operator(opc);
00897   wn->common.rtype       = OPCODE_rtype(opc);
00898   wn->common.desc        = OPCODE_desc(opc);
00899 }
00900 
00901 class STMT_WN_BASE {
00902  public:
00903   WN      *prev;
00904   WN      *next;
00905   mUINT64 linenum;
00906 };
00907 
00908 class STMT_WN : public STMT_WN_BASE {
00909 public:
00910   WN       wn;
00911 
00912 #ifndef WN_NO_ACCESSOR_FUNCTIONS
00913   friend inline WN* WN_prev (const WN*);
00914   friend inline WN*& WN_prev (WN*);
00915   friend inline WN* WN_next (const WN*);
00916   friend inline WN*& WN_next (WN*);
00917   friend inline mUINT64 WN_linenum (const WN*);
00918   friend inline mUINT64& WN_linenum (WN*);
00919   friend inline void* WN_StartAddress (WN*);
00920   friend inline WN* WN_prev_free (const STMT_WN*);
00921   friend inline WN*& WN_prev_free (STMT_WN*);
00922   friend inline WN& WN_real_fields (STMT_WN*);
00923 #endif /* WN_NO_ACCESSOR_FUNCTIONS */
00924 };
00925 
00926 //#define WN_OFFSET_IN_STMT_WN (offsetof(STMT_WN,wn))
00927 //#define WN_CAST_WN_TO_STMT_WN(x) ((STMT_WN *)((UINTPS)x - WN_OFFSET_IN_STMT_WN))
00928 
00929 #define WN_CAST_WN_TO_STMT_WN(x) ((STMT_WN *)( (STMT_WN_BASE *)x - 1))
00930 
00931 #ifndef WN_NO_ACCESSOR_FUNCTIONS
00932 inline WN* WN_prev (const WN* wn) { return (WN_CAST_WN_TO_STMT_WN(wn)->prev); }
00933 inline WN*& WN_prev (WN* wn) { return (WN_CAST_WN_TO_STMT_WN(wn)->prev); }
00934 inline WN* WN_next (const WN* wn) { return (WN_CAST_WN_TO_STMT_WN(wn)->next); }
00935 inline WN*& WN_next (WN* wn) { return (WN_CAST_WN_TO_STMT_WN(wn)->next); }
00936 inline mUINT64 WN_linenum (const WN* wn) { return (WN_CAST_WN_TO_STMT_WN(wn)->linenum); }
00937 inline mUINT64& WN_linenum (WN* wn) { return (WN_CAST_WN_TO_STMT_WN(wn)->linenum); }
00938 inline WN* WN_prev_free (const STMT_WN* stmt_wn) { return stmt_wn->prev; }
00939 inline WN*& WN_prev_free (STMT_WN* stmt_wn) { return stmt_wn->prev; }
00940 inline WN& WN_real_fields (STMT_WN* stmt_wn) { return stmt_wn->wn; }
00941 #else
00942 #define WN_next(x)          (WN_CAST_WN_TO_STMT_WN(x)->next)
00943 #define WN_next_func(x)     (WN_CAST_WN_TO_STMT_WN(x)->next)
00944 #define WN_prev(x)          (WN_CAST_WN_TO_STMT_WN(x)->prev)
00945 #define WN_linenum(x)       (WN_CAST_WN_TO_STMT_WN(x)->linenum)
00946 /* Note: the following are only used internally for creating WNs and
00947    maintaining free lists; they should not be used outside of wn.c */
00948 #define WN_real_fields(x)   ((x)->wn)
00949 #define WN_prev_free(x)     ((x)->prev)
00950 #endif /* WN_NO_ACCESSOR_FUNCTIONS */
00951 
00952 #define WN_has_sym(x)           (OPERATOR_has_sym(WN_operator(x)))
00953 
00954 /*REFERENCED*/
00955 inline ST *
00956 WN_st (const WN *x)
00957   {
00958     Is_True(WN_has_sym(x), ("WN_st: wn doesn't have ST field"));
00959     Is_True(ST_IDX_index(WN_st_idx(x)) != 0 ||
00960             WN_st_idx(x) == 0,
00961             ("WN_st: zero index in nonzero level disallowed"));
00962     return (WN_st_idx(x) != 0 ?
00963             &St_Table[WN_st_idx(x)] :
00964             NULL);
00965   }
00966 
00967 #ifndef WN_NO_ACCESSOR_FUNCTIONS
00968 inline char * WN_asm_string(const WN *wn) { return ST_name(WN_st(wn)); }
00969 inline char * WN_asm_input_constraint(const WN *wn) { return ST_name(WN_st(wn)); }
00970 #endif
00971 
00972 #define WN_parm_flag(x)     WN_call_flag(x)
00973 #define WN_region_is_EH(x)  (WN_region_kind(x) & REGION_KIND_EH)
00974 #define WN_label_loop_info(x)   \
00975                 (WN_kid_count(x)>0 ? WN_kid((x),0) : NULL)
00976 #define WN_set_label_loop_info(x,li) (WN_kid0(x) = (li))
00977 
00978 /* for pragma flags */
00979 
00980 #define WN_PRAGMA_COMPILER_GENERATED 0x01
00981 #define WN_PRAGMA_OMP                0x02
00982 
00983 #define WN_pragma_compiler_generated(x) ((WN_pragma_flags(x))&WN_PRAGMA_COMPILER_GENERATED)
00984 #define WN_set_pragma_compiler_generated(x) ((WN_pragma_flags(x))|=WN_PRAGMA_COMPILER_GENERATED)
00985 #define WN_pragma_omp(x) ((WN_pragma_flags(x)) & WN_PRAGMA_OMP)
00986 #define WN_set_pragma_omp(x) ((WN_pragma_flags(x)) |= WN_PRAGMA_OMP)
00987 #define WN_reset_pragma_omp(x) ((WN_pragma_flags(x)) &= ~(WN_PRAGMA_OMP))
00988 
00989 /* for FUNC_ENTRY: */
00990 #define WN_entry_name(x)    WN_st_idx(x)
00991 #define WN_formal(x,i)      WN_kid((x),i)
00992 #define WN_num_formals(x)   (WN_kid_count(x)-3)
00993 #define WN_func_pragmas(x)  WN_kid((x),WN_kid_count(x)-3)
00994 #define WN_func_varrefs(x)  WN_kid((x),WN_kid_count(x)-2)
00995 #define WN_func_body(x)     WN_kid((x),WN_kid_count(x)-1)
00996 #define WN_entry_first(x)   WN_first(WN_func_body(x))
00997 #define WN_entry_last(x)    WN_last(WN_func_body(x))
00998 #define WN_actual(x,i)      WN_kid((x),i)
00999 
01000 /* for DO_LOOP: */
01001 #define WN_index(x)         WN_kid((x),0)
01002 #define WN_start(x)         WN_kid((x),1)
01003 #define WN_end(x)           WN_kid((x),2)
01004 #define WN_step(x)          WN_kid((x),3)
01005 #define WN_do_body(x)       WN_kid((x),4)
01006 #define WN_do_loop_info(x)  \
01007                 (WN_kid_count(x)>5 ? WN_kid((x),5) : NULL)
01008 #define WN_set_do_loop_info(x,li)  (WN_kid((x),5) = (li))
01009 
01010 #define WN_while_test(x)    WN_kid((x),0)
01011 #define WN_while_body(x)    WN_kid((x),1)
01012 
01013 #define WN_if_test(x)       WN_kid((x),0)
01014 #define WN_then(x)          WN_kid((x),1)
01015 #define WN_else(x)          WN_kid((x),2)
01016 #define WN_else_is_empty(x) (WN_first(WN_else(x)) == NULL)
01017 
01018 #define WN_region_exits(x)  WN_kid((x),0)
01019 #define WN_region_pragmas(x) WN_kid((x),1)
01020 #define WN_region_body(x)   WN_kid((x),2)
01021 
01022 #define WN_array_index(x,i) WN_kid((x),WN_num_dim(x)+i+1)
01023 #define WN_array_dim(x,i)   WN_kid((x),i+1)
01024 #define WN_array_base(x)    WN_kid((x),0)
01025 
01026 /* for LOOP_INFO: */
01027 #define WN_loop_induction(x)\
01028                 (WN_kid_count(x)>0 ? WN_kid((x),0) : NULL)
01029 #define WN_set_loop_induction(x,ind) (WN_kid((x),0) = (ind))
01030 #define WN_loop_trip(x)     \
01031                 (WN_kid_count(x)>1 ? WN_kid((x),1) : NULL)
01032 #define WN_set_loop_trip(x,trip) (WN_kid((x),1) = (trip))
01033 
01034 /* for SWITCH: */
01035 #define WN_switch_test(x)       WN_kid((x),0)
01036 #define WN_switch_table(x)      WN_kid((x),1)
01037 #define WN_switch_default(x)    WN_kid((x),2)
01038 
01039 #if (defined(_LP64) || defined(__GNUC__)) && !defined(_SGI_COMPILER_VERSION)
01040 /* workaround for g++ bug */
01041 #else
01042 #define max(a,b)  ((a > b) ? a : b)
01043 #endif
01044 
01045 
01046 
01047 /* ====================================================================
01048  *
01049  * OPERATOR WN_operator(x)
01050  *      Return OPERATOR associated with WN_opcode(x)
01051  *
01052  * BOOL WN_operator_is(x,y)
01053  *      Return true if WN_operator(x) == y
01054  *
01055  * TYPE_ID WN_rtype(x)
01056  * TYPE_ID WN_desc(x)
01057  *      Return type of WN *x
01058  *
01059  * TY *WN_type(x)
01060  *      Return ty of WN *x
01061  *
01062  * ST_CLASS WN_class(x)
01063  *      Return ST_CLASS of WN *x
01064  *
01065  * ST_SCLASS WN_sclass(x)
01066  *      Return ST_SCLASS of WN *x
01067  *
01068  * ====================================================================
01069  */
01070 
01071 /* WN_opcode() compound */
01072 /*
01073 #define WN_operator(x)          (OPCODE_operator(WN_opcode(x)))
01074 #define WN_rtype(x)             (OPCODE_rtype(WN_opcode(x)))
01075 #define WN_desc(x)              (OPCODE_desc(WN_opcode(x)))
01076 */
01077 #define WN_operator_is(x,y)     (WN_operator(x)==(y))
01078 
01079 /* WN_st() compound */
01080 #define WN_class(x)             (ST_class(WN_st(x)))
01081 #define WN_sclass(x)            (ST_sclass(WN_st(x)))
01082 #define WN_type(x)              (ST_type(WN_st(x)))
01083 /*REFERENCED*/
01084 inline TCON&
01085 WN_val (const WN *x)            { return ST_tcon_val (WN_st(x)); }
01086 /*REFERENCED*/
01087 inline TYPE_ID
01088 WN_val_type (const WN *x)       { return TCON_ty (WN_val (x)); }
01089 
01090 
01091 #define WN_has_map_id(x)        (WN_map_id(x)!= -1)
01092 
01093 #define WN_block_empty(x)       (WN_first(x) == NULL)
01094 #define WN_block_nonempty(x)    (WN_first(x) != NULL)
01095 
01096 
01097 
01098 
01099 
01100 /* types */
01101 /*REFERENCED*/
01102 inline TY_IDX WN_ty(const WN *wn)
01103 {
01104   OPERATOR opr;
01105   opr = WN_operator(wn);
01106   if ((opr == OPR_LDA) || (opr == OPR_LDID) || (opr == OPR_STID) ||
01107       (opr == OPR_LDBITS) || (opr == OPR_STBITS)|| (opr == OPR_PSTID)) {
01108     return(wn->u3.ty_fields.ty);
01109   } else if (opr == OPR_IO_ITEM) {
01110     return (wn->u1u2.uu.ua.io_item_ty);
01111   } else {
01112     return (wn->u1u2.uu.ub.ty);
01113   }
01114 }
01115 
01116 /*REFERENCED*/
01117 inline void WN_set_ty(WN *wn, TY_IDX ty)
01118 {
01119   OPERATOR opr;
01120   opr = WN_operator(wn);
01121   if ((opr == OPR_LDA) || (opr == OPR_LDID) || (opr == OPR_STID) ||
01122       (opr == OPR_LDBITS) || (opr == OPR_STBITS)|| (opr == OPR_PSTID)) {
01123     wn->u3.ty_fields.ty = ty;
01124   } else if (opr == OPR_IO_ITEM) {
01125     wn->u1u2.uu.ua.io_item_ty = ty;
01126   } else {
01127     wn->u1u2.uu.ub.ty = ty;
01128   }
01129 }
01130 
01131 
01132 
01133 /*REFERENCED*/
01134 inline TY_IDX WN_load_addr_ty(const WN *wn)
01135 {
01136   OPERATOR opr;
01137   opr = WN_operator(wn);
01138   if (opr == OPR_ILOAD || opr == OPR_ILDBITS) { 
01139     return(wn->u3.ty_fields.ty);
01140   } else {
01141     return (wn->u1u2.uu.ua.loadx_addr_ty);
01142   }
01143 }
01144 
01145 /*REFERENCED*/
01146 inline void WN_set_load_addr_ty(WN *wn, TY_IDX ty)
01147 {
01148   OPERATOR opr;
01149   opr = WN_operator(wn);
01150   if (opr == OPR_ILOAD || opr == OPR_ILDBITS) {
01151     wn->u3.ty_fields.ty = ty;
01152   } else {
01153     wn->u1u2.uu.ua.loadx_addr_ty = ty;
01154   }
01155 }
01156 
01157 
01158 
01159 
01160 /* flags */
01161 /*REFERENCED*/
01162 inline UINT32 WN_flag(const WN *wn)
01163 {
01164   OPERATOR opr;
01165   opr = WN_operator(wn);
01166   switch (opr) {
01167   case OPR_CALL:
01168   case OPR_ICALL:
01169   case OPR_PICCALL:
01170   case OPR_INTRINSIC_CALL:
01171   case OPR_INTRINSIC_OP:
01172   case OPR_REGION:
01173   case OPR_PARM:
01174     return(WN_call_flag(wn));
01175   case OPR_PREFETCH:
01176   case OPR_PREFETCHX:
01177     return(WN_prefetch_flag(wn));
01178   case OPR_IF:
01179     return (WN_if_flag(wn));
01180   case OPR_LOOP_INFO:
01181     return (WN_loop_flag(wn));
01182   case OPR_IO:
01183     return (WN_io_flag(wn));
01184   case OPR_ASM_STMT:
01185     return (WN_asm_flag(wn));
01186 
01187   case OPR_EQ:
01188   case OPR_NE:
01189     return (WN_eq_logical_flag(wn));
01190 
01191   default:
01192     return(WN_label_flag(wn));
01193   }
01194 }
01195 
01196 /*REFERENCED*/
01197 inline void WN_set_flag(WN *wn, UINT32 flag)
01198 {
01199   OPERATOR opr;
01200   opr = WN_operator(wn);
01201   switch (opr) {
01202   case OPR_CALL:
01203   case OPR_ICALL:
01204   case OPR_PICCALL:
01205   case OPR_INTRINSIC_CALL:
01206   case OPR_INTRINSIC_OP:
01207   case OPR_REGION:
01208   case OPR_PARM:
01209     WN_call_flag(wn) = flag;
01210     break;
01211   case OPR_PREFETCH:
01212   case OPR_PREFETCHX:
01213     WN_prefetch_flag(wn) = flag;
01214     break;
01215   case OPR_IF:
01216     WN_if_flag(wn) = flag;
01217     break;
01218   case OPR_IO:
01219     WN_io_flag(wn) = flag;
01220     break;
01221   case OPR_LOOP_INFO:
01222     WN_loop_flag(wn) = flag;
01223     break;
01224   case OPR_EQ:
01225   case OPR_NE:
01226     WN_eq_logical_flag(wn) =flag;
01227 
01228   default:
01229     WN_label_flag(wn) = flag;
01230     break;
01231   }
01232 }
01233 
01234 
01235 /* return starting address of wn */
01236 /*REFERENCED*/
01237 inline void *WN_StartAddress(WN *wn)
01238 {
01239   if (OPCODE_has_next_prev(WN_opcode(wn))) {
01240     return((void *)WN_CAST_WN_TO_STMT_WN(wn));
01241   } else return((void *) wn);
01242 }
01243 
01244 /* return size of wn */
01245 /*REFERENCED*/
01246 inline INT32 WN_Size(WN *wn)
01247 {
01248   INT16 extra_kids = max(0,WN_kid_count(wn)-2);
01249   if (OPCODE_has_next_prev(WN_opcode(wn))) {
01250     return(sizeof(WN) + (2+extra_kids)*sizeof(WN*) + sizeof(mUINT64));
01251   } else {
01252     return(sizeof(WN) + (0+extra_kids)*sizeof(WN*));
01253   }
01254 }
01255 
01256 /*REFERENCED*/
01257 inline void WN_Set_Linenum(WN *wn, INT64 ln)
01258 {
01259   Is_True(OPCODE_has_next_prev(WN_opcode(wn)),
01260         ("can only set line numbers for statements"));
01261   WN_linenum(wn) = ln;
01262 }
01263 
01264 /*REFERENCED*/
01265 inline INT64 WN_Get_Linenum(const WN *wn)
01266 {
01267   if (OPCODE_has_next_prev(WN_opcode(wn))) {
01268     return WN_linenum(wn);
01269   } else {
01270     return 0;
01271   }
01272 }
01273 
01274 
01275 /*REFERENCED*/
01276 inline BOOL WN_Is_Volatile_Mem(const WN *wn)
01277 {
01278   OPCODE opc = WN_opcode(wn);
01279   if (OPCODE_has_1ty(opc) || OPCODE_has_2ty(opc)) {
01280     if (OPCODE_operator(opc) == OPR_ISTORE ||
01281         OPCODE_operator(opc) == OPR_PSTORE ||
01282         OPCODE_operator(opc) == OPR_MSTORE) {
01283       TY_IDX pointed = TY_pointed (Ty_Table[WN_ty (wn)]);
01284       DevAssert(pointed, ("TY_pointed of ISTORE/MSTORE type is NULL"));
01285       return TY_is_volatile(pointed);
01286     } else {
01287       return TY_is_volatile(WN_ty(wn)) ||
01288         OPCODE_has_2ty(opc) && TY_is_volatile(WN_load_addr_ty(wn));
01289     }
01290   }
01291   return FALSE;
01292 }
01293 
01294 
01295 #define WN_IF_IS_GUARD 0x1
01296 #define WN_Is_If_Guard(x)       (WN_if_flag(x) & WN_IF_IS_GUARD)        
01297 #define WN_Set_If_Guard(x)      (WN_if_flag(x) |= WN_IF_IS_GUARD)       
01298 #define WN_Reset_If_Guard(x)    (WN_if_flag(x) &= ~(WN_IF_IS_GUARD))    
01299 
01300 #define WN_IF_IS_MPVERSION 0x2
01301 #define WN_Is_If_MpVersion(x)    (WN_if_flag(x) & WN_IF_IS_MPVERSION)   
01302 #define WN_Set_If_MpVersion(x)   (WN_if_flag(x) |= WN_IF_IS_MPVERSION)  
01303 #define WN_Reset_If_MpVersion(x) (WN_if_flag(x) &= ~(WN_IF_IS_MPVERSION))       
01304 
01305 #define WN_LABEL_BREAK 0x1
01306 #define WN_Label_Is_Break(x)            (WN_label_flag(x) & WN_LABEL_BREAK)
01307 #define WN_Set_Label_Is_Break(x)        (WN_label_flag(x) |= WN_LABEL_BREAK)
01308 #define WN_Reset_Label_Is_Break(x)      (WN_label_flag(x) &= ~(WN_LABEL_BREAK))
01309 
01310 /* WN_loop_flag stuff */
01311 
01312 #define WN_LOOP_INNERMOST 0x1
01313 #define WN_LOOP_WINDDOWN_REG 0x2
01314 #define WN_LOOP_WINDDOWN_CACHE 0x4
01315 #define WN_LOOP_UNIMPORTANT_MISC 0x8
01316 #define WN_LOOP_NZ_TRIP 0x10
01317 
01318 /* Is the trip count estimate based on guessing the size of symbols */
01319 #define WN_LOOP_SYMB_TRIP 0x20
01320 
01321 /* Is the loop an innermost loop */
01322 #define WN_Loop_Innermost(x)            (WN_loop_flag(x) & WN_LOOP_INNERMOST)
01323 #define WN_Set_Loop_Innermost(x)        (WN_loop_flag(x) |= WN_LOOP_INNERMOST)
01324 #define WN_Reset_Loop_Innermost(x)      (WN_loop_flag(x) &= ~WN_LOOP_INNERMOST)
01325 
01326 /* does this loop arise because it is part of register winddown 
01327    from outer unrolling (and therefore its importance is less) */
01328 #define WN_Loop_Winddown_Reg(x)       (WN_loop_flag(x) & WN_LOOP_WINDDOWN_REG)
01329 #define WN_Set_Loop_Winddown_Reg(x)   (WN_loop_flag(x) |= WN_LOOP_WINDDOWN_REG)
01330 #define WN_Reset_Loop_Winddown_Reg(x) \
01331   (WN_loop_flag(x) &= ~WN_LOOP_WINDDOWN_REG)
01332 
01333 /* does this loop arise because it is part of cache winddown 
01334    (and therefore its importance might be less, but probably isn't) */
01335 #define WN_Loop_Winddown_Cache(x) \
01336   (WN_loop_flag(x) & WN_LOOP_WINDDOWN_CACHE)
01337 #define WN_Set_Loop_Winddown_Cache(x) \
01338   (WN_loop_flag(x) |= WN_LOOP_WINDDOWN_CACHE)
01339 #define WN_Reset_Loop_Winddown_Cache(x) \
01340   (WN_loop_flag(x) &= ~WN_LOOP_WINDDOWN_CACHE)
01341 
01342 /* Is this loop deemed to take significantly less execution time than
01343    some other loop, and is therefore need not be optimizes as agressively
01344    at low optimization levels, and is that so for some reason other than
01345    indicated one of the other WN_Loop flags.  Currently, this is only set
01346    for loops that arise from distribution of the imperfect part of a loop
01347    nest. */
01348 #define WN_Loop_Unimportant_Misc(x) \
01349   (WN_loop_flag(x) & WN_LOOP_UNIMPORTANT_MISC)
01350 #define WN_Set_Loop_Unimportant_Misc(x) \
01351   (WN_loop_flag(x) |= WN_LOOP_UNIMPORTANT_MISC)
01352 #define WN_Reset_Loop_Unimportant_Misc(x) \
01353   (WN_loop_flag(x) &= ~WN_LOOP_UNIMPORTANT_MISC)
01354 
01355 #define WN_Loop_Unimportant(x) \
01356   (WN_loop_flag(x) & \
01357    (WN_LOOP_WINDDOWN_CACHE | WN_LOOP_WINDDOWN_REG | WN_LOOP_UNIMPORTANT_MISC))
01358 
01359 #define WN_Loop_Nz_Trip(x)         (WN_loop_flag(x) & WN_LOOP_NZ_TRIP)
01360 #define WN_Set_Loop_Nz_Trip(x)     (WN_loop_flag(x) |= WN_LOOP_NZ_TRIP)
01361 #define WN_Reset_Loop_Nz_Trip(x)   (WN_loop_flag(x) &= ~WN_LOOP_NZ_TRIP)
01362 
01363 #define WN_Loop_Symb_Trip(x)         (WN_loop_flag(x) & WN_LOOP_SYMB_TRIP)
01364 #define WN_Set_Loop_Symb_Trip(x)     (WN_loop_flag(x) |= WN_LOOP_SYMB_TRIP)
01365 #define WN_Reset_Loop_Symb_Trip(x)   (WN_loop_flag(x) &= ~WN_LOOP_SYMB_TRIP)
01366 
01367 #define WN_LABEL_HANDLER_BEGIN 0x2
01368 #define WN_Label_Is_Handler_Begin(x)       (WN_label_flag(x) & \
01369                                             WN_LABEL_HANDLER_BEGIN)
01370 #define WN_Set_Label_Is_Handler_Begin(x)   (WN_label_flag(x) |= \
01371                                             WN_LABEL_HANDLER_BEGIN)
01372 #define WN_Reset_Label_Is_Handler_Begin(x) (WN_label_flag(x) &= \
01373                                           ~(WN_LABEL_HANDLER_BEGIN))
01374 
01375 #define WN_Set_IO_Library(x,y)  (WN_io_flag(x) = (y))
01376 #define WN_IO_Library(x)        ((IOLIB) WN_io_flag(x))
01377 
01378 #define WN_PARM_BY_REFERENCE        0x01
01379 #define WN_PARM_BY_VALUE            0x02
01380 #define WN_PARM_IN                  WN_PARM_BY_VALUE
01381 #define WN_PARM_OUT                 0x04
01382 #define WN_PARM_DUMMY               0x08
01383 /* The next two WN_PARM_READ_ONLY, WN_PARM_PASSED_NOT_SAVED only for C/C++ */
01384 #define WN_PARM_READ_ONLY           0x10 /* parm is only referenced, not
01385                                             modified by the callee */ 
01386 #define WN_PARM_PASSED_NOT_SAVED    0x20 /* parm is passed to callee,
01387                                             however, the callee does not
01388                                             save the address of the parm */
01389 #define WN_PARM_NOT_EXPOSED_USE   0x40  /* there is no exposed use */
01390 #define WN_PARM_IS_KILLED   0x80        /* the parameter is killed, for
01391                                            pass by reference */
01392 
01393 /* following for record detail information about dummy-actual arguments
01394  * association
01395  *  [email protected]
01396  */
01397 # define WN_PARM_PASS_ADDRESS                  0x0100 
01398 # define WN_PARM_PASS_ADDRESS_FROM_DV          0x0200
01399 # define WN_PARM_PASS_DV                       0x0400 
01400 # define WN_PARM_PASS_DV_COPY                  0x0800 
01401 # define WN_PARM_COPY_IN                       0x2000
01402 # define WN_PARM_COPY_IN_COPY_OUT              0x4000
01403 # define WN_PARM_MAKE_DV                       0x8000 
01404 # define WN_PARM_COPY_IN_MAKE_DV               0x010000 
01405 # define WN_PARM_MAKE_NEW_DV                   0x020000 
01406 # define WN_PARM_PASS_SECTION_ADDRESS          0x040000 
01407 # define WN_PARM_CHECK_CONTIG_FLAG             0x080000 
01408 
01409 
01410 #define WN_Parm_By_Reference(x)         (WN_parm_flag(x) & WN_PARM_BY_REFERENCE)
01411 #define WN_Set_Parm_By_Reference(x)     (WN_parm_flag(x) |= WN_PARM_BY_REFERENCE)
01412 #define WN_Clear_Parm_By_Reference(x)   (WN_parm_flag(x) &= ~WN_PARM_BY_REFERENCE)
01413 #define WN_Parm_By_Value(x)             (WN_parm_flag(x) & WN_PARM_BY_VALUE)
01414 #define WN_Set_Parm_By_Value(x)         (WN_parm_flag(x) |= WN_PARM_BY_VALUE)
01415 #define WN_Clear_Parm_By_Value(x)       (WN_parm_flag(x) &= ~WN_PARM_BY_VALUE)
01416 #define WN_Parm_In(x)                   (WN_parm_flag(x) & WN_PARM_IN)
01417 #define WN_Set_Parm_In(x)               (WN_parm_flag(x) |= WN_PARM_IN)
01418 #define WN_Parm_Out(x)                  (WN_parm_flag(x) & WN_PARM_OUT)
01419 #define WN_Set_Parm_Out(x)              (WN_parm_flag(x) |= WN_PARM_OUT)
01420 #define WN_Parm_Dummy(x)                (WN_parm_flag(x) & WN_PARM_DUMMY)
01421 #define WN_Set_Parm_Dummy(x)            (WN_parm_flag(x) |= WN_PARM_DUMMY)
01422 #define WN_Parm_Read_Only(x)            (WN_parm_flag(x) & WN_PARM_READ_ONLY)
01423 #define WN_Set_Parm_Read_Only(x)        (WN_parm_flag(x) |= WN_PARM_READ_ONLY)
01424 #define WN_Parm_Passed_Not_Saved(x)     (WN_parm_flag(x) & WN_PARM_PASSED_NOT_SAVED)
01425 #define WN_Set_Parm_Passed_Not_Saved(x) (WN_parm_flag(x) |= WN_PARM_PASSED_NOT_SAVED)
01426 #define WN_Set_Parm_Not_Exposed_Use(x)  (WN_parm_flag(x) |= WN_PARM_NOT_EXPOSED_USE)
01427 #define WN_Parm_Not_Exposed_Use(x)      (WN_parm_flag(x) & WN_PARM_NOT_EXPOSED_USE)
01428 #define WN_Set_Parm_Is_Killed(x)        (WN_parm_flag(x) |= WN_PARM_IS_KILLED)
01429 #define WN_Parm_Is_Killed(x)            (WN_parm_flag(x) & WN_PARM_IS_KILLED)
01430 
01431 #define WN_Parm_Pass_Address(x)         (WN_parm_flag(x) & WN_PARM_PASS_ADDRESS)
01432 #define WN_Set_Parm_Pass_Address(x)     (WN_parm_flag(x) |= WN_PARM_PASS_ADDRESS)
01433 #define WN_Parm_Pass_Address_From_Dv(x)         (WN_parm_flag(x) & WN_PARM_PASS_ADDRESS_FROM_DV)
01434 #define WN_Set_Parm_Pass_Address_From_Dv(x)     (WN_parm_flag(x) |= WN_PARM_PASS_ADDRESS_FROM_DV)
01435 #define WN_Parm_Pass_Dv(x)         (WN_parm_flag(x) & WN_PARM_PASS_DV)
01436 #define WN_Set_Parm_Pass_Dv(x)     (WN_parm_flag(x) |= WN_PARM_PASS_DV)
01437 #define WN_Parm_Pass_Dv_Copy(x)         (WN_parm_flag(x) & WN_PARM_PASS_DV_COPY)
01438 #define WN_Set_Parm_Pass_Dv_Copy(x)     (WN_parm_flag(x) |= WN_PARM_PASS_DV_COPY)
01439 #define WN_Parm_Copy_In(x)         (WN_parm_flag(x) & WN_PARM_COPY_IN)
01440 #define WN_Set_Parm_Copy_In(x)     (WN_parm_flag(x) |= WN_PARM_COPY_IN)
01441 #define WN_Parm_Copy_In_Copy_out(x)         (WN_parm_flag(x) & WN_PARM_BY_REFERENCE)
01442 #define WN_Set_Parm_Copy_In_Copy_out(x)     (WN_parm_flag(x) |= WN_PARM_COPY_IN_COPY_OUT)
01443 #define WN_Parm_Make_Dv(x)         (WN_parm_flag(x) & WN_PARM_MAKE_DV)
01444 #define WN_Set_Parm_Make_Dv(x)     (WN_parm_flag(x) |= WN_PARM_MAKE_DV)
01445 #define WN_Parm_Copy_In_Make_Dv(x)         (WN_parm_flag(x) & WN_PARM_COPY_IN_MAKE_DV)
01446 #define WN_Set_Parm_Copy_In_Make_Dv(x)     (WN_parm_flag(x) |= WN_PARM_COPY_IN_MAKE_DV)
01447 #define WN_Parm_Make_New_Dv(x)         (WN_parm_flag(x) & WN_PARM_MAKE_NEW_DV)
01448 #define WN_Set_Parm_Make_New_Dv(x)     (WN_parm_flag(x) |= WN_PARM_MAKE_NEW_DV)
01449 #define WN_Parm_Pass_Section_Address(x)         (WN_parm_flag(x) & WN_PARM_PASS_SECTION_ADDRESS)
01450 #define WN_Set_Parm_Pass_Section_Address(x)     (WN_parm_flag(x) |= WN_PARM_PASS_SECTION_ADDRESS)
01451 #define WN_Parm_Check_Contig_Flag(x)         (WN_parm_flag(x) & WN_PARM_CHECK_CONTIG_FLAG)
01452 #define WN_Set_Parm_Check_Contig_Flag(x)     (WN_parm_flag(x) |= WN_PARM_CHECK_CONTIG_FLAG)
01453 
01454 #define WN_EQ_IS_LOGICAL        0x01 /*OPR_EQ or OPR_NE is logical opr */
01455 #define WN_Eq_Is_Logical(x)       (WN_eq_logical_flag(x) & WN_EQ_IS_LOGICAL)
01456 #define WN_Set_Eq_Is_Logical(x)   (WN_eq_logical_flag(x) |= WN_EQ_IS_LOGICAL)
01457 #define WN_Reset_Eq_Is_Logical(x) (WN_eq_logical_flag(x) &= WN_EQ_IS_LOGICAL)
01458 
01459 #define WN_CALL_NEVER_RETURN    0x01 /* call will never return */
01460 #define WN_CALL_NON_DATA_MOD    0x02 /* modifies data not present in program */
01461 #define WN_CALL_NON_PARM_MOD    0x04 /* modifies data whose address is not passed as parameter */
01462 #define WN_CALL_PARM_MOD        0x08 /* modifies data whose address is passed as parameter */
01463 #define WN_CALL_NON_DATA_REF    0x10 /* references data not present in program */
01464 #define WN_CALL_NON_PARM_REF    0x20 /* references data whose address is not passed as parameter */
01465 #define WN_CALL_PARM_REF        0x40 /* references data whose address is passed as parameter */
01466 #define WN_CALL_INLINE          0x80 /* marked for IPA to attempt to inline */
01467 #define WN_CALL_DONT_INLINE     0x100   /* marked for IPA to not inline */
01468 #define WN_CALL_DOES_MEM_ALLOC  0x200   /* malloc_like function */
01469 #define WN_CALL_DOES_MEM_FREE   0x400   /* free_like function */
01470 #define WN_CALL_FORTRAN_POINTER_RULE 0x800 /* call obeys fortran semantics as
01471                                               regards points-to
01472                                               relationships */
01473 #define WN_CALL_REPLACE_BY_JUMP 0x1000  /* replace call by jump in thunks */
01474 
01475      /* Some flags make promises when they're clear, and others when
01476       * they're set. The following macro tells us which are
01477       * which. Make sure to update the macro when you add a new
01478       * WN_CALL_* flag.
01479       */
01480 #define WN_CALL_CONSERVATIVE    (WN_CALL_NON_DATA_MOD | \
01481                                  WN_CALL_NON_PARM_MOD | \
01482                                  WN_CALL_PARM_MOD     | \
01483                                  WN_CALL_NON_DATA_REF | \
01484                                  WN_CALL_NON_PARM_REF | \
01485                                  WN_CALL_PARM_REF)
01486 
01487 #define WN_Call_Never_Return(x)         (WN_call_flag(x) & WN_CALL_NEVER_RETURN)
01488 #define WN_Set_Call_Never_Return(x)     (WN_call_flag(x) |= WN_CALL_NEVER_RETURN)
01489 #define WN_Reset_Call_Never_Return(x)   (WN_call_flag(x) &= ~WN_CALL_NEVER_RETURN)
01490 #define WN_Call_Non_Data_Mod(x)         (WN_call_flag(x) & WN_CALL_NON_DATA_MOD)
01491 #define WN_Set_Call_Non_Data_Mod(x)     (WN_call_flag(x) |= WN_CALL_NON_DATA_MOD)
01492 #define WN_Reset_Call_Non_Data_Mod(x)   (WN_call_flag(x) &= ~WN_CALL_NON_DATA_MOD)
01493 #define WN_Call_Non_Data_Ref(x)         (WN_call_flag(x) & WN_CALL_NON_DATA_REF)
01494 #define WN_Set_Call_Non_Data_Ref(x)     (WN_call_flag(x) |= WN_CALL_NON_DATA_REF)
01495 #define WN_Reset_Call_Non_Data_Ref(x)   (WN_call_flag(x) &= ~WN_CALL_NON_DATA_REF)
01496 #define WN_Call_Non_Parm_Mod(x)         (WN_call_flag(x) & WN_CALL_NON_PARM_MOD)
01497 #define WN_Set_Call_Non_Parm_Mod(x)     (WN_call_flag(x) |= WN_CALL_NON_PARM_MOD)
01498 #define WN_Reset_Call_Non_Parm_Mod(x)   (WN_call_flag(x) &= ~WN_CALL_NON_PARM_MOD)
01499 #define WN_Call_Non_Parm_Ref(x)         (WN_call_flag(x) & WN_CALL_NON_PARM_REF)
01500 #define WN_Set_Call_Non_Parm_Ref(x)     (WN_call_flag(x) |= WN_CALL_NON_PARM_REF)
01501 #define WN_Reset_Call_Non_Parm_Ref(x)   (WN_call_flag(x) &= ~WN_CALL_NON_PARM_REF)
01502 #define WN_Call_Parm_Mod(x)             (WN_call_flag(x) & WN_CALL_PARM_MOD)
01503 #define WN_Set_Call_Parm_Mod(x)         (WN_call_flag(x) |= WN_CALL_PARM_MOD)
01504 #define WN_Reset_Call_Parm_Mod(x)       (WN_call_flag(x) &= ~WN_CALL_PARM_MOD)
01505 #define WN_Call_Parm_Ref(x)             (WN_call_flag(x) & WN_CALL_PARM_REF)
01506 #define WN_Set_Call_Parm_Ref(x)         (WN_call_flag(x) |= WN_CALL_PARM_REF)
01507 #define WN_Reset_Call_Parm_Ref(x)       (WN_call_flag(x) &= ~WN_CALL_PARM_REF)
01508 #define WN_Call_Inline(x)               (WN_call_flag(x) & WN_CALL_INLINE)
01509 #define WN_Set_Call_Inline(x)           (WN_call_flag(x) |= WN_CALL_INLINE)
01510 #define WN_Reset_Call_Inline(x)         (WN_call_flag(x) &= ~WN_CALL_INLINE)
01511 #define WN_Call_Dont_Inline(x)          (WN_call_flag(x) & WN_CALL_DONT_INLINE)
01512 #define WN_Set_Call_Dont_Inline(x)      (WN_call_flag(x) |= WN_CALL_DONT_INLINE)
01513 #define WN_Reset_Call_Dont_Inline(x)    (WN_call_flag(x) &= ~WN_CALL_DONT_INLINE)
01514 #define WN_Call_Does_Mem_Alloc(x)       (WN_call_flag(x) & WN_CALL_DOES_MEM_ALLOC)
01515 #define WN_Set_Call_Does_Mem_Alloc(x)   (WN_call_flag(x) |= WN_CALL_DOES_MEM_ALLOC)
01516 #define WN_Reset_Call_Does_Mem_Alloc(x) (WN_call_flag(x) &= ~WN_CALL_DOES_MEM_ALLOC)
01517 #define WN_Call_Does_Mem_Free(x)        (WN_call_flag(x) & WN_CALL_DOES_MEM_FREE)
01518 #define WN_Set_Call_Does_Mem_Free(x)    (WN_call_flag(x) |= WN_CALL_DOES_MEM_FREE)
01519 #define WN_Reset_Call_Does_Mem_Free(x)  (WN_call_flag(x) &= ~WN_CALL_DOES_MEM_FREE)
01520 #define WN_Call_Fortran_Pointer_Rule(x) (WN_call_flag(x) & WN_CALL_FORTRAN_POINTER_RULE)
01521 #define WN_Set_Call_Fortran_Pointer_Rule(x) \
01522                                         (WN_call_flag(x) |= WN_CALL_FORTRAN_POINTER_RULE)
01523 #define WN_Reset_Call_Fortran_Pointer_Rule(x) \
01524                                         (WN_call_flag(x) &= ~WN_CALL_FORTRAN_POINTER_RULE)
01525 #define WN_Call_Replace_By_Jump(x)      (WN_call_flag(x) & WN_CALL_REPLACE_BY_JUMP)
01526 #define WN_Set_Call_Replace_By_Jump(x)  (WN_call_flag(x) |= WN_CALL_REPLACE_BY_JUMP)
01527 #define WN_Reset_Call_Replace_By_Jump(x) (WN_call_flag(x) &= ~WN_CALL_REPLACE_BY_JUMP)
01528 
01529 #define WN_Set_Call_Default_Flags(x)    (WN_call_flag(x) |= WN_CALL_CONSERVATIVE)
01530 #define WN_Call_No_Side_Effect(x)       ((WN_call_flag(x) & (WN_CALL_NON_DATA_MOD | WN_CALL_NON_PARM_MOD | WN_CALL_PARM_MOD)) == 0)
01531 #define WN_Call_Pure(x)                 ((WN_call_flag(x) & (WN_CALL_NON_DATA_MOD | WN_CALL_NON_PARM_MOD | WN_CALL_PARM_MOD | WN_CALL_NON_DATA_REF | WN_CALL_NON_PARM_REF)) == 0)
01532 
01533 /* Macros for OPR_ASM_STMT flag access */
01534 
01535 #define WN_ASM_VOLATILE         0x0001
01536 #define WN_ASM_CLOBBERS_MEM     0x0002
01537 #define WN_ASM_CLOBBERS_CC      0x0004
01538 
01539 #define WN_Asm_Volatile(x)              (WN_asm_flag(x) & WN_ASM_VOLATILE)
01540 #define WN_Set_Asm_Volatile(x)          (WN_asm_flag(x) |= WN_ASM_VOLATILE)
01541 #define WN_Reset_Asm_Volatile(x)        (WN_asm_flag(x) &= ~WN_ASM_VOLATILE)
01542 #define WN_Asm_Clobbers_Mem(x)          (WN_asm_flag(x) & WN_ASM_CLOBBERS_MEM)
01543 #define WN_Set_Asm_Clobbers_Mem(x)      (WN_asm_flag(x) |= WN_ASM_CLOBBERS_MEM)
01544 #define WN_Reset_Asm_Clobbers_Mem(x)    (WN_asm_flag(x) &= ~WN_ASM_CLOBBERS_MEM)
01545 #define WN_Asm_Clobbers_Cc(x)           (WN_asm_flag(x) & WN_ASM_CLOBBERS_CC)
01546 #define WN_Set_Asm_Clobbers_Cc(x)       (WN_asm_flag(x) |= WN_ASM_CLOBBERS_CC)
01547 #define WN_Reset_Asm_Clobbers_Cc(x)     (WN_asm_flag(x) &= ~WN_ASM_CLOBBERS_CC)
01548 
01549 /*
01550  *  Changed to inline function for compatibility.
01551  *  The actual number of kids (kid_count) may be much larger
01552  *  as dummy node are created to encapsulate variables used/modified by 
01553  *  the routine.
01554  *
01555  *      #define WN_num_actuals(x)   (WN_kid_count(x))
01556  */
01557 /*REFERENCED*/
01558 inline mINT16 WN_num_actuals(const WN *wn)
01559 {
01560   INT32 n= WN_kid_count(wn);
01561   INT32 i;
01562   OPERATOR opr = WN_operator(wn);
01563 
01564   /* for indirect calls, the last kid is the address of the procedure 
01565    * being called. So, skip it while counting the parameters. 
01566    */
01567   if (opr == OPR_ICALL || opr == OPR_PICCALL) n--;
01568 
01569   for(i= n-1; i>=0; i--)
01570   {
01571     WN *kid = WN_kid(wn,i);
01572     if (!kid) { continue; } /* eraxxon: handle buggy WHIRL (from mfef90) */
01573 
01574     OPERATOR kid_opr = WN_operator(kid);
01575     if ( (kid_opr != OPR_PARM) || !WN_Parm_Dummy(kid) )
01576     {
01577       return i+1;
01578     }
01579   }
01580   return 0;
01581 }
01582 
01583 /* Flag structure in a prefetch node, and macros to manipulate the flag */
01584 
01585 /***********************************************************************
01586  *
01587  * flag structure
01588  *    3322 2222 2222 1111 1111 11  
01589  *    1098 7654 3210 9876 5432 1098 7654 3210
01590  *    xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx
01591  *                                  ^^^^^^^^^ 1st-lev stride   (8 bits,  0.. 7)
01592  *                        ^^^^^^^^^           2nd-lev stride   (8 bits,  8..15)
01593  *              ^^^^^^^^^                     unused           (8 bits, 16..23)
01594  *            ^                               read(0)/write(1) (1 bit,  24)
01595  *           ^                                1 if manual prefetch  (1 bit, 25)
01596  *         ^^                                 unused           (2 bits, 26..27)
01597  *    ^^^^                                    confidence #     (4 bits, 28..31)
01598  *
01599  ***********************************************************************/
01600 
01601 #define PF_GET_READ(flag)       (((~(flag)) >> 24) & 0x1)
01602 #define PF_GET_WRITE(flag)      (((flag)  >> 24) & 0x1)
01603 #define PF_GET_STRIDE_1L(flag)  ((flag)  & 0xff)
01604 #define PF_GET_STRIDE_2L(flag)  (((flag) >> 8)   & 0xff)
01605 #define PF_GET_CONFIDENCE(flag) (((flag) >> 28)  & 0xf)
01606 #define PF_GET_MANUAL(flag)     (((flag) >> 25) & 0x1)
01607 
01608 #define PF_SET_READ(flag)          flag &= 0xfeffffff
01609 #define PF_SET_WRITE(flag)         flag |= 0x01000000
01610 #define PF_SET_STRIDE_1L(flag, x)  flag = (((flag)&0xffffff00) | ((x)&0xff))
01611 #define PF_SET_STRIDE_2L(flag, x)  flag = (((flag)&0xffff00ff) | ((x)&0xff)<<8)
01612 #define PF_SET_CONFIDENCE(flag, x) flag = (((flag)&0x0fffffff) | ((x)&0xf)<<28)
01613 #define PF_SET_MANUAL(flag)        flag |= 0x02000000
01614 #define PF_UNSET_MANUAL(flag)      flag &= 0xfdffffff
01615 
01616 #define WN_pf_read(wn)       (((~(WN_prefetch_flag(wn))) >> 24) & 0x1)
01617 #define WN_pf_write(wn)      (((WN_prefetch_flag(wn))  >> 24) & 0x1)
01618 #define WN_pf_stride_1L(wn)  ((WN_prefetch_flag(wn))  & 0xff)
01619 #define WN_pf_stride_2L(wn)  (((WN_prefetch_flag(wn)) >> 8)   & 0xff)
01620 #define WN_pf_confidence(wn) (((WN_prefetch_flag(wn)) >> 28)  & 0xf)
01621 #define WN_pf_manual(wn)     (((WN_prefetch_flag(wn)) >> 25) & 0x1)
01622 
01623 #define WN_pf_set_read(wn)          WN_prefetch_flag(wn) &= 0xfeffffff
01624 #define WN_pf_set_write(wn)         WN_prefetch_flag(wn) |= 0x01000000
01625 #define WN_pf_set_stride_1L(wn, x)  WN_prefetch_flag(wn) = (((WN_prefetch_flag(wn))&0xffffff00) | ((x)&0xff))
01626 #define WN_pf_set_stride_2L(wn, x)  WN_prefetch_flag(wn) = (((WN_prefetch_flag(wn))&0xffff00ff) | ((x)&0xff)<<8)
01627 #define WN_pf_set_confidence(wn, x) WN_prefetch_flag(wn) = (((WN_prefetch_flag(wn))&0x0fffffff) | ((x)&0xf)<<28)
01628 #define WN_pf_set_manual(wn)        WN_prefetch_flag(wn) |= 0x02000000
01629 #define WN_pf_unset_manual(wn)      WN_prefetch_flag(wn) &= 0xfdffffff
01630 
01631 /* end prefetch macros */
01632 
01633 /*
01634 //Some helper functions for handling struct field accesses
01635 unsigned int Get_Num_Fields(TY_IDX base) {
01636 
01637   if (!TY_Is_Structured(base)) {
01638     return 0;
01639   }
01640   
01641   int num = 0;
01642   FLD_HANDLE fh = TY_fld(base); 
01643   while (true) {
01644     num++;
01645     TY_IDX fld_ty = FLD_type(fh);
01646     num += Get_Num_Fields(fld_ty);
01647     if (FLD_last_field(fh)) {
01648       break;
01649     }
01650     fh = FLD_next(fh);
01651   } 
01652   return num;
01653 }
01654 
01655 TY_IDX Get_Field_Type(TY_IDX base, int field_id) {
01656 
01657   Is_True(TY_Is_Structured(base), ("CALLING GET_FIELD_TYPE with a non struct type"));
01658 
01659   FLD_HANDLE fh = TY_fld(base);
01660   for (int i = 1; i < field_id; i++, fh = FLD_next(fh)) {
01661     TY_IDX fld_ty = FLD_type(fh);
01662     int num_subfld = Get_Num_Fields(fld_ty);
01663     if (i + num_subfld >= field_id) {
01664       return Get_Field_Type(fld_ty, field_id - i);
01665     } else {
01666       i += num_subfld;
01667     }
01668   }
01669   return FLD_type(fh);
01670 }
01671 */
01672 
01673 #endif /* wn_core_INCLUDED */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines