https://gcc.gnu.org/g:7d5e7ba6c3697116126763da71de866b9d215e70
commit 7d5e7ba6c3697116126763da71de866b9d215e70 Author: Michael Meissner <[email protected]> Date: Thu Nov 19 12:57:57 2026 -0500 Add extra debug support. This patch adds debug switches -mdebug=extra1 through -mdebug=extra4. This patch also adds the ability to provide a number in the range of -128 through 127 as a debug argument. The patch also prints additional information about the various floating point formats used for the different modes. 2026-11-19 Michael Meissner <[email protected]> gcc/ * gcc/common/config/rs6000/rs6000-common.cc (rs6000_handle_option): Add -mdebug=extra{1,2,3,4} and -mdebug=<n>. * config/rs6000/rs6000.cc (DEBUG_FMT_ID): New macro. (rs6000_debug_fp_mode): New debug function. (rs6000_debug_reg_global): If -mdebug=reg, print which -mdebug options are set and print extra information about the various floating point formats used. * config/rs6000/rs6000.h (MASK_DEBUG_*): Add -mdebug=<xxx> options. (TARGET_DEBUG_*): Likewise. Diff: --- gcc/common/config/rs6000/rs6000-common.cc | 13 +++ gcc/config/rs6000/rs6000.cc | 135 +++++++++++++++++++++++++++++- gcc/config/rs6000/rs6000.h | 56 ++++++++----- 3 files changed, 183 insertions(+), 21 deletions(-) diff --git a/gcc/common/config/rs6000/rs6000-common.cc b/gcc/common/config/rs6000/rs6000-common.cc index 5be6fd804351..8ee6ce86cb35 100644 --- a/gcc/common/config/rs6000/rs6000-common.cc +++ b/gcc/common/config/rs6000/rs6000-common.cc @@ -171,6 +171,19 @@ rs6000_handle_option (struct gcc_options *opts, struct gcc_options *opts_set, mask = MASK_DEBUG_TARGET; else if (! strcmp (q, "builtin")) mask = MASK_DEBUG_BUILTIN; + else if (! strcmp (q, "extra1")) + mask = MASK_DEBUG_EXTRA1; + else if (! strcmp (q, "extra2")) + mask = MASK_DEBUG_EXTRA2; + else if (! strcmp (q, "extra3")) + mask = MASK_DEBUG_EXTRA3; + else if (! strcmp (q, "extra4")) + mask = MASK_DEBUG_EXTRA4; + else if ((*q >= '0' && *q <= '9') + || ((q[0] == '-' || (q[0] == '+')) + && (q[1] >= '0' && q[1] <= '9'))) + mask = (MASK_DEBUG_NUMBER + & (unsigned) strtol (q, (char **)NULL, 0)); else error_at (loc, "unknown %<-mdebug-%s%> switch", q); diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 8d2a6c0582c2..2482349623c7 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -2251,9 +2251,24 @@ rs6000_debug_print_mode (ssize_t m) #define DEBUG_FMT_ID "%-32s= " #define DEBUG_FMT_D DEBUG_FMT_ID "%d\n" -#define DEBUG_FMT_WX DEBUG_FMT_ID "%#.12" HOST_WIDE_INT_PRINT "x: " +#define DEBUG_FMT_X DEBUG_FMT_ID "%#.13x: " +#define DEBUG_FMT_WX DEBUG_FMT_ID "%#.13" HOST_WIDE_INT_PRINT "x: " #define DEBUG_FMT_S DEBUG_FMT_ID "%s\n" +/* Print interesting floating point information. */ +static void +rs6000_debug_fp_mode (machine_mode m) +{ + fprintf (stderr, + DEBUG_FMT_ID "nan: %c, snan: %c, inf: %c, -0: %c, size: %2d\n", + GET_MODE_NAME (m), + HONOR_NANS (m) ? 'y' : 'n', + HONOR_SNANS (m) ? 'y' : 'n', + HONOR_INFINITIES (m) ? 'y' : 'n', + HONOR_SIGNED_ZEROS (m) ? 'y' : 'n', + (int) GET_MODE_SIZE (m)); +} + /* Print various interesting information with -mdebug=reg. */ static void rs6000_debug_reg_global (void) @@ -2430,6 +2445,95 @@ rs6000_debug_reg_global (void) fputs ("\n", stderr); } + + /* Decode the -mdebug options. */ + if (rs6000_debug) + { + const char *comma = ""; + fprintf (stderr, DEBUG_FMT_X, "-mdebug", rs6000_debug); + + if ((rs6000_debug & MASK_DEBUG_ALL) == MASK_DEBUG_ALL) + { + fprintf (stderr, "%s%s", comma, "all"); + comma = ", "; + } + else + { + if (TARGET_DEBUG_EXTRA1) + { + fprintf (stderr, "%s%s", comma, "extra1"); + comma = ", "; + } + + if (TARGET_DEBUG_EXTRA2) + { + fprintf (stderr, "%s%s", comma, "extra2"); + comma = ", "; + } + + if (TARGET_DEBUG_EXTRA3) + { + fprintf (stderr, "%s%s", comma, "extra3"); + comma = ", "; + } + + if (TARGET_DEBUG_EXTRA4) + { + fprintf (stderr, "%s%s", comma, "extra4"); + comma = ", "; + } + + if (TARGET_DEBUG_STACK) + { + fprintf (stderr, "%s%s", comma, "stack"); + comma = ", "; + } + + if (TARGET_DEBUG_ARG) + { + fprintf (stderr, "%s%s", comma, "arg"); + comma = ", "; + } + + if (TARGET_DEBUG_REG) + { + fprintf (stderr, "%s%s", comma, "reg"); + comma = ", "; + } + + if (TARGET_DEBUG_ADDR) + { + fprintf (stderr, "%s%s", comma, "addr"); + comma = ", "; + } + + if (TARGET_DEBUG_COST) + { + fprintf (stderr, "%s%s", comma, "cost"); + comma = ", "; + } + + if (TARGET_DEBUG_TARGET) + { + fprintf (stderr, "%s%s", comma, "target"); + comma = ", "; + } + + if (TARGET_DEBUG_BUILTIN) + { + fprintf (stderr, "%s%s", comma, "builtin"); + comma = ", "; + } + } + + if (TARGET_DEBUG_NUMBER) + fprintf (stderr, "%snumber = %d", + comma, + (int) TARGET_DEBUG_NUMBER); + + fprintf (stderr, "\n"); + } + if (rs6000_cpu_index >= 0) { const char *name = processor_target_table[rs6000_cpu_index].name; @@ -2630,6 +2734,35 @@ rs6000_debug_reg_global (void) if (TARGET_DIRECT_MOVE_128) fprintf (stderr, DEBUG_FMT_D, "VSX easy 64-bit mfvsrld element", (int)VECTOR_ELEMENT_MFVSRLD_64BIT); + + /* Print information about the various floating point formats used. */ + if (TARGET_HARD_FLOAT) + { + rs6000_debug_fp_mode (SFmode); + rs6000_debug_fp_mode (DFmode); + + if (rs6000_long_double_type_size == 128) + rs6000_debug_fp_mode (TFmode); + + if (TARGET_FLOAT128_TYPE) + { + rs6000_debug_fp_mode (KFmode); + rs6000_debug_fp_mode (IFmode); + } + + if (TARGET_DFP) + { + rs6000_debug_fp_mode (SDmode); + rs6000_debug_fp_mode (DDmode); + rs6000_debug_fp_mode (TDmode); + } + + if (TARGET_VSX) + { + rs6000_debug_fp_mode (V4SFmode); + rs6000_debug_fp_mode (V2DFmode); + } + } } diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h index ecd415a9b2f4..0f22e238514f 100644 --- a/gcc/config/rs6000/rs6000.h +++ b/gcc/config/rs6000/rs6000.h @@ -295,28 +295,44 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); #define ASSEMBLER_DIALECT 1 /* Debug support */ -#define MASK_DEBUG_STACK 0x01 /* debug stack applications */ -#define MASK_DEBUG_ARG 0x02 /* debug argument handling */ -#define MASK_DEBUG_REG 0x04 /* debug register handling */ -#define MASK_DEBUG_ADDR 0x08 /* debug memory addressing */ -#define MASK_DEBUG_COST 0x10 /* debug rtx codes */ -#define MASK_DEBUG_TARGET 0x20 /* debug target attribute/pragma */ -#define MASK_DEBUG_BUILTIN 0x40 /* debug builtins */ -#define MASK_DEBUG_ALL (MASK_DEBUG_STACK \ - | MASK_DEBUG_ARG \ - | MASK_DEBUG_REG \ - | MASK_DEBUG_ADDR \ - | MASK_DEBUG_COST \ - | MASK_DEBUG_TARGET \ +#define MASK_DEBUG_NUMBER 0x0000ff /* debug number value. */ +#define MASK_DEBUG_EXTRA1 0x000100 /* random testing #1. */ +#define MASK_DEBUG_EXTRA2 0x000200 /* random testing #2. */ +#define MASK_DEBUG_EXTRA3 0x000400 /* random testing #3. */ +#define MASK_DEBUG_EXTRA4 0x000800 /* random testing #4. */ +#define MASK_DEBUG_REG 0x001000 /* register handling. */ +#define MASK_DEBUG_STACK 0x002000 /* stack applications. */ +#define MASK_DEBUG_ARG 0x004000 /* argument handling. */ +#define MASK_DEBUG_ADDR 0x008000 /* memory addressing. */ +#define MASK_DEBUG_COST 0x010000 /* rtx costs. */ +#define MASK_DEBUG_TARGET 0x020000 /* target attr./pragma. */ +#define MASK_DEBUG_BUILTIN 0x040000 /* builtins */ + +/* All mask bits, but the bottom 8 bits for passing a number. */ +#define MASK_DEBUG_ALL (MASK_DEBUG_EXTRA1 \ + | MASK_DEBUG_EXTRA2 \ + | MASK_DEBUG_EXTRA3 \ + | MASK_DEBUG_EXTRA4 \ + | MASK_DEBUG_STACK \ + | MASK_DEBUG_ARG \ + | MASK_DEBUG_REG \ + | MASK_DEBUG_ADDR \ + | MASK_DEBUG_COST \ + | MASK_DEBUG_TARGET \ | MASK_DEBUG_BUILTIN) -#define TARGET_DEBUG_STACK (rs6000_debug & MASK_DEBUG_STACK) -#define TARGET_DEBUG_ARG (rs6000_debug & MASK_DEBUG_ARG) -#define TARGET_DEBUG_REG (rs6000_debug & MASK_DEBUG_REG) -#define TARGET_DEBUG_ADDR (rs6000_debug & MASK_DEBUG_ADDR) -#define TARGET_DEBUG_COST (rs6000_debug & MASK_DEBUG_COST) -#define TARGET_DEBUG_TARGET (rs6000_debug & MASK_DEBUG_TARGET) -#define TARGET_DEBUG_BUILTIN (rs6000_debug & MASK_DEBUG_BUILTIN) +#define TARGET_DEBUG_NUMBER ((signed char)rs6000_debug) +#define TARGET_DEBUG_EXTRA1 ((rs6000_debug & MASK_DEBUG_EXTRA1) != 0) +#define TARGET_DEBUG_EXTRA2 ((rs6000_debug & MASK_DEBUG_EXTRA2) != 0) +#define TARGET_DEBUG_EXTRA3 ((rs6000_debug & MASK_DEBUG_EXTRA3) != 0) +#define TARGET_DEBUG_EXTRA4 ((rs6000_debug & MASK_DEBUG_EXTRA4) != 0) +#define TARGET_DEBUG_STACK ((rs6000_debug & MASK_DEBUG_STACK) != 0) +#define TARGET_DEBUG_ARG ((rs6000_debug & MASK_DEBUG_ARG) != 0) +#define TARGET_DEBUG_REG ((rs6000_debug & MASK_DEBUG_REG) != 0) +#define TARGET_DEBUG_ADDR ((rs6000_debug & MASK_DEBUG_ADDR) != 0) +#define TARGET_DEBUG_COST ((rs6000_debug & MASK_DEBUG_COST) != 0) +#define TARGET_DEBUG_TARGET ((rs6000_debug & MASK_DEBUG_TARGET) != 0) +#define TARGET_DEBUG_BUILTIN ((rs6000_debug & MASK_DEBUG_BUILTIN) != 0) /* Helper macros for TFmode. Quad floating point (TFmode) can be either IBM long double format that uses a pair of doubles, or IEEE 128-bit floating
