void xml_short_constant(tree cst, FILE *out) { size_t i; const char *p; char buf[100]; REAL_VALUE_TYPE rt; switch (TREE_CODE(cst)) { case REAL_CST: rt = TREE_REAL_CST(cst); if (REAL_VALUE_ISINF(rt)) fprintf(out, "<float-literal special='%sInfinity' />", REAL_VALUE_NEGATIVE(rt) ? "-" : "+"); else if (REAL_VALUE_ISNAN(rt)) fprintf(out, "<float-literal special='NaN' />"); else { real_to_decimal(buf, &rt, sizeof(buf), 0, 1); fprintf(out, "<float-literal value='%s' />", buf); } break; case INTEGER_CST: fprintf(out, "<integer-literal value='%lld' />", double_int_to_ll(TREE_INT_CST(cst))); break; case STRING_CST: fprintf(out, "<string-literal>"); p = TREE_STRING_POINTER(cst); for (i = 0; i < TREE_STRING_LENGTH(cst); i++) { if (p[i] == '\\') fputc('\\', out), fputc('\\', out); else if (p[i] == '&') fputs("&", out); else if (p[i] == '<') fputs("<", out); else if (p[i] == '>') fputs(">", out); else if (ISPRINT(p[i])) fputc(p[i], out); else fprintf(out, "\\x%02x", p[i] & 0xFF); } fprintf(out, "</string-literal>"); break; default: fprintf(stderr, "failing: unhandled cst tree type %s\n", tree_code_name[TREE_CODE(cst)]); abort(); } }
static void java_perform_atof (YYSTYPE *java_lval, char *literal_token, int fflag, int number_beginning) { REAL_VALUE_TYPE value; tree type = (fflag ? FLOAT_TYPE_NODE : DOUBLE_TYPE_NODE); SET_REAL_VALUE_ATOF (value, REAL_VALUE_ATOF (literal_token, TYPE_MODE (type))); if (REAL_VALUE_ISINF (value) || REAL_VALUE_ISNAN (value)) { JAVA_FLOAT_RANGE_ERROR (fflag ? "float" : "double"); value = DCONST0; } else if (IS_ZERO (value)) { /* We check to see if the value is really 0 or if we've found an underflow. We do this in the most primitive imaginable way. */ int really_zero = 1; char *p = literal_token; if (*p == '-') ++p; while (*p && *p != 'e' && *p != 'E') { if (*p != '0' && *p != '.') { really_zero = 0; break; } ++p; } if (! really_zero) { int save_col = ctxp->lexer->position.col; ctxp->lexer->position.col = number_beginning; java_lex_error ("Floating point literal underflow", 0); ctxp->lexer->position.col = save_col; } } SET_LVAL_NODE (build_real (type, value)); }
void print_node_brief (FILE *file, const char *prefix, const_tree node, int indent) { enum tree_code_class tclass; if (node == 0) return; tclass = TREE_CODE_CLASS (TREE_CODE (node)); /* Always print the slot this node is in, and its code, address and name if any. */ if (indent > 0) fprintf (file, " "); fprintf (file, "%s <%s", prefix, get_tree_code_name (TREE_CODE (node))); dump_addr (file, " ", node); if (tclass == tcc_declaration) { if (DECL_NAME (node)) fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (node))); else if (TREE_CODE (node) == LABEL_DECL && LABEL_DECL_UID (node) != -1) { if (dump_flags & TDF_NOUID) fprintf (file, " L.xxxx"); else fprintf (file, " L.%d", (int) LABEL_DECL_UID (node)); } else { if (dump_flags & TDF_NOUID) fprintf (file, " %c.xxxx", TREE_CODE (node) == CONST_DECL ? 'C' : 'D'); else fprintf (file, " %c.%u", TREE_CODE (node) == CONST_DECL ? 'C' : 'D', DECL_UID (node)); } } else if (tclass == tcc_type) { if (TYPE_NAME (node)) { if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE) fprintf (file, " %s", IDENTIFIER_POINTER (TYPE_NAME (node))); else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL && DECL_NAME (TYPE_NAME (node))) fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node)))); } if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node))) fprintf (file, " address-space-%d", TYPE_ADDR_SPACE (node)); } if (TREE_CODE (node) == IDENTIFIER_NODE) fprintf (file, " %s", IDENTIFIER_POINTER (node)); /* We might as well always print the value of an integer or real. */ if (TREE_CODE (node) == INTEGER_CST) { if (TREE_OVERFLOW (node)) fprintf (file, " overflow"); fprintf (file, " "); print_dec (node, file, TYPE_SIGN (TREE_TYPE (node))); } if (TREE_CODE (node) == REAL_CST) { REAL_VALUE_TYPE d; if (TREE_OVERFLOW (node)) fprintf (file, " overflow"); d = TREE_REAL_CST (node); if (REAL_VALUE_ISINF (d)) fprintf (file, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf"); else if (REAL_VALUE_ISNAN (d)) fprintf (file, " Nan"); else { char string[60]; real_to_decimal (string, &d, sizeof (string), 0, 1); fprintf (file, " %s", string); } } if (TREE_CODE (node) == FIXED_CST) { FIXED_VALUE_TYPE f; char string[60]; if (TREE_OVERFLOW (node)) fprintf (file, " overflow"); f = TREE_FIXED_CST (node); fixed_to_decimal (string, &f, sizeof (string)); fprintf (file, " %s", string); } fprintf (file, ">"); }
static bool fold_const_call_ss (real_value *result, built_in_function fn, const real_value *arg, const real_format *format) { switch (fn) { CASE_FLT_FN (BUILT_IN_SQRT): return (real_compare (GE_EXPR, arg, &dconst0) && do_mpfr_arg1 (result, mpfr_sqrt, arg, format)); CASE_FLT_FN (BUILT_IN_CBRT): return do_mpfr_arg1 (result, mpfr_cbrt, arg, format); CASE_FLT_FN (BUILT_IN_ASIN): return (real_compare (GE_EXPR, arg, &dconstm1) && real_compare (LE_EXPR, arg, &dconst1) && do_mpfr_arg1 (result, mpfr_asin, arg, format)); CASE_FLT_FN (BUILT_IN_ACOS): return (real_compare (GE_EXPR, arg, &dconstm1) && real_compare (LE_EXPR, arg, &dconst1) && do_mpfr_arg1 (result, mpfr_acos, arg, format)); CASE_FLT_FN (BUILT_IN_ATAN): return do_mpfr_arg1 (result, mpfr_atan, arg, format); CASE_FLT_FN (BUILT_IN_ASINH): return do_mpfr_arg1 (result, mpfr_asinh, arg, format); CASE_FLT_FN (BUILT_IN_ACOSH): return (real_compare (GE_EXPR, arg, &dconst1) && do_mpfr_arg1 (result, mpfr_acosh, arg, format)); CASE_FLT_FN (BUILT_IN_ATANH): return (real_compare (GE_EXPR, arg, &dconstm1) && real_compare (LE_EXPR, arg, &dconst1) && do_mpfr_arg1 (result, mpfr_atanh, arg, format)); CASE_FLT_FN (BUILT_IN_SIN): return do_mpfr_arg1 (result, mpfr_sin, arg, format); CASE_FLT_FN (BUILT_IN_COS): return do_mpfr_arg1 (result, mpfr_cos, arg, format); CASE_FLT_FN (BUILT_IN_TAN): return do_mpfr_arg1 (result, mpfr_tan, arg, format); CASE_FLT_FN (BUILT_IN_SINH): return do_mpfr_arg1 (result, mpfr_sinh, arg, format); CASE_FLT_FN (BUILT_IN_COSH): return do_mpfr_arg1 (result, mpfr_cosh, arg, format); CASE_FLT_FN (BUILT_IN_TANH): return do_mpfr_arg1 (result, mpfr_tanh, arg, format); CASE_FLT_FN (BUILT_IN_ERF): return do_mpfr_arg1 (result, mpfr_erf, arg, format); CASE_FLT_FN (BUILT_IN_ERFC): return do_mpfr_arg1 (result, mpfr_erfc, arg, format); CASE_FLT_FN (BUILT_IN_TGAMMA): return do_mpfr_arg1 (result, mpfr_gamma, arg, format); CASE_FLT_FN (BUILT_IN_EXP): return do_mpfr_arg1 (result, mpfr_exp, arg, format); CASE_FLT_FN (BUILT_IN_EXP2): return do_mpfr_arg1 (result, mpfr_exp2, arg, format); CASE_FLT_FN (BUILT_IN_EXP10): CASE_FLT_FN (BUILT_IN_POW10): return do_mpfr_arg1 (result, mpfr_exp10, arg, format); CASE_FLT_FN (BUILT_IN_EXPM1): return do_mpfr_arg1 (result, mpfr_expm1, arg, format); CASE_FLT_FN (BUILT_IN_LOG): return (real_compare (GT_EXPR, arg, &dconst0) && do_mpfr_arg1 (result, mpfr_log, arg, format)); CASE_FLT_FN (BUILT_IN_LOG2): return (real_compare (GT_EXPR, arg, &dconst0) && do_mpfr_arg1 (result, mpfr_log2, arg, format)); CASE_FLT_FN (BUILT_IN_LOG10): return (real_compare (GT_EXPR, arg, &dconst0) && do_mpfr_arg1 (result, mpfr_log10, arg, format)); CASE_FLT_FN (BUILT_IN_LOG1P): return (real_compare (GT_EXPR, arg, &dconstm1) && do_mpfr_arg1 (result, mpfr_log1p, arg, format)); CASE_FLT_FN (BUILT_IN_J0): return do_mpfr_arg1 (result, mpfr_j0, arg, format); CASE_FLT_FN (BUILT_IN_J1): return do_mpfr_arg1 (result, mpfr_j1, arg, format); CASE_FLT_FN (BUILT_IN_Y0): return (real_compare (GT_EXPR, arg, &dconst0) && do_mpfr_arg1 (result, mpfr_y0, arg, format)); CASE_FLT_FN (BUILT_IN_Y1): return (real_compare (GT_EXPR, arg, &dconst0) && do_mpfr_arg1 (result, mpfr_y1, arg, format)); CASE_FLT_FN (BUILT_IN_FLOOR): if (!REAL_VALUE_ISNAN (*arg) || !flag_errno_math) { real_floor (result, format, arg); return true; } return false; CASE_FLT_FN (BUILT_IN_CEIL): if (!REAL_VALUE_ISNAN (*arg) || !flag_errno_math) { real_ceil (result, format, arg); return true; } return false; CASE_FLT_FN (BUILT_IN_TRUNC): real_trunc (result, format, arg); return true; CASE_FLT_FN (BUILT_IN_ROUND): if (!REAL_VALUE_ISNAN (*arg) || !flag_errno_math) { real_round (result, format, arg); return true; } return false; CASE_FLT_FN (BUILT_IN_LOGB): return fold_const_logb (result, arg, format); CASE_FLT_FN (BUILT_IN_SIGNIFICAND): return fold_const_significand (result, arg, format); default: return false; } }
static bool fold_const_call_ss (real_value *result, combined_fn fn, const real_value *arg, const real_format *format) { switch (fn) { CASE_CFN_SQRT: return (real_compare (GE_EXPR, arg, &dconst0) && do_mpfr_arg1 (result, mpfr_sqrt, arg, format)); CASE_CFN_CBRT: return do_mpfr_arg1 (result, mpfr_cbrt, arg, format); CASE_CFN_ASIN: return (real_compare (GE_EXPR, arg, &dconstm1) && real_compare (LE_EXPR, arg, &dconst1) && do_mpfr_arg1 (result, mpfr_asin, arg, format)); CASE_CFN_ACOS: return (real_compare (GE_EXPR, arg, &dconstm1) && real_compare (LE_EXPR, arg, &dconst1) && do_mpfr_arg1 (result, mpfr_acos, arg, format)); CASE_CFN_ATAN: return do_mpfr_arg1 (result, mpfr_atan, arg, format); CASE_CFN_ASINH: return do_mpfr_arg1 (result, mpfr_asinh, arg, format); CASE_CFN_ACOSH: return (real_compare (GE_EXPR, arg, &dconst1) && do_mpfr_arg1 (result, mpfr_acosh, arg, format)); CASE_CFN_ATANH: return (real_compare (GE_EXPR, arg, &dconstm1) && real_compare (LE_EXPR, arg, &dconst1) && do_mpfr_arg1 (result, mpfr_atanh, arg, format)); CASE_CFN_SIN: return do_mpfr_arg1 (result, mpfr_sin, arg, format); CASE_CFN_COS: return do_mpfr_arg1 (result, mpfr_cos, arg, format); CASE_CFN_TAN: return do_mpfr_arg1 (result, mpfr_tan, arg, format); CASE_CFN_SINH: return do_mpfr_arg1 (result, mpfr_sinh, arg, format); CASE_CFN_COSH: return do_mpfr_arg1 (result, mpfr_cosh, arg, format); CASE_CFN_TANH: return do_mpfr_arg1 (result, mpfr_tanh, arg, format); CASE_CFN_ERF: return do_mpfr_arg1 (result, mpfr_erf, arg, format); CASE_CFN_ERFC: return do_mpfr_arg1 (result, mpfr_erfc, arg, format); CASE_CFN_TGAMMA: return do_mpfr_arg1 (result, mpfr_gamma, arg, format); CASE_CFN_EXP: return do_mpfr_arg1 (result, mpfr_exp, arg, format); CASE_CFN_EXP2: return do_mpfr_arg1 (result, mpfr_exp2, arg, format); CASE_CFN_EXP10: CASE_CFN_POW10: return do_mpfr_arg1 (result, mpfr_exp10, arg, format); CASE_CFN_EXPM1: return do_mpfr_arg1 (result, mpfr_expm1, arg, format); CASE_CFN_LOG: return (real_compare (GT_EXPR, arg, &dconst0) && do_mpfr_arg1 (result, mpfr_log, arg, format)); CASE_CFN_LOG2: return (real_compare (GT_EXPR, arg, &dconst0) && do_mpfr_arg1 (result, mpfr_log2, arg, format)); CASE_CFN_LOG10: return (real_compare (GT_EXPR, arg, &dconst0) && do_mpfr_arg1 (result, mpfr_log10, arg, format)); CASE_CFN_LOG1P: return (real_compare (GT_EXPR, arg, &dconstm1) && do_mpfr_arg1 (result, mpfr_log1p, arg, format)); CASE_CFN_J0: return do_mpfr_arg1 (result, mpfr_j0, arg, format); CASE_CFN_J1: return do_mpfr_arg1 (result, mpfr_j1, arg, format); CASE_CFN_Y0: return (real_compare (GT_EXPR, arg, &dconst0) && do_mpfr_arg1 (result, mpfr_y0, arg, format)); CASE_CFN_Y1: return (real_compare (GT_EXPR, arg, &dconst0) && do_mpfr_arg1 (result, mpfr_y1, arg, format)); CASE_CFN_FLOOR: if (!REAL_VALUE_ISNAN (*arg) || !flag_errno_math) { real_floor (result, format, arg); return true; } return false; CASE_CFN_CEIL: if (!REAL_VALUE_ISNAN (*arg) || !flag_errno_math) { real_ceil (result, format, arg); return true; } return false; CASE_CFN_TRUNC: real_trunc (result, format, arg); return true; CASE_CFN_ROUND: if (!REAL_VALUE_ISNAN (*arg) || !flag_errno_math) { real_round (result, format, arg); return true; } return false; CASE_CFN_LOGB: return fold_const_logb (result, arg, format); CASE_CFN_SIGNIFICAND: return fold_const_significand (result, arg, format); default: return false; } }