📄 callconv.t
字号:
@c@c COPYRIGHT (c) 1988-2002.@c On-Line Applications Research Corporation (OAR).@c All rights reserved.@c@c $Id: callconv.t,v 1.7 2002/07/31 00:14:11 joel Exp $@c@chapter Calling Conventions@section IntroductionEach high-level language compiler generatessubroutine entry and exit code based upon a set of rules knownas the compiler's calling convention. These rules address thefollowing issues:@itemize @bullet@item register preservation and usage@item parameter passing@item call and return mechanism@end itemizeA compiler's calling convention is of importance wheninterfacing to subroutines written in another language eitherassembly or high-level. Even when the high-level language andtarget processor are the same, different compilers may usedifferent calling conventions. As a result, calling conventionsare both processor and compiler dependent.@section Processor BackgroundAll members of the i960 architecture family supporttwo methods for performing procedure calls: a RISC-stylebranch-and-link and an integrated call and return mechanism.On a branch-and-link, the processor branches to theinvoked procedure and saves the return address in a register,@code{G14}. Typically, the invoked procedure will not invoke anotherprocedure and is referred to as a leaf procedure. Manyhigh-level language compilers for the i960 family recognize leafprocedures and automatically optimize them to utilize thebranch-and-link mechanism. Branch-and-link procedures areinvoked using the @code{bal} and @code{balx} instructions and return controlvia the @code{bx} instruction. By convention, @code{G14} is zero when not ina leaf procedure. It is the responsibility of the leafprocedure to clear @code{G14} before returning.The integrated call and return mechanism alsobranches to the invoked procedure and saves the return addressas did the branch and link mechanism. However, the importantdifference is that the @code{call}, @code{callx}, and @code{calls} instructions savethe local register set (@code{R0} through @code{R15}) before transferringcontrol to the invoked procedure. The @code{ret} instructionautomatically restores the previous local register set. Thei960CA provides a register cache which can be configured toretain the last five to sixteen recent register caches. Whenthe register cache is full, the oldest cached register set iswritten to the stack.@section Calling MechanismAll RTEMS directives are invoked using either a @code{call}or @code{callx} instruction and return to the user via the @code{ret}instruction.@section Register UsageAs discussed above, the @code{call} and @code{callx} instructionsautomatically save the current contents of the local registerset (@code{R0} through @code{R15}). The contents of the local registers willbe restored as part of returning to the application. Thecontents of global registers @code{G0} through @code{G7} are not preserved byRTEMS directives.@section Parameter PassingRTEMS uses the standard i960 family C parameterpassing mechanism in which @code{G0} contains the first parameter, @code{G1}the second, and so on for the remaining parameters. No RTEMSdirective requires more than six parameters.@section User-Provided RoutinesAll user-provided routines invoked by RTEMS, such asuser extensions, device drivers, and MPCI routines, must alsoadhere to these calling conventions.@section Leaf ProceduresRTEMS utilizes leaf procedures internally to improveperformance. This improves execution speed as well as reducingstack usage and the number of register sets which must be cached.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -