static void pp_c_integer_constant (c_pretty_printer *pp, tree i) { tree type = TREE_TYPE (i); if (TREE_INT_CST_HIGH (i) == 0) pp_wide_integer (pp, TREE_INT_CST_LOW (i)); else { if (tree_int_cst_sgn (i) < 0) { pp_character (pp, '-'); i = build_int_cst_wide (NULL_TREE, -TREE_INT_CST_LOW (i), ~TREE_INT_CST_HIGH (i) + !TREE_INT_CST_LOW (i)); } sprintf (pp_buffer (pp)->digit_buffer, HOST_WIDE_INT_PRINT_DOUBLE_HEX, TREE_INT_CST_HIGH (i), TREE_INT_CST_LOW (i)); pp_string (pp, pp_buffer (pp)->digit_buffer); } if (TYPE_UNSIGNED (type)) pp_character (pp, 'u'); if (type == long_integer_type_node || type == long_unsigned_type_node) pp_character (pp, 'l'); else if (type == long_long_integer_type_node || type == long_long_unsigned_type_node) pp_string (pp, "ll"); }
static void pp_c_char (c_pretty_printer *pp, int c) { if (ISPRINT (c)) { switch (c) { case '\\': pp_string (pp, "\\\\"); break; case '\'': pp_string (pp, "\\\'"); break; case '\"': pp_string (pp, "\\\""); break; default: pp_character (pp, c); } } else pp_scalar (pp, "\\%03o", (unsigned) c); }
/* * Print atomic token tk */ static void print_atomic(printer_t *p, pp_atomic_token_t *tk) { char *s; s = get_string(p, tk); pp_string(p, s, tk->size); free_atomic_token(p, tk); }
static void test_end_group_cb (diagnostic_context * context) { pp_string (context->printer, "---------------------------------- END GROUP -------------------------------"); pp_newline_and_flush (context->printer); }
/* * Print the terms of uninterpreted type in array a * - n = size of the array */ static void eval_pp_constant_assignments(yices_pp_t *printer, evaluator_t *eval, term_t *a, uint32_t n) { model_t *model; term_table_t *terms; char *name; value_unint_t *d; uint32_t i; term_t t; value_t c; type_kind_t tau; model = eval->model; terms = model->terms; for (i=0; i<n; i++) { t = a[i]; tau = term_type_kind(terms, t); if (tau == UNINTERPRETED_TYPE || tau == SCALAR_TYPE) { c = eval_in_model(eval, t); d = vtbl_unint(&model->vtbl, c); name = term_name(terms, t); assert(name != NULL); if (d->name == NULL || strcmp(name, d->name) != 0) { pp_open_block(printer, PP_OPEN_EQ); pp_string(printer, name); vtbl_pp_object(printer, &model->vtbl, c); pp_close_block(printer, true); } } } }
static void test_begin_group_cb (diagnostic_context * context) { pp_string (context->printer, "================================= BEGIN GROUP =============================="); pp_newline (context->printer); }
void test_diagnostic_start_span_fn (diagnostic_context *context, expanded_location exploc) { pp_string (context->printer, "START_SPAN_FN: "); pp_newline (context->printer); }
static void pp_c_floating_constant (c_pretty_printer *pp, tree r) { real_to_decimal (pp_buffer (pp)->digit_buffer, &TREE_REAL_CST (r), sizeof (pp_buffer (pp)->digit_buffer), 0, 1); pp_string (pp, pp_buffer(pp)->digit_buffer); if (TREE_TYPE (r) == float_type_node) pp_character (pp, 'f'); else if (TREE_TYPE (r) == long_double_type_node) pp_character (pp, 'l'); else if (TREE_TYPE (r) == dfloat128_type_node) pp_string (pp, "dl"); else if (TREE_TYPE (r) == dfloat64_type_node) pp_string (pp, "dd"); else if (TREE_TYPE (r) == dfloat32_type_node) pp_string (pp, "df"); }
/* * Print label of tk prefixed with '(' if tk has parentheses */ static void print_label(printer_t *p, pp_open_token_t *tk) { char *s; if (tk_has_par(tk)) { pp_open_par(p); } s = get_label(p, tk); pp_string(p, s, tk->label_size); free_open_token(p, tk); }
/* * Print the function terms in array a * - n = size of the array */ static void eval_pp_function_assignments(yices_pp_t *printer, evaluator_t *eval, term_t *a, uint32_t n) { model_t *model; term_table_t *terms; value_fun_t *fun; char *name; term_t t; value_t c; uint32_t i; model = eval->model; terms = model->terms; // first pass: function objects for (i=0; i<n; i++) { t = a[i]; if (is_function_term(terms, t)) { /* * t is mapped to a function object fun if t and fun have * different names, we print (= <t's name> <fun 's name>) * otherwise we print nothing and store fun in the vtbl's queue * (fun's map definition will be printed later). */ c = eval_in_model(eval, t); name = term_name(terms, t); assert(name != NULL); if (object_is_function(&model->vtbl, c)) { fun = vtbl_function(&model->vtbl, c); if (fun->name == NULL || strcmp(name, fun->name) != 0) { pp_open_block(printer, PP_OPEN_EQ); pp_string(printer, name); vtbl_pp_object(printer, &model->vtbl, c); pp_close_block(printer, true); } else { vtbl_push_object(&model->vtbl, c); } } } } /* * second pass: deal with update objects */ for (i=0; i<n; i++) { t = a[i]; if (is_function_term(terms, t)) { c = eval_in_model(eval, t); name = term_name(terms, t); assert(name != NULL); if (object_is_update(&model->vtbl, c)) { vtbl_normalize_and_pp_update(printer, &model->vtbl, name, c, true); } } } }
/* * Print the assignment for i in model */ void model_pp_term_value(yices_pp_t *printer, model_t *model, term_t t) { char *name; value_t v; assert(term_kind(model->terms, t) == UNINTERPRETED_TERM); pp_open_block(printer, PP_OPEN_EQ); name = term_name(model->terms, t); if (name == NULL) { pp_id(printer, "t!", t); } else { pp_string(printer, name); } v = model_find_term_value(model, t); if (v == null_value) { pp_string(printer, "???"); } else { vtbl_pp_object(printer, &model->vtbl, v); } pp_close_block(printer, true); }
/* * Print the function terms in array a * - n = size of the array */ static void model_pp_function_assignments(yices_pp_t *printer, model_t *model, term_t *a, uint32_t n) { term_table_t *terms; value_fun_t *fun; char *name; term_t t; value_t c; uint32_t i; terms = model->terms; for (i=0; i<n; i++) { t = a[i]; if (is_function_term(terms, t)) { /* * t is mapped to a function object fun * if t and fun have different names, we print * (= <t's name> <fun 's name>) otherwise we print nothing * and push fun in vtbl's internal queue. */ c = model_find_term_value(model, t); name = term_name(terms, t); assert(name != NULL); if (object_is_function(&model->vtbl, c)) { fun = vtbl_function(&model->vtbl, c); if (fun->name == NULL || strcmp(name, fun->name) != 0) { pp_open_block(printer, PP_OPEN_EQ); pp_string(printer, name); vtbl_pp_object(printer, &model->vtbl, c); pp_close_block(printer, true); } else { vtbl_push_object(&model->vtbl, c); } } } } /* * Second pass: print the update objects */ for (i=0; i<n; i++) { t = a[i]; if (is_function_term(terms, t)) { c = model_find_term_value(model, t); name = term_name(terms, t); assert(name != NULL); if (object_is_update(&model->vtbl, c)) { vtbl_normalize_and_pp_update(printer, &model->vtbl, name, c, true); } } } }
/* Print the physical source line corresponding to the location of this diagnostics, and a caret indicating the precise column. */ void diagnostic_show_locus (diagnostic_context * context, const diagnostic_info *diagnostic) { const char *line; char *buffer; expanded_location s; int max_width; const char *saved_prefix; const char *caret_cs, *caret_ce; if (!context->show_caret || diagnostic->location <= BUILTINS_LOCATION || diagnostic->location == context->last_location) return; context->last_location = diagnostic->location; s = expand_location_to_spelling_point (diagnostic->location); line = location_get_source_line (s); if (line == NULL) return; max_width = context->caret_max_width; line = adjust_line (line, max_width, &(s.column)); pp_newline (context->printer); saved_prefix = pp_get_prefix (context->printer); pp_set_prefix (context->printer, NULL); pp_character (context->printer, ' '); while (max_width > 0 && *line != '\0') { char c = *line == '\t' ? ' ' : *line; pp_character (context->printer, c); max_width--; line++; } pp_newline (context->printer); caret_cs = colorize_start (pp_show_color (context->printer), "caret"); caret_ce = colorize_stop (pp_show_color (context->printer)); /* pp_printf does not implement %*c. */ size_t len = s.column + 3 + strlen (caret_cs) + strlen (caret_ce); buffer = XALLOCAVEC (char, len); snprintf (buffer, len, "%s %*c%s", caret_cs, s.column, '^', caret_ce); pp_string (context->printer, buffer); pp_set_prefix (context->printer, saved_prefix); }
static void print_insn_with_notes (pretty_printer *pp, const_rtx x) { pp_string (pp, print_rtx_head); print_insn (pp, x, 1); pp_newline (pp); if (INSN_P (x) && REG_NOTES (x)) for (rtx note = REG_NOTES (x); note; note = XEXP (note, 1)) { pp_printf (pp, "%s %s ", print_rtx_head, GET_REG_NOTE_NAME (REG_NOTE_KIND (note))); if (GET_CODE (note) == INT_LIST) pp_printf (pp, "%d", XINT (note, 0)); else print_pattern (pp, XEXP (note, 0), 1); pp_newline (pp); } }
/* Called during diagnostic message formatting process to print a source-level entity onto BUFFER. The meaning of the format specifiers is as follows: %D: a general decl, %E: An expression, %F: a function declaration, %T: a type. These format specifiers form a subset of the format specifiers set used by the C++ front-end. Please notice when called, the `%' part was already skipped by the diagnostic machinery. */ static bool c_tree_printer (pretty_printer *pp, text_info *text) { tree t = va_arg (*text->args_ptr, tree); const char *n = "({anonymous})"; switch (*text->format_spec) { case 'D': case 'F': if (DECL_NAME (t)) n = (*lang_hooks.decl_printable_name) (t, 2); break; case 'T': if (TREE_CODE (t) == TYPE_DECL) { if (DECL_NAME (t)) n = (*lang_hooks.decl_printable_name) (t, 2); } else { t = TYPE_NAME (t); if (t) n = IDENTIFIER_POINTER (t); } break; case 'E': if (TREE_CODE (t) == IDENTIFIER_NODE) n = IDENTIFIER_POINTER (t); else return false; break; default: return false; } pp_string (pp, n); return true; }
/* Default tree printer. Handles declarations only. */ extern "C" bool default_tree_printer(pretty_printer * pp, text_info *text, const char *spec, int precision, bool wide, bool set_locus, bool hash) { tree t; /* FUTURE: %+x should set the locus. */ if(precision != 0 || wide || hash) return false; switch(*spec) { case 'D': t = va_arg(*text->args_ptr, tree); if(DECL_DEBUG_EXPR_IS_FROM(t) && DECL_DEBUG_EXPR(t)) t = DECL_DEBUG_EXPR(t); break; case 'F': case 'T': t = va_arg(*text->args_ptr, tree); break; default: return false; } if(set_locus && text->locus) *text->locus = DECL_SOURCE_LOCATION(t); if(DECL_P(t)) { const char *n = DECL_NAME(t) ? lang_hooks.decl_printable_name(t, 2) : "<anonymous>"; pp_string(pp, n); } else dump_generic_node(pp, t, 0, 0, 0); return true; }
/* * Print the assignment for t as computed by the evaluator * - t must be a valid, uninterpreted term */ static void eval_pp_term_value(yices_pp_t *printer, evaluator_t *eval, term_t t) { model_t *model; char *name; value_t v; assert(term_kind(eval->model->terms, t) == UNINTERPRETED_TERM); model = eval->model; v = eval_in_model(eval, t); if (v >= 0) { // v = good value for t pp_open_block(printer, PP_OPEN_EQ); name = term_name(model->terms, t); if (name == NULL) { pp_id(printer, "t!", t); } else { pp_string(printer, name); } vtbl_pp_object(printer, &model->vtbl, v); pp_close_block(printer, true); } }
void print_insn (pretty_printer *pp, const_rtx x, int verbose) { if (verbose) { /* Blech, pretty-print can't print integers with a specified width. */ char uid_prefix[32]; snprintf (uid_prefix, sizeof uid_prefix, " %4d: ", INSN_UID (x)); pp_string (pp, uid_prefix); } switch (GET_CODE (x)) { case INSN: print_pattern (pp, PATTERN (x), verbose); break; case DEBUG_INSN: { const char *name = "?"; if (DECL_P (INSN_VAR_LOCATION_DECL (x))) { tree id = DECL_NAME (INSN_VAR_LOCATION_DECL (x)); char idbuf[32]; if (id) name = IDENTIFIER_POINTER (id); else if (TREE_CODE (INSN_VAR_LOCATION_DECL (x)) == DEBUG_EXPR_DECL) { sprintf (idbuf, "D#%i", DEBUG_TEMP_UID (INSN_VAR_LOCATION_DECL (x))); name = idbuf; } else { sprintf (idbuf, "D.%i", DECL_UID (INSN_VAR_LOCATION_DECL (x))); name = idbuf; } } pp_printf (pp, "debug %s => ", name); if (VAR_LOC_UNKNOWN_P (INSN_VAR_LOCATION_LOC (x))) pp_string (pp, "optimized away"); else print_pattern (pp, INSN_VAR_LOCATION_LOC (x), verbose); } break; case JUMP_INSN: print_pattern (pp, PATTERN (x), verbose); break; case CALL_INSN: if (GET_CODE (PATTERN (x)) == PARALLEL) print_pattern (pp, XVECEXP (PATTERN (x), 0, 0), verbose); else print_pattern (pp, PATTERN (x), verbose); break; case CODE_LABEL: pp_printf (pp, "L%d:", INSN_UID (x)); break; case JUMP_TABLE_DATA: pp_string (pp, "jump_table_data{\n"); print_pattern (pp, PATTERN (x), verbose); pp_right_brace (pp); break; case BARRIER: pp_string (pp, "barrier"); break; case NOTE: { pp_string (pp, GET_NOTE_INSN_NAME (NOTE_KIND (x))); switch (NOTE_KIND (x)) { case NOTE_INSN_EH_REGION_BEG: case NOTE_INSN_EH_REGION_END: pp_printf (pp, " %d", NOTE_EH_HANDLER (x)); break; case NOTE_INSN_BLOCK_BEG: case NOTE_INSN_BLOCK_END: pp_printf (pp, " %d", BLOCK_NUMBER (NOTE_BLOCK (x))); break; case NOTE_INSN_BASIC_BLOCK: pp_printf (pp, " %d", NOTE_BASIC_BLOCK (x)->index); break; case NOTE_INSN_DELETED_LABEL: case NOTE_INSN_DELETED_DEBUG_LABEL: { const char *label = NOTE_DELETED_LABEL_NAME (x); if (label == NULL) label = ""; pp_printf (pp, " (\"%s\")", label); } break; case NOTE_INSN_VAR_LOCATION: case NOTE_INSN_CALL_ARG_LOCATION: pp_left_brace (pp); print_pattern (pp, NOTE_VAR_LOCATION (x), verbose); pp_right_brace (pp); break; default: break; } break; } default: gcc_unreachable (); } } /* print_insn */
static void print_exp (pretty_printer *pp, const_rtx x, int verbose) { const char *st[4]; const char *fun; rtx op[4]; int i; fun = (char *) 0; for (i = 0; i < 4; i++) { st[i] = (char *) 0; op[i] = NULL_RTX; } switch (GET_CODE (x)) { case PLUS: op[0] = XEXP (x, 0); if (CONST_INT_P (XEXP (x, 1)) && INTVAL (XEXP (x, 1)) < 0) { st[1] = "-"; op[1] = GEN_INT (-INTVAL (XEXP (x, 1))); } else { st[1] = "+"; op[1] = XEXP (x, 1); } break; case LO_SUM: op[0] = XEXP (x, 0); st[1] = "+low("; op[1] = XEXP (x, 1); st[2] = ")"; break; case MINUS: op[0] = XEXP (x, 0); st[1] = "-"; op[1] = XEXP (x, 1); break; case COMPARE: fun = "cmp"; op[0] = XEXP (x, 0); op[1] = XEXP (x, 1); break; case NEG: st[0] = "-"; op[0] = XEXP (x, 0); break; case FMA: st[0] = "{"; op[0] = XEXP (x, 0); st[1] = "*"; op[1] = XEXP (x, 1); st[2] = "+"; op[2] = XEXP (x, 2); st[3] = "}"; break; case MULT: op[0] = XEXP (x, 0); st[1] = "*"; op[1] = XEXP (x, 1); break; case DIV: op[0] = XEXP (x, 0); st[1] = "/"; op[1] = XEXP (x, 1); break; case UDIV: fun = "udiv"; op[0] = XEXP (x, 0); op[1] = XEXP (x, 1); break; case MOD: op[0] = XEXP (x, 0); st[1] = "%"; op[1] = XEXP (x, 1); break; case UMOD: fun = "umod"; op[0] = XEXP (x, 0); op[1] = XEXP (x, 1); break; case SMIN: fun = "smin"; op[0] = XEXP (x, 0); op[1] = XEXP (x, 1); break; case SMAX: fun = "smax"; op[0] = XEXP (x, 0); op[1] = XEXP (x, 1); break; case UMIN: fun = "umin"; op[0] = XEXP (x, 0); op[1] = XEXP (x, 1); break; case UMAX: fun = "umax"; op[0] = XEXP (x, 0); op[1] = XEXP (x, 1); break; case NOT: st[0] = "!"; op[0] = XEXP (x, 0); break; case AND: op[0] = XEXP (x, 0); st[1] = "&"; op[1] = XEXP (x, 1); break; case IOR: op[0] = XEXP (x, 0); st[1] = "|"; op[1] = XEXP (x, 1); break; case XOR: op[0] = XEXP (x, 0); st[1] = "^"; op[1] = XEXP (x, 1); break; case ASHIFT: op[0] = XEXP (x, 0); st[1] = "<<"; op[1] = XEXP (x, 1); break; case LSHIFTRT: op[0] = XEXP (x, 0); st[1] = " 0>>"; op[1] = XEXP (x, 1); break; case ASHIFTRT: op[0] = XEXP (x, 0); st[1] = ">>"; op[1] = XEXP (x, 1); break; case ROTATE: op[0] = XEXP (x, 0); st[1] = "<-<"; op[1] = XEXP (x, 1); break; case ROTATERT: op[0] = XEXP (x, 0); st[1] = ">->"; op[1] = XEXP (x, 1); break; case NE: op[0] = XEXP (x, 0); st[1] = "!="; op[1] = XEXP (x, 1); break; case EQ: op[0] = XEXP (x, 0); st[1] = "=="; op[1] = XEXP (x, 1); break; case GE: op[0] = XEXP (x, 0); st[1] = ">="; op[1] = XEXP (x, 1); break; case GT: op[0] = XEXP (x, 0); st[1] = ">"; op[1] = XEXP (x, 1); break; case LE: op[0] = XEXP (x, 0); st[1] = "<="; op[1] = XEXP (x, 1); break; case LT: op[0] = XEXP (x, 0); st[1] = "<"; op[1] = XEXP (x, 1); break; case SIGN_EXTRACT: fun = (verbose) ? "sign_extract" : "sxt"; op[0] = XEXP (x, 0); op[1] = XEXP (x, 1); op[2] = XEXP (x, 2); break; case ZERO_EXTRACT: fun = (verbose) ? "zero_extract" : "zxt"; op[0] = XEXP (x, 0); op[1] = XEXP (x, 1); op[2] = XEXP (x, 2); break; case SIGN_EXTEND: fun = (verbose) ? "sign_extend" : "sxn"; op[0] = XEXP (x, 0); break; case ZERO_EXTEND: fun = (verbose) ? "zero_extend" : "zxn"; op[0] = XEXP (x, 0); break; case FLOAT_EXTEND: fun = (verbose) ? "float_extend" : "fxn"; op[0] = XEXP (x, 0); break; case TRUNCATE: fun = (verbose) ? "trunc" : "trn"; op[0] = XEXP (x, 0); break; case FLOAT_TRUNCATE: fun = (verbose) ? "float_trunc" : "ftr"; op[0] = XEXP (x, 0); break; case FLOAT: fun = (verbose) ? "float" : "flt"; op[0] = XEXP (x, 0); break; case UNSIGNED_FLOAT: fun = (verbose) ? "uns_float" : "ufl"; op[0] = XEXP (x, 0); break; case FIX: fun = "fix"; op[0] = XEXP (x, 0); break; case UNSIGNED_FIX: fun = (verbose) ? "uns_fix" : "ufx"; op[0] = XEXP (x, 0); break; case PRE_DEC: st[0] = "--"; op[0] = XEXP (x, 0); break; case PRE_INC: st[0] = "++"; op[0] = XEXP (x, 0); break; case POST_DEC: op[0] = XEXP (x, 0); st[1] = "--"; break; case POST_INC: op[0] = XEXP (x, 0); st[1] = "++"; break; case PRE_MODIFY: st[0] = "pre "; op[0] = XEXP (XEXP (x, 1), 0); st[1] = "+="; op[1] = XEXP (XEXP (x, 1), 1); break; case POST_MODIFY: st[0] = "post "; op[0] = XEXP (XEXP (x, 1), 0); st[1] = "+="; op[1] = XEXP (XEXP (x, 1), 1); break; case CALL: st[0] = "call "; op[0] = XEXP (x, 0); if (verbose) { st[1] = " argc:"; op[1] = XEXP (x, 1); } break; case IF_THEN_ELSE: st[0] = "{("; op[0] = XEXP (x, 0); st[1] = ")?"; op[1] = XEXP (x, 1); st[2] = ":"; op[2] = XEXP (x, 2); st[3] = "}"; break; case TRAP_IF: fun = "trap_if"; op[0] = TRAP_CONDITION (x); break; case PREFETCH: fun = "prefetch"; op[0] = XEXP (x, 0); op[1] = XEXP (x, 1); op[2] = XEXP (x, 2); break; case UNSPEC: case UNSPEC_VOLATILE: { pp_string (pp, "unspec"); if (GET_CODE (x) == UNSPEC_VOLATILE) pp_string (pp, "/v"); pp_left_bracket (pp); for (i = 0; i < XVECLEN (x, 0); i++) { if (i != 0) pp_comma (pp); print_pattern (pp, XVECEXP (x, 0, i), verbose); } pp_string (pp, "] "); pp_decimal_int (pp, XINT (x, 1)); } break; default: { /* Most unhandled codes can be printed as pseudo-functions. */ if (GET_RTX_CLASS (GET_CODE (x)) == RTX_UNARY) { fun = GET_RTX_NAME (GET_CODE (x)); op[0] = XEXP (x, 0); } else if (GET_RTX_CLASS (GET_CODE (x)) == RTX_COMPARE || GET_RTX_CLASS (GET_CODE (x)) == RTX_COMM_COMPARE || GET_RTX_CLASS (GET_CODE (x)) == RTX_BIN_ARITH || GET_RTX_CLASS (GET_CODE (x)) == RTX_COMM_ARITH) { fun = GET_RTX_NAME (GET_CODE (x)); op[0] = XEXP (x, 0); op[1] = XEXP (x, 1); } else if (GET_RTX_CLASS (GET_CODE (x)) == RTX_TERNARY) { fun = GET_RTX_NAME (GET_CODE (x)); op[0] = XEXP (x, 0); op[1] = XEXP (x, 1); op[2] = XEXP (x, 2); } else /* Give up, just print the RTX name. */ st[0] = GET_RTX_NAME (GET_CODE (x)); } break; } /* Print this as a function? */ if (fun) { pp_string (pp, fun); pp_left_paren (pp); } for (i = 0; i < 4; i++) { if (st[i]) pp_string (pp, st[i]); if (op[i]) { if (fun && i != 0) pp_comma (pp); print_value (pp, op[i], verbose); } } if (fun) pp_right_paren (pp); } /* print_exp */
void print_pattern (pretty_printer *pp, const_rtx x, int verbose) { if (! x) { pp_string (pp, "(nil)"); return; } switch (GET_CODE (x)) { case SET: print_value (pp, SET_DEST (x), verbose); pp_equal (pp); print_value (pp, SET_SRC (x), verbose); break; case RETURN: case SIMPLE_RETURN: case EH_RETURN: pp_string (pp, GET_RTX_NAME (GET_CODE (x))); break; case CALL: print_exp (pp, x, verbose); break; case CLOBBER: case USE: pp_printf (pp, "%s ", GET_RTX_NAME (GET_CODE (x))); print_value (pp, XEXP (x, 0), verbose); break; case VAR_LOCATION: pp_string (pp, "loc "); print_value (pp, PAT_VAR_LOCATION_LOC (x), verbose); break; case COND_EXEC: pp_left_paren (pp); if (GET_CODE (COND_EXEC_TEST (x)) == NE && XEXP (COND_EXEC_TEST (x), 1) == const0_rtx) print_value (pp, XEXP (COND_EXEC_TEST (x), 0), verbose); else if (GET_CODE (COND_EXEC_TEST (x)) == EQ && XEXP (COND_EXEC_TEST (x), 1) == const0_rtx) { pp_exclamation (pp); print_value (pp, XEXP (COND_EXEC_TEST (x), 0), verbose); } else print_value (pp, COND_EXEC_TEST (x), verbose); pp_string (pp, ") "); print_pattern (pp, COND_EXEC_CODE (x), verbose); break; case PARALLEL: { int i; pp_left_brace (pp); for (i = 0; i < XVECLEN (x, 0); i++) { print_pattern (pp, XVECEXP (x, 0, i), verbose); pp_semicolon (pp); } pp_right_brace (pp); } break; case SEQUENCE: { pp_string (pp, "sequence{"); if (INSN_P (XVECEXP (x, 0, 0))) { /* Print the sequence insns indented. */ const char * save_print_rtx_head = print_rtx_head; char indented_print_rtx_head[32]; pp_newline (pp); gcc_assert (strlen (print_rtx_head) < sizeof (indented_print_rtx_head) - 4); snprintf (indented_print_rtx_head, sizeof (indented_print_rtx_head), "%s ", print_rtx_head); print_rtx_head = indented_print_rtx_head; for (int i = 0; i < XVECLEN (x, 0); i++) print_insn_with_notes (pp, XVECEXP (x, 0, i)); pp_printf (pp, "%s ", save_print_rtx_head); print_rtx_head = save_print_rtx_head; } else { for (int i = 0; i < XVECLEN (x, 0); i++) { print_pattern (pp, XVECEXP (x, 0, i), verbose); pp_semicolon (pp); } } pp_right_brace (pp); } break; case ASM_INPUT: pp_printf (pp, "asm {%s}", XSTR (x, 0)); break; case ADDR_VEC: /* Fall through. */ case ADDR_DIFF_VEC: print_value (pp, XEXP (x, 0), verbose); break; case TRAP_IF: pp_string (pp, "trap_if "); print_value (pp, TRAP_CONDITION (x), verbose); break; case UNSPEC: case UNSPEC_VOLATILE: /* Fallthru -- leave UNSPECs to print_exp. */ default: print_value (pp, x, verbose); } } /* print_pattern */
void print_value (pretty_printer *pp, const_rtx x, int verbose) { char tmp[1024]; if (!x) { pp_string (pp, "(nil)"); return; } switch (GET_CODE (x)) { case CONST_INT: pp_scalar (pp, HOST_WIDE_INT_PRINT_HEX, (unsigned HOST_WIDE_INT) INTVAL (x)); break; case CONST_DOUBLE: if (FLOAT_MODE_P (GET_MODE (x))) { real_to_decimal (tmp, CONST_DOUBLE_REAL_VALUE (x), sizeof (tmp), 0, 1); pp_string (pp, tmp); } else pp_printf (pp, "<%wx,%wx>", (unsigned HOST_WIDE_INT) CONST_DOUBLE_LOW (x), (unsigned HOST_WIDE_INT) CONST_DOUBLE_HIGH (x)); break; case CONST_FIXED: fixed_to_decimal (tmp, CONST_FIXED_VALUE (x), sizeof (tmp)); pp_string (pp, tmp); break; case CONST_STRING: pp_printf (pp, "\"%s\"", XSTR (x, 0)); break; case SYMBOL_REF: pp_printf (pp, "`%s'", XSTR (x, 0)); break; case LABEL_REF: pp_printf (pp, "L%d", INSN_UID (XEXP (x, 0))); break; case CONST: case HIGH: case STRICT_LOW_PART: pp_printf (pp, "%s(", GET_RTX_NAME (GET_CODE (x))); print_value (pp, XEXP (x, 0), verbose); pp_right_paren (pp); break; case REG: if (REGNO (x) < FIRST_PSEUDO_REGISTER) { if (ISDIGIT (reg_names[REGNO (x)][0])) pp_modulo (pp); pp_string (pp, reg_names[REGNO (x)]); } else pp_printf (pp, "r%d", REGNO (x)); if (verbose) pp_printf (pp, ":%s", GET_MODE_NAME (GET_MODE (x))); break; case SUBREG: print_value (pp, SUBREG_REG (x), verbose); pp_printf (pp, "#%d", SUBREG_BYTE (x)); break; case SCRATCH: case CC0: case PC: pp_string (pp, GET_RTX_NAME (GET_CODE (x))); break; case MEM: pp_left_bracket (pp); print_value (pp, XEXP (x, 0), verbose); pp_right_bracket (pp); break; case DEBUG_EXPR: pp_printf (pp, "D#%i", DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (x))); break; default: print_exp (pp, x, verbose); break; } } /* print_value */
static inline void pp_ellipsis(printer_t *p) { pp_string(p, "...", 3); }
void pp_c_type_specifier (c_pretty_printer *pp, tree t) { const enum tree_code code = TREE_CODE (t); switch (code) { case ERROR_MARK: pp_c_identifier (pp, "<type-error>"); break; case IDENTIFIER_NODE: pp_c_tree_decl_identifier (pp, t); break; case VOID_TYPE: case BOOLEAN_TYPE: case INTEGER_TYPE: case REAL_TYPE: if (TYPE_NAME (t)) { t = TYPE_NAME (t); pp_c_type_specifier (pp, t); } else { int prec = TYPE_PRECISION (t); t = c_common_type_for_mode (TYPE_MODE (t), TYPE_UNSIGNED (t)); if (TYPE_NAME (t)) { pp_c_type_specifier (pp, t); if (TYPE_PRECISION (t) != prec) { pp_string (pp, ":"); pp_decimal_int (pp, prec); } } else { switch (code) { case INTEGER_TYPE: pp_string (pp, (TYPE_UNSIGNED (t) ? "<unnamed-unsigned:" : "<unnamed-signed:")); break; case REAL_TYPE: pp_string (pp, "<unnamed-float:"); break; default: gcc_unreachable (); } pp_decimal_int (pp, prec); pp_string (pp, ">"); } } break; case TYPE_DECL: if (DECL_NAME (t)) pp_id_expression (pp, t); else pp_c_identifier (pp, "<typedef-error>"); break; case UNION_TYPE: case RECORD_TYPE: case ENUMERAL_TYPE: if (code == UNION_TYPE) pp_c_identifier (pp, "union"); else if (code == RECORD_TYPE) pp_c_identifier (pp, "struct"); else if (code == ENUMERAL_TYPE) pp_c_identifier (pp, "enum"); else pp_c_identifier (pp, "<tag-error>"); if (TYPE_NAME (t)) pp_id_expression (pp, TYPE_NAME (t)); else pp_c_identifier (pp, "<anonymous>"); break; default: pp_unsupported_tree (pp, t); break; } }
static tree mf_varname_tree (tree decl) { const char *buf_contents; tree result; gcc_assert (decl); pretty_printer buf; /* Add FILENAME[:LINENUMBER[:COLUMNNUMBER]]. */ { expanded_location xloc = expand_location (DECL_SOURCE_LOCATION (decl)); const char *sourcefile; unsigned sourceline = xloc.line; unsigned sourcecolumn = 0; sourcecolumn = xloc.column; sourcefile = xloc.file; if (sourcefile == NULL && current_function_decl != NULL_TREE) sourcefile = DECL_SOURCE_FILE (current_function_decl); if (sourcefile == NULL) sourcefile = "<unknown file>"; pp_string (&buf, sourcefile); if (sourceline != 0) { pp_colon (&buf); pp_decimal_int (&buf, sourceline); if (sourcecolumn != 0) { pp_colon (&buf); pp_decimal_int (&buf, sourcecolumn); } } } if (current_function_decl != NULL_TREE) { /* Add (FUNCTION) */ pp_string (&buf, " ("); { const char *funcname = NULL; if (DECL_NAME (current_function_decl)) funcname = lang_hooks.decl_printable_name (current_function_decl, 1); if (funcname == NULL) funcname = "anonymous fn"; pp_string (&buf, funcname); } pp_string (&buf, ") "); } else pp_space (&buf); /* Add <variable-declaration>, possibly demangled. */ { const char *declname = NULL; if (DECL_NAME (decl) != NULL) { if (strcmp ("GNU C++", lang_hooks.name) == 0) { /* The gcc/cp decl_printable_name hook doesn't do as good a job as the libiberty demangler. */ declname = cplus_demangle (IDENTIFIER_POINTER (DECL_NAME (decl)), DMGL_AUTO | DMGL_VERBOSE); } if (declname == NULL) declname = lang_hooks.decl_printable_name (decl, 3); } if (declname == NULL) declname = "<unnamed variable>"; pp_string (&buf, declname); } /* Return the lot as a new STRING_CST. */ buf_contents = ggc_strdup (pp_formatted_text (&buf)); result = mf_build_string (buf_contents); pp_clear_output_area (&buf); return result; }
/* Called during diagnostic message formatting process to print a source-level entity onto BUFFER. The meaning of the format specifiers is as follows: %D: a general decl, %E: an identifier or expression, %F: a function declaration, %T: a type. These format specifiers form a subset of the format specifiers set used by the C++ front-end. Please notice when called, the `%' part was already skipped by the diagnostic machinery. */ static bool c_tree_printer (pretty_printer *pp, text_info *text, const char *spec, int precision, bool wide, bool set_locus, bool hash) { tree t = va_arg (*text->args_ptr, tree); tree name; c_pretty_printer *cpp = (c_pretty_printer *) pp; pp->padding = pp_none; if (precision != 0 || wide || hash) return false; if (set_locus && text->locus) *text->locus = DECL_SOURCE_LOCATION (t); switch (*spec) { case 'D': if (DECL_DEBUG_EXPR_IS_FROM (t) && DECL_DEBUG_EXPR (t)) { t = DECL_DEBUG_EXPR (t); if (!DECL_P (t)) { pp_c_expression (cpp, t); return true; } } /* FALLTHRU */ case 'F': if (DECL_NAME (t)) { pp_identifier (cpp, lang_hooks.decl_printable_name (t, 2)); return true; } break; case 'T': gcc_assert (TYPE_P (t)); name = TYPE_NAME (t); if (name && TREE_CODE (name) == TYPE_DECL) { if (DECL_NAME (name)) pp_identifier (cpp, lang_hooks.decl_printable_name (name, 2)); else pp_type_id (cpp, t); return true; } else { pp_type_id (cpp, t); return true; } break; case 'E': if (TREE_CODE (t) == IDENTIFIER_NODE) pp_identifier (cpp, IDENTIFIER_POINTER (t)); else pp_expression (cpp, t); return true; default: return false; } pp_string (cpp, _("({anonymous})")); return true; }