コード例 #1
0
ファイル: aarch64-builtins.c プロジェクト: rockflying/gcc
void
aarch64_init_builtins (void)
{
  tree ftype_set_fpr
    = build_function_type_list (void_type_node, unsigned_type_node, NULL);
  tree ftype_get_fpr
    = build_function_type_list (unsigned_type_node, NULL);

  aarch64_builtin_decls[AARCH64_BUILTIN_GET_FPCR]
    = add_builtin_function ("__builtin_aarch64_get_fpcr", ftype_get_fpr,
			    AARCH64_BUILTIN_GET_FPCR, BUILT_IN_MD, NULL, NULL_TREE);
  aarch64_builtin_decls[AARCH64_BUILTIN_SET_FPCR]
    = add_builtin_function ("__builtin_aarch64_set_fpcr", ftype_set_fpr,
			    AARCH64_BUILTIN_SET_FPCR, BUILT_IN_MD, NULL, NULL_TREE);
  aarch64_builtin_decls[AARCH64_BUILTIN_GET_FPSR]
    = add_builtin_function ("__builtin_aarch64_get_fpsr", ftype_get_fpr,
			    AARCH64_BUILTIN_GET_FPSR, BUILT_IN_MD, NULL, NULL_TREE);
  aarch64_builtin_decls[AARCH64_BUILTIN_SET_FPSR]
    = add_builtin_function ("__builtin_aarch64_set_fpsr", ftype_set_fpr,
			    AARCH64_BUILTIN_SET_FPSR, BUILT_IN_MD, NULL, NULL_TREE);

  if (TARGET_SIMD)
    aarch64_init_simd_builtins ();
  if (TARGET_CRC32)
    aarch64_init_crc32_builtins ();
}
コード例 #2
0
ファイル: tree-mudflap.c プロジェクト: ChaosJohn/gcc
/* Initialize the global tree nodes that correspond to mf-runtime.h
   declarations.  */
void
mudflap_init (void)
{
  static bool done = false;
  tree mf_const_string_type;
  tree mf_cache_array_type;
  tree mf_check_register_fntype;
  tree mf_unregister_fntype;
  tree mf_init_fntype;
  tree mf_set_options_fntype;

  if (done)
    return;
  done = true;

  mf_uintptr_type = lang_hooks.types.type_for_mode (ptr_mode,
                                                    /*unsignedp=*/true);
  mf_const_string_type
    = build_pointer_type (build_qualified_type
                          (char_type_node, TYPE_QUAL_CONST));

  mf_cache_struct_type = mf_make_mf_cache_struct_type (mf_uintptr_type);
  mf_cache_structptr_type = build_pointer_type (mf_cache_struct_type);
  mf_cache_array_type = build_array_type (mf_cache_struct_type, 0);
  mf_check_register_fntype =
    build_function_type_list (void_type_node, ptr_type_node, size_type_node,
			      integer_type_node, mf_const_string_type, NULL_TREE);
  mf_unregister_fntype =
    build_function_type_list (void_type_node, ptr_type_node, size_type_node,
			      integer_type_node, NULL_TREE);
  mf_init_fntype =
    build_function_type_list (void_type_node, NULL_TREE);
  mf_set_options_fntype =
    build_function_type_list (integer_type_node, mf_const_string_type, NULL_TREE);

  mf_cache_array_decl = mf_make_builtin (VAR_DECL, "__mf_lookup_cache",
                                         mf_cache_array_type);
  mf_cache_shift_decl = mf_make_builtin (VAR_DECL, "__mf_lc_shift",
                                         unsigned_char_type_node);
  mf_cache_mask_decl = mf_make_builtin (VAR_DECL, "__mf_lc_mask",
                                        mf_uintptr_type);
  /* Don't process these in mudflap_enqueue_decl, should they come by
     there for some reason.  */
  mf_mark (mf_cache_array_decl);
  mf_mark (mf_cache_shift_decl);
  mf_mark (mf_cache_mask_decl);
  mf_check_fndecl = mf_make_builtin (FUNCTION_DECL, "__mf_check",
                                     mf_check_register_fntype);
  mf_register_fndecl = mf_make_builtin (FUNCTION_DECL, "__mf_register",
                                        mf_check_register_fntype);
  mf_unregister_fndecl = mf_make_builtin (FUNCTION_DECL, "__mf_unregister",
                                          mf_unregister_fntype);
  mf_init_fndecl = mf_make_builtin (FUNCTION_DECL, "__mf_init",
                                    mf_init_fntype);
  mf_set_options_fndecl = mf_make_builtin (FUNCTION_DECL, "__mf_set_options",
                                           mf_set_options_fntype);
}
コード例 #3
0
ファイル: nds32-intrinsic.c プロジェクト: earonesty/gcc
void
nds32_init_builtins_impl (void)
{
  tree pointer_type_node  = build_pointer_type (integer_type_node);

  tree void_ftype_void    = build_function_type (void_type_node,
						 void_list_node);

  tree void_ftype_pint    = build_function_type_list (void_type_node,
						      pointer_type_node,
						      NULL_TREE);

  tree int_ftype_int      = build_function_type_list (integer_type_node,
						      integer_type_node,
						      NULL_TREE);

  tree void_ftype_int_int = build_function_type_list (void_type_node,
						      integer_type_node,
						      integer_type_node,
						      NULL_TREE);

  /* Cache.  */
  add_builtin_function ("__builtin_nds32_isync",  void_ftype_pint,
			NDS32_BUILTIN_ISYNC,
			BUILT_IN_MD, NULL, NULL_TREE);
  add_builtin_function ("__builtin_nds32_isb",  void_ftype_void,
			NDS32_BUILTIN_ISB,
			BUILT_IN_MD, NULL, NULL_TREE);

  /* Register Transfer.  */
  add_builtin_function ("__builtin_nds32_mfsr",  int_ftype_int,
			NDS32_BUILTIN_MFSR,
			BUILT_IN_MD, NULL, NULL_TREE);
  add_builtin_function ("__builtin_nds32_mfusr", int_ftype_int,
			NDS32_BUILTIN_MFUSR,
			BUILT_IN_MD, NULL, NULL_TREE);
  add_builtin_function ("__builtin_nds32_mtsr",  void_ftype_int_int,
			NDS32_BUILTIN_MTSR,
			BUILT_IN_MD, NULL, NULL_TREE);
  add_builtin_function ("__builtin_nds32_mtusr", void_ftype_int_int,
			NDS32_BUILTIN_MTUSR,
			BUILT_IN_MD, NULL, NULL_TREE);

  /* Interrupt.  */
  add_builtin_function ("__builtin_nds32_setgie_en",  void_ftype_void,
			NDS32_BUILTIN_SETGIE_EN,
			BUILT_IN_MD, NULL, NULL_TREE);
  add_builtin_function ("__builtin_nds32_setgie_dis", void_ftype_void,
			NDS32_BUILTIN_SETGIE_DIS,
			BUILT_IN_MD, NULL, NULL_TREE);
}
コード例 #4
0
ファイル: plugin_lbc.c プロジェクト: sdzahed/LBC-Plugin
void
lbc_init (void)
{
    static bool done = false;
	tree lbc_init_uninit_rz_fntype;
	tree lbc_ensure_sframe_fntype;
	tree lbc_is_char_red_fntype;
	tree lbc_const_void_ptr_type;

    if (done)
        return;
    done = true;

    decl_map = (Pvoid_t) NULL;

    DEBUGLOG("LBC Plugin: Building decls\n");

	lbc_const_void_ptr_type = build_qualified_type (ptr_type_node, TYPE_QUAL_CONST);

	lbc_init_uninit_rz_fntype =
		build_function_type_list (void_type_node, ptr_type_node,
				unsigned_type_node, NULL_TREE);
	/*lbc_ensure_sframe_fntype =
		build_function_type_list (void_type_node, ptr_type_node,
                ptr_type_node, NULL_TREE);*/
	lbc_ensure_sframe_fntype =
		build_function_type_list (void_type_node, void_type_node, NULL_TREE);

	lbc_is_char_red_fntype =
		build_function_type_list (void_type_node, unsigned_type_node,
				unsigned_type_node, lbc_const_void_ptr_type, NULL_TREE);

	lbc_init_front_rz_fndecl = mf_make_builtin (FUNCTION_DECL, "init_front_redzone",
			lbc_init_uninit_rz_fntype);
	lbc_uninit_front_rz_fndecl = mf_make_builtin (FUNCTION_DECL, "uninit_front_redzone",
			lbc_init_uninit_rz_fntype);
	lbc_init_rear_rz_fndecl = mf_make_builtin (FUNCTION_DECL, "init_rear_redzone",
			lbc_init_uninit_rz_fntype);
	lbc_uninit_rear_rz_fndecl = mf_make_builtin (FUNCTION_DECL, "uninit_rear_redzone",
			lbc_init_uninit_rz_fntype);
	lbc_ensure_sframe_bitmap_fndecl = mf_make_builtin (FUNCTION_DECL, "ensure_sframe_bitmap",
			lbc_ensure_sframe_fntype);
	lbc_is_char_red_fndecl = mf_make_builtin (FUNCTION_DECL, "is_char_red",
			lbc_is_char_red_fntype);
    DEBUGLOG("LBC Plugin: Done Building decls\n");
}
コード例 #5
0
ファイル: except.c プロジェクト: Samsara00/DragonFlyBSD
static tree
declare_nothrow_library_fn (tree name, tree return_type, tree parm_type)
{
  return push_library_fn (name, build_function_type_list (return_type,
							  parm_type,
							  NULL_TREE),
			  empty_except_spec);
}
コード例 #6
0
ファイル: cilk-common.c プロジェクト: krichter722/gcc
static tree
declare_cilk_for_builtin (const char *name, tree type,
			  enum built_in_function code)
{
  tree cb, ft, fn;

  cb = build_function_type_list (void_type_node,
				 ptr_type_node, type, type,
				 NULL_TREE);
  cb = build_pointer_type (cb);
  ft = build_function_type_list (void_type_node,
				 cb, ptr_type_node, type,
				 integer_type_node, NULL_TREE);
  fn = install_builtin (name, ft, code, false);
  TREE_NOTHROW (fn) = 0;

  return fn;
}
コード例 #7
0
ファイル: except.c プロジェクト: Samsara00/DragonFlyBSD
void
init_exception_processing (void)
{
  tree tmp;

  /* void std::terminate (); */
  push_namespace (std_identifier);
  tmp = build_function_type_list (void_type_node, NULL_TREE);
  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 = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE);
  call_unexpected_node
    = push_throw_library_fn (get_identifier ("__cxa_call_unexpected"), tmp);
}
コード例 #8
0
static tree
declare_library_fn (tree name, tree return_type, tree parm_type, int ecf_flags)
{
  return push_library_fn (name, build_function_type_list (return_type,
							  parm_type,
							  NULL_TREE),
			  empty_except_spec,
			  ecf_flags);
}
コード例 #9
0
/* parsing language hook */
static void slang_parse_file ()
{

    int i;
    for(i = 0; i<num_in_fnames; ++i) {
        parse_program(in_fnames[i]);
    } 
#if 0
  tree  char_p = build_pointer_type (char_type_node);
  tree  puts_type   = build_function_type_list (integer_type_node,
						char_p, NULL_TREE);
  tree  puts_fndecl = build_function_decl ("puts", true, puts_type);

  tree  main_type   = build_function_type_list (integer_type_node, NULL_TREE);
  tree  main_fndecl = build_function_decl ("main", false, main_type);

  const char *msg = "HelloWorld , ... This is pradeeps compiler";
  tree hello_str = build_string_literal (strlen(msg) + 1, msg);

  tree  call = build_call_expr (puts_fndecl,1, hello_str);
  tree block = make_node(BLOCK);
  tree       c1 = build_pointer_type (char_type_node);
  tree stmts = NULL_TREE ;//alloc_stmt_list ();
  append_to_statement_list (call, &stmts);

  build_function (main_fndecl, stmts, block);

  FILE *fd = fopen("/home/pradeep/Desktop/dump.txt","w");


  gimplify_function_tree (main_fndecl);

  dump_function_to_file (main_fndecl, fd, 0);

  fclose(fd);

  cgraph_finalize_function (main_fndecl, false);

  current_function_decl = NULL_TREE;
  pop_cfun();
#endif

}
コード例 #10
0
ファイル: except.c プロジェクト: kusumi/DragonFlyBSD
void
init_exception_processing (void)
{
  tree tmp;

  /* void std::terminate (); */
  push_namespace (std_identifier);
  tmp = build_function_type_list (void_type_node, NULL_TREE);
  terminate_fn = build_cp_library_fn_ptr ("terminate", tmp,
					   ECF_NOTHROW | ECF_NORETURN
					   | ECF_COLD);
  gcc_checking_assert (TREE_THIS_VOLATILE (terminate_fn)
		       && TREE_NOTHROW (terminate_fn));
  pop_namespace ();

  /* void __cxa_call_unexpected(void *); */
  tmp = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE);
  call_unexpected_fn
    = push_throw_library_fn (get_identifier ("__cxa_call_unexpected"), tmp);
}
コード例 #11
0
static void
tree_init_edge_profiler (void)
{
    tree interval_profiler_fn_type;
    tree pow2_profiler_fn_type;
    tree one_value_profiler_fn_type;
    tree gcov_type_ptr;

    if (!gcov_type_node)
    {
        gcov_type_node = get_gcov_type ();
        gcov_type_ptr = build_pointer_type (gcov_type_node);

        /* void (*) (gcov_type *, gcov_type, int, unsigned)  */
        interval_profiler_fn_type
            = build_function_type_list (void_type_node,
                                        gcov_type_ptr, gcov_type_node,
                                        integer_type_node,
                                        unsigned_type_node, NULL_TREE);
        tree_interval_profiler_fn
            = build_fn_decl ("__gcov_interval_profiler",
                             interval_profiler_fn_type);

        /* void (*) (gcov_type *, gcov_type)  */
        pow2_profiler_fn_type
            = build_function_type_list (void_type_node,
                                        gcov_type_ptr, gcov_type_node,
                                        NULL_TREE);
        tree_pow2_profiler_fn = build_fn_decl ("__gcov_pow2_profiler",
                                               pow2_profiler_fn_type);

        /* void (*) (gcov_type *, gcov_type)  */
        one_value_profiler_fn_type
            = build_function_type_list (void_type_node,
                                        gcov_type_ptr, gcov_type_node,
                                        NULL_TREE);
        tree_one_value_profiler_fn
            = build_fn_decl ("__gcov_one_value_profiler",
                             one_value_profiler_fn_type);
    }
}
コード例 #12
0
ファイル: xkaapi.c プロジェクト: texane/xkaapi_gcc_plugin
static void init_decls(void)
{
    static unsigned int is_once = 0;
    tree type;

    if (is_once) return ;
    is_once = 1;

    type = build_function_type_list
           (ptr_type_node, size_type_node, NULL_TREE);
    kaapi_pushdata_aligned_decl =
        build_fn_decl("kaapi_pushdata_aligned", type);

    type = build_function_type_list
           (void_type_node, ptr_type_node, ptr_type_node, NULL_TREE);
    kaapi_pushtask_decl =
        build_fn_decl("kaapi_pushtask", type);

    type = build_function_type_list
           (void_type_node, void_type_node, NULL_TREE);
    kaapi_barrier_decl =
        build_fn_decl("kaapi_barrier", type);
}
コード例 #13
0
ファイル: slimer.c プロジェクト: enferex/GOAT-Plugs
/* Insert call to __slimer_init to initalize things at runtime */
static void insert_slimer_init(void)
{
    int i;
    gimple stmt;
    tree decl, proto;

    proto = build_function_type_list(void_type_node, integer_type_node, NULL_TREE);
    decl = build_fn_decl("__slimer_init", proto);
    stmt = gsi_stmt(gsi_start_bb(ENTRY_BLOCK_PTR->next_bb));
    insert_call(stmt, decl);

    for (i=0; i<n_funcs; ++i)
      insert_add_fn(stmt, i);

    /* Add this fndecl to our list of things we do not process */
    VEC_safe_push(tree, gc, analyized_fns, decl);
}
コード例 #14
0
ファイル: xkaapi.c プロジェクト: texane/xkaapi_gcc_plugin
static tree create_dummy_adapter(void)
{
    /* create function type */
    static tree type = NULL;
    static tree decl = NULL;

    if (decl != NULL) return decl;

    /* create the type void fu(void)*/
    type = build_function_type_list
           (void_type_node, ptr_type_node, ptr_type_node, NULL_TREE);

    /* create the function decl */
    decl = build_fn_decl("__xkaapi_dummy_adapter", type);

    return decl;
}
コード例 #15
0
ファイル: cci.c プロジェクト: fabio-d/xc16plusplus-source
void mchp_init_cci_builtins(void) {

#define CCI(TARGET, CCI_KIND, CCI_KEYWORD, TGT_FN, N) \
  if (TARGET && CCI_KIND == CCI_pragma) \
    c_register_pragma(0, CCI_KEYWORD, TGT_FN);
#include CCI_H

/*
 * Special case mapping
 *
 */
 if (IMPORT_MCHP("iar")) {
   /* define builtins for the functions that we don't define
    *   and mark them as unsupported
    */

   tree attrib, args;
   tree fn_type;

#  define MESSAGE "Intrinsic function is unsupported for this target"
   args = build_tree_list(NULL_TREE, build_string(strlen(MESSAGE), MESSAGE));
   attrib = build_tree_list(get_identifier("target_error"), args);
#  undef MESSAGE

   fn_type = build_function_type_list(void_type_node, void_type_node,NULL_TREE);
   add_builtin_function("__disable_fiq", fn_type, 0, BUILT_IN_MD, NULL, attrib);
   /*                                             ^ this should be okay
    *  because we are going to generate an error for it...
    */

   add_builtin_function("__disable_irq", fn_type, 0, BUILT_IN_MD, NULL, attrib);
   /*                                             ^ this should be okay
    *  because we are going to generate an error for it...
    */

   add_builtin_function("__enable_fiq", fn_type, 0, BUILT_IN_MD, NULL, attrib);
   /*                                            ^ this should be okay
    *  because we are going to generate an error for it...
    */

   add_builtin_function("__enable_irq", fn_type, 0, BUILT_IN_MD, NULL, attrib);
   /*                                            ^ this should be okay
    *  because we are going to generate an error for it...
    */
 }
}
コード例 #16
0
// create the function call to a `record_assignment' function and insert it
// before the given statement
static void insert_instrumentation_fn(gimple curr_stmt, tree var_id,
                                      tree new_value)
{
    // build function declaration
    tree proto = build_function_type_list(
                     void_type_node,      /* return type */
                     integer_type_node,   /* first arg's type */
                     const_ptr_type_node, /* second arg's type */
                     NULL_TREE);
    tree decl = build_fn_decl("record_assignment", proto);

    // build the function call with the new value tree and the variable id tree
    // and insert it before the statement that was passed as the first argument
    gimple call = gimple_build_call(decl, 2, var_id, new_value);
    gimple_stmt_iterator gsi = gsi_for_stmt(curr_stmt);
    gsi_insert_before(&gsi, call, GSI_NEW_STMT);
}
コード例 #17
0
ファイル: aarch64-builtins.c プロジェクト: rockflying/gcc
static void
aarch64_init_crc32_builtins ()
{
  tree usi_type = aarch64_simd_builtin_std_type (SImode, qualifier_unsigned);
  unsigned int i = 0;

  for (i = 0; i < ARRAY_SIZE (aarch64_crc_builtin_data); ++i)
    {
      aarch64_crc_builtin_datum* d = &aarch64_crc_builtin_data[i];
      tree argtype = aarch64_simd_builtin_std_type (d->mode,
						    qualifier_unsigned);
      tree ftype = build_function_type_list (usi_type, usi_type, argtype, NULL_TREE);
      tree fndecl = add_builtin_function (d->name, ftype, d->fcode,
                                          BUILT_IN_MD, NULL, NULL_TREE);

      aarch64_builtin_decls[d->fcode] = fndecl;
    }
}
コード例 #18
0
ファイル: plugin.cpp プロジェクト: heyfluke/gen-trace
static tree
build_function_decl (const char *name, tree param_type)
{
    tree func_decl, function_type_list;

    function_type_list = build_function_type_list (
                             void_type_node, build_pointer_type (param_type),
                             build_pointer_type (build_type_variant (char_type_node, true, false)),
                             NULL_TREE);
    func_decl = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL,
                            get_identifier (name), function_type_list);
    if (dump_file)
    {
        fprintf (dump_file, "begin print built function type %s:\n", name);
        print_generic_decl (dump_file, func_decl, TDF_VERBOSE);
        fprintf (dump_file, "end print built function type %s:\n", name);
    }
    TREE_USED (func_decl) = 1;

    return func_decl;
}
コード例 #19
0
ファイル: resource.c プロジェクト: BoxianLai/moxiedev
void
write_resource_constructor (tree *list_p)
{
  tree decl, t, register_resource_fn;
  unsigned ix;

  if (resources == NULL)
    return;

  t = build_function_type_list (void_type_node, ptr_type_node, NULL);
  t = build_decl (input_location,
		  FUNCTION_DECL, get_identifier ("_Jv_RegisterResource"), t);
  TREE_PUBLIC (t) = 1;
  DECL_EXTERNAL (t) = 1;
  register_resource_fn = t;

  /* Write out entries in the same order in which they were defined.  */
  FOR_EACH_VEC_ELT (tree, resources, ix, decl)
    {
      t = build_fold_addr_expr (decl);
      t = build_call_expr (register_resource_fn, 1, t);
      append_to_statement_list (t, list_p);
    }
コード例 #20
0
void
write_resource_constructor (tree *list_p)
{
  tree iter, t, register_resource_fn;

  if (resources == NULL)
    return;

  t = build_function_type_list (void_type_node, ptr_type_node, NULL);
  t = build_decl (FUNCTION_DECL, get_identifier ("_Jv_RegisterResource"), t);
  TREE_PUBLIC (t) = 1;
  DECL_EXTERNAL (t) = 1;
  register_resource_fn = t;

  /* Write out entries in the same order in which they were defined.  */
  for (iter = nreverse (resources); iter ; iter = TREE_CHAIN (iter))
    {
      t = build_fold_addr_expr (TREE_VALUE (iter));
      t = tree_cons (NULL, t, NULL);
      t = build_function_call_expr (register_resource_fn, t);
      append_to_statement_list (t, list_p);
    }
}
コード例 #21
0
ファイル: slimer.c プロジェクト: enferex/GOAT-Plugs
/* Insert a call to the runtime function "__slimer_add_fn" which will add the
 * "junk" function created at compile-time to an array at runtime
 */
static void insert_add_fn(gimple stmt, int index)
{
    tree fn;
    gimple call;
    gimple_stmt_iterator gsi;
    static tree decl, proto, idx;

    if (!decl || !proto)
    {
        proto = build_function_type_list(void_type_node, ptr_type_node,
                                         integer_type_node, NULL_TREE);
        decl = build_fn_decl("__slimer_add_fn", proto);
    
        /* Add this fndecl to our list of things we do not process */
        VEC_safe_push(tree, gc, analyized_fns, decl);
    }

    /* Create a constant value and pointer to the function we are to add */
    idx = build_int_cst(integer_type_node, index);
    fn = build_addr(VEC_index(tree, fakes, index), NULL_TREE);
    call = gimple_build_call(decl, 2, fn, idx);
    gsi = gsi_for_stmt(stmt);
    gsi_insert_before(&gsi, call, GSI_NEW_STMT);
}
コード例 #22
0
ファイル: except.c プロジェクト: kusumi/DragonFlyBSD
static tree
declare_library_fn (const char *name, tree rtype, tree ptype,
		    int ecf, int tm_ecf)
{
  tree ident = get_identifier (name);
  tree res = get_global_binding (ident);
  if (!res)
    {
      tree type = build_function_type_list (rtype, ptype, NULL_TREE);
      tree except = ecf & ECF_NOTHROW ? empty_except_spec : NULL_TREE;
      res = push_library_fn (ident, type, except, ecf);
      if (tm_ecf && flag_tm)
	{
	  char *tm_name = concat ("_ITM_", name + 2, NULL_TREE);
	  tree tm_ident = get_identifier (tm_name);
	  free (tm_name);
	  tree tm_fn = get_global_binding (tm_ident);
	  if (!tm_fn)
	    tm_fn = push_library_fn (tm_ident, type, except, ecf | tm_ecf);
	  record_tm_replacement (res, tm_fn);
	}
    }
  return res;
}
コード例 #23
0
ファイル: f95-lang.c プロジェクト: mohammadsavadkuhi/gcc
static void
build_builtin_fntypes (tree *fntype, tree type)
{
  /* type (*) (type) */
  fntype[0] = build_function_type_list (type, type, NULL_TREE);
  /* type (*) (type, type) */
  fntype[1] = build_function_type_list (type, type, type, NULL_TREE);
  /* type (*) (type, int) */
  fntype[2] = build_function_type_list (type,
                                        type, integer_type_node, NULL_TREE);
  /* type (*) (void) */
  fntype[3] = build_function_type_list (type, NULL_TREE);
  /* type (*) (type, &int) */
  fntype[4] = build_function_type_list (type, type,
                                        build_pointer_type (integer_type_node),
                                        NULL_TREE);
  /* type (*) (int, type) */
  fntype[5] = build_function_type_list (type,
                                        integer_type_node, type, NULL_TREE);
}
コード例 #24
0
ファイル: except.c プロジェクト: kusumi/DragonFlyBSD
tree
build_throw (tree exp)
{
  if (exp == error_mark_node)
    return exp;

  if (processing_template_decl)
    {
      if (cfun)
	current_function_returns_abnormally = 1;
      exp = build_min (THROW_EXPR, void_type_node, exp);
      SET_EXPR_LOCATION (exp, input_location);
      return exp;
    }

  if (exp && null_node_p (exp))
    warning (0, "throwing NULL, which has integral, not pointer type");

  if (exp != NULL_TREE)
    {
      if (!is_admissible_throw_operand_or_catch_parameter (exp, true))
	return error_mark_node;
    }

  if (! doing_eh ())
    return error_mark_node;

  if (exp)
    {
      tree throw_type;
      tree temp_type;
      tree cleanup;
      tree object, ptr;
      tree tmp;
      tree allocate_expr;

      /* The CLEANUP_TYPE is the internal type of a destructor.  */
      if (!cleanup_type)
	{
	  tmp = build_function_type_list (void_type_node,
					  ptr_type_node, NULL_TREE);
	  cleanup_type = build_pointer_type (tmp);
	}

      if (!throw_fn)
	{
	  tree name = get_identifier ("__cxa_throw");
	  throw_fn = get_global_binding (name);
	  if (!throw_fn)
	    {
	      /* Declare void __cxa_throw (void*, void*, void (*)(void*)).  */
	      /* ??? Second argument is supposed to be "std::type_info*".  */
	      tmp = build_function_type_list (void_type_node,
					      ptr_type_node, ptr_type_node,
					      cleanup_type, NULL_TREE);
	      throw_fn = push_throw_library_fn (name, tmp);

	      if (flag_tm)
		{
		  tree itm_name = get_identifier ("_ITM_cxa_throw");
		  tree itm_fn = get_global_binding (itm_name);
		  if (!itm_fn)
		    itm_fn = push_throw_library_fn (itm_name, tmp);
		  apply_tm_attr (itm_fn, get_identifier ("transaction_pure"));
		  record_tm_replacement (throw_fn, itm_fn);
		}
	    }
	}

      /* [except.throw]

	 A throw-expression initializes a temporary object, the type
	 of which is determined by removing any top-level
	 cv-qualifiers from the static type of the operand of throw
	 and adjusting the type from "array of T" or "function return
	 T" to "pointer to T" or "pointer to function returning T"
	 respectively.  */
      temp_type = is_bitfield_expr_with_lowered_type (exp);
      if (!temp_type)
	temp_type = cv_unqualified (type_decays_to (TREE_TYPE (exp)));

      /* OK, this is kind of wacky.  The standard says that we call
	 terminate when the exception handling mechanism, after
	 completing evaluation of the expression to be thrown but
	 before the exception is caught (_except.throw_), calls a
	 user function that exits via an uncaught exception.

	 So we have to protect the actual initialization of the
	 exception object with terminate(), but evaluate the
	 expression first.  Since there could be temps in the
	 expression, we need to handle that, too.  We also expand
	 the call to __cxa_allocate_exception first (which doesn't
	 matter, since it can't throw).  */

      /* Allocate the space for the exception.  */
      allocate_expr = do_allocate_exception (temp_type);
      allocate_expr = get_target_expr (allocate_expr);
      ptr = TARGET_EXPR_SLOT (allocate_expr);
      TARGET_EXPR_CLEANUP (allocate_expr) = do_free_exception (ptr);
      CLEANUP_EH_ONLY (allocate_expr) = 1;

      object = build_nop (build_pointer_type (temp_type), ptr);
      object = cp_build_fold_indirect_ref (object);

      /* And initialize the exception object.  */
      if (CLASS_TYPE_P (temp_type))
	{
	  int flags = LOOKUP_NORMAL | LOOKUP_ONLYCONVERTING;
	  vec<tree, va_gc> *exp_vec;
	  bool converted = false;

	  /* Under C++0x [12.8/16 class.copy], a thrown lvalue is sometimes
	     treated as an rvalue for the purposes of overload resolution
	     to favor move constructors over copy constructors.  */
	  if (/* Must be a local, automatic variable.  */
	      VAR_P (exp)
	      && DECL_CONTEXT (exp) == current_function_decl
	      && ! TREE_STATIC (exp)
	      /* The variable must not have the `volatile' qualifier.  */
	      && !(cp_type_quals (TREE_TYPE (exp)) & TYPE_QUAL_VOLATILE))
	    {
	      tree moved = move (exp);
	      exp_vec = make_tree_vector_single (moved);
	      moved = (build_special_member_call
		       (object, complete_ctor_identifier, &exp_vec,
			TREE_TYPE (object), flags|LOOKUP_PREFER_RVALUE,
			tf_none));
	      release_tree_vector (exp_vec);
	      if (moved != error_mark_node)
		{
		  exp = moved;
		  converted = true;
		}
	    }

	  /* Call the copy constructor.  */
	  if (!converted)
	    {
	      exp_vec = make_tree_vector_single (exp);
	      exp = (build_special_member_call
		     (object, complete_ctor_identifier, &exp_vec,
		      TREE_TYPE (object), flags, tf_warning_or_error));
	      release_tree_vector (exp_vec);
	    }

	  if (exp == error_mark_node)
	    {
	      error ("  in thrown expression");
	      return error_mark_node;
	    }
	}
      else
	{
	  tmp = decay_conversion (exp, tf_warning_or_error);
	  if (tmp == error_mark_node)
	    return error_mark_node;
	  exp = build2 (INIT_EXPR, temp_type, object, tmp);
	}

      /* Mark any cleanups from the initialization as MUST_NOT_THROW, since
	 they are run after the exception object is initialized.  */
      cp_walk_tree_without_duplicates (&exp, wrap_cleanups_r, 0);

      /* Prepend the allocation.  */
      exp = build2 (COMPOUND_EXPR, TREE_TYPE (exp), allocate_expr, exp);

      /* Force all the cleanups to be evaluated here so that we don't have
	 to do them during unwinding.  */
      exp = build1 (CLEANUP_POINT_EXPR, void_type_node, exp);

      throw_type = build_eh_type_type (prepare_eh_type (TREE_TYPE (object)));

      cleanup = NULL_TREE;
      if (type_build_dtor_call (TREE_TYPE (object)))
	{
	  tree dtor_fn = lookup_fnfields (TYPE_BINFO (TREE_TYPE (object)),
					  complete_dtor_identifier, 0);
	  dtor_fn = BASELINK_FUNCTIONS (dtor_fn);
	  mark_used (dtor_fn);
	  if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (object)))
	    {
	      cxx_mark_addressable (dtor_fn);
	      /* Pretend it's a normal function.  */
	      cleanup = build1 (ADDR_EXPR, cleanup_type, dtor_fn);
	    }
	}
      if (cleanup == NULL_TREE)
	cleanup = build_int_cst (cleanup_type, 0);

      /* ??? Indicate that this function call throws throw_type.  */
      tmp = cp_build_function_call_nary (throw_fn, tf_warning_or_error,
					 ptr, throw_type, cleanup, NULL_TREE);

      /* Tack on the initialization stuff.  */
      exp = build2 (COMPOUND_EXPR, TREE_TYPE (tmp), exp, tmp);
    }
  else
    {
      /* Rethrow current exception.  */
      if (!rethrow_fn)
	{
	  tree name = get_identifier ("__cxa_rethrow");
	  rethrow_fn = get_global_binding (name);
	  if (!rethrow_fn)
	    /* Declare void __cxa_rethrow (void).  */
	    rethrow_fn = push_throw_library_fn
	      (name, build_function_type_list (void_type_node, NULL_TREE));

	  if (flag_tm)
	    apply_tm_attr (rethrow_fn, get_identifier ("transaction_pure"));
	}

      /* ??? Indicate that this function call allows exceptions of the type
	 of the enclosing catch block (if known).  */
      exp = cp_build_function_call_vec (rethrow_fn, NULL, tf_warning_or_error);
    }

  exp = build1 (THROW_EXPR, void_type_node, exp);
  SET_EXPR_LOCATION (exp, input_location);

  return exp;
}
コード例 #25
0
ファイル: tree-profile.c プロジェクト: ArtemL/GCC
void
gimple_init_edge_profiler (void)
{
  tree interval_profiler_fn_type;
  tree pow2_profiler_fn_type;
  tree one_value_profiler_fn_type;
  tree gcov_type_ptr;
  tree ic_profiler_fn_type;
  tree average_profiler_fn_type;
  tree time_profiler_fn_type;

  if (!gcov_type_node)
    {
      gcov_type_node = get_gcov_type ();
      gcov_type_ptr = build_pointer_type (gcov_type_node);

      /* void (*) (gcov_type *, gcov_type, int, unsigned)  */
      interval_profiler_fn_type
	      = build_function_type_list (void_type_node,
					  gcov_type_ptr, gcov_type_node,
					  integer_type_node,
					  unsigned_type_node, NULL_TREE);
      tree_interval_profiler_fn
	      = build_fn_decl ("__gcov_interval_profiler",
				     interval_profiler_fn_type);
      TREE_NOTHROW (tree_interval_profiler_fn) = 1;
      DECL_ATTRIBUTES (tree_interval_profiler_fn)
	= tree_cons (get_identifier ("leaf"), NULL,
		     DECL_ATTRIBUTES (tree_interval_profiler_fn));

      /* void (*) (gcov_type *, gcov_type)  */
      pow2_profiler_fn_type
	      = build_function_type_list (void_type_node,
					  gcov_type_ptr, gcov_type_node,
					  NULL_TREE);
      tree_pow2_profiler_fn = build_fn_decl ("__gcov_pow2_profiler",
						   pow2_profiler_fn_type);
      TREE_NOTHROW (tree_pow2_profiler_fn) = 1;
      DECL_ATTRIBUTES (tree_pow2_profiler_fn)
	= tree_cons (get_identifier ("leaf"), NULL,
		     DECL_ATTRIBUTES (tree_pow2_profiler_fn));

      /* void (*) (gcov_type *, gcov_type)  */
      one_value_profiler_fn_type
	      = build_function_type_list (void_type_node,
					  gcov_type_ptr, gcov_type_node,
					  NULL_TREE);
      tree_one_value_profiler_fn
	      = build_fn_decl ("__gcov_one_value_profiler",
				     one_value_profiler_fn_type);
      TREE_NOTHROW (tree_one_value_profiler_fn) = 1;
      DECL_ATTRIBUTES (tree_one_value_profiler_fn)
	= tree_cons (get_identifier ("leaf"), NULL,
		     DECL_ATTRIBUTES (tree_one_value_profiler_fn));

      init_ic_make_global_vars ();

      /* Workaround for binutils bug 14342.  Once it is fixed, remove lto path.  */
      if (flag_lto)
        {
	  /* void (*) (gcov_type, void *)  */
	  ic_profiler_fn_type
		   = build_function_type_list (void_type_node,
					      gcov_type_ptr, gcov_type_node,
					      ptr_void, ptr_void,
					      NULL_TREE);
	  tree_indirect_call_profiler_fn
		  = build_fn_decl ("__gcov_indirect_call_profiler",
					 ic_profiler_fn_type);
        }
      else
        {
	  /* void (*) (gcov_type, void *)  */
	  ic_profiler_fn_type
		   = build_function_type_list (void_type_node,
					      gcov_type_node,
					      ptr_void,
					      NULL_TREE);
	  tree_indirect_call_profiler_fn
		  = build_fn_decl ("__gcov_indirect_call_profiler_v2",
					 ic_profiler_fn_type);
        }
      TREE_NOTHROW (tree_indirect_call_profiler_fn) = 1;
      DECL_ATTRIBUTES (tree_indirect_call_profiler_fn)
	= tree_cons (get_identifier ("leaf"), NULL,
		     DECL_ATTRIBUTES (tree_indirect_call_profiler_fn));

      /* void (*) (gcov_type *, gcov_type, void *)  */
      time_profiler_fn_type
	       = build_function_type_list (void_type_node,
					  gcov_type_ptr, NULL_TREE);
      tree_time_profiler_fn
	      = build_fn_decl ("__gcov_time_profiler",
				     time_profiler_fn_type);
      TREE_NOTHROW (tree_time_profiler_fn) = 1;
      DECL_ATTRIBUTES (tree_time_profiler_fn)
	= tree_cons (get_identifier ("leaf"), NULL,
		     DECL_ATTRIBUTES (tree_time_profiler_fn));

      /* void (*) (gcov_type *, gcov_type)  */
      average_profiler_fn_type
	      = build_function_type_list (void_type_node,
					  gcov_type_ptr, gcov_type_node, NULL_TREE);
      tree_average_profiler_fn
	      = build_fn_decl ("__gcov_average_profiler",
				     average_profiler_fn_type);
      TREE_NOTHROW (tree_average_profiler_fn) = 1;
      DECL_ATTRIBUTES (tree_average_profiler_fn)
	= tree_cons (get_identifier ("leaf"), NULL,
		     DECL_ATTRIBUTES (tree_average_profiler_fn));
      tree_ior_profiler_fn
	      = build_fn_decl ("__gcov_ior_profiler",
				     average_profiler_fn_type);
      TREE_NOTHROW (tree_ior_profiler_fn) = 1;
      DECL_ATTRIBUTES (tree_ior_profiler_fn)
	= tree_cons (get_identifier ("leaf"), NULL,
		     DECL_ATTRIBUTES (tree_ior_profiler_fn));

      /* LTO streamer needs assembler names.  Because we create these decls
         late, we need to initialize them by hand.  */
      DECL_ASSEMBLER_NAME (tree_interval_profiler_fn);
      DECL_ASSEMBLER_NAME (tree_pow2_profiler_fn);
      DECL_ASSEMBLER_NAME (tree_one_value_profiler_fn);
      DECL_ASSEMBLER_NAME (tree_indirect_call_profiler_fn);
      DECL_ASSEMBLER_NAME (tree_time_profiler_fn);
      DECL_ASSEMBLER_NAME (tree_average_profiler_fn);
      DECL_ASSEMBLER_NAME (tree_ior_profiler_fn);
    }
}
コード例 #26
0
ファイル: f95-lang.c プロジェクト: mohammadsavadkuhi/gcc
static void
gfc_init_builtin_functions (void)
{
  enum builtin_type
  {
#define DEF_PRIMITIVE_TYPE(NAME, VALUE) NAME,
#define DEF_FUNCTION_TYPE_0(NAME, RETURN) NAME,
#define DEF_FUNCTION_TYPE_1(NAME, RETURN, ARG1) NAME,
#define DEF_FUNCTION_TYPE_2(NAME, RETURN, ARG1, ARG2) NAME,
#define DEF_FUNCTION_TYPE_3(NAME, RETURN, ARG1, ARG2, ARG3) NAME,
#define DEF_FUNCTION_TYPE_4(NAME, RETURN, ARG1, ARG2, ARG3, ARG4) NAME,
#define DEF_FUNCTION_TYPE_5(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) NAME,
#define DEF_FUNCTION_TYPE_6(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
			    ARG6) NAME,
#define DEF_FUNCTION_TYPE_7(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
			    ARG6, ARG7) NAME,
#define DEF_FUNCTION_TYPE_8(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
			    ARG6, ARG7, ARG8) NAME,
#define DEF_FUNCTION_TYPE_VAR_0(NAME, RETURN) NAME,
#define DEF_POINTER_TYPE(NAME, TYPE) NAME,
#include "types.def"
#undef DEF_PRIMITIVE_TYPE
#undef DEF_FUNCTION_TYPE_0
#undef DEF_FUNCTION_TYPE_1
#undef DEF_FUNCTION_TYPE_2
#undef DEF_FUNCTION_TYPE_3
#undef DEF_FUNCTION_TYPE_4
#undef DEF_FUNCTION_TYPE_5
#undef DEF_FUNCTION_TYPE_6
#undef DEF_FUNCTION_TYPE_7
#undef DEF_FUNCTION_TYPE_8
#undef DEF_FUNCTION_TYPE_VAR_0
#undef DEF_POINTER_TYPE
    BT_LAST
  };

  tree mfunc_float[6];
  tree mfunc_double[6];
  tree mfunc_longdouble[6];
  tree mfunc_cfloat[6];
  tree mfunc_cdouble[6];
  tree mfunc_clongdouble[6];
  tree func_cfloat_float, func_float_cfloat;
  tree func_cdouble_double, func_double_cdouble;
  tree func_clongdouble_longdouble, func_longdouble_clongdouble;
  tree func_float_floatp_floatp;
  tree func_double_doublep_doublep;
  tree func_longdouble_longdoublep_longdoublep;
  tree ftype, ptype;
  tree builtin_types[(int) BT_LAST + 1];

  build_builtin_fntypes (mfunc_float, float_type_node);
  build_builtin_fntypes (mfunc_double, double_type_node);
  build_builtin_fntypes (mfunc_longdouble, long_double_type_node);
  build_builtin_fntypes (mfunc_cfloat, complex_float_type_node);
  build_builtin_fntypes (mfunc_cdouble, complex_double_type_node);
  build_builtin_fntypes (mfunc_clongdouble, complex_long_double_type_node);

  func_cfloat_float = build_function_type_list (float_type_node,
                                                complex_float_type_node,
                                                NULL_TREE);

  func_float_cfloat = build_function_type_list (complex_float_type_node,
                                                float_type_node, NULL_TREE);

  func_cdouble_double = build_function_type_list (double_type_node,
                                                  complex_double_type_node,
                                                  NULL_TREE);

  func_double_cdouble = build_function_type_list (complex_double_type_node,
                                                  double_type_node, NULL_TREE);

  func_clongdouble_longdouble =
    build_function_type_list (long_double_type_node,
                              complex_long_double_type_node, NULL_TREE);

  func_longdouble_clongdouble =
    build_function_type_list (complex_long_double_type_node,
                              long_double_type_node, NULL_TREE);

  ptype = build_pointer_type (float_type_node);
  func_float_floatp_floatp =
    build_function_type_list (void_type_node, ptype, ptype, NULL_TREE);

  ptype = build_pointer_type (double_type_node);
  func_double_doublep_doublep =
    build_function_type_list (void_type_node, ptype, ptype, NULL_TREE);

  ptype = build_pointer_type (long_double_type_node);
  func_longdouble_longdoublep_longdoublep =
    build_function_type_list (void_type_node, ptype, ptype, NULL_TREE);

/* Non-math builtins are defined manually, so they're not included here.  */
#define OTHER_BUILTIN(ID,NAME,TYPE,CONST)

#include "mathbuiltins.def"

  gfc_define_builtin ("__builtin_roundl", mfunc_longdouble[0], 
		      BUILT_IN_ROUNDL, "roundl", ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_round", mfunc_double[0], 
		      BUILT_IN_ROUND, "round", ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_roundf", mfunc_float[0], 
		      BUILT_IN_ROUNDF, "roundf", ATTR_CONST_NOTHROW_LEAF_LIST);

  gfc_define_builtin ("__builtin_truncl", mfunc_longdouble[0],
		      BUILT_IN_TRUNCL, "truncl", ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_trunc", mfunc_double[0],
		      BUILT_IN_TRUNC, "trunc", ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_truncf", mfunc_float[0],
		      BUILT_IN_TRUNCF, "truncf", ATTR_CONST_NOTHROW_LEAF_LIST);

  gfc_define_builtin ("__builtin_cabsl", func_clongdouble_longdouble, 
		      BUILT_IN_CABSL, "cabsl", ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_cabs", func_cdouble_double, 
		      BUILT_IN_CABS, "cabs", ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_cabsf", func_cfloat_float, 
		      BUILT_IN_CABSF, "cabsf", ATTR_CONST_NOTHROW_LEAF_LIST);
 
  gfc_define_builtin ("__builtin_copysignl", mfunc_longdouble[1], 
		      BUILT_IN_COPYSIGNL, "copysignl",
		      ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_copysign", mfunc_double[1], 
		      BUILT_IN_COPYSIGN, "copysign",
		      ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_copysignf", mfunc_float[1], 
		      BUILT_IN_COPYSIGNF, "copysignf",
		      ATTR_CONST_NOTHROW_LEAF_LIST);
 
  gfc_define_builtin ("__builtin_nextafterl", mfunc_longdouble[1], 
		      BUILT_IN_NEXTAFTERL, "nextafterl",
		      ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_nextafter", mfunc_double[1], 
		      BUILT_IN_NEXTAFTER, "nextafter",
		      ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_nextafterf", mfunc_float[1], 
		      BUILT_IN_NEXTAFTERF, "nextafterf",
		      ATTR_CONST_NOTHROW_LEAF_LIST);
 
  gfc_define_builtin ("__builtin_frexpl", mfunc_longdouble[4], 
		      BUILT_IN_FREXPL, "frexpl", ATTR_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_frexp", mfunc_double[4], 
		      BUILT_IN_FREXP, "frexp", ATTR_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_frexpf", mfunc_float[4], 
		      BUILT_IN_FREXPF, "frexpf", ATTR_NOTHROW_LEAF_LIST);
 
  gfc_define_builtin ("__builtin_fabsl", mfunc_longdouble[0], 
		      BUILT_IN_FABSL, "fabsl", ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_fabs", mfunc_double[0], 
		      BUILT_IN_FABS, "fabs", ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_fabsf", mfunc_float[0], 
		      BUILT_IN_FABSF, "fabsf", ATTR_CONST_NOTHROW_LEAF_LIST);
 
  gfc_define_builtin ("__builtin_scalbnl", mfunc_longdouble[5], 
		      BUILT_IN_SCALBNL, "scalbnl", ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_scalbn", mfunc_double[5], 
		      BUILT_IN_SCALBN, "scalbn", ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_scalbnf", mfunc_float[5], 
		      BUILT_IN_SCALBNF, "scalbnf", ATTR_CONST_NOTHROW_LEAF_LIST);
 
  gfc_define_builtin ("__builtin_fmodl", mfunc_longdouble[1], 
		      BUILT_IN_FMODL, "fmodl", ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_fmod", mfunc_double[1], 
		      BUILT_IN_FMOD, "fmod", ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_fmodf", mfunc_float[1], 
		      BUILT_IN_FMODF, "fmodf", ATTR_CONST_NOTHROW_LEAF_LIST);

  /* iround{f,,l}, lround{f,,l} and llround{f,,l} */
  ftype = build_function_type_list (integer_type_node,
                                    float_type_node, NULL_TREE); 
  gfc_define_builtin("__builtin_iroundf", ftype, BUILT_IN_IROUNDF,
		     "iroundf", ATTR_CONST_NOTHROW_LEAF_LIST);
  ftype = build_function_type_list (long_integer_type_node,
                                    float_type_node, NULL_TREE); 
  gfc_define_builtin ("__builtin_lroundf", ftype, BUILT_IN_LROUNDF,
		      "lroundf", ATTR_CONST_NOTHROW_LEAF_LIST);
  ftype = build_function_type_list (long_long_integer_type_node,
                                    float_type_node, NULL_TREE); 
  gfc_define_builtin ("__builtin_llroundf", ftype, BUILT_IN_LLROUNDF,
		      "llroundf", ATTR_CONST_NOTHROW_LEAF_LIST);

  ftype = build_function_type_list (integer_type_node,
                                    double_type_node, NULL_TREE); 
  gfc_define_builtin("__builtin_iround", ftype, BUILT_IN_IROUND,
		     "iround", ATTR_CONST_NOTHROW_LEAF_LIST);
  ftype = build_function_type_list (long_integer_type_node,
                                    double_type_node, NULL_TREE); 
  gfc_define_builtin ("__builtin_lround", ftype, BUILT_IN_LROUND,
		      "lround", ATTR_CONST_NOTHROW_LEAF_LIST);
  ftype = build_function_type_list (long_long_integer_type_node,
                                    double_type_node, NULL_TREE); 
  gfc_define_builtin ("__builtin_llround", ftype, BUILT_IN_LLROUND,
		      "llround", ATTR_CONST_NOTHROW_LEAF_LIST);

  ftype = build_function_type_list (integer_type_node,
                                    long_double_type_node, NULL_TREE); 
  gfc_define_builtin("__builtin_iroundl", ftype, BUILT_IN_IROUNDL,
		     "iroundl", ATTR_CONST_NOTHROW_LEAF_LIST);
  ftype = build_function_type_list (long_integer_type_node,
                                    long_double_type_node, NULL_TREE); 
  gfc_define_builtin ("__builtin_lroundl", ftype, BUILT_IN_LROUNDL,
		      "lroundl", ATTR_CONST_NOTHROW_LEAF_LIST);
  ftype = build_function_type_list (long_long_integer_type_node,
                                    long_double_type_node, NULL_TREE); 
  gfc_define_builtin ("__builtin_llroundl", ftype, BUILT_IN_LLROUNDL,
		      "llroundl", ATTR_CONST_NOTHROW_LEAF_LIST);

  /* These are used to implement the ** operator.  */
  gfc_define_builtin ("__builtin_powl", mfunc_longdouble[1], 
		      BUILT_IN_POWL, "powl", ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_pow", mfunc_double[1], 
		      BUILT_IN_POW, "pow", ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_powf", mfunc_float[1], 
		      BUILT_IN_POWF, "powf", ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_cpowl", mfunc_clongdouble[1], 
		      BUILT_IN_CPOWL, "cpowl", ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_cpow", mfunc_cdouble[1], 
		      BUILT_IN_CPOW, "cpow", ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_cpowf", mfunc_cfloat[1], 
		      BUILT_IN_CPOWF, "cpowf", ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_powil", mfunc_longdouble[2], 
		      BUILT_IN_POWIL, "powil", ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_powi", mfunc_double[2], 
		      BUILT_IN_POWI, "powi", ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_powif", mfunc_float[2], 
		      BUILT_IN_POWIF, "powif", ATTR_CONST_NOTHROW_LEAF_LIST);


  if (targetm.libc_has_function (function_c99_math_complex))
    {
      gfc_define_builtin ("__builtin_cbrtl", mfunc_longdouble[0],
			  BUILT_IN_CBRTL, "cbrtl",
			  ATTR_CONST_NOTHROW_LEAF_LIST);
      gfc_define_builtin ("__builtin_cbrt", mfunc_double[0],
			  BUILT_IN_CBRT, "cbrt",
			  ATTR_CONST_NOTHROW_LEAF_LIST);
      gfc_define_builtin ("__builtin_cbrtf", mfunc_float[0],
			  BUILT_IN_CBRTF, "cbrtf",
			  ATTR_CONST_NOTHROW_LEAF_LIST);
      gfc_define_builtin ("__builtin_cexpil", func_longdouble_clongdouble, 
			  BUILT_IN_CEXPIL, "cexpil",
			  ATTR_CONST_NOTHROW_LEAF_LIST);
      gfc_define_builtin ("__builtin_cexpi", func_double_cdouble,
			  BUILT_IN_CEXPI, "cexpi",
			  ATTR_CONST_NOTHROW_LEAF_LIST);
      gfc_define_builtin ("__builtin_cexpif", func_float_cfloat,
			  BUILT_IN_CEXPIF, "cexpif",
			  ATTR_CONST_NOTHROW_LEAF_LIST);
    }

  if (targetm.libc_has_function (function_sincos))
    {
      gfc_define_builtin ("__builtin_sincosl",
			  func_longdouble_longdoublep_longdoublep,
			  BUILT_IN_SINCOSL, "sincosl", ATTR_NOTHROW_LEAF_LIST);
      gfc_define_builtin ("__builtin_sincos", func_double_doublep_doublep,
			  BUILT_IN_SINCOS, "sincos", ATTR_NOTHROW_LEAF_LIST);
      gfc_define_builtin ("__builtin_sincosf", func_float_floatp_floatp,
			  BUILT_IN_SINCOSF, "sincosf", ATTR_NOTHROW_LEAF_LIST);
    }

  /* For LEADZ, TRAILZ, POPCNT and POPPAR.  */
  ftype = build_function_type_list (integer_type_node,
                                    unsigned_type_node, NULL_TREE);
  gfc_define_builtin ("__builtin_clz", ftype, BUILT_IN_CLZ,
		      "__builtin_clz", ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_ctz", ftype, BUILT_IN_CTZ,
		      "__builtin_ctz", ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_parity", ftype, BUILT_IN_PARITY,
		      "__builtin_parity", ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_popcount", ftype, BUILT_IN_POPCOUNT,
		      "__builtin_popcount", ATTR_CONST_NOTHROW_LEAF_LIST);

  ftype = build_function_type_list (integer_type_node,
                                    long_unsigned_type_node, NULL_TREE);
  gfc_define_builtin ("__builtin_clzl", ftype, BUILT_IN_CLZL,
		      "__builtin_clzl", ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_ctzl", ftype, BUILT_IN_CTZL,
		      "__builtin_ctzl", ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_parityl", ftype, BUILT_IN_PARITYL,
		      "__builtin_parityl", ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_popcountl", ftype, BUILT_IN_POPCOUNTL,
		      "__builtin_popcountl", ATTR_CONST_NOTHROW_LEAF_LIST);

  ftype = build_function_type_list (integer_type_node,
                                    long_long_unsigned_type_node, NULL_TREE);
  gfc_define_builtin ("__builtin_clzll", ftype, BUILT_IN_CLZLL,
		      "__builtin_clzll", ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_ctzll", ftype, BUILT_IN_CTZLL,
		      "__builtin_ctzll", ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_parityll", ftype, BUILT_IN_PARITYLL,
		      "__builtin_parityll", ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__builtin_popcountll", ftype, BUILT_IN_POPCOUNTLL,
		      "__builtin_popcountll", ATTR_CONST_NOTHROW_LEAF_LIST);

  /* Other builtin functions we use.  */

  ftype = build_function_type_list (long_integer_type_node,
                                    long_integer_type_node,
                                    long_integer_type_node, NULL_TREE);
  gfc_define_builtin ("__builtin_expect", ftype, BUILT_IN_EXPECT,
		      "__builtin_expect", ATTR_CONST_NOTHROW_LEAF_LIST);

  ftype = build_function_type_list (void_type_node,
                                    pvoid_type_node, NULL_TREE);
  gfc_define_builtin ("__builtin_free", ftype, BUILT_IN_FREE,
		      "free", ATTR_NOTHROW_LEAF_LIST);

  ftype = build_function_type_list (pvoid_type_node,
                                    size_type_node, NULL_TREE);
  gfc_define_builtin ("__builtin_malloc", ftype, BUILT_IN_MALLOC,
		      "malloc", ATTR_NOTHROW_LEAF_MALLOC_LIST);

  ftype = build_function_type_list (pvoid_type_node, size_type_node,
				    size_type_node, NULL_TREE);
  gfc_define_builtin ("__builtin_calloc", ftype, BUILT_IN_CALLOC,
		      "calloc", ATTR_NOTHROW_LEAF_MALLOC_LIST);
  DECL_IS_MALLOC (builtin_decl_explicit (BUILT_IN_CALLOC)) = 1;

  ftype = build_function_type_list (pvoid_type_node,
                                    size_type_node, pvoid_type_node,
                                    NULL_TREE);
  gfc_define_builtin ("__builtin_realloc", ftype, BUILT_IN_REALLOC,
		      "realloc", ATTR_NOTHROW_LEAF_LIST);

  ftype = build_function_type_list (integer_type_node,
                                    void_type_node, NULL_TREE);
  gfc_define_builtin ("__builtin_isnan", ftype, BUILT_IN_ISNAN,
		      "__builtin_isnan", ATTR_CONST_NOTHROW_LEAF_LIST);

#define DEF_PRIMITIVE_TYPE(ENUM, VALUE) \
  builtin_types[(int) ENUM] = VALUE;
#define DEF_FUNCTION_TYPE_0(ENUM, RETURN)                       \
  builtin_types[(int) ENUM]                                     \
    = build_function_type_list (builtin_types[(int) RETURN],	\
                                NULL_TREE);
#define DEF_FUNCTION_TYPE_1(ENUM, RETURN, ARG1)				\
  builtin_types[(int) ENUM]						\
    = build_function_type_list (builtin_types[(int) RETURN],            \
                                builtin_types[(int) ARG1],              \
                                NULL_TREE);
#define DEF_FUNCTION_TYPE_2(ENUM, RETURN, ARG1, ARG2)           \
  builtin_types[(int) ENUM]                                     \
    = build_function_type_list (builtin_types[(int) RETURN],    \
                                builtin_types[(int) ARG1],      \
                                builtin_types[(int) ARG2],      \
                                NULL_TREE);
#define DEF_FUNCTION_TYPE_3(ENUM, RETURN, ARG1, ARG2, ARG3)             \
  builtin_types[(int) ENUM]                                             \
    = build_function_type_list (builtin_types[(int) RETURN],            \
                                builtin_types[(int) ARG1],              \
                                builtin_types[(int) ARG2],              \
                                builtin_types[(int) ARG3],              \
                                NULL_TREE);
#define DEF_FUNCTION_TYPE_4(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4)	\
  builtin_types[(int) ENUM]						\
    = build_function_type_list (builtin_types[(int) RETURN],            \
                                builtin_types[(int) ARG1],              \
                                builtin_types[(int) ARG2],              \
                                builtin_types[(int) ARG3],		\
                                builtin_types[(int) ARG4],              \
                                NULL_TREE);
#define DEF_FUNCTION_TYPE_5(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5)	\
  builtin_types[(int) ENUM]						\
    = build_function_type_list (builtin_types[(int) RETURN],            \
                                builtin_types[(int) ARG1],              \
                                builtin_types[(int) ARG2],              \
                                builtin_types[(int) ARG3],		\
                                builtin_types[(int) ARG4],              \
                                builtin_types[(int) ARG5],              \
                                NULL_TREE);
#define DEF_FUNCTION_TYPE_6(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
			    ARG6)					\
  builtin_types[(int) ENUM]						\
    = build_function_type_list (builtin_types[(int) RETURN],            \
                                builtin_types[(int) ARG1],              \
                                builtin_types[(int) ARG2],              \
                                builtin_types[(int) ARG3],		\
                                builtin_types[(int) ARG4],		\
                                builtin_types[(int) ARG5],              \
                                builtin_types[(int) ARG6],              \
                                NULL_TREE);
#define DEF_FUNCTION_TYPE_7(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
			    ARG6, ARG7)					\
  builtin_types[(int) ENUM]						\
    = build_function_type_list (builtin_types[(int) RETURN],            \
                                builtin_types[(int) ARG1],              \
                                builtin_types[(int) ARG2],              \
                                builtin_types[(int) ARG3],		\
                                builtin_types[(int) ARG4],		\
                                builtin_types[(int) ARG5],              \
                                builtin_types[(int) ARG6],              \
                                builtin_types[(int) ARG7],              \
                                NULL_TREE);
#define DEF_FUNCTION_TYPE_8(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
			    ARG6, ARG7, ARG8)				\
  builtin_types[(int) ENUM]						\
    = build_function_type_list (builtin_types[(int) RETURN],		\
				builtin_types[(int) ARG1],		\
				builtin_types[(int) ARG2],		\
				builtin_types[(int) ARG3],		\
				builtin_types[(int) ARG4],		\
				builtin_types[(int) ARG5],		\
				builtin_types[(int) ARG6],		\
				builtin_types[(int) ARG7],		\
				builtin_types[(int) ARG8],		\
				NULL_TREE);
#define DEF_FUNCTION_TYPE_VAR_0(ENUM, RETURN)				\
  builtin_types[(int) ENUM]						\
    = build_varargs_function_type_list (builtin_types[(int) RETURN],    \
                                        NULL_TREE);
#define DEF_POINTER_TYPE(ENUM, TYPE)			\
  builtin_types[(int) ENUM]				\
    = build_pointer_type (builtin_types[(int) TYPE]);
#include "types.def"
#undef DEF_PRIMITIVE_TYPE
#undef DEF_FUNCTION_TYPE_0
#undef DEF_FUNCTION_TYPE_1
#undef DEF_FUNCTION_TYPE_2
#undef DEF_FUNCTION_TYPE_3
#undef DEF_FUNCTION_TYPE_4
#undef DEF_FUNCTION_TYPE_5
#undef DEF_FUNCTION_TYPE_6
#undef DEF_FUNCTION_TYPE_7
#undef DEF_FUNCTION_TYPE_8
#undef DEF_FUNCTION_TYPE_VAR_0
#undef DEF_POINTER_TYPE
  builtin_types[(int) BT_LAST] = NULL_TREE;

  /* Initialize synchronization builtins.  */
#undef DEF_SYNC_BUILTIN
#define DEF_SYNC_BUILTIN(code, name, type, attr) \
    gfc_define_builtin (name, builtin_types[type], code, name, \
			attr);
#include "../sync-builtins.def"
#undef DEF_SYNC_BUILTIN

  if (gfc_option.gfc_flag_openmp || flag_tree_parallelize_loops)
    {
#undef DEF_GOMP_BUILTIN
#define DEF_GOMP_BUILTIN(code, name, type, attr) \
      gfc_define_builtin ("__builtin_" name, builtin_types[type], \
			  code, name, attr);
#include "../omp-builtins.def"
#undef DEF_GOMP_BUILTIN
    }

  gfc_define_builtin ("__builtin_trap", builtin_types[BT_FN_VOID],
		      BUILT_IN_TRAP, NULL, ATTR_NOTHROW_LEAF_LIST);
  TREE_THIS_VOLATILE (builtin_decl_explicit (BUILT_IN_TRAP)) = 1;

  gfc_define_builtin ("__emutls_get_address",
		      builtin_types[BT_FN_PTR_PTR],
		      BUILT_IN_EMUTLS_GET_ADDRESS,
		      "__emutls_get_address", ATTR_CONST_NOTHROW_LEAF_LIST);
  gfc_define_builtin ("__emutls_register_common",
		      builtin_types[BT_FN_VOID_PTR_WORD_WORD_PTR],
		      BUILT_IN_EMUTLS_REGISTER_COMMON,
		      "__emutls_register_common", ATTR_NOTHROW_LEAF_LIST);

  build_common_builtin_nodes ();
  targetm.init_builtins ();
}
コード例 #27
0
ファイル: builtins.c プロジェクト: Nodplus/gcc
/* Initialize the builtins.  */
void
initialize_builtins (void)
{
  tree double_ftype_double, double_ftype_double_double;
  tree float_ftype_float_float;
  tree boolean_ftype_boolean_boolean;
  int i;

  for (i = 0; java_builtins[i].builtin_code != END_BUILTINS; ++i)
    {
      tree klass_id = get_identifier (java_builtins[i].class_name.s);
      tree m = get_identifier (java_builtins[i].method_name.s);

      java_builtins[i].class_name.t = klass_id;
      java_builtins[i].method_name.t = m;
    }

  void_list_node = end_params_node;

  float_ftype_float_float
    = build_function_type_list (float_type_node,
				float_type_node, float_type_node, NULL_TREE);

  double_ftype_double
    = build_function_type_list (double_type_node, double_type_node, NULL_TREE);
  double_ftype_double_double
    = build_function_type_list (double_type_node,
				double_type_node, double_type_node, NULL_TREE);

  define_builtin (BUILT_IN_FMOD, "__builtin_fmod",
		  double_ftype_double_double, "fmod", ECF_CONST);
  define_builtin (BUILT_IN_FMODF, "__builtin_fmodf",
		  float_ftype_float_float, "fmodf", ECF_CONST);

  define_builtin (BUILT_IN_ACOS, "__builtin_acos",
		  double_ftype_double, "_ZN4java4lang4Math4acosEJdd",
		  ECF_CONST);
  define_builtin (BUILT_IN_ASIN, "__builtin_asin",
		  double_ftype_double, "_ZN4java4lang4Math4asinEJdd",
		  ECF_CONST);
  define_builtin (BUILT_IN_ATAN, "__builtin_atan",
		  double_ftype_double, "_ZN4java4lang4Math4atanEJdd",
		  ECF_CONST);
  define_builtin (BUILT_IN_ATAN2, "__builtin_atan2",
		  double_ftype_double_double, "_ZN4java4lang4Math5atan2EJddd",
		  ECF_CONST);
  define_builtin (BUILT_IN_CEIL, "__builtin_ceil",
		  double_ftype_double, "_ZN4java4lang4Math4ceilEJdd",
		  ECF_CONST);
  define_builtin (BUILT_IN_COS, "__builtin_cos",
		  double_ftype_double, "_ZN4java4lang4Math3cosEJdd",
		  ECF_CONST);
  define_builtin (BUILT_IN_EXP, "__builtin_exp",
		  double_ftype_double, "_ZN4java4lang4Math3expEJdd",
		  ECF_CONST);
  define_builtin (BUILT_IN_FLOOR, "__builtin_floor",
		  double_ftype_double, "_ZN4java4lang4Math5floorEJdd",
		  ECF_CONST);
  define_builtin (BUILT_IN_LOG, "__builtin_log",
		  double_ftype_double, "_ZN4java4lang4Math3logEJdd",
		  ECF_CONST);
  define_builtin (BUILT_IN_POW, "__builtin_pow",
		  double_ftype_double_double, "_ZN4java4lang4Math3powEJddd",
		  ECF_CONST);
  define_builtin (BUILT_IN_SIN, "__builtin_sin",
		  double_ftype_double, "_ZN4java4lang4Math3sinEJdd",
		  ECF_CONST);
  define_builtin (BUILT_IN_SQRT, "__builtin_sqrt",
		  double_ftype_double, "_ZN4java4lang4Math4sqrtEJdd",
		  ECF_CONST);
  define_builtin (BUILT_IN_TAN, "__builtin_tan",
		  double_ftype_double, "_ZN4java4lang4Math3tanEJdd",
		  ECF_CONST);
  
  boolean_ftype_boolean_boolean
    = build_function_type_list (boolean_type_node,
				boolean_type_node, boolean_type_node,
				NULL_TREE);
  define_builtin (BUILT_IN_EXPECT, "__builtin_expect", 
		  boolean_ftype_boolean_boolean,
		  "__builtin_expect",
		  ECF_CONST | ECF_NOTHROW);
  define_builtin (BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_4, 
		  "__sync_bool_compare_and_swap_4",
		  build_function_type_list (boolean_type_node,
					    int_type_node, 
					    build_pointer_type (int_type_node),
					    int_type_node, NULL_TREE), 
		  "__sync_bool_compare_and_swap_4", ECF_NOTHROW | ECF_LEAF);
  define_builtin (BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_8, 
		  "__sync_bool_compare_and_swap_8",
		  build_function_type_list (boolean_type_node,
					    long_type_node, 
					    build_pointer_type (long_type_node),
					    int_type_node, NULL_TREE), 
		  "__sync_bool_compare_and_swap_8", ECF_NOTHROW | ECF_LEAF);
  define_builtin (BUILT_IN_SYNC_SYNCHRONIZE, "__sync_synchronize",
		  build_function_type_list (void_type_node, NULL_TREE),
		  "__sync_synchronize", ECF_NOTHROW | ECF_LEAF);
  
  define_builtin (BUILT_IN_RETURN_ADDRESS, "__builtin_return_address",
		  build_function_type_list (ptr_type_node, int_type_node, NULL_TREE),
		  "__builtin_return_address", ECF_NOTHROW | ECF_LEAF);
  define_builtin (BUILT_IN_TRAP, "__builtin_trap",
		  build_function_type_list (void_type_node, NULL_TREE),
		  "__builtin_trap", ECF_NOTHROW | ECF_LEAF | ECF_NORETURN);
  build_common_builtin_nodes ();
}
コード例 #28
0
ファイル: aarch64-builtins.c プロジェクト: AHelper/gcc
static void
aarch64_init_simd_builtins (void)
{
  unsigned int i, fcode = AARCH64_SIMD_PATTERN_START;

  aarch64_init_simd_builtin_types ();

  /* Strong-typing hasn't been implemented for all AdvSIMD builtin intrinsics.
     Therefore we need to preserve the old __builtin scalar types.  It can be
     removed once all the intrinsics become strongly typed using the qualifier
     system.  */
  aarch64_init_simd_builtin_scalar_types ();
 
  tree lane_check_fpr = build_function_type_list (void_type_node,
						  size_type_node,
						  size_type_node,
						  intSI_type_node,
						  NULL);
  aarch64_builtin_decls[AARCH64_SIMD_BUILTIN_LANE_CHECK] =
      add_builtin_function ("__builtin_aarch64_im_lane_boundsi", lane_check_fpr,
			    AARCH64_SIMD_BUILTIN_LANE_CHECK, BUILT_IN_MD,
			    NULL, NULL_TREE);

  for (i = 0; i < ARRAY_SIZE (aarch64_simd_builtin_data); i++, fcode++)
    {
      bool print_type_signature_p = false;
      char type_signature[SIMD_MAX_BUILTIN_ARGS] = { 0 };
      aarch64_simd_builtin_datum *d = &aarch64_simd_builtin_data[i];
      char namebuf[60];
      tree ftype = NULL;
      tree fndecl = NULL;

      d->fcode = fcode;

      /* We must track two variables here.  op_num is
	 the operand number as in the RTL pattern.  This is
	 required to access the mode (e.g. V4SF mode) of the
	 argument, from which the base type can be derived.
	 arg_num is an index in to the qualifiers data, which
	 gives qualifiers to the type (e.g. const unsigned).
	 The reason these two variables may differ by one is the
	 void return type.  While all return types take the 0th entry
	 in the qualifiers array, there is no operand for them in the
	 RTL pattern.  */
      int op_num = insn_data[d->code].n_operands - 1;
      int arg_num = d->qualifiers[0] & qualifier_void
		      ? op_num + 1
		      : op_num;
      tree return_type = void_type_node, args = void_list_node;
      tree eltype;

      /* Build a function type directly from the insn_data for this
	 builtin.  The build_function_type () function takes care of
	 removing duplicates for us.  */
      for (; op_num >= 0; arg_num--, op_num--)
	{
	  machine_mode op_mode = insn_data[d->code].operand[op_num].mode;
	  enum aarch64_type_qualifiers qualifiers = d->qualifiers[arg_num];

	  if (qualifiers & qualifier_unsigned)
	    {
	      type_signature[arg_num] = 'u';
	      print_type_signature_p = true;
	    }
	  else if (qualifiers & qualifier_poly)
	    {
	      type_signature[arg_num] = 'p';
	      print_type_signature_p = true;
	    }
	  else
	    type_signature[arg_num] = 's';

	  /* Skip an internal operand for vget_{low, high}.  */
	  if (qualifiers & qualifier_internal)
	    continue;

	  /* Some builtins have different user-facing types
	     for certain arguments, encoded in d->mode.  */
	  if (qualifiers & qualifier_map_mode)
	      op_mode = d->mode;

	  /* For pointers, we want a pointer to the basic type
	     of the vector.  */
	  if (qualifiers & qualifier_pointer && VECTOR_MODE_P (op_mode))
	    op_mode = GET_MODE_INNER (op_mode);

	  eltype = aarch64_simd_builtin_type
		     (op_mode,
		      (qualifiers & qualifier_unsigned) != 0,
		      (qualifiers & qualifier_poly) != 0);
	  gcc_assert (eltype != NULL);

	  /* Add qualifiers.  */
	  if (qualifiers & qualifier_const)
	    eltype = build_qualified_type (eltype, TYPE_QUAL_CONST);

	  if (qualifiers & qualifier_pointer)
	      eltype = build_pointer_type (eltype);

	  /* If we have reached arg_num == 0, we are at a non-void
	     return type.  Otherwise, we are still processing
	     arguments.  */
	  if (arg_num == 0)
	    return_type = eltype;
	  else
	    args = tree_cons (NULL_TREE, eltype, args);
	}

      ftype = build_function_type (return_type, args);

      gcc_assert (ftype != NULL);

      if (print_type_signature_p)
	snprintf (namebuf, sizeof (namebuf), "__builtin_aarch64_%s_%s",
		  d->name, type_signature);
      else
	snprintf (namebuf, sizeof (namebuf), "__builtin_aarch64_%s",
		  d->name);

      fndecl = add_builtin_function (namebuf, ftype, fcode, BUILT_IN_MD,
				     NULL, NULL_TREE);
      aarch64_builtin_decls[fcode] = fndecl;
    }
}
コード例 #29
0
ファイル: ortho-lang.c プロジェクト: Jonsba/ghdl
static bool
ortho_init (void)
{
  tree n;

  input_location = BUILTINS_LOCATION;

  /* Create a global binding.  Don't use push_binding, as neither a BLOCK nor
     a BIND_EXPR are needed.  */
  push_binding (GLOBAL_BINDING);

  build_common_tree_nodes (0, 0);

  n = build_decl (input_location,
                  TYPE_DECL, get_identifier ("int"), integer_type_node);
  pushdecl (n);
  n = build_decl (input_location,
                  TYPE_DECL, get_identifier ("char"), char_type_node);
  pushdecl (n);

  /* Create alloca builtin.  */
  {
    tree args_type = tree_cons (NULL_TREE, size_type_node, void_list_node);
    tree func_type = build_function_type (ptr_type_node, args_type);

    define_builtin ("__builtin_alloca", func_type,
		    BUILT_IN_ALLOCA, NULL, 0);

    stack_alloc_function_ptr = build1
      (ADDR_EXPR,
       build_pointer_type (func_type),
       builtin_decl_implicit (BUILT_IN_ALLOCA));
  }

  {
    tree ptr_ftype = build_function_type (ptr_type_node, NULL_TREE);

    define_builtin ("__builtin_stack_save", ptr_ftype,
		    BUILT_IN_STACK_SAVE, NULL, 0);
  }

  {
    tree ftype_ptr = build_function_type_list (void_type_node,
					       ptr_type_node, NULL_TREE);

    define_builtin ("__builtin_stack_restore", ftype_ptr,
		    BUILT_IN_STACK_RESTORE, NULL, 0);
  }

  {
    tree ftype_ptr = build_function_type_list (void_type_node, NULL_TREE);

    define_builtin ("__builtin_trap", ftype_ptr,
		    BUILT_IN_TRAP, NULL, ECF_NOTHROW | ECF_LEAF);
    TREE_THIS_VOLATILE (builtin_decl_explicit (BUILT_IN_TRAP)) = 1;
  }

  {
    REAL_VALUE_TYPE v;

    REAL_VALUE_FROM_INT (v, 1, 0, DFmode);
    real_ldexp (&fp_const_p5, &v, -1);

    REAL_VALUE_FROM_INT (v, -1, -1, DFmode);
    real_ldexp (&fp_const_m_p5, &v, -1);

    REAL_VALUE_FROM_INT (fp_const_zero, 0, 0, DFmode);
  }

  build_common_builtin_nodes ();
  // FIXME: this MAY remove the need for creating the builtins above...
  // Evaluate tree.c / build_common_builtin_nodes (); for each in turn.

  return true;
}
コード例 #30
0
ファイル: tree-profile.c プロジェクト: 3F/gcc
void
gimple_init_edge_profiler (void)
{
  tree interval_profiler_fn_type;
  tree pow2_profiler_fn_type;
  tree one_value_profiler_fn_type;
  tree gcov_type_ptr;
  tree ic_profiler_fn_type;
  tree average_profiler_fn_type;
  tree time_profiler_fn_type;

  if (!gcov_type_node)
    {
      gcov_type_node = get_gcov_type ();
      gcov_type_ptr = build_pointer_type (gcov_type_node);

      /* void (*) (gcov_type *, gcov_type, int, unsigned)  */
      interval_profiler_fn_type
	      = build_function_type_list (void_type_node,
					  gcov_type_ptr, gcov_type_node,
					  integer_type_node,
					  unsigned_type_node, NULL_TREE);
      tree_interval_profiler_fn
	      = build_fn_decl ("__gcov_interval_profiler",
				     interval_profiler_fn_type);
      TREE_NOTHROW (tree_interval_profiler_fn) = 1;
      DECL_ATTRIBUTES (tree_interval_profiler_fn)
	= tree_cons (get_identifier ("leaf"), NULL,
		     DECL_ATTRIBUTES (tree_interval_profiler_fn));

      /* void (*) (gcov_type *, gcov_type)  */
      pow2_profiler_fn_type
	      = build_function_type_list (void_type_node,
					  gcov_type_ptr, gcov_type_node,
					  NULL_TREE);
      tree_pow2_profiler_fn = build_fn_decl ("__gcov_pow2_profiler",
						   pow2_profiler_fn_type);
      TREE_NOTHROW (tree_pow2_profiler_fn) = 1;
      DECL_ATTRIBUTES (tree_pow2_profiler_fn)
	= tree_cons (get_identifier ("leaf"), NULL,
		     DECL_ATTRIBUTES (tree_pow2_profiler_fn));

      /* void (*) (gcov_type *, gcov_type)  */
      one_value_profiler_fn_type
	      = build_function_type_list (void_type_node,
					  gcov_type_ptr, gcov_type_node,
					  NULL_TREE);
      tree_one_value_profiler_fn
	      = build_fn_decl ("__gcov_one_value_profiler",
				     one_value_profiler_fn_type);
      TREE_NOTHROW (tree_one_value_profiler_fn) = 1;
      DECL_ATTRIBUTES (tree_one_value_profiler_fn)
	= tree_cons (get_identifier ("leaf"), NULL,
		     DECL_ATTRIBUTES (tree_one_value_profiler_fn));

      init_ic_make_global_vars ();

      /* void (*) (gcov_type, void *)  */
      ic_profiler_fn_type
	       = build_function_type_list (void_type_node,
					  gcov_type_node,
					  ptr_void,
					  NULL_TREE);
      tree_indirect_call_profiler_fn
	      = build_fn_decl ( (PARAM_VALUE (PARAM_INDIR_CALL_TOPN_PROFILE) ?
				 "__gcov_indirect_call_topn_profiler":
				 "__gcov_indirect_call_profiler_v2"),
			       ic_profiler_fn_type);

      TREE_NOTHROW (tree_indirect_call_profiler_fn) = 1;
      DECL_ATTRIBUTES (tree_indirect_call_profiler_fn)
	= tree_cons (get_identifier ("leaf"), NULL,
		     DECL_ATTRIBUTES (tree_indirect_call_profiler_fn));

      /* void (*) (gcov_type *, gcov_type, void *)  */
      time_profiler_fn_type
	       = build_function_type_list (void_type_node,
					  gcov_type_ptr, NULL_TREE);
      tree_time_profiler_fn
	      = build_fn_decl ("__gcov_time_profiler",
				     time_profiler_fn_type);
      TREE_NOTHROW (tree_time_profiler_fn) = 1;
      DECL_ATTRIBUTES (tree_time_profiler_fn)
	= tree_cons (get_identifier ("leaf"), NULL,
		     DECL_ATTRIBUTES (tree_time_profiler_fn));

      /* void (*) (gcov_type *, gcov_type)  */
      average_profiler_fn_type
	      = build_function_type_list (void_type_node,
					  gcov_type_ptr, gcov_type_node, NULL_TREE);
      tree_average_profiler_fn
	      = build_fn_decl ("__gcov_average_profiler",
				     average_profiler_fn_type);
      TREE_NOTHROW (tree_average_profiler_fn) = 1;
      DECL_ATTRIBUTES (tree_average_profiler_fn)
	= tree_cons (get_identifier ("leaf"), NULL,
		     DECL_ATTRIBUTES (tree_average_profiler_fn));
      tree_ior_profiler_fn
	      = build_fn_decl ("__gcov_ior_profiler",
				     average_profiler_fn_type);
      TREE_NOTHROW (tree_ior_profiler_fn) = 1;
      DECL_ATTRIBUTES (tree_ior_profiler_fn)
	= tree_cons (get_identifier ("leaf"), NULL,
		     DECL_ATTRIBUTES (tree_ior_profiler_fn));

      /* LTO streamer needs assembler names.  Because we create these decls
         late, we need to initialize them by hand.  */
      DECL_ASSEMBLER_NAME (tree_interval_profiler_fn);
      DECL_ASSEMBLER_NAME (tree_pow2_profiler_fn);
      DECL_ASSEMBLER_NAME (tree_one_value_profiler_fn);
      DECL_ASSEMBLER_NAME (tree_indirect_call_profiler_fn);
      DECL_ASSEMBLER_NAME (tree_time_profiler_fn);
      DECL_ASSEMBLER_NAME (tree_average_profiler_fn);
      DECL_ASSEMBLER_NAME (tree_ior_profiler_fn);
    }
}