Open64 (mfef90, whirl2f, and IR tools)
TAG: version-openad; SVN changeset: 916
|
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 /*--------------------------------------------------------------------------- 00037 WN simplifier 00038 00039 Description: 00040 00041 This file contains routines which simplify WHIRL trees as they are 00042 constructed. 00043 00044 Exported functions: 00045 00046 00047 WN *WN_SimplifyIload(OPCODE opc, WN_OFFSET offset, 00048 TY_IDX ty, UINT field_id, TY_IDX load_addr_ty, WN *addr) 00049 WN *WN_SimplifyIstore(OPCODE opc, WN_OFFSET offset, TY_IDX ty, UINT field_id, WN *value, WN *addr); 00050 WN *WN_SimplifyPstore(OPCODE opc, WN_OFFSET offset, TY_IDX ty, UINT field_id, WN * 00051 value, WN *addr); 00052 00053 WN * WN_SimplifyIntrinsic(OPCODE opc, UINT32 intrinsic, INT32 n, WN *k[]) 00054 WN * WN_SimplifyExp3(OPCODE opc, WN *k0, WN *k1, WN *k3) 00055 WN * WN_SimplifyExp2(OPCODE opc, WN *k0, WN *k1) 00056 WN * WN_SimplifyExp1(OPCODE opc, WN *k0) 00057 WN * WN_SimplifyCvtl(OPCODE opc, INT16 cvtl_bits, WN *k0) 00058 00059 Simplify binary and unary operations. opc is the opcode we are 00060 trying to build, and k0 and k1 are the operands of the WHIRL node being constructed. 00061 If simplification occurred, the functions return a simplified node. 00062 If no simplifications occurred, the function return NULL. These functions 00063 delete unused whirl nodes and trees during simplification. 00064 00065 INT32 WN_Simp_Compare_Trees(WN *t1, WN *t2) 00066 00067 Walk the two trees and return -1 if t1 is "less than" t2, 1 if 00068 t1 is "greater than" t2, and 0 if the two trees are formally identical. Note 00069 that commuted commutative expressions (x*y and y*x) are not considered formally 00070 identical for this routine. The order is computed as follows: 00071 1) If the root opcodes are different, the numerical value of the opcode 00072 determines the order. 00073 2) Compare children. The result will be the result of the first non-zero 00074 comparison. 00075 3) Special cases: 00076 a) INTCONST compares the signed value of WN_const_val. 00077 b) LOAD, LOADX, LDA, MLOAD compare the offset first. 00078 c) IDNAME and LDID compare offsets and then symbol table entries 00079 d) CONST compares symbol table entries 00080 e) ARRAY compares num_dim, element_size and then children 00081 f) CVTL compares cvtl_bits before its child. 00082 g) Symbol table entries are compared by examining id first, then 00083 index. 00084 00085 WN * WN_Simplify_Tree(WN * tree) 00086 Run the simplifier over a tree using a bottom up walk. This routine is 00087 most useful if one changes a child of some node directly, and wants to 00088 simplify the tree afterward. 00089 00090 00091 WN * WN_Simplify_Rebuild_Expr_Tree(WN * tree) 00092 Assumes that all the children of tree are already simplified, rebuild the 00093 tree with simplification. This is useful to catch cases such as when an LDID of 00094 a constant is replaced with a CONST node, and the tree can now be folded. 00095 00096 BOOL WN_Simplifier_Enable(BOOL enable) 00097 Turn on the simplifier, and return the old state of the simplifier. 00098 00099 The simplifier is controlled by a few variables set in 00100 config.c. Most of these are the same as the old cfold control 00101 variables. The variables which affect the simplifier are: 00102 00103 Enable_WN_Simp: Turn on the simplifier. On by default at all optimization 00104 levels. It is controlled by the switch OPT:wn_simplify. 00105 Defined as SIMPNODE_enable. 00106 00107 Enable_Cfold_Aggressive: Turn on "aggressive" optimizations. On by default at -O1. 00108 00109 Enable_Cfold_Reassociate: Allow optimizations on floating point quantities which 00110 require reassociation. 00111 00112 Recip_Allowed: Allow the RECIP operator to be generated 00113 00114 Rsqrt_Allowed: Allow the RSQRT operator to be generated 00115 00116 Div_Split_Allowed: Allow a/b to become a*(1/b) 00117 00118 00119 Simp_Multiply_To_Shift: Allow conversion of multiplies by powers of 2 to shifts 00120 00121 WN_Simp_Fold_ILOAD - allow ILOAD(LDA) to become LDID 00122 00123 WN_Simp_Fold_LDA - allow LDA[offset] + c to become LDA[offset+c] 00124 00125 00126 00127 There are a couple of variables which control the interaction of the 00128 simplifier with other modules: 00129 00130 WN_SimpParentMap - set to LNO's parent map. If not WN_MAP_UNDEFINED, 00131 causes the simplifier to keep parent pointers current. 00132 00133 WN_SimpAlias_Manager - set to an alias manager. If set to non-null, causes 00134 the simplifier to copy the alias informations on loads and stores 00135 it rebuilds. 00136 00137 00138 **************************************************************************/ 00139 00140 00141 00142 #ifndef wn_simp_INCLUDED 00143 #define wn_simp_INCLUDED 00144 #ifdef __cplusplus 00145 extern "C" { 00146 #endif 00147 00148 extern BOOL WN_Simplifier_Enable(BOOL enable); 00149 00150 extern WN *WN_SimplifyCvtl(OPCODE opc, INT16 cvtl_bits, WN *k0); 00151 00152 extern WN *WN_SimplifyExp1(OPCODE opc, WN *k0); 00153 00154 extern WN *WN_SimplifyExp2(OPCODE opc, WN *k0, WN *k1); 00155 00156 extern WN *WN_SimplifyExp3(OPCODE opc, WN *k0, WN *k1, WN *k2); 00157 00158 extern WN *WN_SimplifyIntrinsic(OPCODE opc, UINT32 intrinsic, INT32 n, WN *k[]); 00159 00160 extern WN *WN_SimplifyIload(OPCODE opc, WN_OFFSET offset, 00161 TY_IDX ty, UINT field_id, TY_IDX load_addr_ty, 00162 WN *addr); 00163 00164 00165 extern WN *WN_SimplifyIstore(OPCODE opc, WN_OFFSET offset, 00166 TY_IDX ty, UINT field_id, WN *value, WN *addr); 00167 extern WN *WN_SimplifyPstore(OPCODE opc, WN_OFFSET offset, 00168 TY_IDX ty, UINT field_id, WN *value, WN *addr); 00169 00170 00171 extern INT32 WN_Simp_Compare_Trees(WN *t1, WN *t2); 00172 00173 struct ALIAS_MANAGER; /* Needed as a forward reference */ 00174 00175 extern WN *WN_Simplify_Tree(WN *tree, ALIAS_MANAGER *am=NULL); 00176 00177 extern WN *WN_Simplify_Rebuild_Expr_Tree(WN *tree, ALIAS_MANAGER *am=NULL); 00178 00179 extern WN_MAP WN_SimpParentMap; 00180 00181 extern BOOL WN_Simp_Fold_ILOAD; 00182 00183 extern BOOL WN_Simp_Fold_LDA; 00184 00185 00186 #ifdef __cplusplus 00187 } 00188 #endif 00189 #endif