void real_from_mpfr (REAL_VALUE_TYPE *r, mpfr_srcptr m, tree type, mp_rnd_t rndmode) { /* We use a string as an intermediate type. */ char buf[128], *rstr; mp_exp_t exp; /* Take care of Infinity and NaN. */ if (mpfr_inf_p (m)) { real_inf (r); if (mpfr_sgn (m) < 0) *r = real_value_negate (r); return; } if (mpfr_nan_p (m)) { real_nan (r, "", 1, TYPE_MODE (type)); return; } rstr = mpfr_get_str (NULL, &exp, 16, 0, m, rndmode); /* The additional 12 chars add space for the sprintf below. This leaves 6 digits for the exponent which is supposedly enough. */ gcc_assert (rstr != NULL && strlen (rstr) < sizeof (buf) - 12); /* REAL_VALUE_ATOF expects the exponent for mantissa * 2**exp, mpfr_get_str returns the exponent for mantissa * 16**exp, adjust for that. */ exp *= 4; if (rstr[0] == '-') sprintf (buf, "-0x.%sp%d", &rstr[1], (int) exp); else sprintf (buf, "0x.%sp%d", rstr, (int) exp); mpfr_free_str (rstr); real_from_string (r, buf); }
static enum fixed_value_range_code check_real_for_fixed_mode (REAL_VALUE_TYPE *real_value, machine_mode mode) { REAL_VALUE_TYPE max_value, min_value, epsilon_value; real_2expN (&max_value, GET_MODE_IBIT (mode), VOIDmode); real_2expN (&epsilon_value, -GET_MODE_FBIT (mode), VOIDmode); if (SIGNED_FIXED_POINT_MODE_P (mode)) min_value = real_value_negate (&max_value); else real_from_string (&min_value, "0.0"); if (real_compare (LT_EXPR, real_value, &min_value)) return FIXED_UNDERFLOW; if (real_compare (EQ_EXPR, real_value, &max_value)) return FIXED_MAX_EPS; real_arithmetic (&max_value, MINUS_EXPR, &max_value, &epsilon_value); if (real_compare (GT_EXPR, real_value, &max_value)) return FIXED_GT_MAX_EPS; return FIXED_OK; }
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 (false); 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; } fp_const_m_p5 = real_value_negate (&dconsthalf); 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; }