PA-RISC Procedure Calling Conventions Reference Manual
> Chapter 3 Register Usage and Parameter Passing3.5 Parameter Passing and Function Results |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
3.5.1 Value ParametersValue parameters are mapped to a sequential list of argument words with successive parameters mapping to successive argument words, except 64-bit parameters, which must be aligned on 64-bit boundaries. Irregularly sized data items should be extended to 32 or 64 bits. (The practice that has been adopted is to right-justify the value itself, and then left-extend it.) Non-standard length parameters that are signed integers are sign-extended to the left to 32 or 64 bits. This convention does not specify how 1-31, 33-63-bit data items are passed by value (except single ASCII characters). Table 3-2 lists the sizes for recognized inter-language parameter data types. The form column indicates which of the forms (space ID), nonfloating-point, floating-point, or any) the data type is considered to be. 3.5.2 Inter-Language Parameter Data Types and SizesTable 3-4 Parameter Data Types and Sizes
3.5.3 Reference ParametersA short pointer to the referenced data item (using sr4 - sr7) is passed as a nonfloating-point 32-bit value parameter. The alignment requirements for the short pointer are the same as those mentioned for value parameters larger than 64 bits. Note that sr4 can only be used if the call is known to be local, because an external call will modify sr4. (See Chapter 5 for further details.) 3.5.4 Value-Result and Result ParametersIt is intended that language processors can use either the reference or value parameter mechanisms for value-result and result parameters. In particular, Ada uses the argument registers/parameters as output registers/parameters. 3.5.5 Routine ReferencesThis convention requires that routine references (i.e. procedure parameters, function pointers, external subroutines) be passed as 32-bit nonfloating-point values. It is expected that language processors that require a static link to be passed with a routine reference (i.e. Pascal passing level 2 procedures) will pass that static link as a separate 32-bit nonfloating-point value parameter. A language processor is free to maximize the efficiency of static scope linking within the requirements, without impacting other language processors. (Pascal passes routine references as either two separate 32-bit values or as one 64-bit value.) See Chapter 5 for further details on Routine References. 3.5.6 Argument Register Usage ConventionsParameters to routines are logically located in the argument list. When a call is made, the first four words of the argument list are passed in registers, depending on the usage and number of the argument. The first four words of the actual argument list on the stack are reserved as spill locations for the argument registers. These requirements imply that the minimum argument list size is 16 bytes; this space must be allocated in the frame for non-leaf procedures, but it may remain unused. The standard argument register use conventions are shown in Table 3-3. Table 3-5 Argument Register Use
3.5.7 Function Return ValuesFunction result values are placed in registers as described in Table 3-4. As with value parameters, irregularly sized function results should be extended to 32 or 64 bits. (The practice that has been adopted is to right-justify the value itself, and then left-extend it.) Non-standard length function results that are signed integers are sign-extended to the left to 32 or 64 bits. This convention does not specify how 1 - 31 or 33 - 63-bit data items are returned (except single ASCII characters). When calling functions that return results larger than 64 bits, the caller passes a short pointer (using sr5 - sr7) in gr28 (ret0) which describes the memory location for the function result. The address given should be the address for the high-order byte of the result. The function may assume that the result address will be aligned to the natural boundary for a data item of the result's type. It should be noted that some compilers support options which allow data structures to be aligned on non-natural boundaries. The instruction sequence used to store a function result should be consistent with the data alignment assumptions made by potential callers of that function. Table 3-6 Return Values * Although not common, it is possible to return floating-point values in general registers, as long as the argument relocation bits in the symbol record are set correctly. (Refer to Parameter Relocation for more details.) ** The caller may not assume that the result's address is still in gr28 on return from the function. 3.5.8 Parameter Type CheckingSome compilers may place argument descriptors in the object file which contain information about the type of each parameter passed and each formal argument expected. These descriptors are then checked by the linker for compatibility. If they do not match, a warning is generated. There is currently no mechanism available in the PA-RISC assembler to generate these argument descriptors.
|