📄 tm-sparc.h
字号:
((C) == 'f' ? FP_REGS : NO_REGS)/* The letters I, J, K, L and M in a register constraint string can be used to stand for particular ranges of immediate operands. This macro defines what the ranges are. C is the letter, and VALUE is a constant value. Return 1 if VALUE is in the range specified by C. For SPARC, `I' is used for the range of constants an insn can actually contain. `J' is used for the range which is just zero (since that is R0). `K' is used for the 5-bit operand of a compare insns. */#define SMALL_INT(X) ((unsigned) (INTVAL (X) + 0x1000) < 0x2000)#define CONST_OK_FOR_LETTER_P(VALUE, C) \ ((C) == 'I' ? (unsigned) ((VALUE) + 0x1000) < 0x2000 \ : (C) == 'J' ? (VALUE) == 0 \ : (C) == 'K' ? (unsigned) (VALUE) < 0x20 \ : 0)/* Similar, but for floating constants, and defining letters G and H. Here VALUE is the CONST_DOUBLE rtx itself. */#define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \ ((C) == 'G' && CONST_DOUBLE_LOW ((VALUE)) == 0 \ && CONST_DOUBLE_HIGH ((VALUE)) == 0)/* Given an rtx X being reloaded into a reg required to be in class CLASS, return the class of reg to actually use. In general this is just CLASS; but on some machines in some cases it is preferable to use a more restrictive class. */#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 SPARC, this is the size of MODE in words, except in the FP regs, where a single reg is always enough. */#define CLASS_MAX_NREGS(CLASS, MODE) \ ((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. */#define STARTING_FRAME_OFFSET -16/* If we generate an insn to push BYTES bytes, this says how many the stack pointer really advances by. On SPARC, don't define this because there are no push insns. *//* #define PUSH_ROUNDING(BYTES) *//* Offset of first parameter from the argument pointer register value. This is 64 for the ins and locals, plus 4 for the struct-return reg if this function isn't going to use it. */#define FIRST_PARM_OFFSET(FNDECL) \ (DECL_MODE (DECL_RESULT (FNDECL)) == BLKmode \ ? STRUCT_VALUE_OFFSET : STRUCT_VALUE_OFFSET + 4)/* Offset from top-of-stack address to location to store the function parameter if it can't go in a register. Addresses for following parameters are computed relative to this one. */#define FIRST_PARM_CALLER_OFFSET(FNDECL) \ (STRUCT_VALUE_OFFSET + 4 - STACK_POINTER_OFFSET)/* When a parameter is passed in a register, stack space is still allocated for it. */#define REG_PARM_STACK_SPACE/* Value is 1 if returning from a function call automatically pops the arguments described by the number-of-args field in the call. 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. */#define RETURN_POPS_ARGS(FUNTYPE) 0/* Some subroutine macros specific to this machine. */#define BASE_RETURN_VALUE_REG(MODE) \ ((MODE) == SFmode || (MODE) == DFmode ? 32 : 8)#define BASE_OUTGOING_VALUE_REG(MODE) \ ((MODE) == SFmode || (MODE) == DFmode ? 32 : 24)#define BASE_PASSING_ARG_REG(MODE) (8)#define BASE_INCOMING_ARG_REG(MODE) (24)/* 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 SPARC the value is found in the first "output" register. */#define FUNCTION_VALUE(VALTYPE, FUNC) \ gen_rtx (REG, TYPE_MODE (VALTYPE), BASE_RETURN_VALUE_REG (TYPE_MODE (VALTYPE)))/* But the called function leaves it in the first "input" register. */#define FUNCTION_OUTGOING_VALUE(VALTYPE, FUNC) \ gen_rtx (REG, TYPE_MODE (VALTYPE), BASE_OUTGOING_VALUE_REG (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, BASE_RETURN_VALUE_REG (MODE))/* 1 if N is a possible register number for a function value as seen by the caller. On SPARC, the first "output" reg is used for integer values, and the first floating point register is used for floating point values. */#define FUNCTION_VALUE_REGNO_P(N) ((N) == 8 || (N) == 32)/* 1 if N is a possible register number for function argument passing. On SPARC, these are the "output" registers. */#define FUNCTION_ARG_REGNO_P(N) ((N) < 14 && (N) > 7)/* 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 SPARC, this is a single integer, which is a number of words of arguments scanned so far (including the invisible argument, if any, which holds the structure-value-address). Thus 7 or more means all following args should go on the stack. */#define CUMULATIVE_ARGS int/* Define the number of register that can hold parameters. This macro is used only in other macro definitions below. */#define NPARM_REGS 6/* 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 SPARC, the offset always starts at 0: the first parm reg is always the same reg. */#define INIT_CUMULATIVE_ARGS(CUM,FNTYPE) ((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) / 4 \ : (int_size_in_bytes (TYPE) + 3) / 4))/* Determine where to put an argument 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 SPARC the first six args are normally in registers and the rest are pushed. Any arg that starts within the first 6 words is at least partially passed in a register unless its data type forbids. */ #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \((CUM) < NPARM_REGS \ && ((TYPE)==0 || ! TREE_ADDRESSABLE ((tree)(TYPE))) \ && ((MODE) != BLKmode || (TYPE_ALIGN ((TYPE)) % 32 == 0)) \ ? gen_rtx (REG, (MODE), BASE_PASSING_ARG_REG (MODE) + (CUM)) : 0)/* Define where a function finds its arguments. This is different from FUNCTION_ARG because of register windows. */#define FUNCTION_INCOMING_ARG(CUM, MODE, TYPE, NAMED) \((CUM) < NPARM_REGS \ && ((TYPE)==0 || ! TREE_ADDRESSABLE ((tree)(TYPE))) \ && ((MODE) != BLKmode || (TYPE_ALIGN ((TYPE)) % 32 == 0)) \ ? gen_rtx (REG, (MODE), BASE_INCOMING_ARG_REG (MODE) + (CUM)) : 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. Any arg that starts in the first 6 regs but won't entirely fit in them needs partial registers on the Sparc. */ #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \ (((CUM) < NPARM_REGS \ && ((TYPE)==0 || ! TREE_ADDRESSABLE ((tree)(TYPE))) \ && ((MODE) != BLKmode || (TYPE_ALIGN ((TYPE)) % 32 == 0)) \ && ((CUM) \ + ((MODE) == BLKmode \ ? (int_size_in_bytes (TYPE) + 3) / 4 \ : (GET_MODE_SIZE (MODE) + 3) / 4)) - NPARM_REGS > 0) \ ? (NPARM_REGS - (CUM)) \ : 0)/* Output the label for a function definition. */#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \{ \ extern tree double_type_node, float_type_node; \ if (TREE_TYPE (DECL) == float_type_node) \ fprintf (FILE, "\t.proc 6\n"); \ else if (TREE_TYPE (DECL) == double_type_node) \ fprintf (FILE, "\t.proc 7\n"); \ else if (TREE_TYPE (DECL) == void_type_node) \ fprintf (FILE, "\t.proc 0\n"); \ else fprintf (FILE, "\t.proc 1\n"); \ ASM_OUTPUT_LABEL (FILE, NAME); \}/* 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. *//* On SPARC, move-double insns between fpu and cpu need an 8-byte block of memory. If any fpu reg is used in the function, we allocate such a block here, at the bottom of the frame, just in case it's needed. If this function is a leaf procedure, then we may choose not to do a "save" insn. Currently we do this only if it touches the "output" registers. The "local" and "input" registers are off limits. It might be better to allow one such register to go to the stack, but I doubt it. */#define FUNCTION_PROLOGUE(FILE, SIZE) \{ \ extern char call_used_regs[]; \ extern int current_function_pretend_args_size; \ extern int frame_pointer_needed; \ int fsize = (((SIZE) + 7 - STARTING_FRAME_OFFSET) & -8); \ int actual_fsize; \ int n_fregs = 0, i; \ int n_iregs = 64; \ for (i = 32; i < FIRST_PSEUDO_REGISTER; i++) \ if (regs_ever_live[i] && ! call_used_regs[i]) \ n_fregs++; \ for (i = 16; i < 32; i++) \ if (regs_ever_live[i]) { n_iregs = 96; break; } \ fprintf (FILE, "\t!#PROLOGUE# 0\n"); \ actual_fsize = fsize + n_iregs + (n_fregs*4+7 & -8); \ fsize += current_function_pretend_args_size+7 & -8; \ actual_fsize += current_function_pretend_args_size+7 & -8; \ if (actual_fsize < 4096) \ fprintf (FILE, "\tsave %%sp,-%d,%%sp\n", actual_fsize); \ else \ { \ fprintf (FILE, "\tsethi %%hi(0x%x),%%g1\n\tadd %%g1,%%lo(0x%x),%%g1\n", \ -actual_fsize, -actual_fsize); \ fprintf (FILE, "\tsave %%sp,%%g1,%%sp\n"); \ } \ fprintf (FILE, "\t!#PROLOGUE# 1\n"); \ if (n_fregs) \ { \ for (i = 32, n_fregs = 0; i < FIRST_PSEUDO_REGISTER; i++) \ if (regs_ever_live[i] && ! call_used_regs[i]) \ { \ if (regs_ever_live[i+1] && ! call_used_regs[i+1]) \ fprintf (FILE, "\tstd %s,[%%sp+0x%x]\n", \ reg_names[i], n_iregs + 4 * n_fregs), \ n_fregs += 2, i += 1; \ else \ fprintf (FILE, "\tstf %s,[%%sp+0x%x]\n", \ reg_names[i], n_iregs + 4 * n_fregs++); \ } \ } \ if (regs_ever_live[32]) \ fprintf (FILE, "\tst %s,[%%fp-16]\n\tst %s,[%%fp-12]\n", \ reg_names[0], reg_names[0]); \}/* Output assembler code to FILE to increment profiler label # LABELNO for profiling a function entry. */#define FUNCTION_PROFILER(FILE, LABELNO) \ fprintf (FILE, "\tsethi %%hi(LP%d),%%o0\n\tcall mcount\n\tor %%lo(LP%d),%%o0,%%o0\n", \ (LABELNO), (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, "\tsethi %%hi(LPBX0),%%o0\n\tld [%%lo(LPBX0)+%%o0],%%o1\n\ttst %%o1\n\tbne LPY%d\n\tadd %%o0,%%lo(LPBX0),%%o0\n\tcall ___bb_init_func\n\tnop\nLPY%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) \{ \ int blockn = (BLOCKNO); \ fprintf (FILE, "\tsethi %%hi(LPBX2+%d),%%g1\n\tld [%%lo(LPBX2+%d)+%%g1],%%g2\n\\tadd %%g2,1,%%g2\n\tst %%g2,[%%lo(LPBX2+%d)+%%g1]\n", \ 4 * blockn, 4 * blockn, 4 * blockn); \ CC_STATUS_INIT; /* We have clobbered %g1. Also %g2. */ \}/* 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. */extern int may_call_alloca;extern int current_function_pretend_args_size;#define EXIT_IGNORE_STACK \ (get_frame_size () != 0 \ || may_call_alloca || current_function_pretend_args_size)/* 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! 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. *//* This declaration is needed due to traditional/ANSI incompatibilities which cannot be #ifdefed away because they occur inside of macros. Sigh. */extern union tree_node *current_function_decl;#define FUNCTION_EPILOGUE(FILE, SIZE) \{ \ extern char call_used_regs[]; \ extern int may_call_alloca; \ extern int current_function_pretend_args_size; \ extern int max_pending_stack_adjust; \ extern int frame_pointer_needed; \ int fsize = (((SIZE) + 7 - STARTING_FRAME_OFFSET) & -8); \ int actual_fsize; \ int n_fregs = 0, i; \ int n_iregs = 64; \ for (i = 32, n_fregs = 0; i < FIRST_PSEUDO_REGISTER; i++) \ if (regs_ever_live[i] && ! call_used_regs[i]) \ n_fregs++; \ for (i = 16; i < 32; i++) \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -