本文整理汇总了C++中TREE_CODE_CLASS函数的典型用法代码示例。如果您正苦于以下问题:C++ TREE_CODE_CLASS函数的具体用法?C++ TREE_CODE_CLASS怎么用?C++ TREE_CODE_CLASS使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TREE_CODE_CLASS函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gimple_cond_get_ops_from_tree
void
gimple_cond_get_ops_from_tree (tree cond, enum tree_code *code_p,
tree *lhs_p, tree *rhs_p)
{
gcc_assert (TREE_CODE_CLASS (TREE_CODE (cond)) == tcc_comparison
|| TREE_CODE (cond) == TRUTH_NOT_EXPR
|| is_gimple_min_invariant (cond)
|| SSA_VAR_P (cond));
extract_ops_from_tree (cond, code_p, lhs_p, rhs_p);
/* Canonicalize conditionals of the form 'if (!VAL)'. */
if (*code_p == TRUTH_NOT_EXPR)
{
*code_p = EQ_EXPR;
gcc_assert (*lhs_p && *rhs_p == NULL_TREE);
*rhs_p = build_zero_cst (TREE_TYPE (*lhs_p));
}
/* Canonicalize conditionals of the form 'if (VAL)' */
else if (TREE_CODE_CLASS (*code_p) != tcc_comparison)
{
*code_p = NE_EXPR;
gcc_assert (*lhs_p && *rhs_p == NULL_TREE);
*rhs_p = build_zero_cst (TREE_TYPE (*lhs_p));
}
}
示例2: gimple_simplify
tree
gimple_simplify (enum tree_code code, tree type,
tree op0, tree op1,
gimple_seq *seq, tree (*valueize)(tree))
{
if (constant_for_folding (op0) && constant_for_folding (op1))
{
tree res = const_binop (code, type, op0, op1);
if (res != NULL_TREE
&& CONSTANT_CLASS_P (res))
return res;
}
/* Canonicalize operand order both for matching and fallback stmt
generation. */
if ((commutative_tree_code (code)
|| TREE_CODE_CLASS (code) == tcc_comparison)
&& tree_swap_operands_p (op0, op1, false))
{
tree tem = op0;
op0 = op1;
op1 = tem;
if (TREE_CODE_CLASS (code) == tcc_comparison)
code = swap_tree_comparison (code);
}
code_helper rcode;
tree ops[3] = {};
if (!gimple_simplify (&rcode, ops, seq, valueize,
code, type, op0, op1))
return NULL_TREE;
return maybe_push_res_to_seq (rcode, type, ops, seq);
}
示例3: gimple_resimplify2
bool
gimple_resimplify2 (gimple_seq *seq,
code_helper *res_code, tree type, tree *res_ops,
tree (*valueize)(tree))
{
if (constant_for_folding (res_ops[0]) && constant_for_folding (res_ops[1]))
{
tree tem = NULL_TREE;
if (res_code->is_tree_code ())
tem = const_binop (*res_code, type, res_ops[0], res_ops[1]);
else
tem = fold_const_call (combined_fn (*res_code), type,
res_ops[0], res_ops[1]);
if (tem != NULL_TREE
&& CONSTANT_CLASS_P (tem))
{
if (TREE_OVERFLOW_P (tem))
tem = drop_tree_overflow (tem);
res_ops[0] = tem;
res_ops[1] = NULL_TREE;
res_ops[2] = NULL_TREE;
*res_code = TREE_CODE (res_ops[0]);
return true;
}
}
/* Canonicalize operand order. */
bool canonicalized = false;
if (res_code->is_tree_code ()
&& (TREE_CODE_CLASS ((enum tree_code) *res_code) == tcc_comparison
|| commutative_tree_code (*res_code))
&& tree_swap_operands_p (res_ops[0], res_ops[1]))
{
std::swap (res_ops[0], res_ops[1]);
if (TREE_CODE_CLASS ((enum tree_code) *res_code) == tcc_comparison)
*res_code = swap_tree_comparison (*res_code);
canonicalized = true;
}
code_helper res_code2;
tree res_ops2[3] = {};
if (gimple_simplify (&res_code2, res_ops2, seq, valueize,
*res_code, type, res_ops[0], res_ops[1]))
{
*res_code = res_code2;
res_ops[0] = res_ops2[0];
res_ops[1] = res_ops2[1];
res_ops[2] = res_ops2[2];
return true;
}
return canonicalized;
}
示例4: ccmp_candidate_p
/* Check whether G is a potential conditional compare candidate. */
static bool
ccmp_candidate_p (gimple *g)
{
tree rhs = gimple_assign_rhs_to_tree (g);
tree lhs, op0, op1;
gimple *gs0, *gs1;
enum tree_code tcode, tcode0, tcode1;
tcode = TREE_CODE (rhs);
if (tcode != BIT_AND_EXPR && tcode != BIT_IOR_EXPR)
return false;
lhs = gimple_assign_lhs (g);
op0 = TREE_OPERAND (rhs, 0);
op1 = TREE_OPERAND (rhs, 1);
if ((TREE_CODE (op0) != SSA_NAME) || (TREE_CODE (op1) != SSA_NAME)
|| !has_single_use (lhs))
return false;
gs0 = get_gimple_for_ssa_name (op0);
gs1 = get_gimple_for_ssa_name (op1);
if (!gs0 || !gs1 || !is_gimple_assign (gs0) || !is_gimple_assign (gs1)
/* g, gs0 and gs1 must be in the same basic block, since current stage
is out-of-ssa. We can not guarantee the correctness when forwording
the gs0 and gs1 into g whithout DATAFLOW analysis. */
|| gimple_bb (gs0) != gimple_bb (gs1)
|| gimple_bb (gs0) != gimple_bb (g))
return false;
if (!(INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_rhs1 (gs0)))
|| POINTER_TYPE_P (TREE_TYPE (gimple_assign_rhs1 (gs0))))
|| !(INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_rhs1 (gs1)))
|| POINTER_TYPE_P (TREE_TYPE (gimple_assign_rhs1 (gs1)))))
return false;
tcode0 = gimple_assign_rhs_code (gs0);
tcode1 = gimple_assign_rhs_code (gs1);
if (TREE_CODE_CLASS (tcode0) == tcc_comparison
&& TREE_CODE_CLASS (tcode1) == tcc_comparison)
return true;
if (TREE_CODE_CLASS (tcode0) == tcc_comparison
&& ccmp_candidate_p (gs1))
return true;
else if (TREE_CODE_CLASS (tcode1) == tcc_comparison
&& ccmp_candidate_p (gs0))
return true;
/* We skip ccmp_candidate_p (gs1) && ccmp_candidate_p (gs0) since
there is no way to set the CC flag. */
return false;
}
示例5: outermost_invariant_loop_expr
static struct loop *
outermost_invariant_loop_expr (tree expr, struct loop *loop)
{
enum tree_code_class codeclass = TREE_CODE_CLASS (TREE_CODE (expr));
unsigned i, nops;
struct loop *max_loop = superloop_at_depth (loop, 1), *aloop;
if (TREE_CODE (expr) == SSA_NAME
|| TREE_CODE (expr) == INTEGER_CST
|| is_gimple_min_invariant (expr))
return outermost_invariant_loop (expr, loop);
if (codeclass != tcc_unary
&& codeclass != tcc_binary
&& codeclass != tcc_expression
&& codeclass != tcc_vl_exp
&& codeclass != tcc_comparison)
return NULL;
nops = TREE_OPERAND_LENGTH (expr);
for (i = 0; i < nops; i++)
{
aloop = outermost_invariant_loop_expr (TREE_OPERAND (expr, i), loop);
if (!aloop)
return NULL;
if (flow_loop_nested_p (max_loop, aloop))
max_loop = aloop;
}
return max_loop;
}
示例6: get_string_cst
static tree get_string_cst(tree var)
{
if (var == NULL_TREE)
return NULL_TREE;
if (TREE_CODE(var) == STRING_CST)
return var;
switch (TREE_CODE_CLASS(TREE_CODE(var))) {
case tcc_expression:
case tcc_reference: {
int i;
for (i = 0; i < TREE_OPERAND_LENGTH(var); i++) {
tree ret = get_string_cst(TREE_OPERAND(var, i));
if (ret != NULL_TREE)
return ret;
}
break;
}
default:
break;
}
return NULL_TREE;
}
示例7: cp_tree_size
/* Langhook for tree_size: determine size of our 'x' and 'c' nodes. */
size_t
cp_tree_size (enum tree_code code)
{
gcc_checking_assert (code >= NUM_TREE_CODES);
switch (code)
{
case PTRMEM_CST: return sizeof (ptrmem_cst);
case BASELINK: return sizeof (tree_baselink);
case TEMPLATE_PARM_INDEX: return sizeof (template_parm_index);
case DEFAULT_ARG: return sizeof (tree_default_arg);
case DEFERRED_NOEXCEPT: return sizeof (tree_deferred_noexcept);
case OVERLOAD: return sizeof (tree_overload);
case STATIC_ASSERT: return sizeof (tree_static_assert);
case TYPE_ARGUMENT_PACK:
case TYPE_PACK_EXPANSION: return sizeof (tree_type_non_common);
case NONTYPE_ARGUMENT_PACK:
case EXPR_PACK_EXPANSION: return sizeof (tree_exp);
case ARGUMENT_PACK_SELECT: return sizeof (tree_argument_pack_select);
case TRAIT_EXPR: return sizeof (tree_trait_expr);
case LAMBDA_EXPR: return sizeof (tree_lambda_expr);
case TEMPLATE_INFO: return sizeof (tree_template_info);
case CONSTRAINT_INFO: return sizeof (tree_constraint_info);
case USERDEF_LITERAL: return sizeof (tree_userdef_literal);
case TEMPLATE_DECL: return sizeof (tree_template_decl);
default:
switch (TREE_CODE_CLASS (code))
{
case tcc_declaration: return sizeof (tree_decl_non_common);
case tcc_type: return sizeof (tree_type_non_common);
default: gcc_unreachable ();
}
}
/* NOTREACHED */
}
示例8: get_expr_type
static tree
get_expr_type (enum tree_code code, tree op)
{
return (TREE_CODE_CLASS (code) == tcc_comparison)
? boolean_type_node
: TREE_TYPE (op);
}
示例9: set_based_decl_codes
static void set_based_decl_codes(const_tree type, struct decl_hash *decl_hash_data)
{
gcc_assert(type != NULL_TREE);
gcc_assert(TREE_CODE_CLASS(TREE_CODE(type)) == tcc_type);
while (type && decl_hash_data->tree_codes_len < CODES_LIMIT) {
decl_hash_data->tree_codes[decl_hash_data->tree_codes_len] = get_tree_code(type);
decl_hash_data->tree_codes_len++;
type = TREE_TYPE(type);
}
}
示例10: can_propagate_from
static bool
can_propagate_from (gimple def_stmt)
{
use_operand_p use_p;
ssa_op_iter iter;
gcc_assert (is_gimple_assign (def_stmt));
/* If the rhs has side-effects we cannot propagate from it. */
if (gimple_has_volatile_ops (def_stmt))
return false;
/* If the rhs is a load we cannot propagate from it. */
if (TREE_CODE_CLASS (gimple_assign_rhs_code (def_stmt)) == tcc_reference
|| TREE_CODE_CLASS (gimple_assign_rhs_code (def_stmt)) == tcc_declaration)
return false;
/* Constants can be always propagated. */
if (gimple_assign_single_p (def_stmt)
&& is_gimple_min_invariant (gimple_assign_rhs1 (def_stmt)))
return true;
/* We cannot propagate ssa names that occur in abnormal phi nodes. */
FOR_EACH_SSA_USE_OPERAND (use_p, def_stmt, iter, SSA_OP_USE)
if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (USE_FROM_PTR (use_p)))
return false;
/* If the definition is a conversion of a pointer to a function type,
then we can not apply optimizations as some targets require
function pointers to be canonicalized and in this case this
optimization could eliminate a necessary canonicalization. */
if (CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (def_stmt)))
{
tree rhs = gimple_assign_rhs1 (def_stmt);
if (POINTER_TYPE_P (TREE_TYPE (rhs))
&& TREE_CODE (TREE_TYPE (TREE_TYPE (rhs))) == FUNCTION_TYPE)
return false;
}
return true;
}
示例11: recalculate_side_effects
void
recalculate_side_effects (tree t)
{
enum tree_code code = TREE_CODE (t);
int len = TREE_CODE_LENGTH (code);
int i;
switch (TREE_CODE_CLASS (code))
{
case tcc_expression:
switch (code)
{
case INIT_EXPR:
case MODIFY_EXPR:
case VA_ARG_EXPR:
case PREDECREMENT_EXPR:
case PREINCREMENT_EXPR:
case POSTDECREMENT_EXPR:
case POSTINCREMENT_EXPR:
/* All of these have side-effects, no matter what their
operands are. */
return;
default:
break;
}
/* Fall through. */
case tcc_comparison: /* a comparison expression */
case tcc_unary: /* a unary arithmetic expression */
case tcc_binary: /* a binary arithmetic expression */
case tcc_reference: /* a reference */
TREE_SIDE_EFFECTS (t) = TREE_THIS_VOLATILE (t);
for (i = 0; i < len; ++i)
{
tree op = TREE_OPERAND (t, i);
if (op && TREE_SIDE_EFFECTS (op))
TREE_SIDE_EFFECTS (t) = 1;
}
break;
default:
/* Can never be used with non-expressions. */
gcc_unreachable ();
}
}
示例12: build_and_record_new_cond
static void
build_and_record_new_cond (enum tree_code code,
tree op0, tree op1,
vec<cond_equivalence> *p,
bool val = true)
{
cond_equivalence c;
struct hashable_expr *cond = &c.cond;
gcc_assert (TREE_CODE_CLASS (code) == tcc_comparison);
cond->type = boolean_type_node;
cond->kind = EXPR_BINARY;
cond->ops.binary.op = code;
cond->ops.binary.opnd0 = op0;
cond->ops.binary.opnd1 = op1;
c.value = val ? boolean_true_node : boolean_false_node;
p->safe_push (c);
}
示例13: cilk_ignorable_spawn_rhs_op
static bool
cilk_ignorable_spawn_rhs_op (tree exp)
{
enum tree_code code = TREE_CODE (exp);
switch (TREE_CODE_CLASS (code))
{
case tcc_expression:
return code == ADDR_EXPR;
case tcc_comparison:
/* We need the spawn as operand 0 for now. That's where it
appears in the only case we really care about, conversion
to bool. */
return (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST);
case tcc_unary:
case tcc_reference:
return true;
default:
return false;
}
}
示例14: is_gimple_formal_tmp_rhs
bool
is_gimple_formal_tmp_rhs (tree t)
{
enum tree_code code = TREE_CODE (t);
switch (TREE_CODE_CLASS (code))
{
case tcc_unary:
case tcc_binary:
case tcc_comparison:
return true;
default:
break;
}
switch (code)
{
case TRUTH_NOT_EXPR:
case TRUTH_AND_EXPR:
case TRUTH_OR_EXPR:
case TRUTH_XOR_EXPR:
case ADDR_EXPR:
case CALL_EXPR:
case CONSTRUCTOR:
case COMPLEX_EXPR:
case INTEGER_CST:
case REAL_CST:
case STRING_CST:
case COMPLEX_CST:
case VECTOR_CST:
case OBJ_TYPE_REF:
case ASSERT_EXPR:
return true;
default:
break;
}
return is_gimple_lvalue (t) || is_gimple_val (t);
}
示例15: build_stmt
tree
build_stmt (location_t loc, enum tree_code code, ...)
{
tree ret;
int length, i;
va_list p;
bool side_effects;
/* This function cannot be used to construct variably-sized nodes. */
gcc_assert (TREE_CODE_CLASS (code) != tcc_vl_exp);
va_start (p, code);
ret = make_node (code);
TREE_TYPE (ret) = void_type_node;
length = TREE_CODE_LENGTH (code);
SET_EXPR_LOCATION (ret, loc);
/* TREE_SIDE_EFFECTS will already be set for statements with
implicit side effects. Here we make sure it is set for other
expressions by checking whether the parameters have side
effects. */
side_effects = false;
for (i = 0; i < length; i++)
{
tree t = va_arg (p, tree);
if (t && !TYPE_P (t))
side_effects |= TREE_SIDE_EFFECTS (t);
TREE_OPERAND (ret, i) = t;
}
TREE_SIDE_EFFECTS (ret) |= side_effects;
va_end (p);
return ret;
}