--- gcc/config/ns32k/ns32k.h 2018/04/24 18:10:24 1.1.1.1 +++ gcc/config/ns32k/ns32k.h 2018/04/24 18:14:50 1.1.1.2 @@ -26,7 +26,7 @@ extern enum reg_class secondary_reload_c /* Names to predefine in the preprocessor for this target machine. */ -#define CPP_PREDEFINES "-Dns32000 -Dunix" +#define CPP_PREDEFINES "-Dns32000 -Dunix -Asystem(unix) -Acpu(ns32k) -Amachine(ns32k)" /* Print subsidiary information on the compiler version in use. */ #define TARGET_VERSION fprintf (stderr, " (32000, GAS syntax)"); @@ -511,6 +511,11 @@ enum reg_class { NO_REGS, GENERAL_REGS, * . * * If a frame pointer is not needed we need assembler of the form + * + * # Make space on the stack + * + * adjspd + * * # Save any general purpose registers necessary * * save [] @@ -529,20 +534,32 @@ enum reg_class { NO_REGS, GENERAL_REGS, for (regno = 0; regno < 8; regno++) \ if (regs_ever_live[regno] \ && ! call_used_regs[regno]) \ - { \ - *bufp++ = regno; g_regs_used++; \ - } \ + { \ + *bufp++ = regno; g_regs_used++; \ + } \ *bufp = -1; \ for (; regno < 16; regno++) \ - if (regs_ever_live[regno] && !call_used_regs[regno]) { \ - *fbufp++ = regno; \ - } \ + if (regs_ever_live[regno] && !call_used_regs[regno]) \ + { \ + *fbufp++ = regno; \ + } \ *fbufp = -1; \ bufp = used_regs_buf; \ if (frame_pointer_needed) \ fprintf (FILE, "\tenter ["); \ - else if (g_regs_used) \ - fprintf (FILE, "\tsave ["); \ + else \ + { \ + if (SIZE) \ + fprintf (FILE, "\tadjspd %$%d\n", SIZE + 4); \ + if (g_regs_used && g_regs_used > 4) \ + fprintf (FILE, "\tsave ["); \ + else \ + { \ + while (*bufp >= 0) \ + fprintf (FILE, "\tmovd r%d,tos\n", *bufp++); \ + g_regs_used = 0; \ + } \ + } \ while (*bufp >= 0) \ { \ fprintf (FILE, "r%d", *bufp++); \ @@ -610,7 +627,12 @@ enum reg_class { NO_REGS, GENERAL_REGS, . . . - restore [] */ + restore [] + + # reclaim space allocated on stack + + adjspd <-(local stack space + 4)> */ + #define FUNCTION_EPILOGUE(FILE, SIZE) \ { register int regno, g_regs_used = 0, f_regs_used = 0; \ @@ -619,16 +641,17 @@ enum reg_class { NO_REGS, GENERAL_REGS, extern char call_used_regs[]; \ *fbufp++ = -2; \ for (regno = 8; regno < 16; regno++) \ - if (regs_ever_live[regno] && !call_used_regs[regno]) { \ + if (regs_ever_live[regno] && !call_used_regs[regno]) \ + { \ *fbufp++ = regno; f_regs_used++; \ - } \ + } \ fbufp--; \ for (regno = 0; regno < 8; regno++) \ if (regs_ever_live[regno] \ && ! call_used_regs[regno]) \ - { \ - *bufp++ = regno; g_regs_used++; \ - } \ + { \ + *bufp++ = regno; g_regs_used++; \ + } \ while (fbufp > used_fregs_buf) \ { \ if ((*fbufp & 1) && fbufp[0] == fbufp[-1] + 1) \ @@ -640,8 +663,17 @@ enum reg_class { NO_REGS, GENERAL_REGS, } \ if (frame_pointer_needed) \ fprintf (FILE, "\texit ["); \ - else if (g_regs_used) \ - fprintf (FILE, "\trestore ["); \ + else \ + { \ + if (g_regs_used && g_regs_used > 4) \ + fprintf (FILE, "\trestore ["); \ + else \ + { \ + while (bufp > used_regs_buf) \ + fprintf (FILE, "\tmovd tos,r%d\n", *--bufp); \ + g_regs_used = 0; \ + } \ + } \ while (bufp > used_regs_buf) \ { \ fprintf (FILE, "r%d", *--bufp); \ @@ -650,6 +682,8 @@ enum reg_class { NO_REGS, GENERAL_REGS, } \ if (g_regs_used || frame_pointer_needed) \ fprintf (FILE, "]\n"); \ + if (SIZE && !frame_pointer_needed) \ + fprintf (FILE, "\tadjspd %$%d\n", -(SIZE + 4)); \ if (current_function_pops_args) \ fprintf (FILE, "\tret %d\n", current_function_pops_args); \ else fprintf (FILE, "\tret 0\n"); } @@ -666,7 +700,8 @@ enum reg_class { NO_REGS, GENERAL_REGS, for (regno = 0; regno < 16; regno++) \ if (regs_ever_live[regno] && ! call_used_regs[regno]) \ offset += 4; \ - (DEPTH) = offset - get_frame_size (); \ + (DEPTH) = (offset + get_frame_size () \ + + (get_frame_size () == 0 ? 0 : 4)); \ } @@ -959,8 +994,9 @@ __transfer_from_trampoline () \ /* Specify the machine mode that this machine uses for the index in the tablejump instruction. - Can do SImode, but HI mode is more efficient. */ -#define CASE_VECTOR_MODE HImode + HI mode is more efficient but the range is not wide enough for + all programs. */ +#define CASE_VECTOR_MODE SImode /* Define this if the tablejump instruction expects the table to contain offsets from the address of the table. @@ -1274,7 +1310,7 @@ do { \ /* This is how to output an element of a case-vector that is relative. */ /* ** Notice that the second element is LI format! */ #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \ - fprintf (FILE, "\t.word L%d-LI%d\n", VALUE, REL) + fprintf (FILE, "\t.long L%d-LI%d\n", VALUE, REL) /* This is how to output an assembler line that says to advance the location counter