URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [config/] [iq2000/] [abi] - Rev 750
Go to most recent revision | Compare with Previous | Blame | View Log
IQ2000 ABI=========Sizes and alignments--------------------Type Size (bytes) Alignment (bytes)char 1 1short 2 2int 4 4unsigned 4 4long 4 4long long 8 8float 4 4double 8 8pointers 4 4* alignment within aggregates (structs and unions) is as above, withpadding added if needed* aggregates have alignment equal to that of their most alignedmember* aggregates have sizes which are a multiple of their alignmentFloating point--------------All emulated using IEEE floating point conventions.Registers----------------%0 always zero%1 call clobbered%2 return value%3 return value%4 argument register 1%5 argument register 2%6 argument register 3%7 argument register 4%8 argument register 5%9 argument register 6%10 argument register 7%11 argument register 8%12 call clobbered%13 call clobbered%14 call clobbered%15 call clobbered%16 call saved%17 call saved%18 call saved%19 call saved%20 call saved%21 call saved%22 call saved%23 call saved%24 call clobbered%25 call clobbered%26 reserved%27 frame ptr%28 global ptr%29 stack ptr%30 reserved%31 return addressStack alignment 8 bytesStructures passed <= 32 bits as values, else as pointersThe IQ2000 Stack---------------Space is allocated as needed in the stack frame for the following at compiletime:* Outgoing parameters beyond the eighth* All automatic arrays, automatic data aggregates, automaticscalars which must be addressable, and automatic scalars forwhich there is no room in registers* Compiler-generated temporary values (typically when there aretoo many for the compiler to keep them all in registers)Space can be allocated dynamically (at runtime) in the stack frame for thefollowing:* Memory allocated using the alloca() function of the C libraryAddressable automatic variables on the stack are addressed with positiveoffsets relative to %27; dynamically allocated space is addressed with positiveoffsets from the pointer returned by alloca().Stack Frame-----------+-----------------------+| Caller memory args |+-----------------------+ <-sp| Return address |+-----------------------+| Previous FP |+-----------------------+| Saved Registers |+-----------------------+| ... |+-----------------------+| Local Variables |+-----------------------+ <-fp| Alloca |+-----------------------+| ... |+-----------------------+| Parameter Word 2 |+-----------------------+| Parameter Word 1 |+-----------------------+ <-spParameter Assignment to Registers---------------------------------Consider the parameters in a function call as ordered from left (firstparameter) to right. GR contains the number of the next availablegeneral-purpose register. STARG is the address of the next available stackparameter word.INITIALIZE:Set GR=r4 and STARG to point to parameter word 1.SCAN:If there are no more parameters, terminate.Otherwise, select one of the following depending on the typeof the next parameter:SIMPLE ARG:A SIMPLE ARG is one of the following:* One of the simple integer types which will fit into ageneral-purpose register,* A pointer to an object of any type,* A struct or union small enough to fit in a register (<= 32 bits)* A larger struct or union, which shall be treated as apointer to the object or to a copy of the object.(See below for when copies are made.)If GR > r11, go to STACK. Otherwise, load the parameter value intogeneral-purpose register GR and advance GR to the next general-purposeregister. Values shorter than the register size are sign-extended orzero-extended depending on whether they are signed or unsigned. Thengo to SCAN.DOUBLE or LONG LONGIf GR > r10, go to STACK. Otherwise, if GR is odd, advance GR to thenext register. Load the 64-bit long long or double value into registerpair GR and GR+1. Advance GR to GR+2 and go to SCAN.STACK:Parameters not otherwise handled above are passed in the parameterwords of the caller's stack frame. SIMPLE ARGs, as defined above, areconsidered to have size and alignment equal to the size of ageneral-purpose register, with simple argument types shorter than thissign- or zero-extended to this width. Round STARG up to a multiple ofthe alignment requirement of the parameter and copy the argumentbyte-for-byte into STARG, STARG+1, ... STARG+size-1. Set STARG toSTARG+size and go to SCAN.Structure passing-----------------As noted above, code which passes structures and unions by value is implementedspecially. (In this section, "struct" will refer to structs and unionsinclusively.) Structs small enough to fit in a register are passed by value ina single register or in a stack frame slot the size of a register. Structscontaining a single double or long long component are passed by value in tworegisters or in a stack frame slot the size of two registers. Other structsare handled by passing the address of the structure. In this case, a copy ofthe structure will be made if necessary in order to preserve the pass-by-valuesemantics.Copies of large structs are made under the following rules:ANSI mode K&R Mode--------- --------Normal param Callee copies if needed Caller copiesVarargs (...) param Caller copies Caller copiesIn the case of normal (non-varargs) large-struct parameters in ANSI mode, thecallee is responsible for producing the same effect as if a copy of thestructure were passed, preserving the pass-by-value semantics. This may beaccomplished by having the callee make a copy, but in some cases the callee maybe able to determine that a copy is not necessary in order to produce the sameresults. In such cases, the callee may choose to avoid making a copy of theparameter.Varargs handling----------------No special changes are needed for handling varargs parameters other than thecaller knowing that a copy is needed on struct parameters larger than aregister (see above).The varargs macros set up a register save area for the general-purposeregisters to be saved. Because the save area lies between the caller andcallee stack frames, the saved register parameters are contiguous withparameters passed on the stack. A pointer advances from the register save areainto the caller's stack frame.Function return values----------------------Type Register---- --------int r2short r2long r2long long r2-r3float r2double r2-r3struct/union see belowStructs/unions which will fit into two general-purpose registers are returnedin r2, or in r2-r3 if necessary. Larger structs/unions are handled by thecaller passing as a "hidden" first argument a pointer to space allocated toreceive the return value.Copyright (C) 2003 Free Software Foundation, Inc.Copying and distribution of this file, with or without modification,are permitted in any medium without royalty provided the copyrightnotice and this notice are preserved.
Go to most recent revision | Compare with Previous | Blame | View Log
