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 */
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; }
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; } }