本文整理汇总了C++中DECL_SIZE_UNIT函数的典型用法代码示例。如果您正苦于以下问题:C++ DECL_SIZE_UNIT函数的具体用法?C++ DECL_SIZE_UNIT怎么用?C++ DECL_SIZE_UNIT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DECL_SIZE_UNIT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: vxworks_emutls_var_init
static tree
vxworks_emutls_var_init (tree var, tree decl, tree tmpl_addr)
{
VEC(constructor_elt,gc) *v = VEC_alloc (constructor_elt, gc, 3);
constructor_elt *elt;
tree type = TREE_TYPE (var);
tree field = TYPE_FIELDS (type);
elt = VEC_quick_push (constructor_elt, v, NULL);
elt->index = field;
elt->value = fold_convert (TREE_TYPE (field), tmpl_addr);
elt = VEC_quick_push (constructor_elt, v, NULL);
field = DECL_CHAIN (field);
elt->index = field;
elt->value = build_int_cst (TREE_TYPE (field), 0);
elt = VEC_quick_push (constructor_elt, v, NULL);
field = DECL_CHAIN (field);
elt->index = field;
elt->value = fold_convert (TREE_TYPE (field), DECL_SIZE_UNIT (decl));
return build_constructor (type, v);
}
示例2: lto_input_ts_decl_common_tree_pointers
static void
lto_input_ts_decl_common_tree_pointers (struct lto_input_block *ib,
struct data_in *data_in, tree expr)
{
DECL_SIZE (expr) = stream_read_tree (ib, data_in);
DECL_SIZE_UNIT (expr) = stream_read_tree (ib, data_in);
DECL_ATTRIBUTES (expr) = stream_read_tree (ib, data_in);
/* Do not stream DECL_ABSTRACT_ORIGIN. We cannot handle debug information
for early inlining so drop it on the floor instead of ICEing in
dwarf2out.c. */
if (TREE_CODE (expr) == PARM_DECL)
TREE_CHAIN (expr) = streamer_read_chain (ib, data_in);
if ((TREE_CODE (expr) == VAR_DECL
|| TREE_CODE (expr) == PARM_DECL)
&& DECL_HAS_VALUE_EXPR_P (expr))
SET_DECL_VALUE_EXPR (expr, stream_read_tree (ib, data_in));
if (TREE_CODE (expr) == VAR_DECL)
{
tree dexpr = stream_read_tree (ib, data_in);
if (dexpr)
SET_DECL_DEBUG_EXPR (expr, dexpr);
}
}
示例3: add_stack_var
static void
add_stack_var (tree decl)
{
if (stack_vars_num >= stack_vars_alloc)
{
if (stack_vars_alloc)
stack_vars_alloc = stack_vars_alloc * 3 / 2;
else
stack_vars_alloc = 32;
stack_vars
= XRESIZEVEC (struct stack_var, stack_vars, stack_vars_alloc);
}
stack_vars[stack_vars_num].decl = decl;
stack_vars[stack_vars_num].offset = 0;
stack_vars[stack_vars_num].size = tree_low_cst (DECL_SIZE_UNIT (decl), 1);
stack_vars[stack_vars_num].alignb = get_decl_align_unit (decl);
/* All variables are initially in their own partition. */
stack_vars[stack_vars_num].representative = stack_vars_num;
stack_vars[stack_vars_num].next = EOC;
/* Ensure that this decl doesn't get put onto the list twice. */
SET_DECL_RTL (decl, pc_rtx);
stack_vars_num++;
}
示例4: compute_unsafe_stack_layout
unsigned int compute_unsafe_stack_layout() {
unsigned int i, total = 0;
tree var;
FOR_EACH_LOCAL_DECL(cfun, i, var) {
total += tree_to_uhwi (DECL_SIZE_UNIT(var)); /* size in bytes */
}
示例5: write_ts_decl_common_tree_pointers
static void
write_ts_decl_common_tree_pointers (struct output_block *ob, tree expr,
bool ref_p)
{
stream_write_tree (ob, DECL_SIZE (expr), ref_p);
stream_write_tree (ob, DECL_SIZE_UNIT (expr), ref_p);
/* Note, DECL_INITIAL is not handled here. Since DECL_INITIAL needs
special handling in LTO, it must be handled by streamer hooks. */
stream_write_tree (ob, DECL_ATTRIBUTES (expr), ref_p);
/* Do not stream DECL_ABSTRACT_ORIGIN. We cannot handle debug information
for early inlining so drop it on the floor instead of ICEing in
dwarf2out.c. */
if (TREE_CODE (expr) == PARM_DECL)
streamer_write_chain (ob, TREE_CHAIN (expr), ref_p);
if ((TREE_CODE (expr) == VAR_DECL
|| TREE_CODE (expr) == PARM_DECL)
&& DECL_HAS_VALUE_EXPR_P (expr))
stream_write_tree (ob, DECL_VALUE_EXPR (expr), ref_p);
if (TREE_CODE (expr) == VAR_DECL)
stream_write_tree (ob, DECL_DEBUG_EXPR (expr), ref_p);
}
示例6: build_field
static void
build_field (segment_info *h, tree union_type, record_layout_info rli)
{
tree field;
tree name;
HOST_WIDE_INT offset = h->offset;
unsigned HOST_WIDE_INT desired_align, known_align;
name = get_identifier (h->sym->name);
field = build_decl (FIELD_DECL, name, h->field);
gfc_set_decl_location (field, &h->sym->declared_at);
known_align = (offset & -offset) * BITS_PER_UNIT;
if (known_align == 0 || known_align > BIGGEST_ALIGNMENT)
known_align = BIGGEST_ALIGNMENT;
desired_align = update_alignment_for_field (rli, field, known_align);
if (desired_align > known_align)
DECL_PACKED (field) = 1;
DECL_FIELD_CONTEXT (field) = union_type;
DECL_FIELD_OFFSET (field) = size_int (offset);
DECL_FIELD_BIT_OFFSET (field) = bitsize_zero_node;
SET_DECL_OFFSET_ALIGN (field, known_align);
rli->offset = size_binop (MAX_EXPR, rli->offset,
size_binop (PLUS_EXPR,
DECL_FIELD_OFFSET (field),
DECL_SIZE_UNIT (field)));
h->field = field;
}
示例7: build_equiv_decl
static tree
build_equiv_decl (tree union_type, bool is_init)
{
tree decl;
char name[15];
static int serial = 0;
if (is_init)
{
decl = gfc_create_var (union_type, "equiv");
TREE_STATIC (decl) = 1;
return decl;
}
snprintf (name, sizeof (name), "equiv.%d", serial++);
decl = build_decl (VAR_DECL, get_identifier (name), union_type);
DECL_ARTIFICIAL (decl) = 1;
DECL_IGNORED_P (decl) = 1;
if (!gfc_can_put_var_on_stack (DECL_SIZE_UNIT (decl)))
TREE_STATIC (decl) = 1;
TREE_ADDRESSABLE (decl) = 1;
TREE_USED (decl) = 1;
/* The source location has been lost, and doesn't really matter.
We need to set it to something though. */
gfc_set_decl_location (decl, &gfc_current_locus);
gfc_add_decl_to_function (decl);
return decl;
}
示例8: expand_one_stack_var
static void
expand_one_stack_var (tree var)
{
HOST_WIDE_INT size, offset, align;
size = tree_low_cst (DECL_SIZE_UNIT (var), 1);
align = get_decl_align_unit (var);
offset = alloc_stack_frame_space (size, align);
expand_one_stack_var_at (var, offset);
}
示例9: ubsan_walk_array_refs_r
static tree
ubsan_walk_array_refs_r (tree *tp, int *walk_subtrees, void *data)
{
hash_set<tree> *pset = (hash_set<tree> *) data;
if (TREE_CODE (*tp) == BIND_EXPR)
{
/* Since walk_tree doesn't call the callback function on the decls
in BIND_EXPR_VARS, we have to walk them manually, so we can avoid
instrumenting DECL_INITIAL of TREE_STATIC vars. */
*walk_subtrees = 0;
for (tree decl = BIND_EXPR_VARS (*tp); decl; decl = DECL_CHAIN (decl))
{
if (TREE_STATIC (decl))
continue;
walk_tree (&DECL_INITIAL (decl), ubsan_walk_array_refs_r, pset,
pset);
walk_tree (&DECL_SIZE (decl), ubsan_walk_array_refs_r, pset, pset);
walk_tree (&DECL_SIZE_UNIT (decl), ubsan_walk_array_refs_r, pset,
pset);
}
walk_tree (&BIND_EXPR_BODY (*tp), ubsan_walk_array_refs_r, pset, pset);
}
else if (TREE_CODE (*tp) == ADDR_EXPR
&& TREE_CODE (TREE_OPERAND (*tp, 0)) == ARRAY_REF)
{
ubsan_maybe_instrument_array_ref (&TREE_OPERAND (*tp, 0), true);
/* Make sure ubsan_maybe_instrument_array_ref is not called again
on the ARRAY_REF, the above call might not instrument anything
as the index might be constant or masked, so ensure it is not
walked again and walk its subtrees manually. */
tree aref = TREE_OPERAND (*tp, 0);
pset->add (aref);
*walk_subtrees = 0;
walk_tree (&TREE_OPERAND (aref, 0), ubsan_walk_array_refs_r, pset, pset);
walk_tree (&TREE_OPERAND (aref, 1), ubsan_walk_array_refs_r, pset, pset);
walk_tree (&TREE_OPERAND (aref, 2), ubsan_walk_array_refs_r, pset, pset);
walk_tree (&TREE_OPERAND (aref, 3), ubsan_walk_array_refs_r, pset, pset);
}
else if (TREE_CODE (*tp) == ARRAY_REF)
ubsan_maybe_instrument_array_ref (tp, false);
return NULL_TREE;
}
示例10: defer_stack_allocation
static bool
defer_stack_allocation (tree var, bool toplevel)
{
/* Variables in the outermost scope automatically conflict with
every other variable. The only reason to want to defer them
at all is that, after sorting, we can more efficiently pack
small variables in the stack frame. Continue to defer at -O2. */
if (toplevel && optimize < 2)
return false;
/* Without optimization, *most* variables are allocated from the
stack, which makes the quadratic problem large exactly when we
want compilation to proceed as quickly as possible. On the
other hand, we don't want the function's stack frame size to
get completely out of hand. So we avoid adding scalars and
"small" aggregates to the list at all. */
if (optimize == 0 && tree_low_cst (DECL_SIZE_UNIT (var), 1) < 32)
return false;
return true;
}
示例11: vxworks_emutls_var_init
static tree
vxworks_emutls_var_init (tree var, tree decl, tree tmpl_addr)
{
vec<constructor_elt, va_gc> *v;
vec_alloc (v, 3);
tree type = TREE_TYPE (var);
tree field = TYPE_FIELDS (type);
constructor_elt elt = {field, fold_convert (TREE_TYPE (field), tmpl_addr)};
v->quick_push (elt);
field = DECL_CHAIN (field);
elt.index = field;
elt.value = build_int_cst (TREE_TYPE (field), 0);
v->quick_push (elt);
field = DECL_CHAIN (field);
elt.index = field;
elt.value = fold_convert (TREE_TYPE (field), DECL_SIZE_UNIT (decl));
v->quick_push (elt);
return build_constructor (type, v);
}
示例12: mf_xform_derefs_1
//.........这里部分代码省略.........
{
gcc_assert (TREE_CODE (var) == VAR_DECL
|| TREE_CODE (var) == PARM_DECL
|| TREE_CODE (var) == RESULT_DECL
|| TREE_CODE (var) == STRING_CST);
/* Don't instrument this access if the underlying
variable is not "eligible". This test matches
those arrays that have only known-valid indexes,
and thus are not labeled TREE_ADDRESSABLE. */
if (! mf_decl_eligible_p (var) || component_ref_only)
return;
else
{
base = build1 (ADDR_EXPR,
build_pointer_type (TREE_TYPE (var)), var);
break;
}
}
}
/* Handle the case of ordinary non-indirection structure
accesses. These have only nested COMPONENT_REF nodes (no
INDIRECT_REF), but pass through the above filter loop.
Note that it's possible for such a struct variable to match
the eligible_p test because someone else might take its
address sometime. */
/* We need special processing for bitfield components, because
their addresses cannot be taken. */
if (bitfield_ref_p)
{
tree field = TREE_OPERAND (t, 1);
if (TREE_CODE (DECL_SIZE_UNIT (field)) == INTEGER_CST)
size = DECL_SIZE_UNIT (field);
if (elt)
elt = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (elt)),
elt);
addr = fold_convert_loc (location, ptr_type_node, elt ? elt : base);
addr = fold_build_pointer_plus_loc (location,
addr, byte_position (field));
}
else
addr = build1 (ADDR_EXPR, build_pointer_type (type), t);
limit = fold_build2_loc (location, MINUS_EXPR, mf_uintptr_type,
fold_build2_loc (location, PLUS_EXPR, mf_uintptr_type,
fold_convert (mf_uintptr_type, addr),
size),
integer_one_node);
}
break;
case INDIRECT_REF:
addr = TREE_OPERAND (t, 0);
base = addr;
limit = fold_build_pointer_plus_hwi_loc
(location, fold_build_pointer_plus_loc (location, base, size), -1);
break;
case MEM_REF:
if (addr_expr_of_non_mem_decl_p (TREE_OPERAND (t, 0)))
return;
addr = fold_build_pointer_plus_loc (location, TREE_OPERAND (t, 0),
示例13: print_node
//.........这里部分代码省略.........
fputs (" decl_1", file);
if (DECL_LANG_FLAG_2 (node))
fputs (" decl_2", file);
if (DECL_LANG_FLAG_3 (node))
fputs (" decl_3", file);
if (DECL_LANG_FLAG_4 (node))
fputs (" decl_4", file);
if (DECL_LANG_FLAG_5 (node))
fputs (" decl_5", file);
if (DECL_LANG_FLAG_6 (node))
fputs (" decl_6", file);
if (DECL_LANG_FLAG_7 (node))
fputs (" decl_7", file);
mode = DECL_MODE (node);
fprintf (file, " %s", GET_MODE_NAME (mode));
}
if ((code == VAR_DECL || code == PARM_DECL || code == RESULT_DECL)
&& DECL_BY_REFERENCE (node))
fputs (" passed-by-reference", file);
if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS) && DECL_DEFER_OUTPUT (node))
fputs (" defer-output", file);
xloc = expand_location (DECL_SOURCE_LOCATION (node));
fprintf (file, " file %s line %d col %d", xloc.file, xloc.line,
xloc.column);
if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
{
print_node (file, "size", DECL_SIZE (node), indent + 4);
print_node (file, "unit size", DECL_SIZE_UNIT (node), indent + 4);
if (code != FUNCTION_DECL || DECL_BUILT_IN (node))
indent_to (file, indent + 3);
if (DECL_USER_ALIGN (node))
fprintf (file, " user");
fprintf (file, " align %d", DECL_ALIGN (node));
if (code == FIELD_DECL)
fprintf (file, " offset_align " HOST_WIDE_INT_PRINT_UNSIGNED,
DECL_OFFSET_ALIGN (node));
if (code == FUNCTION_DECL && DECL_BUILT_IN (node))
{
if (DECL_BUILT_IN_CLASS (node) == BUILT_IN_MD)
fprintf (file, " built-in BUILT_IN_MD %d", DECL_FUNCTION_CODE (node));
else
fprintf (file, " built-in %s:%s",
built_in_class_names[(int) DECL_BUILT_IN_CLASS (node)],
built_in_names[(int) DECL_FUNCTION_CODE (node)]);
}
}
if (code == FIELD_DECL)
{
print_node (file, "offset", DECL_FIELD_OFFSET (node), indent + 4);
print_node (file, "bit offset", DECL_FIELD_BIT_OFFSET (node),
indent + 4);
if (DECL_BIT_FIELD_TYPE (node))
print_node (file, "bit_field_type", DECL_BIT_FIELD_TYPE (node),
indent + 4);
}
示例14: build_common_decl
static tree
build_common_decl (gfc_common_head *com, tree union_type, bool is_init)
{
gfc_symbol *common_sym;
tree decl;
/* Create a namespace to store symbols for common blocks. */
if (gfc_common_ns == NULL)
gfc_common_ns = gfc_get_namespace (NULL);
gfc_get_symbol (com->name, gfc_common_ns, &common_sym);
decl = common_sym->backend_decl;
/* Update the size of this common block as needed. */
if (decl != NULL_TREE)
{
tree size = TYPE_SIZE_UNIT (union_type);
if (tree_int_cst_lt (DECL_SIZE_UNIT (decl), size))
{
/* Named common blocks of the same name shall be of the same size
in all scoping units of a program in which they appear, but
blank common blocks may be of different sizes. */
if (strcmp (com->name, BLANK_COMMON_NAME))
gfc_warning ("Named COMMON block '%s' at %L shall be of the "
"same size", com->name, &com->where);
DECL_SIZE_UNIT (decl) = size;
}
}
/* If this common block has been declared in a previous program unit,
and either it is already initialized or there is no new initialization
for it, just return. */
if ((decl != NULL_TREE) && (!is_init || DECL_INITIAL (decl)))
return decl;
/* If there is no backend_decl for the common block, build it. */
if (decl == NULL_TREE)
{
decl = build_decl (VAR_DECL, get_identifier (com->name), union_type);
SET_DECL_ASSEMBLER_NAME (decl, gfc_sym_mangled_common_id (com->name));
TREE_PUBLIC (decl) = 1;
TREE_STATIC (decl) = 1;
DECL_ALIGN (decl) = BIGGEST_ALIGNMENT;
DECL_USER_ALIGN (decl) = 0;
gfc_set_decl_location (decl, &com->where);
/* Place the back end declaration for this common block in
GLOBAL_BINDING_LEVEL. */
common_sym->backend_decl = pushdecl_top_level (decl);
}
/* Has no initial values. */
if (!is_init)
{
DECL_INITIAL (decl) = NULL_TREE;
DECL_COMMON (decl) = 1;
DECL_DEFER_OUTPUT (decl) = 1;
}
else
{
DECL_INITIAL (decl) = error_mark_node;
DECL_COMMON (decl) = 0;
DECL_DEFER_OUTPUT (decl) = 0;
}
return decl;
}
示例15: mf_walk_comp_ref
/* The method walks the node hierarchy to the topmost node. This is
exactly how its done in mudflap and has been borrowed.
*/
static tree
mf_walk_comp_ref(tree *tp, tree type, location_t location, \
tree *addr_store, tree *base_store)
{
tree var, t, addr, base, size;
t = *tp;
int component_ref_only = (TREE_CODE (t) == COMPONENT_REF);
/* If we have a bitfield component reference, we must note the
innermost addressable object in ELT, from which we will
construct the byte-addressable bounds of the bitfield. */
tree elt = NULL_TREE;
int bitfield_ref_p = (TREE_CODE (t) == COMPONENT_REF
&& DECL_BIT_FIELD_TYPE (TREE_OPERAND (t, 1)));
/* Iterate to the top of the ARRAY_REF/COMPONENT_REF
containment hierarchy to find the outermost VAR_DECL. */
var = TREE_OPERAND (t, 0);
while (1)
{
if (bitfield_ref_p && elt == NULL_TREE
&& (TREE_CODE (var) == ARRAY_REF
|| TREE_CODE (var) == COMPONENT_REF))
elt = var;
if (TREE_CODE (var) == ARRAY_REF)
{
component_ref_only = 0;
var = TREE_OPERAND (var, 0);
}
else if (TREE_CODE (var) == COMPONENT_REF)
var = TREE_OPERAND (var, 0);
else if (INDIRECT_REF_P (var)
|| TREE_CODE (var) == MEM_REF)
{
base = TREE_OPERAND (var, 0);
break;
}
else if (TREE_CODE (var) == VIEW_CONVERT_EXPR)
{
var = TREE_OPERAND (var, 0);
if (CONSTANT_CLASS_P (var)
&& TREE_CODE (var) != STRING_CST)
return NULL_TREE;
}
else
{
DEBUGLOG("TREE_CODE(temp) : %s comp_ref_only = %d eligigle = %d\n", \
tree_code_name[(int)TREE_CODE(var)], component_ref_only, \
mf_decl_eligible_p(var));
gcc_assert (TREE_CODE (var) == VAR_DECL
|| TREE_CODE (var) == SSA_NAME /* TODO: Check this */
|| TREE_CODE (var) == PARM_DECL
|| TREE_CODE (var) == RESULT_DECL
|| TREE_CODE (var) == STRING_CST);
/* Don't instrument this access if the underlying
variable is not "eligible". This test matches
those arrays that have only known-valid indexes,
and thus are not labeled TREE_ADDRESSABLE. */
if (! mf_decl_eligible_p (var)) //TODO is this needed? || component_ref_only)
return NULL_TREE;
else
{
base = build1 (ADDR_EXPR,
build_pointer_type (TREE_TYPE (var)), var);
break;
}
}
}
/* Handle the case of ordinary non-indirection structure
accesses. These have only nested COMPONENT_REF nodes (no
INDIRECT_REF), but pass through the above filter loop.
Note that it's possible for such a struct variable to match
the eligible_p test because someone else might take its
address sometime. */
/* We need special processing for bitfield components, because
their addresses cannot be taken. */
if (bitfield_ref_p)
{
tree field = TREE_OPERAND (t, 1);
if (TREE_CODE (DECL_SIZE_UNIT (field)) == INTEGER_CST)
size = DECL_SIZE_UNIT (field);
if (elt)
elt = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (elt)),
elt);
addr = fold_convert_loc (location, ptr_type_node, elt ? elt : base);
addr = fold_build2_loc (location, POINTER_PLUS_EXPR, ptr_type_node,
addr, fold_convert_loc (location, sizetype,
byte_position (field)));
}
else
addr = build1 (ADDR_EXPR, build_pointer_type (type), t);
//.........这里部分代码省略.........