Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
wn_simp_code.h File Reference
#include "be_symtab.h"
#include "wn_simp_ftable.h"
Include dependency graph for wn_simp_code.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  wn_simp_code

Defines

#define SIMP_TYPE_SIZE(x)   MTYPE_size_min(x)
#define SIMP_IS_TYPE_INTEGRAL(x)   ((MTYPE_type_class(x)&MTYPE_CLASS_INTEGER)!=0)
#define SIMP_IS_TYPE_UNSIGNED(x)   ((MTYPE_type_class(x)&MTYPE_CLASS_UNSIGNED)!=0)
#define SIMP_IS_TYPE_FLOATING(x)   ((MTYPE_type_class(x)&MTYPE_CLASS_FLOAT)!=0)
#define SIMP_IS_TYPE_COMPLEX(x)   ((MTYPE_type_class(x)&MTYPE_CLASS_COMPLEX)!=0)
#define OPC_FROM_OPR(opr, type)   (OPCODE_make_op(opr,type,MTYPE_V))
#define SHOW_TREE(opc, k0, k1, result)   if ((result!=NULL) && trace_trees) show_tree(opc,k0,k1,result)
#define SHOW_RULE(x)   show_rule(x)
#define SIMP_INTCONST(ty, value)   SIMPNODE_CreateIntconst(OPC_FROM_OPR(OPR_INTCONST,ty),(value))
#define SIMP_FLOATCONST(ty, value)   SIMPNODE_CreateFloatconstFromTcon(Host_To_Targ_Float(ty,(value)))
#define SIMP_DELETE(x)   simp_delete(x)
#define SIMP_DELETE_TREE(x)   simp_delete_tree(x)
#define SIMP_TYPE(x)   SIMPNODE_rtype(x)
#define IS_POWER_OF_2(x)   (((x)!=0) && ((x) & ((x)-1))==0)
#define LDA_CANNOT_BE_ZERO   1
#define LDA_EQUIV_POSSIBLE   2
#define LDA_UNTESTABLE   4
#define FACTOR_11   1
#define FACTOR_12   2
#define FACTOR_21   4
#define FACTOR_22   8
#define FACTOR_ALL   (FACTOR_11 | FACTOR_12 | FACTOR_21 | FACTOR_22)
#define FACTOR_OK(flag, type)   ((flag&type)!=0)
#define B(t)   (1<<t)
#define PRECISE_I1   B(MTYPE_F4)|B(MTYPE_F8)|B(MTYPE_FQ)|B(MTYPE_I1)|B(MTYPE_I2)|B(MTYPE_I4)|B(MTYPE_I8)
#define PRECISE_I2   B(MTYPE_F4)|B(MTYPE_F8)|B(MTYPE_FQ)|B(MTYPE_I2)|B(MTYPE_I4)|B(MTYPE_I8)
#define PRECISE_I4   B(MTYPE_F8)|B(MTYPE_FQ)|B(MTYPE_I4)|B(MTYPE_I8)
#define PRECISE_I8   B(MTYPE_FQ)|B(MTYPE_I8)
#define PRECISE_U1   B(MTYPE_F4)|B(MTYPE_F8)|B(MTYPE_FQ)|B(MTYPE_U1)|B(MTYPE_U2)|B(MTYPE_U4)|B(MTYPE_U8)
#define PRECISE_U2   B(MTYPE_F4)|B(MTYPE_F8)|B(MTYPE_FQ)|B(MTYPE_U2)|B(MTYPE_U4)|B(MTYPE_U8)
#define PRECISE_U4   B(MTYPE_F8)|B(MTYPE_FQ)|B(MTYPE_I8)
#define PRECISE_U8   B(MTYPE_FQ)
#define PRECISE_F4   B(MTYPE_F4)|B(MTYPE_F8)|B(MTYPE_FQ)
#define PRECISE_F8   B(MTYPE_F8)|B(MTYPE_FQ)
#define PRECISE_FQ   B(MTYPE_FQ)
#define TESTABLE_TYPE
#define TYPEISIN(t, b)   ( ((1<<(t)) & (b)) !=0)
#define SELECT_ADD_SUB(x)   ((x)? subop : addop)
#define MAX_INTRINSIC_ARGS   6

Typedefs

typedef INT LDA_FLAGS

Enumerations

enum  YESNOMAYBE { NO, YES, MAYBE }

Functions

static void SIMPNODE_Simplify_Initialize (void)
static void show_rule (const char *rule)
static simpnode SIMPNODE_ConstantFold1 (OPCODE opc, simpnode k0)
static simpnode SIMPNODE_ConstantFold2 (OPCODE opc, simpnode k0, simpnode k1)
static simpnode SIMPNODE_SimpCreateExp3 (OPCODE opc, simpnode k0, simpnode k1, simpnode k2)
static simpnode SIMPNODE_SimpCreateExp2 (OPCODE opc, simpnode k0, simpnode k1)
static simpnode SIMPNODE_SimpCreateExp1 (OPCODE opc, simpnode k0)
static simpnode SIMPNODE_SimpCreateExtract (OPCODE opc, INT16 boffset, INT16 bsize, simpnode k0)
static simpnode SIMPNODE_SimpCreateDeposit (OPCODE opc, INT16 boffset, INT16 bsize, simpnode k0, simpnode k1)
static void simp_delete_tree (simpnode w)
static void simp_delete (simpnode w)
simpnode SIMPNODE_GetDefinition (simpnode x)
BOOL SIMP_Is_Int_Constant (simpnode x)
BOOL SIMP_Is_Flt_Constant (simpnode x)
BOOL SIMP_Is_Constant (simpnode x)
INT64 SIMP_Int_ConstVal (simpnode x)
TCON SIMP_Flt_ConstVal (simpnode x)
static INT64 create_bitmask (INT64 num_bits)
static UINT64 wn_simp_code::log2 (UINT64 x)
static BOOL is_add_ok (INT64 *sum, INT64 i1, INT64 i2, TYPE_ID ty)
static BOOL is_sub_ok (INT64 *sum, INT64 i1, INT64 i2, TYPE_ID ty)
static BOOL is_floating_equal (simpnode k, double d)
static BOOL is_numeric_equal (simpnode k, double d)
static LDA_FLAGS get_lda_info (simpnode lda, INT64 &offset, ST_IDX &base_sym_idx)
static YESNOMAYBE LDA_Equal_Address (simpnode lda_x, simpnode lda_y)
INT32 SIMPNODE_Simp_Compare_Trees (simpnode t1, simpnode t2)
static OPCODE is_logop (OPCODE opc)
static BOOL is_ok_to_reassociate (OPCODE opc)
static OPCODE get_inverse_relop (OPCODE opc)
static TYPE_ID get_value_type (simpnode k0)
static simpnode simp_diff_value (simpnode k0, simpnode k1, BOOL negate_result)
static simpnode simp_factor (simpnode k0, simpnode k1, OPERATOR op1, OPCODE opc2, TYPE_ID ty, INT32 flag)
static simpnode make_identity (OPERATOR opr, TYPE_ID ty)
static simpnode simp_factor_idty (simpnode k0, simpnode k1, OPERATOR op1, OPCODE opc2, TYPE_ID ty, INT32 const_only)
static simpnode simp_abs (OPCODE opc, simpnode k0, simpnode k1, BOOL k0const, BOOL k1const)
static simpnode simp_not (OPCODE opc, simpnode k0, simpnode k1, BOOL k0const, BOOL k1const)
static simpnode simp_neg (OPCODE opc, simpnode k0, simpnode k1, BOOL k0const, BOOL k1const)
static simpnode simp_recip (OPCODE opc, simpnode k0, simpnode k1, BOOL k0const, BOOL k1const)
static BOOL convert_precise (TYPE_ID t1, TYPE_ID t2)
static simpnode simp_cvt (OPCODE opc, simpnode k0, simpnode k1, BOOL k0const, BOOL k1const)
static simpnode simp_add_sub (OPCODE opc, simpnode k0, simpnode k1, BOOL k0const, BOOL k1const)
static simpnode simp_times (OPCODE opc, simpnode k0, simpnode k1, BOOL k0const, BOOL k1const)
static simpnode simp_div (OPCODE opc, simpnode k0, simpnode k1, BOOL k0const, BOOL k1const)
static simpnode simp_mod_rem (OPCODE opc, simpnode k0, simpnode k1, BOOL k0const, BOOL k1const)
static simpnode simp_power (OPCODE opc, simpnode k0, simpnode k1, BOOL k0const, BOOL k1const)
static simpnode simp_min_max (OPCODE opc, simpnode k0, simpnode k1, BOOL k0const, BOOL k1const)
static simpnode simp_band (OPCODE opc, simpnode k0, simpnode k1, BOOL k0const, BOOL k1const)
static simpnode simp_bior (OPCODE opc, simpnode k0, simpnode k1, BOOL k0const, BOOL k1const)
static simpnode simp_bnor (OPCODE opc, simpnode k0, simpnode k1, BOOL k0const, BOOL k1const)
static simpnode simp_bxor (OPCODE opc, simpnode k0, simpnode k1, BOOL k0const, BOOL k1const)
static simpnode simp_land (OPCODE opc, simpnode k0, simpnode k1, BOOL k0const, BOOL k1const)
static simpnode simp_lior (OPCODE opc, simpnode k0, simpnode k1, BOOL k0const, BOOL k1const)
static simpnode simp_cand (OPCODE opc, simpnode k0, simpnode k1, BOOL k0const, BOOL k1const)
static simpnode simp_cior (OPCODE opc, simpnode k0, simpnode k1, BOOL k0const, BOOL k1const)
static simpnode simp_shift (OPCODE opc, simpnode k0, simpnode k1, BOOL k0const, BOOL k1const)
static simpnode cancel_in_relop (OPCODE opc, TYPE_ID ty, simpnode k0, simpnode k1)
static simpnode simp_eq_neq (OPCODE opc, simpnode k0, simpnode k1, BOOL k0const, BOOL k1const)
static simpnode simp_relop (OPCODE opc, simpnode k0, simpnode k1, BOOL k0const, BOOL k1const)
static simpnode Fold2_Into_Select (OPCODE opc, simpnode k0, simpnode k1)
static simpnode SIMPNODE_SimplifyExp2_h (OPCODE opc, simpnode k0, simpnode k1)
simpnode SIMPNODE_SimplifyExp2 (OPCODE opc, simpnode k0, simpnode k1)
simpnode SIMPNODE_SimplifyExp1 (OPCODE opc, simpnode k0)
simpnode simp_cvtl (OPCODE opc, INT16 cvtl_bits, simpnode k0)
simpnode SIMPNODE_SimplifyCvtl (OPCODE opc, INT16 cvtl_bits, simpnode k0)
simpnode SIMPNODE_SimplifyExp3 (OPCODE opc, simpnode k0, simpnode k1, simpnode k2)
simpnode SIMPNODE_SimplifyIntrinsic (OPCODE opc, UINT32 intrinsic, INT32 n, simpnode k[])

Variables

static BOOL SIMPNODE_simp_initialized = FALSE
static BOOL trace_trees
static BOOL trace_rules

Define Documentation

#define B (   t)    (1<<t)

Definition at line 1315 of file wn_simp_code.h.

Referenced by NAME().

#define FACTOR_11   1

Definition at line 873 of file wn_simp_code.h.

Referenced by simp_factor().

#define FACTOR_12   2

Definition at line 874 of file wn_simp_code.h.

Referenced by simp_factor().

#define FACTOR_21   4

Definition at line 875 of file wn_simp_code.h.

Referenced by simp_factor().

#define FACTOR_22   8

Definition at line 876 of file wn_simp_code.h.

Referenced by simp_band(), simp_bior(), simp_bxor(), and simp_factor().

#define FACTOR_OK (   flag,
  type 
)    ((flag&type)!=0)

Definition at line 878 of file wn_simp_code.h.

Referenced by simp_factor().

#define IS_POWER_OF_2 (   x)    (((x)!=0) && ((x) & ((x)-1))==0)

Definition at line 270 of file wn_simp_code.h.

Referenced by simp_band(), simp_bior(), simp_eq_neq(), simp_mod_rem(), and simp_shift().

#define LDA_CANNOT_BE_ZERO   1

Definition at line 441 of file wn_simp_code.h.

Referenced by get_lda_info(), and simp_eq_neq().

#define LDA_EQUIV_POSSIBLE   2

Definition at line 442 of file wn_simp_code.h.

Referenced by get_lda_info().

#define LDA_UNTESTABLE   4

Definition at line 443 of file wn_simp_code.h.

Referenced by get_lda_info(), and LDA_Equal_Address().

#define MAX_INTRINSIC_ARGS   6

Definition at line 5114 of file wn_simp_code.h.

Referenced by SIMPNODE_SimplifyIntrinsic().

Definition at line 1324 of file wn_simp_code.h.

Referenced by convert_precise().

#define PRECISE_F8   B(MTYPE_F8)|B(MTYPE_FQ)

Definition at line 1325 of file wn_simp_code.h.

Referenced by convert_precise().

#define PRECISE_FQ   B(MTYPE_FQ)

Definition at line 1326 of file wn_simp_code.h.

Referenced by convert_precise().

Definition at line 1316 of file wn_simp_code.h.

Referenced by convert_precise().

Definition at line 1317 of file wn_simp_code.h.

Referenced by convert_precise().

Definition at line 1318 of file wn_simp_code.h.

Referenced by convert_precise().

#define PRECISE_I8   B(MTYPE_FQ)|B(MTYPE_I8)

Definition at line 1319 of file wn_simp_code.h.

Referenced by convert_precise().

Definition at line 1320 of file wn_simp_code.h.

Referenced by convert_precise().

Definition at line 1321 of file wn_simp_code.h.

Referenced by convert_precise().

Definition at line 1322 of file wn_simp_code.h.

Referenced by convert_precise().

#define PRECISE_U8   B(MTYPE_FQ)

Definition at line 1323 of file wn_simp_code.h.

Referenced by convert_precise().

#define SELECT_ADD_SUB (   x)    ((x)? subop : addop)

Definition at line 1616 of file wn_simp_code.h.

Referenced by simp_add_sub().

#define SHOW_TREE (   opc,
  k0,
  k1,
  result 
)    if ((result!=NULL) && trace_trees) show_tree(opc,k0,k1,result)
#define SIMP_FLOATCONST (   ty,
  value 
)    SIMPNODE_CreateFloatconstFromTcon(Host_To_Targ_Float(ty,(value)))

Definition at line 201 of file wn_simp_code.h.

Referenced by make_identity(), simp_diff_value(), simp_div(), simp_power(), and simp_times().

Definition at line 153 of file wn_simp_code.h.

Referenced by is_floating_equal(), is_numeric_equal(), simp_abs(), simp_div(), and simp_times().

#define SIMP_TYPE (   x)    SIMPNODE_rtype(x)

Definition at line 217 of file wn_simp_code.h.

Referenced by simp_band(), simp_bior(), and simp_shift().

#define SIMP_TYPE_SIZE (   x)    MTYPE_size_min(x)

Definition at line 146 of file wn_simp_code.h.

Referenced by simp_cvtl(), and simp_shift().

#define TESTABLE_TYPE
Value:

Definition at line 1327 of file wn_simp_code.h.

Referenced by convert_precise().

#define TYPEISIN (   t,
 
)    ( ((1<<(t)) & (b)) !=0)

Definition at line 1330 of file wn_simp_code.h.

Referenced by convert_precise().


Typedef Documentation

typedef INT LDA_FLAGS

Definition at line 444 of file wn_simp_code.h.


Enumeration Type Documentation

enum YESNOMAYBE
Enumerator:
NO 
YES 
MAYBE 

Definition at line 489 of file wn_simp_code.h.


Function Documentation

static INT64 create_bitmask ( INT64  num_bits) [static]

Definition at line 274 of file wn_simp_code.h.

Referenced by simp_band(), simp_bior(), and simp_shift().

static OPCODE get_inverse_relop ( OPCODE  opc) [static]

Definition at line 803 of file wn_simp_code.h.

References OPCODE_desc(), OPCODE_operator(), OPCODE_rtype(), OPCODE_UNKNOWN, OPR_EQ, OPR_GE, OPR_GT, OPR_LE, OPR_LT, and OPR_NE.

Referenced by simp_band(), simp_bior(), simp_bxor(), simp_eq_neq(), simp_not(), and SIMPNODE_SimplifyExp3().

Here is the call graph for this function:

static TYPE_ID get_value_type ( simpnode  k0) [static]

Definition at line 827 of file wn_simp_code.h.

References OPCODE_desc(), OPR_ILOAD, OPR_LDBITS, OPR_LDID, SIMPNODE_opcode, SIMPNODE_operator, and SIMPNODE_rtype.

Referenced by simp_cvt(), and simp_shift().

Here is the call graph for this function:

static BOOL is_add_ok ( INT64 sum,
INT64  i1,
INT64  i2,
TYPE_ID  ty 
) [static]

Definition at line 309 of file wn_simp_code.h.

References FALSE, i2, MTYPE_I4, MTYPE_I8, MTYPE_U4, MTYPE_U8, and TRUE.

Referenced by simp_add_sub(), and simp_relop().

static OPCODE is_logop ( OPCODE  opc) [static]

Definition at line 739 of file wn_simp_code.h.

References OPCODE_operator(), OPCODE_UNKNOWN, OPR_LAND, and OPR_LIOR.

Referenced by simp_eq_neq().

Here is the call graph for this function:

static BOOL is_numeric_equal ( simpnode  k,
double  d 
) [static]
static BOOL is_sub_ok ( INT64 sum,
INT64  i1,
INT64  i2,
TYPE_ID  ty 
) [static]

Definition at line 342 of file wn_simp_code.h.

References FALSE, i2, MTYPE_I4, MTYPE_I8, MTYPE_U4, MTYPE_U8, and TRUE.

Referenced by simp_relop().

static YESNOMAYBE LDA_Equal_Address ( simpnode  lda_x,
simpnode  lda_y 
) [static]

Definition at line 494 of file wn_simp_code.h.

References EXPORT_OPTIONAL, EXPORT_PREEMPTIBLE, get_lda_info(), LDA_UNTESTABLE, MAYBE, NO, SCLASS_EXTERN, ST_export(), ST_is_weak_symbol(), ST_ptr(), ST_sclass(), ST_st_idx(), ST_strong_idx(), and YES.

Referenced by simp_eq_neq().

Here is the call graph for this function:

static void show_rule ( const char *  rule) [static]

Definition at line 173 of file wn_simp_code.h.

References fprintf(), trace_rules, and TRACEFILE.

Here is the call graph for this function:

static simpnode simp_abs ( OPCODE  opc,
simpnode  k0,
simpnode  k1,
BOOL  k0const,
BOOL  k1const 
) [static]
static simpnode simp_bnor ( OPCODE  opc,
simpnode  k0,
simpnode  k1,
BOOL  k0const,
BOOL  k1const 
) [static]

Definition at line 2980 of file wn_simp_code.h.

References NULL, OPC_FROM_OPR, OPCODE_rtype(), OPR_BIOR, OPR_BNOT, SHOW_RULE, SIMPNODE_SimpCreateExp1(), and SIMPNODE_SimplifyExp2().

Here is the call graph for this function:

static simpnode simp_cand ( OPCODE  opc,
simpnode  k0,
simpnode  k1,
BOOL  k0const,
BOOL  k1const 
) [static]

Definition at line 3237 of file wn_simp_code.h.

References NULL, OPCODE_rtype(), SHOW_RULE, SIMP_DELETE, SIMP_DELETE_TREE, SIMP_Int_ConstVal(), and SIMP_INTCONST.

Here is the call graph for this function:

static simpnode simp_cior ( OPCODE  opc,
simpnode  k0,
simpnode  k1,
BOOL  k0const,
BOOL  k1const 
) [static]

Definition at line 3277 of file wn_simp_code.h.

References NULL, OPCODE_rtype(), SHOW_RULE, SIMP_DELETE, SIMP_DELETE_TREE, SIMP_Int_ConstVal(), and SIMP_INTCONST.

Here is the call graph for this function:

static void simp_delete ( simpnode  w) [static]

Definition at line 209 of file wn_simp_code.h.

References SIMPNODE_DELETE, and trace_trees.

static void simp_delete_tree ( simpnode  w) [static]

Definition at line 204 of file wn_simp_code.h.

References SIMPNODE_TREE_DELETE, and trace_trees.

static simpnode simp_diff_value ( simpnode  k0,
simpnode  k1,
BOOL  negate_result 
) [static]
TCON SIMP_Flt_ConstVal ( simpnode  x) [inline]

Definition at line 263 of file wn_simp_code.h.

References SIMPNODE_fconst_val, and SIMPNODE_GetDefinition().

Referenced by is_floating_equal(), simp_div(), SIMPNODE_ConstantFold1(), SIMPNODE_ConstantFold2(), and SIMPNODE_SimplifyIntrinsic().

Here is the call graph for this function:

Definition at line 241 of file wn_simp_code.h.

References OPR_CONST, SIMPNODE_GetDefinition(), and SIMPNODE_operator.

Referenced by SIMPNODE_ConstantFold1(), SIMPNODE_ConstantFold2(), and SIMPNODE_SimplifyIntrinsic().

Here is the call graph for this function:

static simpnode simp_min_max ( OPCODE  opc,
simpnode  k0,
simpnode  k1,
BOOL  k0const,
BOOL  k1const 
) [static]
static simpnode simp_mod_rem ( OPCODE  opc,
simpnode  k0,
simpnode  k1,
BOOL  k0const,
BOOL  k1const 
) [static]
static simpnode simp_recip ( OPCODE  opc,
simpnode  k0,
simpnode  k1,
BOOL  k0const,
BOOL  k1const 
) [static]

Definition at line 219 of file wn_simp_code.h.

References CLASS_PREG, OPR_LDID, Preg_Home(), SIMPNODE_operator, ST_class(), WN_load_offset(), and WN_st().

Referenced by SIMP_Flt_ConstVal(), SIMP_Int_ConstVal(), SIMP_Is_Constant(), and SIMP_Is_Flt_Constant().

Here is the call graph for this function:

static simpnode SIMPNODE_SimpCreateDeposit ( OPCODE  opc,
INT16  boffset,
INT16  bsize,
simpnode  k0,
simpnode  k1 
) [static]

Referenced by simp_bior(), and simp_shift().

static simpnode SIMPNODE_SimpCreateExp3 ( OPCODE  opc,
simpnode  k0,
simpnode  k1,
simpnode  k2 
) [static]
static simpnode SIMPNODE_SimpCreateExtract ( OPCODE  opc,
INT16  boffset,
INT16  bsize,
simpnode  k0 
) [static]

Referenced by simp_band(), and simp_shift().

simpnode SIMPNODE_SimplifyCvtl ( OPCODE  opc,
INT16  cvtl_bits,
simpnode  k0 
)

Definition at line 5008 of file wn_simp_code.h.

References NULL, result, SHOW_TREE, simp_cvtl(), SIMPNODE_enable, SIMPNODE_simp_initialized, and SIMPNODE_Simplify_Initialize().

Referenced by simp_cvtl().

Here is the call graph for this function:

Definition at line 4742 of file wn_simp_code.h.

References result, SHOW_TREE, and SIMPNODE_SimplifyExp2_h().

Referenced by simp_bnor().

Here is the call graph for this function:


Variable Documentation

BOOL trace_rules [static]

Definition at line 169 of file wn_simp_code.h.

Referenced by show_rule(), and SIMPNODE_Simplify_Initialize().

BOOL trace_trees [static]

Definition at line 164 of file wn_simp_code.h.

Referenced by simp_delete(), simp_delete_tree(), and SIMPNODE_Simplify_Initialize().

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines