void add_friend (tree type, tree decl, bool complain) { tree typedecl; tree list; tree name; tree ctx; if (decl == error_mark_node) return; typedecl = TYPE_MAIN_DECL (type); list = DECL_FRIENDLIST (typedecl); name = DECL_NAME (decl); type = TREE_TYPE (typedecl); while (list) { if (name == FRIEND_NAME (list)) { tree friends = FRIEND_DECLS (list); for (; friends ; friends = TREE_CHAIN (friends)) { if (decl == TREE_VALUE (friends)) { if (complain) warning (0, "%qD is already a friend of class %qT", decl, type); return; } } maybe_add_class_template_decl_list (type, decl, /*friend_p=*/1); TREE_VALUE (list) = tree_cons (NULL_TREE, decl, TREE_VALUE (list)); return; } list = TREE_CHAIN (list); } ctx = DECL_CONTEXT (decl); if (ctx && CLASS_TYPE_P (ctx) && !uses_template_parms (ctx)) perform_or_defer_access_check (TYPE_BINFO (ctx), decl, decl); maybe_add_class_template_decl_list (type, decl, /*friend_p=*/1); DECL_FRIENDLIST (typedecl) = tree_cons (DECL_NAME (decl), build_tree_list (NULL_TREE, decl), DECL_FRIENDLIST (typedecl)); if (!uses_template_parms (type)) DECL_BEFRIENDING_CLASSES (decl) = tree_cons (NULL_TREE, type, DECL_BEFRIENDING_CLASSES (decl)); }
tree make_attribute (const char *name, const char *arg_name, tree chain) { tree attr_name; tree attr_arg_name; tree attr_args; tree attr; attr_name = get_identifier (name); attr_arg_name = build_string (strlen (arg_name), arg_name); attr_args = tree_cons (NULL_TREE, attr_arg_name, NULL_TREE); attr = tree_cons (attr_name, attr_args, chain); return attr; }
static tree do_free_exception (tree ptr) { tree fn; fn = get_identifier ("__cxa_free_exception"); if (!get_global_value_if_present (fn, &fn)) { /* Declare void __cxa_free_exception (void *). */ fn = push_void_library_fn (fn, tree_cons (NULL_TREE, ptr_type_node, void_list_node)); } return build_function_call (fn, tree_cons (NULL_TREE, ptr, NULL_TREE)); }
tree oacc_build_routine_dims (tree clauses) { /* Must match GOMP_DIM ordering. */ static const omp_clause_code ids[] = {OMP_CLAUSE_GANG, OMP_CLAUSE_WORKER, OMP_CLAUSE_VECTOR, OMP_CLAUSE_SEQ}; int ix; int level = -1; for (; clauses; clauses = OMP_CLAUSE_CHAIN (clauses)) for (ix = GOMP_DIM_MAX + 1; ix--;) if (OMP_CLAUSE_CODE (clauses) == ids[ix]) { if (level >= 0) error_at (OMP_CLAUSE_LOCATION (clauses), "multiple loop axes specified for routine"); level = ix; break; } /* Default to SEQ. */ if (level < 0) level = GOMP_DIM_MAX; tree dims = NULL_TREE; for (ix = GOMP_DIM_MAX; ix--;) dims = tree_cons (build_int_cst (boolean_type_node, ix >= level), build_int_cst (integer_type_node, ix < level), dims); return dims; }
void init_exception_processing (void) { tree tmp; /* void std::terminate (); */ push_namespace (std_identifier); tmp = build_function_type (void_type_node, void_list_node); terminate_node = build_cp_library_fn_ptr ("terminate", tmp); TREE_THIS_VOLATILE (terminate_node) = 1; TREE_NOTHROW (terminate_node) = 1; pop_namespace (); /* void __cxa_call_unexpected(void *); */ tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node); tmp = build_function_type (void_type_node, tmp); call_unexpected_node = push_throw_library_fn (get_identifier ("__cxa_call_unexpected"), tmp); eh_personality_libfunc = init_one_libfunc (USING_SJLJ_EXCEPTIONS ? "__gxx_personality_sj0" : "__gxx_personality_v0"); lang_eh_runtime_type = build_eh_type_type; lang_protect_cleanup_actions = &cp_protect_cleanup_actions; }
/* Add ATTR to the attributes of the current function. If there is no such function, save it to be added to the attributes of the next function. */ static void sh_add_function_attribute (const char *attr) { tree id = get_identifier (attr); if (current_function_decl) decl_attributes (¤t_function_decl, tree_cons (id, NULL_TREE, NULL_TREE), 0); else { *sh_deferred_function_attributes_tail = tree_cons (id, NULL_TREE, *sh_deferred_function_attributes_tail); sh_deferred_function_attributes_tail = &TREE_CHAIN (*sh_deferred_function_attributes_tail); } }
static tree declare_nothrow_library_fn (tree name, tree return_type, tree parm_type) { tree tmp = tree_cons (NULL_TREE, parm_type, void_list_node); return push_library_fn (name, build_function_type (return_type, tmp), empty_except_spec); }
tree parse_signature_string (const unsigned char *sig_string, int sig_length) { tree result_type; const unsigned char *str = sig_string; const unsigned char *limit = str + sig_length; if (str < limit && str[0] == '(') { tree argtype_list = NULL_TREE; str++; while (str < limit && str[0] != ')') { tree argtype = parse_signature_type (&str, limit); argtype_list = tree_cons (NULL_TREE, argtype, argtype_list); } if (str++, str >= limit) abort (); result_type = parse_signature_type (&str, limit); argtype_list = chainon (nreverse (argtype_list), end_params_node); result_type = build_function_type (result_type, argtype_list); } else result_type = parse_signature_type (&str, limit); if (str != limit) error ("junk at end of signature string"); return result_type; }
static tree do_begin_catch (void) { tree fn; fn = get_identifier ("__cxa_begin_catch"); if (!get_global_value_if_present (fn, &fn)) { /* Declare void* __cxa_begin_catch (void *). */ tree tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node); fn = push_library_fn (fn, build_function_type (ptr_type_node, tmp)); } return build_function_call (fn, tree_cons (NULL_TREE, build_exc_ptr (), NULL_TREE)); }
tree add_scope_stmt (int begin_p, int partial_p) { tree *stack_ptr = current_scope_stmt_stack (); tree ss; tree top = *stack_ptr; /* Build the statement. */ ss = build_stmt (SCOPE_STMT, NULL_TREE); SCOPE_BEGIN_P (ss) = begin_p; SCOPE_PARTIAL_P (ss) = partial_p; /* Keep the scope stack up to date. */ if (begin_p) { top = tree_cons (ss, NULL_TREE, top); *stack_ptr = top; } else { if (partial_p != SCOPE_PARTIAL_P (TREE_PURPOSE (top))) abort (); TREE_VALUE (top) = ss; *stack_ptr = TREE_CHAIN (top); } /* Add the new statement to the statement-tree. */ add_stmt (ss); return top; }
void finish_eh_spec_block (tree raw_raises, tree eh_spec_block) { tree raises; TREE_OPERAND (eh_spec_block, 0) = pop_stmt_list (TREE_OPERAND (eh_spec_block, 0)); if (TREE_CODE (eh_spec_block) == MUST_NOT_THROW_EXPR) return; /* Strip cv quals, etc, from the specification types. */ for (raises = NULL_TREE; raw_raises && TREE_VALUE (raw_raises); raw_raises = TREE_CHAIN (raw_raises)) { tree type = prepare_eh_type (TREE_VALUE (raw_raises)); tree tinfo = eh_type_info (type); mark_used (tinfo); raises = tree_cons (NULL_TREE, type, raises); } EH_SPEC_RAISES (eh_spec_block) = raises; }
static tree do_allocate_exception (tree type) { tree fn; fn = get_identifier ("__cxa_allocate_exception"); if (!get_global_value_if_present (fn, &fn)) { /* Declare void *__cxa_allocate_exception(size_t). */ tree tmp = tree_cons (NULL_TREE, size_type_node, void_list_node); fn = push_library_fn (fn, build_function_type (ptr_type_node, tmp)); } return build_function_call (fn, tree_cons (NULL_TREE, size_in_bytes (type), NULL_TREE)); }
static tree start_cdtor (int method_type) { tree fnname = get_file_function_name (method_type); tree void_list_node_1 = build_tree_list (NULL_TREE, void_type_node); tree body; start_function (void_list_node_1, build_nt (CALL_EXPR, fnname, tree_cons (NULL_TREE, NULL_TREE, void_list_node_1), NULL_TREE), NULL_TREE); store_parm_decls (); current_function_cannot_inline = "static constructors and destructors cannot be inlined"; body = c_begin_compound_stmt (); pushlevel (0); clear_last_expr (); add_scope_stmt (/*begin_p=*/1, /*partial_p=*/0); return body; }
unsigned int tree_ssa_prefetch_arrays (struct loops *loops) { unsigned i; struct loop *loop; bool unrolled = false; int todo_flags = 0; if (!HAVE_prefetch /* It is possible to ask compiler for say -mtune=i486 -march=pentium4. -mtune=i486 causes us having PREFETCH_BLOCK 0, since this is part of processor costs and i486 does not have prefetch, but -march=pentium4 causes HAVE_prefetch to be true. Ugh. */ || PREFETCH_BLOCK == 0) return 0; initialize_original_copy_tables (); if (!built_in_decls[BUILT_IN_PREFETCH]) { tree type = build_function_type (void_type_node, tree_cons (NULL_TREE, const_ptr_type_node, NULL_TREE)); tree decl = lang_hooks.builtin_function ("__builtin_prefetch", type, BUILT_IN_PREFETCH, BUILT_IN_NORMAL, NULL, NULL_TREE); DECL_IS_NOVOPS (decl) = true; built_in_decls[BUILT_IN_PREFETCH] = decl; } /* We assume that size of cache line is a power of two, so verify this here. */ gcc_assert ((PREFETCH_BLOCK & (PREFETCH_BLOCK - 1)) == 0); for (i = loops->num - 1; i > 0; i--) { loop = loops->parray[i]; if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "Processing loop %d:\n", loop->num); if (loop) unrolled |= loop_prefetch_arrays (loops, loop); if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "\n\n"); } if (unrolled) { scev_reset (); todo_flags |= TODO_cleanup_cfg; } free_original_copy_tables (); return todo_flags; }
static void tree_gen_one_value_profiler (histogram_value value, unsigned tag, unsigned base) { tree stmt = value->hvalue.stmt; block_stmt_iterator bsi = bsi_for_stmt (stmt); tree ref = tree_coverage_counter_ref (tag, base), ref_ptr; tree args, call, val; ref_ptr = force_gimple_operand_bsi (&bsi, build_addr (ref, current_function_decl), true, NULL_TREE); val = prepare_instrumented_value (&bsi, value); args = tree_cons (NULL_TREE, ref_ptr, tree_cons (NULL_TREE, val, NULL_TREE)); call = build_function_call_expr (tree_one_value_profiler_fn, args); bsi_insert_before (&bsi, call, BSI_SAME_STMT); }
tree gfc_chainon_list (tree list, tree add) { tree l; l = tree_cons (NULL_TREE, add, NULL_TREE); return chainon (list, l); }
static bool wrapper_parm_cb (const void *key0, void **val0, void *data) { struct wrapper_data *wd = (struct wrapper_data *) data; tree arg = * (tree *)&key0; tree val = (tree)*val0; tree parm; if (val == error_mark_node || val == arg) return true; if (TREE_CODE (val) == PAREN_EXPR) { /* We should not reach here with a register receiver. We may see a register variable modified in the argument list. Because register variables are worker-local we don't need to work hard to support them in code that spawns. */ if ((TREE_CODE (arg) == VAR_DECL) && DECL_HARD_REGISTER (arg)) { error_at (EXPR_LOCATION (arg), "explicit register variable %qD may not be modified in " "spawn", arg); arg = null_pointer_node; } else arg = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (arg)), arg); val = TREE_OPERAND (val, 0); *val0 = val; gcc_assert (TREE_CODE (val) == INDIRECT_REF); parm = TREE_OPERAND (val, 0); STRIP_NOPS (parm); } else parm = val; TREE_CHAIN (parm) = wd->parms; wd->parms = parm; wd->argtypes = tree_cons (NULL_TREE, TREE_TYPE (parm), wd->argtypes); wd->arglist = tree_cons (NULL_TREE, arg, wd->arglist); return true; }
void oacc_replace_fn_attrib (tree fn, tree dims) { tree ident = get_identifier (OACC_FN_ATTRIB); tree attribs = DECL_ATTRIBUTES (fn); /* If we happen to be present as the first attrib, drop it. */ if (attribs && TREE_PURPOSE (attribs) == ident) attribs = TREE_CHAIN (attribs); DECL_ATTRIBUTES (fn) = tree_cons (ident, dims, attribs); }
tree tree_code_add_parameter (tree list, tree proto_exp, tree exp) { tree new_exp; new_exp = tree_cons (NULL_TREE, build1 (CONVERT_EXPR, TREE_TYPE (proto_exp), exp), NULL_TREE); if (!list) return new_exp; return chainon (new_exp, list); }
static tree ptr_initializer (tree desc, tree target) { tree init = tinfo_base_init (desc, target); tree to = TREE_TYPE (target); int flags = qualifier_flags (to); bool incomplete = target_incomplete_p (to); if (incomplete) flags |= 8; init = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, flags), init); init = tree_cons (NULL_TREE, get_tinfo_ptr (TYPE_MAIN_VARIANT (to)), init); init = build_constructor (NULL_TREE, nreverse (init)); TREE_CONSTANT (init) = 1; TREE_INVARIANT (init) = 1; TREE_STATIC (init) = 1; return init; }
static inline void maybe_add_dllexport (tree decl) { if (i386_pe_type_dllexport_p (decl)) { tree decl_attrs = DECL_ATTRIBUTES (decl); if (lookup_attribute ("dllexport", decl_attrs) != NULL_TREE) /* Already done. */ return; DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("dllexport"), NULL_TREE, decl_attrs); } }
static void mudflap_register_call (tree obj, tree object_size, tree varname) { tree arg, args, call_stmt; args = tree_cons (NULL_TREE, varname, NULL_TREE); arg = build_int_cst (NULL_TREE, 4); /* __MF_TYPE_STATIC */ args = tree_cons (NULL_TREE, arg, args); arg = convert (size_type_node, object_size); args = tree_cons (NULL_TREE, arg, args); arg = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (obj)), obj); arg = convert (ptr_type_node, arg); args = tree_cons (NULL_TREE, arg, args); call_stmt = build_function_call_expr (mf_register_fndecl, args); append_to_statement_list (call_stmt, &enqueued_call_stmt_chain); }
static void genericize_eh_spec_block (tree *stmt_p) { tree body = EH_SPEC_STMTS (*stmt_p); tree allowed = EH_SPEC_RAISES (*stmt_p); tree failure = build_call (call_unexpected_node, tree_cons (NULL_TREE, build_exc_ptr (), NULL_TREE)); gimplify_stmt (&body); *stmt_p = gimple_build_eh_filter (body, allowed, failure); }
static tree /* APPLE LOCAL radar 2848255 */ do_begin_catch (tree type) { tree fn; /* APPLE LOCAL begin radar 2848255 */ if (c_dialect_objc () && objc2_valid_objc_catch_type (type)) fn = get_identifier ("objc_begin_catch"); else fn = get_identifier ("__cxa_begin_catch"); /* APPLE LOCAL end radar 2848255 */ if (!get_global_value_if_present (fn, &fn)) { /* Declare void* __cxa_begin_catch (void *). */ tree tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node); fn = push_library_fn (fn, build_function_type (ptr_type_node, tmp)); } return build_function_call (fn, tree_cons (NULL_TREE, build_exc_ptr (), NULL_TREE)); }
static void issue_prefetch_ref (struct mem_ref *ref, unsigned unroll_factor, unsigned ahead) { HOST_WIDE_INT delta; tree addr, addr_base, prefetch, params, write_p; block_stmt_iterator bsi; unsigned n_prefetches, ap; if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "Issued prefetch for %p.\n", (void *) ref); bsi = bsi_for_stmt (ref->stmt); n_prefetches = ((unroll_factor + ref->prefetch_mod - 1) / ref->prefetch_mod); addr_base = build_fold_addr_expr_with_type (ref->mem, ptr_type_node); addr_base = force_gimple_operand_bsi (&bsi, unshare_expr (addr_base), true, NULL); for (ap = 0; ap < n_prefetches; ap++) { /* Determine the address to prefetch. */ delta = (ahead + ap * ref->prefetch_mod) * ref->group->step; addr = fold_build2 (PLUS_EXPR, ptr_type_node, addr_base, build_int_cst (ptr_type_node, delta)); addr = force_gimple_operand_bsi (&bsi, unshare_expr (addr), true, NULL); /* Create the prefetch instruction. */ write_p = ref->write_p ? integer_one_node : integer_zero_node; params = tree_cons (NULL_TREE, addr, tree_cons (NULL_TREE, write_p, NULL_TREE)); prefetch = build_function_call_expr (built_in_decls[BUILT_IN_PREFETCH], params); bsi_insert_before (&bsi, prefetch, BSI_SAME_STMT); } }
static tree do_free_exception (tree ptr) { tree fn; fn = get_identifier ("__cxa_free_exception"); if (!get_global_value_if_present (fn, &fn)) { /* Declare void __cxa_free_exception (void *) throw(). */ fn = declare_nothrow_library_fn (fn, void_type_node, ptr_type_node); } return cp_build_function_call (fn, tree_cons (NULL_TREE, ptr, NULL_TREE), tf_warning_or_error); }
tree add_objc_string (tree ident, string_section section) { tree *chain, decl, type; char buf[BUFSIZE]; switch (section) { case class_names: chain = &class_names_chain; snprintf (buf, BUFSIZE, "_OBJC_ClassName_%s", IDENTIFIER_POINTER (ident)); break; case meth_var_names: chain = &meth_var_names_chain; snprintf (buf, BUFSIZE, "_OBJC_METH_VAR_NAME_%d", meth_var_names_idx++); break; case meth_var_types: chain = &meth_var_types_chain; snprintf (buf, BUFSIZE, "_OBJC_METH_VAR_TYPE_%d", meth_var_types_idx++); break; case prop_names_attr: chain = &prop_names_attr_chain; snprintf (buf, BUFSIZE, "_OBJC_PropertyAttributeOrName_%d", property_name_attr_idx++); break; default: gcc_unreachable (); } while (*chain) { if (TREE_VALUE (*chain) == ident) return convert (string_type_node, build_unary_op (input_location, ADDR_EXPR, TREE_PURPOSE (*chain), 1)); chain = &TREE_CHAIN (*chain); } type = build_sized_array_type (char_type_node, IDENTIFIER_LENGTH (ident) + 1); /* Get a runtime-specific string decl which will be finish_var()'ed in generate_strings (). */ decl = (*runtime.string_decl) (type, buf, section); TREE_CONSTANT (decl) = 1; *chain = tree_cons (decl, ident, NULL_TREE); return convert (string_type_node, build_unary_op (input_location, ADDR_EXPR, decl, 1)); }
static tree do_begin_catch (void) { tree fn; fn = get_identifier ("__cxa_begin_catch"); if (!get_global_value_if_present (fn, &fn)) { /* Declare void* __cxa_begin_catch (void *) throw(). */ fn = declare_nothrow_library_fn (fn, ptr_type_node, ptr_type_node); } return cp_build_function_call (fn, tree_cons (NULL_TREE, build_exc_ptr (), NULL_TREE), tf_warning_or_error); }
static tree rewrite_reciprocal (block_stmt_iterator *bsi) { tree stmt, lhs, rhs, stmt1, stmt2, var, name, tmp; tree real_one; stmt = bsi_stmt (*bsi); lhs = GENERIC_TREE_OPERAND (stmt, 0); rhs = GENERIC_TREE_OPERAND (stmt, 1); /* stmt must be GIMPLE_MODIFY_STMT. */ var = create_tmp_var (TREE_TYPE (rhs), "reciptmp"); add_referenced_var (var); DECL_GIMPLE_REG_P (var) = 1; if (TREE_CODE (TREE_TYPE (rhs)) == VECTOR_TYPE) { int i, len; tree list = NULL_TREE; real_one = build_real (TREE_TYPE (TREE_TYPE (rhs)), dconst1); len = TYPE_VECTOR_SUBPARTS (TREE_TYPE (rhs)); for (i = 0; i < len; i++) list = tree_cons (NULL, real_one, list); real_one = build_vector (TREE_TYPE (rhs), list); } else real_one = build_real (TREE_TYPE (rhs), dconst1); tmp = build2 (RDIV_EXPR, TREE_TYPE (rhs), real_one, TREE_OPERAND (rhs, 1)); stmt1 = build_gimple_modify_stmt (var, tmp); name = make_ssa_name (var, stmt1); GIMPLE_STMT_OPERAND (stmt1, 0) = name; tmp = build2 (MULT_EXPR, TREE_TYPE (rhs), name, TREE_OPERAND (rhs, 0)); stmt2 = build_gimple_modify_stmt (lhs, tmp); /* Replace division stmt with reciprocal and multiply stmts. The multiply stmt is not invariant, so update iterator and avoid rescanning. */ bsi_replace (bsi, stmt1, true); bsi_insert_after (bsi, stmt2, BSI_NEW_STMT); SSA_NAME_DEF_STMT (lhs) = stmt2; /* Continue processing with invariant reciprocal statement. */ return stmt1; }
static tree do_allocate_exception (tree type) { tree fn; fn = get_identifier ("__cxa_allocate_exception"); if (!get_global_value_if_present (fn, &fn)) { /* Declare void *__cxa_allocate_exception(size_t) throw(). */ fn = declare_nothrow_library_fn (fn, ptr_type_node, size_type_node); } return cp_build_function_call (fn, tree_cons (NULL_TREE, size_in_bytes (type), NULL_TREE), tf_warning_or_error); }