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
00666 #ifndef lnoutils_INCLUDED
00667 #define lnoutils_INCLUDED "lnoutils.h"
00668
00669 class WN;
00670
00671 #ifndef defs_INCLUDED
00672 #include "defs.h"
00673 #endif
00674 #ifndef ERRORS_INCLUDED
00675 #include "errors.h"
00676 #endif
00677 #ifndef CXX_MEMORY_INCLUDED
00678 #include "cxx_memory.h"
00679 #endif
00680 #ifndef wn_INCLUDED
00681 #include "wn.h"
00682 #endif
00683 #ifndef stab_INCLUDED
00684 #include "stab.h"
00685 #endif
00686 #ifndef dep_graph_INCLUDED
00687 #include "dep_graph.h"
00688 #endif
00689 #ifndef region_util_INCLUDED
00690 #include "region_util.h"
00691 #endif
00692 #ifndef NAME_DECLARE
00693 #include "name.h"
00694 #endif
00695
00696
00697
00698
00699
00700 class DU_MANAGER;
00701
00702 class LS_IN_LOOP {
00703 friend class LS_IN_LOOP_ITER;
00704 private:
00705 enum {HT_ELTS=247};
00706 HASH_TABLE<WN*,INT> _ht;
00707 void Lexorder(WN* wn, ARRAY_DIRECTED_GRAPH16* dg, INT* lex,
00708 BOOL include_scalars = FALSE);
00709 public:
00710 LS_IN_LOOP(WN* loop, ARRAY_DIRECTED_GRAPH16*, MEM_POOL* pool,
00711 BOOL use_scalars = FALSE);
00712 INT In(WN* wn) {return _ht.Find(wn);}
00713 INT Depth;
00714 INT Good_Depth;
00715 WN* Loop;
00716 };
00717
00718 class LS_IN_LOOP_ITER {
00719 private:
00720 HASH_TABLE_ITER<WN*,INT> _hti;
00721 public:
00722 LS_IN_LOOP_ITER(LS_IN_LOOP* a) : _hti(&a->_ht) {}
00723 WN* Step() {WN* wn; INT lex; BOOL b = _hti.Step(&wn, &lex);
00724 return b ? wn : NULL;}
00725 };
00726
00727 extern INT32 Dot_Product(const mINT32* v1, const mINT32* v2, INT count);
00728 extern INT64 Dot_Product(const mINT64* v1, const mINT64* v2, INT count);
00729 extern INT64 Dot_Product(const mINT32* v1, const mINT64* v2, INT count);
00730 extern INT64 Dot_Product(const mINT64* v1, const mINT32* v2, INT count);
00731 extern void Update_MP_Local_Var(ST* st, WN_OFFSET offset, WN *wn);
00732
00733 extern void Dump_WN(WN*, FILE*, INT, INT = 2, INT = 2,
00734 ARRAY_DIRECTED_GRAPH16* =NULL, WN** = NULL, WN* = NULL,
00735 BOOL recursive = TRUE);
00736
00737
00738
00739 extern WN* LWN_Make_Icon(TYPE_ID wtype, INT64 i);
00740
00741 extern TYPE_ID Do_Wtype(WN* wn);
00742
00743 extern TYPE_ID Max_Wtype(TYPE_ID a, TYPE_ID b);
00744
00745 extern INT64 Step_Size(WN* loop,
00746 INT64 newstep);
00747
00748 extern INT64 Step_Size(WN* loop);
00749
00750 extern INT Do_Depth(WN* wn, WN** loops = NULL, INT mx = 0);
00751
00752 extern INT Good_Do_Depth(WN* wn, WN** loops = NULL, INT mx = 0);
00753
00754 extern void Build_Doloop_Stack(WN* wn, DOLOOP_STACK* stack);
00755
00756 extern void Replace_Symbol(WN* wn, SYMBOL symold, SYMBOL symnew,
00757 WN*, WN* = NULL);
00758
00759 extern void Replace_Symbols(WN* wn, SYMBOL* sold, SYMBOL* snew, INT count,
00760 WN**, WN** = NULL);
00761
00762 extern BOOL Add_To_Symbol(WN* wn, INT64 i, ST* st,
00763 WN_OFFSET offset, TYPE_ID wtype, BOOL = FALSE);
00764 extern BOOL Add_To_Symbol(WN* wn, INT64 i, SYMBOL symbol, BOOL = FALSE);
00765
00766 extern WN* Replace_Wnexp_With_Exp_Copy(WN* wn, WN* expr, DU_MANAGER* =NULL,
00767 BOOL* =NULL,ARRAY_DIRECTED_GRAPH16 *dep_graph=NULL);
00768 extern WN* Replace_Scalar_Store_With_Array_Store(WN* scalar_store,
00769 WN* array_store, DU_MANAGER* =NULL);
00770
00771 extern void Replace_Ldid_With_Exp_Copy(SYMBOL, WN* wn, WN* expr,
00772 DU_MANAGER *du=NULL, ARRAY_DIRECTED_GRAPH16 *dep_graph=NULL);
00773
00774 extern WN* LWN_Integer_Cast(WN* tree, TYPE_ID to, TYPE_ID from);
00775
00776 extern WN* LWN_Integer_Casts(WN* tree, TYPE_ID to, TYPE_ID from);
00777
00778 extern SYMBOL Create_Preg_Symbol(const char* name, TYPE_ID type);
00779
00780 extern SYMBOL Create_Stack_Symbol(const char* name, TYPE_ID type);
00781
00782 extern ST* Lookup_Function_Name(const char* name);
00783
00784 extern void Reset_Do_Loop_Depths(WN* loop, INT depth);
00785
00786 enum DIFFERENCE_KIND {
00787 DIFFERENCE_EXEC_NEVER,
00788 DIFFERENCE_EXEC_NEVER_OR_ONCE,
00789 DIFFERENCE_EXEC_ALWAYS
00790 };
00791
00792 ACCESS_VECTOR* Difference_Inequality(ACCESS_VECTOR* lb,
00793 ACCESS_VECTOR* ub,
00794 INT var,
00795 DIFFERENCE_KIND code,
00796 MEM_POOL* pool);
00797 extern void Print_Def_Use(WN *func_nd, FILE *fp);
00798 extern BOOL Statically_Safe_Exp(WN *wn);
00799 extern void Unrolled_DU_Update(WN **bodies, UINT u, INT loopno, BOOL = TRUE,
00800 BOOL cross_index=TRUE);
00801 extern ST *Get_ST_Base(WN *load);
00802 extern BOOL Index_Variable_Live_At_Entry(WN* loop);
00803 extern BOOL Index_Variable_Live_At_Exit(WN* loop);
00804 extern WN* Outermost_Enclosing_Loop(WN* loop);
00805 extern void Finalize_Index_Variable(WN *wn, BOOL insert_after_loop=TRUE,
00806 BOOL try_sink=FALSE);
00807 extern void Finalize_Index_Variable_For_Remove_Unity_Trip_Loop(WN *wn,
00808 BOOL insert_after_loop=TRUE, BOOL try_sink=FALSE);
00809 extern void LNO_Erase_Vertices_In_Loop(WN* wn,ARRAY_DIRECTED_GRAPH16* dg);
00810 extern void Du_Sanity_Check(WN* wn, FILE* fp=stdout, UINT fancy=2);
00811 extern void IV_Loop_Stmt_Check(WN* wn, MEM_POOL* pool);
00812 extern void FB_Sanity_Check(WN *wn);
00813 extern WN* WN_prev_executable(WN* wn);
00814 extern WN* WN_next_executable(WN* wn);
00815 extern BOOL Wn_Is_Inside(WN* inner, const WN* outer);
00816 extern INT Which_Loop_Inside(WN* ref, const DOLOOP_STACK& stack, INT first);
00817 extern INT Which_Loop_Inside(WN* ref, const DOLOOP_STACK& stack);
00818 extern BOOL Upper_Bound_Standardize(WN* ub, BOOL = FALSE);
00819 extern INT64 LWN_Get_Linenum(const WN *wn);
00820 extern BOOL Is_Permutation_Vector(const INT order[], INT count);
00821 extern BOOL Are_Permutations(const INT* order1, const INT* order2, INT count);
00822 extern BOOL Is_Loop_Invariant_Use(WN* wn, WN* outerloop);
00823 extern BOOL Is_Loop_Invariant_Exp(WN* wn, WN* outerloop);
00824 extern HASH_TABLE<WN*,WN*>* Make_Loop_Mapping(WN*, WN*, MEM_POOL*);
00825 extern HASH_TABLE<WN*,BOOL>* Find_Loops_Within(WN* orig, MEM_POOL*);
00826 extern INT Num_Common_Loops(WN *wn1, WN *wn2);
00827 extern WN* LNO_Common_Loop(WN *wn1, WN *wn2);
00828 extern BOOL Equivalent_Access_Arrays(ACCESS_ARRAY *array1,
00829 ACCESS_ARRAY *array2, WN *wn1, WN *wn2);
00830 extern WN* Enclosing_Do_Loop(WN* wn);
00831 extern WN* Enclosing_Loop(WN* wn);
00832 extern WN* Enclosing_Loop_Body(WN* wn);
00833 extern BOOL Loop_Is_Trapezoidal(WN* wn_loop, ARRAY_DIRECTED_GRAPH16* dg,
00834 DU_MANAGER* du);
00835 extern void Remove_Redundant_Stids(WN* wn_start, DU_MANAGER* du);
00836 extern OPCODE Matching_Load_Opcode(OPCODE store_op);
00837 extern WN* Create_ILoad_From_IStore(WN* wn_store, DU_MANAGER* du,
00838 ARRAY_DIRECTED_GRAPH16* dg);
00839 extern BOOL Is_Local_Array_Reference(WN* array);
00840 extern BOOL Is_Mp_Region(WN *wn);
00841 #ifdef KEY
00842 extern BOOL Is_Eh_Or_Try_Region(WN *wn);
00843 #endif
00844 extern BOOL Do_Loop_Is_Mp(WN *wn);
00845 extern RID* Get_Enclosing_Region_ID(WN *wn);
00846 extern BOOL Is_Nested_Doacross(WN* wn_loop);
00847 extern void Remark_Depth(WN *wn, mUINT8 depth);
00848
00849 extern WN* UBexp(WN* end, BOOL* ne = NULL);
00850 extern WN* UBvar(WN* end);
00851
00852 extern BOOL Solve_For(WN* wn_top, const SYMBOL& sym);
00853 extern INT Loop_Depth(WN* stat);
00854 extern INT Block_Loop_Depth(WN* stat);
00855 extern BOOL Do_Loop_Is_Unsigned(WN* wn_loop);
00856 extern WN* Outer_Tile(WN* wn_loop, DU_MANAGER* du);
00857
00858 extern void Add_Pragma_To_MP_Region (const WN* wn,
00859 ST* st,
00860 WN_OFFSET offset,
00861 WN_PRAGMA_ID pragma_id,
00862 BOOL make_compiler_generated=FALSE);
00863
00864 extern WN* Return_Node(WN* wn_func_nd);
00865 extern WN* Loop_Step(WN* wn_loop);
00866 extern WN* Common_Loop_Ancestor(WN* wn1, WN* wn2);
00867 extern BOOL Statically_Safe_Node(WN* wn);
00868 extern void Build_Parent_Stack(WN* wn, STACK<WN*>* stack);
00869 extern WN* Common_Ancestor(WN* wn1, WN* wn2);
00870 extern BOOL Is_Lex_Before(WN* wn1, WN* wn2);
00871 extern INT Symbol_Count(WN* wn, const SYMBOL& sym);
00872 extern WN* Find_Node(SYMBOL sym, WN* wn_tree);
00873 extern BOOL Identity_Permutation(INT permutation[], INT nloops);
00874 extern WN* Trip_Count(WN* wn_loop);
00875 extern INT Reduce_Permutation(INT permutation[], INT nloops,
00876 INT spermutation[], INT max_reduction);
00877 extern BOOL Index_Variable(WN* wn_index);
00878 extern BOOL Contains_Dedicated_Preg(WN* wn_tree);
00879 extern INT Factorial(INT n);
00880 extern void Permutation(INT order, INT nloops, INT permutation[]);
00881 extern INT WN_Whirl_Linenum(WN* wn);
00882 extern void Constant_Propogate(WN *stid, INT64 const_val);
00883 extern WN* Messy_Subscript(WN* wn_array);
00884 extern void Replace_Index_Variable(WN* loop, WN* cp_loop, const char prefix[]);
00885 extern WN* Enclosing_Proper_Do_Loop(WN* wn_ref);
00886 extern void Create_Single_Region(WN* wn_single, WN* wn_end);
00887
00888 #ifdef Is_True_On
00889 extern void LNO_Check_Du(WN* orig);
00890 extern void LNO_Check_Graph(ARRAY_DIRECTED_GRAPH16* dg);
00891 extern void MP_Sanity_Check_Func(WN *func_nd);
00892 #endif
00893
00894 #ifdef TARG_X8664 //introduced by bug 10953
00895 extern WN *Simple_Invariant_Stride_Access(WN *array, WN *loop);
00896 #endif
00897
00898 #endif // LNOUTILS_DECLARE