Movatterモバイル変換
[0]ホーム
This is the mail archive of thebinutils@sources.redhat.commailing list for thebinutils project.
mips eabi documentation...
- From: Eric Christopher <echristo at redhat dot com>
- To: binutils at sources dot redhat dot com
- Date: 11 Jun 2003 13:40:52 -0700
- Subject: mips eabi documentation...
- Organization:
This is it unfortunately... :)MIPS EABI=========Sizes and alignments--------------------TypeSize (bytes)Alignment (bytes)char11short22int44unsigned44long44 (32-bit mode)88 (64-bit mode)long long88float44double88pointers44 (32-bit mode)88 (64-bit mode)* alignment within aggregates (structs and unions) is as above, with padding added if needed* aggregates have alignment equal to that of their most aligned member* aggregates have sizes which are a multiple of their alignmentSubroutine calls----------------Parameter registers: general-purposer4-r11 floating pointf12-f19Register usage: fixed 0 valuer0 volatiler1-r15, r24, r25 non-volatiler16-r23, r30 kernel reservedr26, r27 gp (SDA base)r28 stack pointerr29 frame pointerr30 (if needed) return addressr31Stack alignment8 bytesParameter register allocation integer/floating independently (see below)Structures passed<= 32 bits as values, else as pointersHoming areanoneStack Frame-----------+-----------------------+| Saved Registers|+-----------------------+| ...|+-----------------------+| Local Variables|+-----------------------+| ...|+-----------------------+| Parameter Word 2|+-----------------------+SP -->| Parameter Word 1|+-----------------------+Parameter Assignment to Registers---------------------------------Consider the parameters in a function call as ordered from left (firstparameter) to right. In this algorithm, FR contains the number of thenext available floating-point register (or register pair for modes inwhich floating-point registers hold only 32 bits). GR contains thenumber of the next available general-purpose register. STARG is theaddress of the next available stack parameter word.INITIALIZE:Set GR=r4, FR=f12, 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: DOUBLE OR FLOAT:If FR > f19, go to STACK. Otherwise, load the parameter valueinto floating-point register FR and advance FR to the nextfloating-point register (or register pair in 32-bit mode).Then go to SCAN. SIMPLE ARG:A SIMPLE ARG is one of the following:* One of the simple integer types which will fit into a general-purpose register,* A pointer to an object of any type,* A struct or union small enough to fit in a register (<= 32 bits in 32-bit mode, <= 64 bits in 64-bit mode)* A larger struct or union, which shall be treated as a pointer 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 parametervalue into general-purpose register GR and advance GRto the next general-purpose register. Values shorter thanthe register size are sign-extended or zero-extended dependingon whether they are signed or unsigned. Then go to SCAN. LONG LONG in 32-bit mode:If GR > r10, go to STACK. Otherwise, if GR is odd, advanceGR to the next register. Load the 64-bit long long value intoregister pair GR and GR+1. Advance GR to GR+2 and go to SCAN. STACK:Parameters not otherwise handled above are passed in theparameter words of the caller's stack frame. SIMPLE ARGs,as defined above, are considered to have size and alignmentequal to the size of a general-purpose register, withsimple argument types shorter than this sign- or zero-extendedto this width. float arguments are considered to have sizeand alignment equal to the size of a floating-point register.In 64-bit mode, floats are stored in the low-order 32 bitsof the 64-bit space allocated to them. double and long longare considered to have 64-bit size and alignment. RoundSTARG up to a multiple of the alignment requirement ofthe parameter and copy the argument byte-for-byte intoSTARG, STARG+1, ... STARG+size-1. Set STARG to STARG+sizeand go to SCAN.Structure passing-----------------As noted above, code which passes structures and unions by value isimplemented specially. (In this section, "struct" will refer tostructs and unions inclusively.) Structs small enough to fit in aregister are passed by value in a single register or in a stack frameslot the size of a register. Larger structs are handled by passingthe address of the structure. In this case, a copy of the structurewill be made if necessary in order to preserve the pass-by-valuesemantics.Copies of large structs are made under the following rules:ANSI modeK&R Mode-----------------Normal param Callee copies if neededCaller copiesVarargs (...) paramCaller copiesCaller copiesIn the case of normal (non-varargs) large-struct parameters in ANSImode, the callee is responsible for producing the same effect as if acopy of the structure were passed, preserving the pass-by-valuesemantics. This may be accomplished by having the callee make a copy,but in some cases the callee may be able to determine that a copy isnot necessary in order to produce the same results. In such cases,the callee may choose to avoid making a copy of the parameter.Varargs handling----------------No special changes are needed for handling varargs parameters otherthan the caller knowing that a copy is needed on struct parameterslarger than a register (see above).The varargs macros set up a two-part register save area, one part forthe general-purpose registers and one part for floating-pointregisters, and maintain separate pointers for these two areas and forthe stack parameter area. The register save area lies between thecaller and callee stack frame areas.In the case of software floating-point only the general-purposeregisters need to be saved. Because the save area lies between thetwo stack frames, the saved register parameters are contiguous withparameters passed on the stack. This allows the varargs macros to bemuch simpler. Only one pointer is needed, which advances from theregister save area into the caller's stack frame.Function return values----------------------TypeRegister------------intr2shortr2longr2long longr2-r3 (32-bit mode)r2 (64-bit mode)floatf0doublef0-f1 (32-bit mode)f0 (64-bit mode)struct/unionsee belowStructs/unions which will fit into two general-purpose registers arereturned in r2, or in r2-r3 if necessary. They are aligned within theregister according to the endianness of the processor; e.g. on abig-endian processor the first byte of the struct is returned in themost significant byte of r2, while on a little-endian processor thefirst byte is returned in the least significant byte of r2. Largerstructs/unions are handled by the caller passing as a "hidden" firstargument a pointer to space allocated to receive the return value.Software floating-point-----------------------For software floating-point implementations, floats shall be passedand returned like ints, and doubles shall be passed and returned likelong longs.This implies that, in 32-bit mode, floats will be passed in a singleinteger register and doubles will be passed in an even/odd registerpair. Similarly, floats will be returned in a single register, r2,and doubles will be returned in register pair r2-r3. -- Eric Christopher <echristo@redhat.com>
[8]ページ先頭