📄 gmicro.h
字号:
In general this is just CLASS; but on some machines in some cases it is preferable to use a more restrictive class. *//* On the Gmicro series, there is no restriction on GENERAL_REGS, so CLASS is returned. I do not know whether I should treat FPU_REGS specially or not (at least, m68k does not). */#define PREFERRED_RELOAD_CLASS(X,CLASS) CLASS/* Return the maximum number of consecutive registers needed to represent mode MODE in a register of class CLASS. *//* On the Gmicro, this is the size of MODE in words, except in the FPU regs, where a single reg is always enough. */#define CLASS_MAX_NREGS(CLASS, MODE) \ ((CLASS) == FPU_REGS ? \ 1 : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))/* Stack layout; function entry, exit and calling. *//* Define this if pushing a word on the stack makes the stack pointer a smaller address. */#define STACK_GROWS_DOWNWARD/* 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. *//* On the Gmicro, FP points to the old FP and the first local variables are at (FP - 4). */#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 Gmicro, sp is decremented by the exact size of the operand */#define PUSH_ROUNDING(BYTES) (BYTES)/* Offset of first parameter from the argument pointer register value. *//* On the Gmicro, the first argument is found at (ap + 8) where ap is fp. */#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 Gmicro, the EXITD 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. The adjsp operand of the EXITD insn can't be used for library calls now because the library is compiled with the standard compiler. Use of adjsp operand 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. On the m68k this is an RTD option, so I use the same name for the Gmicro. The option name may be changed in the future. */#define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) \ ((TARGET_RTD && (!(FUNDECL) || TREE_CODE (FUNDECL) != 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 Gmicro the floating return value is in fr0 not r0. */#define FUNCTION_VALUE(VALTYPE, FUNC) LIBCALL_VALUE (TYPE_MODE (VALTYPE))/* Define how to find the value returned by a library function assuming the value has mode MODE. */#define LIBCALL_VALUE(MODE) \ (gen_rtx (REG, (MODE), \ ((TARGET_FPU && ((MODE) == SFmode || (MODE) == DFmode)) ? 16 : 0)))/* 1 if N is a possible register number for a function value. On the Gmicro, r0 and fp0 are the possible registers. */#define FUNCTION_VALUE_REGNO_P(N) ((N) == 0 || (N) == 16)/* 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 function argument passing. On the Gmicro, no registers are used in this way. *//* Really? For the performance improvement, registers should be used !! */#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 Gmicro, 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 Gmicro, the offset starts at 0. */#define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT) \ ((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 Gmicro all args are pushed, except if -mregparm is specified then the first two words of arguments are passed in d0, d1. *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)/* The following macro is defined to output register list. The LSB of Mask is the lowest number register. Regoff is MY_GREG_OFF or MY_FREG_OFF. Do NOT use <i> in File, Mask, Regoff !! Should be changed from macros to functions. M.Yuhara */#define MY_GREG_OFF 0#define MY_FREG_OFF 16#define MY_PRINT_MASK(File, Mask, Regoff) \{ \ int i, first = -1; \ if ((Mask) == 0) { \ fprintf(File, "#0"); \ } else { \ fprintf(File, "("); \ for (i = 0; i < 16; i++) { \ if ( (Mask) & (1 << i) ) { \ if (first < 0) { \ if (first == -2) { \ fprintf(File, ","); \ } \ first = i; \ fprintf(File, "%s", reg_names[Regoff + i]); \ } \ } else if (first >= 0) { \ if (i > first + 1) { \ fprintf(File, "-%s", reg_names[Regoff + i - 1]); \ } \ first = -2; \ } \ } \ if ( (first >= 0) && (first != 15) ) \ fprintf(File, "-%s", reg_names[Regoff + 15]);\ fprintf(File, ")"); \ } \}#define MY_PRINT_ONEREG_L(FILE,MASK) \{ register int i; \ for (i = 0; i < 16; i++) \ if ( (1 << i) & (MASK)) { \ fprintf(FILE, "%s", reg_names[i]); \ (MASK) &= ~(1 << i); \ break; \ } \}#define MY_PRINT_ONEREG_H(FILE,MASK) \{ register int i; \ for (i = 15; i >= 0; i--) \ if ( (1 << i) & (MASK)) { \ fprintf(FILE, "%s", reg_names[i]); \ (MASK) &= ~(1 << i); \ break; \ } \}/* This macro generates the assembly code for function entry. FILE is a stdio stream to output the code to. SIZE is an int: how many units of temporary storage to allocate. Refer to the array `regs_ever_live' to determine which registers to save; `regs_ever_live[I]' is nonzero if register number I is ever used in the function. This macro is responsible for knowing which registers should not be saved even if used. *//* The next macro needs much optimization !! M.Yuhara */#define FUNCTION_PROLOGUE(FILE, SIZE) \{ register int regno; \ register int mask = 0; \ register int nregs = 0; \ static char *reg_names[] = REGISTER_NAMES; \ extern char call_used_regs[]; \ int fsize = ((SIZE) + 3) & -4; \ for (regno = 0; regno < 16; regno++) \ if (regs_ever_live[regno] && !call_used_regs[regno]) { \ mask |= (1 << regno); \ nregs++; \ } \ if (frame_pointer_needed) { \ mask &= ~(1 << FRAME_POINTER_REGNUM); \ if (nregs > 4) { \ fprintf(FILE, "\tenter.w #%d,", fsize); \ MY_PRINT_MASK(FILE, mask, MY_GREG_OFF); \ fprintf(FILE,"\n"); \ } else { \ fprintf(FILE, "\tmov.w fp,@-sp\n"); \ fprintf(FILE, "\tmov.w sp,fp\n"); \ if (fsize > 0) \ myoutput_sp_adjust(FILE, "sub", fsize); \ while (nregs--) { \ fprintf(FILE, "\tmov.w "); \ MY_PRINT_ONEREG_H(FILE, mask); \ fprintf(FILE, ",@-sp\n"); \ } \ } \ } else { \ if (fsize > 0) \ myoutput_sp_adjust(FILE, "sub", fsize); \ if (mask != 0) { \ if (nregs > 4) { \ fprintf(FILE, "\tstm.w "); \ MY_PRINT_MASK(FILE, mask, MY_GREG_OFF); \ fprintf(FILE, ",@-sp\n"); \ } else { \ while (nregs--) { \ fprintf(FILE, "\tmov.w "); \ MY_PRINT_ONEREG_H(FILE, mask); \ fprintf(FILE, ",@-sp\n"); \ } \ } \ } \ } \ mask = 0; \ for (regno = 16; regno < 32; regno++) \ if (regs_ever_live[regno] && !call_used_regs[regno]) \ mask |= 1 << (regno - 16); \ if (mask != 0) { \ fprintf(FILE, "\tfstm.w "); \ MY_PRINT_MASK(FILE, mask, MY_FREG_OFF); \ fprintf(FILE, ",@-sp\n", mask); \ } \}/* Output assembler code to FILE to increment profiler label # LABELNO for profiling a function entry. *//* ??? M.Yuhara */#define FUNCTION_PROFILER(FILE, LABELNO) \ fprintf (FILE, "\tmova @LP%d,r0\n\tjsr mcount\n", (LABELNO))/* Output assembler code to FILE to initialize this source file's basic block profiling info, if that has not already been done. */#define FUNCTION_BLOCK_PROFILER(FILE, LABELNO) \ fprintf (FILE, "\tcmp #0,@LPBX0\n\tbne LPI%d\n\tpusha @LPBX0\n\tjsr ___bb_init_func\n\tadd #4,sp\nLPI%d:\n", \ LABELNO, LABELNO);/* Output assembler code to FILE to increment the entry-count for the BLOCKNO'th basic block in this source file. */#define BLOCK_PROFILER(FILE, BLOCKNO) \ fprintf (FILE, "\tadd #1,@(LPBX2+%d)\n", 4 * BLOCKNO)/* 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. */#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 (when frame_pinter_needed) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ It should use the frame pointer only. This is mandatory because of alloca; we also take advantage of it to omit stack adjustments before returning. *//* The Gmicro FPU seems to be unable to fldm/fstm double or single floating. It only allows extended !! *//* Optimization is not enough, especially FREGs load !! M.Yuhara */#define FUNCTION_EPILOGUE(FILE, SIZE) \{ register int regno; \ register int mask, fmask; \ register int nregs, nfregs; \ int offset, foffset; \ extern char call_used_regs[]; \ static char *reg_names[] = REGISTER_NAMES; \ int fsize = ((SIZE) + 3) & -4; \ FUNCTION_EXTRA_EPILOGUE (FILE, SIZE); \ nfregs = 0; fmask = 0; \ for (regno = 16; regno < 31; regno++) \ if (regs_ever_live[regno] && ! call_used_regs[regno]) \ { nfregs++; fmask |= 1 << (regno - 16); } \ foffset = nfregs * 12; \ nregs = 0; mask = 0; \ if (frame_pointer_needed) regs_ever_live[FRAME_POINTER_REGNUM] = 0; \ for (regno = 0; regno < 16; regno++) \ if (regs_ever_live[regno] && ! call_used_regs[regno]) \ { nregs++; mask |= 1 << regno; } \ if (frame_pointer_needed) { \ offset = nregs * 4 + fsize; \ if (nfregs > 0) { \ fprintf(FILE, "\tfldm.x @(%d,fp),", -(foffset + offset));\ MY_PRINT_MASK(FILE, fmask, MY_FREG_OFF); \ fprintf(FILE, "\n"); \ } \ if (nregs > 4 \ || current_function_pops_args) { \ fprintf(FILE, "\tmova @(%d,fp),sp\n", -offset); \ fprintf(FILE, "\texitd "); \ MY_PRINT_MASK(FILE, mask, MY_GREG_OFF); \ fprintf(FILE, ",#%d\n", current_function_pops_args); \ } else { \ while (nregs--) { \ fprintf(FILE, "\tmov:l.w @(%d,fp),", -offset); \ MY_PRINT_ONEREG_L(FILE, mask); \ fprintf(FILE, "\n"); \ offset -= 4; \ } \ if (TARGET_NEWRETURN) { \ fprintf(FILE, "\tmova.w @(4,fp),sp\n"); \ fprintf(FILE, "\tmov:l.w @fp,fp\n"); \ } else { \ fprintf(FILE, "\tmov.w fp,sp\n"); \ fprintf(FILE, "\tmov.w @sp+,fp\n"); \ } \ fprintf(FILE, "\trts\n"); \ } \ } else { \ if (nfregs > 0) { \ fprintf(FILE, "\tfldm.w @sp+,"); \ MY_PRINT_MASK(FILE, fmask, MY_FREG_OFF); \ fprintf(FILE, "\n"); \ } \ if (nregs > 4) { \ fprintf(FILE, "\tldm.w @sp+,"); \ MY_PRINT_MASK(FILE, mask, MY_GREG_OFF); \ fprintf(FILE, "\n"); \ } else { \ while (nregs--) { \ fprintf(FILE, "\tmov.w @sp+,"); \ MY_PRINT_ONEREG_L(FILE,mask); \ fprintf(FILE, "\n"); \ } \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -