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 void print_exp (char *buf, const_rtx x, int verbose) { char tmp[BUF_LEN]; const char *st[4]; char *cur = buf; const char *fun = (char *) 0; const char *sep; rtx op[4]; int i; 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 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 ABS: fun = "abs"; op[0] = XEXP (x, 0); break; case SQRT: fun = "sqrt"; op[0] = XEXP (x, 0); break; case FFS: fun = "ffs"; op[0] = XEXP (x, 0); break; case EQ: 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 GT: op[0] = XEXP (x, 0); st[1] = ">"; op[1] = XEXP (x, 1); break; case GTU: fun = "gtu"; op[0] = XEXP (x, 0); op[1] = XEXP (x, 1); break; case LT: op[0] = XEXP (x, 0); st[1] = "<"; op[1] = XEXP (x, 1); break; case LTU: fun = "ltu"; op[0] = XEXP (x, 0); op[1] = XEXP (x, 1); break; case GE: op[0] = XEXP (x, 0); st[1] = ">="; op[1] = XEXP (x, 1); break; case GEU: fun = "geu"; op[0] = XEXP (x, 0); op[1] = XEXP (x, 1); break; case LE: op[0] = XEXP (x, 0); st[1] = "<="; op[1] = XEXP (x, 1); break; case LEU: fun = "leu"; op[0] = XEXP (x, 0); 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: { cur = safe_concat (buf, cur, "unspec"); if (GET_CODE (x) == UNSPEC_VOLATILE) cur = safe_concat (buf, cur, "/v"); cur = safe_concat (buf, cur, "["); sep = ""; for (i = 0; i < XVECLEN (x, 0); i++) { print_pattern (tmp, XVECEXP (x, 0, i), verbose); cur = safe_concat (buf, cur, sep); cur = safe_concat (buf, cur, tmp); sep = ","; } cur = safe_concat (buf, cur, "] "); sprintf (tmp, "%d", XINT (x, 1)); cur = safe_concat (buf, cur, tmp); } break; default: /* If (verbose) debug_rtx (x); */ st[0] = GET_RTX_NAME (GET_CODE (x)); break; } /* Print this as a function? */ if (fun) { cur = safe_concat (buf, cur, fun); cur = safe_concat (buf, cur, "("); } for (i = 0; i < 4; i++) { if (st[i]) cur = safe_concat (buf, cur, st[i]); if (op[i]) { if (fun && i != 0) cur = safe_concat (buf, cur, ","); print_value (tmp, op[i], verbose); cur = safe_concat (buf, cur, tmp); } } if (fun) cur = safe_concat (buf, cur, ")"); } /* 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_pattern (char *buf, const_rtx x, int verbose) { char t1[BUF_LEN], t2[BUF_LEN], t3[BUF_LEN]; switch (GET_CODE (x)) { case SET: print_value (t1, SET_DEST (x), verbose); print_value (t2, SET_SRC (x), verbose); sprintf (buf, "%s=%s", t1, t2); break; case RETURN: sprintf (buf, "return"); break; case SIMPLE_RETURN: sprintf (buf, "simple_return"); break; case CALL: print_exp (buf, x, verbose); break; case CLOBBER: print_value (t1, XEXP (x, 0), verbose); sprintf (buf, "clobber %s", t1); break; case USE: print_value (t1, XEXP (x, 0), verbose); sprintf (buf, "use %s", t1); break; case VAR_LOCATION: print_value (t1, PAT_VAR_LOCATION_LOC (x), verbose); sprintf (buf, "loc %s", t1); break; case COND_EXEC: if (GET_CODE (COND_EXEC_TEST (x)) == NE && XEXP (COND_EXEC_TEST (x), 1) == const0_rtx) print_value (t1, XEXP (COND_EXEC_TEST (x), 0), verbose); else if (GET_CODE (COND_EXEC_TEST (x)) == EQ && XEXP (COND_EXEC_TEST (x), 1) == const0_rtx) { t1[0] = '!'; print_value (t1 + 1, XEXP (COND_EXEC_TEST (x), 0), verbose); } else print_value (t1, COND_EXEC_TEST (x), verbose); print_pattern (t2, COND_EXEC_CODE (x), verbose); sprintf (buf, "(%s) %s", t1, t2); break; case PARALLEL: { int i; sprintf (t1, "{"); for (i = 0; i < XVECLEN (x, 0); i++) { print_pattern (t2, XVECEXP (x, 0, i), verbose); sprintf (t3, "%s%s;", t1, t2); strcpy (t1, t3); } sprintf (buf, "%s}", t1); } break; case SEQUENCE: /* Should never see SEQUENCE codes until after reorg. */ gcc_unreachable (); case ASM_INPUT: sprintf (buf, "asm {%s}", XSTR (x, 0)); break; case ADDR_VEC: /* Fall through. */ case ADDR_DIFF_VEC: print_value (buf, XEXP (x, 0), verbose); break; case TRAP_IF: print_value (t1, TRAP_CONDITION (x), verbose); sprintf (buf, "trap_if %s", t1); break; case UNSPEC: { int i; sprintf (t1, "unspec{"); for (i = 0; i < XVECLEN (x, 0); i++) { print_pattern (t2, XVECEXP (x, 0, i), verbose); sprintf (t3, "%s%s;", t1, t2); strcpy (t1, t3); } sprintf (buf, "%s}", t1); } break; case UNSPEC_VOLATILE: { int i; sprintf (t1, "unspec/v{"); for (i = 0; i < XVECLEN (x, 0); i++) { print_pattern (t2, XVECEXP (x, 0, i), verbose); sprintf (t3, "%s%s;", t1, t2); strcpy (t1, t3); } sprintf (buf, "%s}", t1); } break; default: print_value (buf, x, verbose); } } /* print_pattern */