📄 ns32k.h
字号:
/* Define this if the nominal address of the stack frame is at the high-address end of the local variables; that is, each additional local variable allocated goes at a more negative offset in the frame. */#define FRAME_GROWS_DOWNWARD/* Offset within stack frame to start allocating local variables at. If FRAME_GROWS_DOWNWARD, this is the offset to the END of the first local allocated. Otherwise, it is the offset to the BEGINNING of the first local allocated. */#define STARTING_FRAME_OFFSET 0/* If we generate an insn to push BYTES bytes, this says how many the stack pointer really advances by. On the 32000, sp@- in a byte insn really pushes a BYTE. */#define PUSH_ROUNDING(BYTES) (BYTES)/* Offset of first parameter from the argument pointer register value. */#define FIRST_PARM_OFFSET(FNDECL) 8/* Value is the number of byte of arguments automatically popped when returning from a subroutine call. FUNDECL is the declaration node of the function (as a tree), FUNTYPE is the data type of the function (as a tree), or for a library call it is an identifier node for the subroutine name. SIZE is the number of bytes of arguments passed on the stack. On the 32000, the RET insn may be used to pop them if the number of args is fixed, but if the number is variable then the caller must pop them all. RET can't be used for library calls now because the library is compiled with the Unix compiler. Use of RET is a selectable option, since it is incompatible with standard Unix calling sequences. If the option is not selected, the caller must always pop the args. */#define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) \ ((TARGET_RTD && TREE_CODE (FUNTYPE) != IDENTIFIER_NODE \ && (TYPE_ARG_TYPES (FUNTYPE) == 0 \ || (TREE_VALUE (tree_last (TYPE_ARG_TYPES (FUNTYPE))) \ == void_type_node))) \ ? (SIZE) : 0)/* Define how to find the value returned by a function. VALTYPE is the data type of the value (as a tree). If the precise function being called is known, FUNC is its FUNCTION_DECL; otherwise, FUNC is 0. *//* On the 32000 the return value is in R0, or perhaps in F0 is there is fp support. */ #define FUNCTION_VALUE(VALTYPE, FUNC) \ (TREE_CODE (VALTYPE) == REAL_TYPE && TARGET_32081 \ ? gen_rtx (REG, TYPE_MODE (VALTYPE), 8) \ : gen_rtx (REG, TYPE_MODE (VALTYPE), 0))/* Define how to find the value returned by a library function assuming the value has mode MODE. *//* On the 32000 the return value is in R0, or perhaps F0 is there is fp support. */ #define LIBCALL_VALUE(MODE) \ (((MODE) == DFmode || (MODE) == SFmode) && TARGET_32081 \ ? gen_rtx (REG, MODE, 8) \ : gen_rtx (REG, MODE, 0))/* Define this if PCC uses the nonreentrant convention for returning structure and union values. */#define PCC_STATIC_STRUCT_RETURN/* 1 if N is a possible register number for a function value. On the 32000, R0 and F0 are the only registers thus used. */#define FUNCTION_VALUE_REGNO_P(N) (((N) & ~8) == 0)/* 1 if N is a possible register number for function argument passing. On the 32000, no registers are used in this way. */#define FUNCTION_ARG_REGNO_P(N) 0/* Define a data type for recording info about an argument list during the scan of that argument list. This data type should hold all necessary information about the function itself and about the args processed so far, enough to enable macros such as FUNCTION_ARG to determine where the next arg should go. On the ns32k, this is a single integer, which is a number of bytes of arguments scanned so far. */#define CUMULATIVE_ARGS int/* Initialize a variable CUM of type CUMULATIVE_ARGS for a call to a function whose data type is FNTYPE. For a library call, FNTYPE is 0. On the ns32k, the offset starts at 0. */#define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME) \ ((CUM) = 0)/* Update the data in CUM to advance over an argument of mode MODE and data type TYPE. (TYPE is null for libcalls where that information may not be available.) */#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \ ((CUM) += ((MODE) != BLKmode \ ? (GET_MODE_SIZE (MODE) + 3) & ~3 \ : (int_size_in_bytes (TYPE) + 3) & ~3))/* Define where to put the arguments to a function. Value is zero to push the argument on the stack, or a hard register in which to store the argument. MODE is the argument's machine mode. TYPE is the data type of the argument (as a tree). This is null for libcalls where that information may not be available. CUM is a variable of type CUMULATIVE_ARGS which gives info about the preceding args and about the function being called. NAMED is nonzero if this argument is a named parameter (otherwise it is an extra parameter matching an ellipsis). *//* On the 32000 all args are pushed, except if -mregparm is specified then the first two words of arguments are passed in r0, r1. *NOTE* -mregparm does not work. It exists only to test register calling conventions. */#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \((TARGET_REGPARM && (CUM) < 8) ? gen_rtx (REG, (MODE), (CUM) / 4) : 0)/* For an arg passed partly in registers and partly in memory, this is the number of registers used. For args passed entirely in registers or entirely in memory, zero. */#define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \((TARGET_REGPARM && (CUM) < 8 \ && 8 < ((CUM) + ((MODE) == BLKmode \ ? int_size_in_bytes (TYPE) \ : GET_MODE_SIZE (MODE)))) \ ? 2 - (CUM) / 4 : 0)#ifndef MAIN_FUNCTION_PROLOGUE#define MAIN_FUNCTION_PROLOGUE#endif/* * The function prologue for the ns32k is fairly simple. * If a frame pointer is needed (decided in reload.c ?) then * we need assembler of the form * * # Save the oldframe pointer, set the new frame pointer, make space * # on the stack and save any general purpose registers necessary * * enter [<general purpose regs to save>], <local stack space> * * movf fn, tos # Save any floating point registers necessary * . * . * * If a frame pointer is not needed we need assembler of the form * * # Make space on the stack * * adjspd <local stack space + 4> * * # Save any general purpose registers necessary * * save [<general purpose regs to save>] * * movf fn, tos # Save any floating point registers necessary * . * . */#if defined(IMMEDIATE_PREFIX) && IMMEDIATE_PREFIX#define ADJSP(FILE, n) \ fprintf (FILE, "\tadjspd %c%d\n", IMMEDIATE_PREFIX, (n))#else#define ADJSP(FILE, n) \ fprintf (FILE, "\tadjspd %d\n", (n))#endif#define FUNCTION_PROLOGUE(FILE, SIZE) \{ register int regno, g_regs_used = 0; \ int used_regs_buf[8], *bufp = used_regs_buf; \ int used_fregs_buf[8], *fbufp = used_fregs_buf; \ extern char call_used_regs[]; \ extern int current_function_uses_pic_offset_table, flag_pic; \ MAIN_FUNCTION_PROLOGUE; \ for (regno = 0; regno < 8; regno++) \ if (regs_ever_live[regno] \ && ! call_used_regs[regno]) \ { \ *bufp++ = regno; g_regs_used++; \ } \ *bufp = -1; \ for (; regno < 16; 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 (SIZE) \ ADJSP (FILE, 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++); \ if (*bufp >= 0) \ fputc (',', FILE); \ } \ if (frame_pointer_needed) \ fprintf (FILE, "],%d\n", SIZE); \ else if (g_regs_used) \ fprintf (FILE, "]\n"); \ fbufp = used_fregs_buf; \ while (*fbufp >= 0) \ { \ if ((*fbufp & 1) || (fbufp[0] != fbufp[1] - 1)) \ fprintf (FILE, "\tmovf f%d,tos\n", *fbufp++ - 8); \ else \ { \ fprintf (FILE, "\tmovl f%d,tos\n", fbufp[0] - 8); \ fbufp += 2; \ } \ } \ if (flag_pic && current_function_uses_pic_offset_table) \ { \ fprintf (FILE, "\tsprd sb,tos\n"); \ if (TARGET_REGPARM) \ { \ fprintf (FILE, "\taddr __GLOBAL_OFFSET_TABLE_(pc),tos\n"); \ fprintf (FILE, "\tlprd sb,tos\n"); \ } \ else \ { \ fprintf (FILE, "\taddr __GLOBAL_OFFSET_TABLE_(pc),r0\n"); \ fprintf (FILE, "\tlprd sb,r0\n"); \ } \ } \}/* Output assembler code to FILE to increment profiler label # LABELNO for profiling a function entry. THIS DEFINITION FOR THE 32000 IS A GUESS. IT HAS NOT BEEN TESTED. */#define FUNCTION_PROFILER(FILE, LABELNO) \ fprintf (FILE, "\taddr LP%d,r0\n\tbsr mcount\n", (LABELNO))/* EXIT_IGNORE_STACK should be nonzero if, when returning from a function, the stack pointer does not matter. The value is tested only in functions that have frame pointers. No definition is equivalent to always zero. We use 0, because using 1 requires hair in FUNCTION_EPILOGUE that is worse than the stack adjust we could save. *//* #define EXIT_IGNORE_STACK 1 *//* This macro generates the assembly code for function exit, on machines that need it. If FUNCTION_EPILOGUE is not defined then individual return instructions are generated for each return statement. Args are same as for FUNCTION_PROLOGUE. The function epilogue should not depend on the current stack pointer, if EXIT_IGNORE_STACK is nonzero. That doesn't apply here. If a frame pointer is needed (decided in reload.c ?) then we need assembler of the form movf tos, fn # Restore any saved floating point registers . . # Restore any saved general purpose registers, restore the stack # pointer from the frame pointer, restore the old frame pointer. exit [<general purpose regs to save>] If a frame pointer is not needed we need assembler of the form # Restore any general purpose registers saved movf tos, fn # Restore any saved floating point registers . . . restore [<general purpose regs to save>] # 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; \ int used_regs_buf[8], *bufp = used_regs_buf; \ int used_fregs_buf[8], *fbufp = used_fregs_buf; \ extern char call_used_regs[]; \ extern int current_function_uses_pic_offset_table, flag_pic; \ if (flag_pic && current_function_uses_pic_offset_table) \ fprintf (FILE, "\tlprd sb,tos\n"); \ *fbufp++ = -2; \ for (regno = 8; regno < 16; 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++; \ } \ while (fbufp > used_fregs_buf) \ { \ if ((*fbufp & 1) && fbufp[0] == fbufp[-1] + 1) \ { \ fprintf (FILE, "\tmovl tos,f%d\n", fbufp[-1] - 8); \ fbufp -= 2; \ } \ else fprintf (FILE, "\tmovf tos,f%d\n", *fbufp-- - 8); \ } \ if (frame_pointer_needed) \ fprintf (FILE, "\texit ["); \ 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); \ if (bufp > used_regs_buf) \ fputc (',', FILE); \ } \ if (g_regs_used || frame_pointer_needed) \ fprintf (FILE, "]\n"); \ if (SIZE && !frame_pointer_needed) \ ADJSP (FILE, -(SIZE + 4)); \ if (current_function_pops_args) \ fprintf (FILE, "\tret %d\n", current_function_pops_args); \ else fprintf (FILE, "\tret 0\n"); }/* Store in the variable DEPTH the initial difference between the frame pointer reg contents and the stack pointer reg contents, as of the start of the function body. This depends on the layout of the fixed parts of the stack frame and on how registers are saved. */#define INITIAL_FRAME_POINTER_OFFSET(DEPTH) \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -