Next:How Scalar Function Values Are Returned, Previous:Passing Function Arguments on the Stack, Up:Stack Layout and Calling Conventions [Contents][Index]
This section describes the macros which let you control how varioustypes of arguments are passed in registers or how they are arranged inthe stack.
rtxTARGET_FUNCTION_ARG(cumulative_args_tca, const function_arg_info&arg) ¶Return an RTX indicating whether function argumentarg is passedin a register and if so, which register. Argumentca summarizes allthe previous arguments.
The return value is usually either areg RTX for the hardregister in which to pass the argument, or zero to pass the argumenton the stack.
The value of the expression can also be aparallel RTX. This isused when an argument is passed in multiple locations. The mode of theparallel should be the mode of the entire argument. Theparallel holds any number ofexpr_list pairs; each onedescribes where part of the argument is passed. In eachexpr_list the first operand must be areg RTX for the hardregister in which to pass this part of the argument, and the mode of theregister RTX indicates how large this part of the argument is. Thesecond operand of theexpr_list is aconst_int which givesthe offset in bytes into the entire argument of where this part starts.As a special exception the firstexpr_list in theparallelRTX may have a first operand of zero. This indicates that the entireargument is also stored on the stack.
The last time this hook is called, it is called withMODE ==VOIDmode, and its result is passed to thecall orcall_valuepattern as operands 2 and 3 respectively.
The usual way to make the ISO librarystdarg.h work on amachine where some arguments are usually passed in registers, is tocause nameless arguments to be passed on the stack instead. This isdone by makingTARGET_FUNCTION_ARG return 0 whenevernamed isfalse.
You may use the hooktargetm.calls.must_pass_in_stackin the definition of this macro to determine if this argument is of atype that must be passed in the stack. IfREG_PARM_STACK_SPACEis not defined andTARGET_FUNCTION_ARG returns nonzero for such anargument, the compiler will abort. IfREG_PARM_STACK_SPACE isdefined, the argument will be computed in the stack and then loaded intoa register.
boolTARGET_MUST_PASS_IN_STACK(const function_arg_info&arg) ¶This target hook should returntrue if we should not passargsolely in registers. The fileexpr.h defines adefinition that is usually appropriate, refer toexpr.h for additionaldocumentation.
rtxTARGET_FUNCTION_INCOMING_ARG(cumulative_args_tca, const function_arg_info&arg) ¶Define this hook if the caller and callee on the target have differentviews of where arguments are passed. Also define this hook if there arefunctions that are never directly called, but are invoked by the hardwareand which have nonstandard calling conventions.
In this caseTARGET_FUNCTION_ARG computes the register inwhich the caller passes the value, andTARGET_FUNCTION_INCOMING_ARG should be defined in a similarfashion to tell the function being called where the arguments willarrive.
TARGET_FUNCTION_INCOMING_ARG can also return arbitrary addresscomputation using hard register, which can be forced into a register,so that it can be used to pass special arguments.
IfTARGET_FUNCTION_INCOMING_ARG is not defined,TARGET_FUNCTION_ARG serves both purposes.
boolTARGET_USE_PSEUDO_PIC_REG(void) ¶This hook should return 1 in case pseudo register should be createdfor pic_offset_table_rtx during function expand.
voidTARGET_INIT_PIC_REG(void) ¶Perform a target dependent initialization of pic_offset_table_rtx.This hook is called at the start of register allocation.
intTARGET_ARG_PARTIAL_BYTES(cumulative_args_tcum, const function_arg_info&arg) ¶This target hook returns the number of bytes at the beginning of anargument that must be put in registers. The value must be zero forarguments that are passed entirely in registers or that are entirelypushed on the stack.
On some machines, certain arguments must be passed partially inregisters and partially in memory. On these machines, typically thefirst few words of arguments are passed in registers, and the reston the stack. If a multi-word argument (adouble or astructure) crosses that boundary, its first few words must be passedin registers and the rest must be pushed. This macro tells thecompiler when this occurs, and how many bytes should go in registers.
TARGET_FUNCTION_ARG for these arguments should return the firstregister to be used by the caller for this argument; likewiseTARGET_FUNCTION_INCOMING_ARG, for the called function.
boolTARGET_PASS_BY_REFERENCE(cumulative_args_tcum, const function_arg_info&arg) ¶This target hook should returntrue if argumentarg at theposition indicated bycum should be passed by reference. Thispredicate is queried after target independent reasons for beingpassed by reference, such asTREE_ADDRESSABLE (arg.type).
If the hook returns true, a copy of that argument is made in memory and apointer to the argument is passed instead of the argument itself.The pointer is passed in whatever way is appropriate for passing a pointerto that type.
boolTARGET_CALLEE_COPIES(cumulative_args_tcum, const function_arg_info&arg) ¶The function argument described by the parameters to this hook isknown to be passed by reference. The hook should return true if thefunction argument should be copied by the callee instead of copiedby the caller.
For any argument for which the hook returns true, if it can bedetermined that the argument is not modified, then a copy neednot be generated.
The default version of this hook always returns false.
A C type for declaring a variable that is used as the first argumentofTARGET_FUNCTION_ARG and other related values. For sometarget machines, the typeint suffices and can hold the numberof bytes of argument so far.
There is no need to record inCUMULATIVE_ARGS anything about thearguments that have been passed on the stack. The compiler has othervariables to keep track of that. For target machines on which allarguments are passed on the stack, there is no need to store anything inCUMULATIVE_ARGS; however, the data structure must exist andshould not be empty, so useint.
If defined, this macro is called before generating any code for afunction, but after thecfun descriptor for the function has beencreated. The back end may use this macro to updatecfun toreflect an ABI other than that which would normally be used by default.If the compiler is generating code for a compiler-generated function,fndecl may beNULL.
A C statement (sans semicolon) for initializing the variablecum for the state at the beginning of the argument list. Thevariable has typeCUMULATIVE_ARGS. The value offntypeis the tree node for the data type of the function which will receivethe args, or 0 if the args are to a compiler support library function.For direct calls that are not libcalls,fndecl contain thedeclaration node of the function.fndecl is also set whenINIT_CUMULATIVE_ARGS is used to find arguments for the functionbeing compiled.n_named_args is set to the number of namedarguments, including a structure return address if it is passed as aparameter, when making a call. When processing incoming arguments,n_named_args is set to −1.
When processing a call to a compiler support library function,libname identifies which one. It is asymbol_ref rtx whichcontains the name of the function, as a string.libname is 0 whenan ordinary C function call is being processed. Thus, each time thismacro is called, eitherlibname orfntype is nonzero, butnever both of them at once.
LikeINIT_CUMULATIVE_ARGS but only used for outgoing libcalls,it gets aMODE argument instead offntype, that would beNULL.indirect would always be zero, too. If this macrois not defined,INIT_CUMULATIVE_ARGS (cum, NULL_RTX, libname,0) is used instead.
LikeINIT_CUMULATIVE_ARGS but overrides it for the purposes offinding the arguments for the function being compiled. If this macro isundefined,INIT_CUMULATIVE_ARGS is used instead.
The value passed forlibname is always 0, since library routineswith special calling conventions are never compiled with GCC. Theargumentlibname exists for symmetry withINIT_CUMULATIVE_ARGS.
voidTARGET_FUNCTION_ARG_ADVANCE(cumulative_args_tca, const function_arg_info&arg) ¶This hook updates the summarizer variable pointed to byca toadvance past argumentarg in the argument list. Once this is done,the variablecum is suitable for analyzing thefollowingargument withTARGET_FUNCTION_ARG, etc.
This hook need not do anything if the argument in question was passedon the stack. The compiler knows how to track the amount of stack spaceused for arguments without any special help.
HOST_WIDE_INTTARGET_FUNCTION_ARG_OFFSET(machine_modemode, const_treetype) ¶This hook returns the number of bytes to add to the offset of anargument of typetype and modemode when passed in memory.This is needed for the SPU, which passeschar andshortarguments in the preferred slot that is in the middle of the quad wordinstead of starting at the top. The default implementation returns 0.
pad_directionTARGET_FUNCTION_ARG_PADDING(machine_modemode, const_treetype) ¶This hook determines whether, and in which direction, to pad outan argument of modemode and typetype. It returnsPAD_UPWARD to insert padding above the argument,PAD_DOWNWARDto insert padding below the argument, orPAD_NONE to inhibit padding.
Theamount of padding is not controlled by this hook, but byTARGET_FUNCTION_ARG_ROUND_BOUNDARY. It is always just enoughto reach the next multiple of that boundary.
This hook has a default definition that is right for most systems.For little-endian machines, the default is to pad upward. Forbig-endian machines, the default is to pad downward for an argument ofconstant size shorter than anint, and upward otherwise.
If defined, a C expression which determines whether the defaultimplementation of va_arg will attempt to pad down before reading thenext argument, if that argument is smaller than its aligned space ascontrolled byPARM_BOUNDARY. If this macro is not defined, all sucharguments are padded down ifBYTES_BIG_ENDIAN is true.
Specify padding for the last element of a block move between registers andmemory.first is nonzero if this is the only element. Defining thismacro allows better control of register function parameters on big-endianmachines, without usingPARALLEL rtl. In particular,MUST_PASS_IN_STACK need not test padding and mode of types inregisters, as there is no longer a "wrong" part of a register; For example,a three byte aggregate may be passed in the high part of a register if sorequired.
unsigned intTARGET_FUNCTION_ARG_BOUNDARY(machine_modemode, const_treetype) ¶This hook returns the alignment boundary, in bits, of an argumentwith the specified mode and type. The default hook returnsPARM_BOUNDARY for all arguments.
unsigned intTARGET_FUNCTION_ARG_ROUND_BOUNDARY(machine_modemode, const_treetype) ¶Normally, the size of an argument is rounded up toPARM_BOUNDARY,which is the default value for this hook. You can define this hook toreturn a different value if an argument size must be rounded to a largervalue.
A C expression that is nonzero ifregno is the number of a hardregister in which function arguments are sometimes passed. This doesnot include implicit arguments such as the static chain andthe structure-value address. On many machines, no registers can beused for this purpose since all function arguments are pushed on thestack.
boolTARGET_SPLIT_COMPLEX_ARG(const_treetype) ¶This hook should return true if parameter of typetype are passedas two scalar parameters. By default, GCC will attempt to pack complexarguments into the target’s word size. Some ABIs require complex argumentsto be split and treated as their individual components. For example, onAIX64, complex floats should be passed in a pair of floating pointregisters, even though a complex float would fit in one 64-bit floatingpoint register.
The default value of this hook isNULL, which is treated as alwaysfalse.
treeTARGET_BUILD_BUILTIN_VA_LIST(void) ¶This hook returns a type node forva_list for the target.The default version of the hook returnsvoid*.
intTARGET_ENUM_VA_LIST_P(intidx, const char **pname, tree *ptree) ¶This target hook is used in functionc_common_nodes_and_builtinsto iterate through the target specific builtin types for va_list. Thevariableidx is used as iterator.pname has to be a pointerto aconst char * andptree a pointer to atree typedvariable.The argumentspname andptree are used to store the result ofthis macro and are set to the name of the va_list builtin type and itsinternal type.If the return value of this macro is zero, then there is no more element.Otherwise theIDX should be increased for the next call of thismacro to iterate through all types.
treeTARGET_FN_ABI_VA_LIST(treefndecl) ¶This hook returns the va_list type of the calling convention specified byfndecl.The default version of this hook returnsva_list_type_node.
treeTARGET_CANONICAL_VA_LIST_TYPE(treetype) ¶This hook returns the va_list type of the calling convention specified by thetype oftype. Iftype is not a valid va_list type, it returnsNULL_TREE.
treeTARGET_GIMPLIFY_VA_ARG_EXPR(treevalist, treetype, gimple_seq *pre_p, gimple_seq *post_p) ¶This hook performs target-specific gimplification ofVA_ARG_EXPR. The first two parameters correspond to thearguments tova_arg; the latter two are as ingimplify.cc:gimplify_expr.
boolTARGET_VALID_POINTER_MODE(scalar_int_modemode) ¶Define this to return nonzero if the port can handle pointerswith machine modemode. The default version of thishook returns true for bothptr_mode andPmode.
boolTARGET_REF_MAY_ALIAS_ERRNO(ao_ref *ref) ¶Define this to return nonzero if the memory referencerefmay alias with the system C library errno location. The defaultversion of this hook assumes the system C library errno locationis either a declaration of type int or accessed by dereferencinga pointer to int.
boolTARGET_MODE_CAN_TRANSFER_BITS(machine_modemode) ¶Define this to return false if the modemode cannot be usedfor memory copying ofGET_MODE_SIZE (mode) units. This might bebecause a register class allowed formode has registers that donot transparently transfer every bit pattern or because the load orstore patterns available formode have this issue.
The default is to assume modes with the same precision as size are fineto be used.
rtxTARGET_REDZONE_CLOBBER() ¶Define this to return some RTL for theredzoneasm clobberif target has a red zone and wants to support theredzone clobberor return NULL if the clobber should be ignored.
The default is to ignore theredzone clobber.
machine_modeTARGET_TRANSLATE_MODE_ATTRIBUTE(machine_modemode) ¶Define this hook if during mode attribute processing, the port shouldtranslate machine_modemode to another mode. For example, rs6000’sKFmode, when it is the same asTFmode.
The default version of the hook returns that mode that was passed in.
boolTARGET_SCALAR_MODE_SUPPORTED_P(scalar_modemode) ¶Define this to return nonzero if the port is prepared to handleinsns involving scalar modemode. For a scalar mode to beconsidered supported, all the basic arithmetic and comparisonsmust work.
The default version of this hook returns true for any moderequired to handle the basic C types (as defined by the port).Included here are the double-word arithmetic supported by thecode inoptabs.cc.
boolTARGET_VECTOR_MODE_SUPPORTED_P(machine_modemode) ¶Define this to return nonzero if the current target is prepared to handleinsns involving vector modemode. At the very least, itmust have move patterns for this mode.
boolTARGET_VECTOR_MODE_SUPPORTED_ANY_TARGET_P(machine_modemode) ¶Define this to return nonzero if the port is prepared to handleinsns involving vector modemode in any target configuration.Returningtrue means that the mode can be used as the ‘TYPE_MODE’for vector types.
The default version of this hook returns true. The final mode assigned to‘TYPE_MODE’ will also be checked againstTARGET_VECTOR_MODE_SUPPORTED_P to take target configuration intoaccount.
boolTARGET_COMPATIBLE_VECTOR_TYPES_P(const_treetype1, const_treetype2) ¶Return true if there is no target-specific reason for treatingvector typestype1 andtype2 as distinct types. The callerhas already checked for target-independent reasons, meaning that thetypes are known to have the same mode, to have the same number of elements,and to have what the caller considers to be compatible element types.
The main reason for defining this hook is to reject pairs of typesthat are handled differently by the target’s calling convention.For example, when a newN-bit vector architecture is addedto a target, the target may want to handle normalN-bitVECTOR_TYPE arguments and return values in the same way asbefore, to maintain backwards compatibility. However, it may alsoprovide new, architecture-specificVECTOR_TYPEs that are passedand returned in a more efficient way. It is then important to maintaina distinction between the “normal”VECTOR_TYPEs and the newarchitecture-specific ones.
The default implementation returns true, which is correct for most targets.
opt_machine_modeTARGET_ARRAY_MODE(machine_modemode, unsigned HOST_WIDE_INTnelems) ¶Return the mode that GCC should use for an array that hasnelems elements, with each element having modemode.Return no mode if the target has no special requirements. In thelatter case, GCC looks for an integer mode of the appropriate sizeif available and uses BLKmode otherwise. Usually the search for theinteger mode is limited toMAX_FIXED_MODE_SIZE, but theTARGET_ARRAY_MODE_SUPPORTED_P hook allows a larger mode to beused in specific cases.
The main use of this hook is to specify that an array of vectors shouldalso have a vector mode. The default implementation returns no mode.
boolTARGET_ARRAY_MODE_SUPPORTED_P(machine_modemode, unsigned HOST_WIDE_INTnelems) ¶Return true if GCC should try to use a scalar mode to store an arrayofnelems elements, given that each element has modemode.Returning true here overrides the usualMAX_FIXED_MODE limitand allows GCC to use any defined integer mode.
One use of this hook is to support vector load and store operationsthat operate on several homogeneous vectors. For example, ARM NEONhas operations like:
int8x8x3_t vld3_s8 (const int8_t *)
where the return type is defined as:
typedef struct int8x8x3_t{ int8x8_t val[3];} int8x8x3_t;If this hook allowsval to have a scalar mode, thenint8x8x3_t can have the same mode. GCC can then storeint8x8x3_ts in registers rather than forcing them onto the stack.
boolTARGET_LIBGCC_FLOATING_MODE_SUPPORTED_P(scalar_float_modemode) ¶Define this to return nonzero if libgcc provides support for the floating-point modemode, which is known to passTARGET_SCALAR_MODE_SUPPORTED_P. The default version of this hook returns true for all ofSFmode,DFmode,XFmode andTFmode, if such modes exist.
opt_scalar_float_modeTARGET_FLOATN_MODE(intn, boolextended) ¶Define this to return the machine mode to use for the type_Floatn, ifextended is false, or the type_Floatnx, ifextended is true. If such a type is notsupported, returnopt_scalar_float_mode (). The default version ofthis hook returnsSFmode for_Float32,DFmode for_Float64 and_Float32x andTFmode for_Float128, if those modes exist and satisfy the requirements for those types and passTARGET_SCALAR_MODE_SUPPORTED_P andTARGET_LIBGCC_FLOATING_MODE_SUPPORTED_P; for_Float64x, it returns the first ofXFmode andTFmode that exists and satisfies the same requirements; for other types, it returnsopt_scalar_float_mode (). The hook is only called for valuesofn andextended that are valid according toISO/IEC TS 18661-3:2015; that is,n is one of 32, 64, 128, or,ifextended is false, 16 or greater than 128 and a multiple of 32.
boolTARGET_FLOATN_BUILTIN_P(intfunc) ¶Define this to return true if the_Floatn and_Floatnx built-in functions should implicitly enable thebuilt-in function without the__builtin_ prefix in addition to thenormal built-in function with the__builtin_ prefix. The default isto only enable built-in functions without the__builtin_ prefix forthe GNU C langauge. In strict ANSI/ISO mode, the built-in function withoutthe__builtin_ prefix is not enabled. The argumentFUNC is theenum built_in_function id of the function to be enabled.
boolTARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P(machine_modemode) ¶Define this to return nonzero for machine modes for which the port hassmall register classes. If this target hook returns nonzero for a givenmode, the compiler will try to minimize the lifetime of registersinmode. The hook may be called withVOIDmode as argument.In this case, the hook is expected to return nonzero if it returns nonzerofor any mode.
On some machines, it is risky to let hard registers live across arbitraryinsns. Typically, these machines have instructions that require valuesto be in specific registers (like an accumulator), and reload will failif the required hard register is used for another purpose across such aninsn.
Passes before reload do not know which hard registers will be usedin an instruction, but the machine modes of the registers set or used inthe instruction are already known. And for some machines, registerclasses are small for, say, integer registers but not for floating pointregisters. For example, the AMD x86-64 architecture requires specificregisters for the legacy x86 integer instructions, but there are manySSE registers for floating point operations. On such targets, a goodstrategy may be to return nonzero from this hook forINTEGRAL_MODE_Pmachine modes but zero for the SSE register classes.
The default version of this hook returns false for any mode. It is alwayssafe to redefine this hook to return with a nonzero value. But if youunnecessarily define it, you will reduce the amount of optimizationsthat can be performed in some cases. If you do not define this hookto return a nonzero value when it is required, the compiler will run outof spill registers and print a fatal error message.
Next:How Scalar Function Values Are Returned, Previous:Passing Function Arguments on the Stack, Up:Stack Layout and Calling Conventions [Contents][Index]