source: rtems/doc/supplements/i960/callconv.texi @ ae68ff0

4.104.114.84.95
Last change on this file since ae68ff0 was ae68ff0, checked in by Joel Sherrill <joel.sherrill@…>, on 05/27/97 at 12:40:11

Initial revision

  • Property mode set to 100644
File size: 4.9 KB
Line 
1@c
2@c  COPYRIGHT (c) 1988-1997.
3@c  On-Line Applications Research Corporation (OAR).
4@c  All rights reserved.
5@c
6
7@ifinfo
8@node Calling Conventions, Calling Conventions Introduction, CPU Model Dependent Features Floating Point Unit, Top
9@end ifinfo
10@chapter Calling Conventions
11@ifinfo
12@menu
13* Calling Conventions Introduction::
14* Calling Conventions Processor Background::
15* Calling Conventions Calling Mechanism::
16* Calling Conventions Register Usage::
17* Calling Conventions Parameter Passing::
18* Calling Conventions User-Provided Routines::
19* Calling Conventions Leaf Procedures::
20@end menu
21@end ifinfo
22
23@ifinfo
24@node Calling Conventions Introduction, Calling Conventions Processor Background, Calling Conventions, Calling Conventions
25@end ifinfo
26@section Introduction
27
28Each high-level language compiler generates
29subroutine entry and exit code based upon a set of rules known
30as the compiler's calling convention.   These rules address the
31following issues:
32
33@itemize @bullet
34@item register preservation and usage
35
36@item parameter passing
37
38@item call and return mechanism
39@end itemize
40
41A compiler's calling convention is of importance when
42interfacing to subroutines written in another language either
43assembly or high-level.  Even when the high-level language and
44target processor are the same, different compilers may use
45different calling conventions.  As a result, calling conventions
46are both processor and compiler dependent.
47
48@ifinfo
49@node Calling Conventions Processor Background, Calling Conventions Calling Mechanism, Calling Conventions Introduction, Calling Conventions
50@end ifinfo
51@section Processor Background
52
53All members of the i960 architecture family support
54two methods for performing procedure calls: a RISC-style
55branch-and-link and an integrated call and return mechanism.
56
57On a branch-and-link, the processor branches to the
58invoked procedure and saves the return address in a register,
59G14.  Typically, the invoked procedure will not invoke another
60procedure and is referred to as a leaf procedure.  Many
61high-level language compilers for the i960 family recognize leaf
62procedures and automatically optimize them to utilize the
63branch-and-link mechanism.  Branch-and-link procedures are
64invoked using the bal and balx instructions and return control
65via the bx instruction.  By convention, G14 is zero when not in
66a leaf procedure.  It is the responsibility of the leaf
67procedure to clear G14 before returning.
68
69The integrated call and return mechanism also
70branches to the invoked procedure and saves the return address
71as did the branch and link mechanism. However, the important
72difference is that the call, callx, and calls instructions save
73the local register set (R0 through R15) before transferring
74control to the invoked procedure.  The ret instruction
75automatically restores the previous local register set.  The
76i960CA provides a register cache which can be configured to
77retain the last five to sixteen recent register caches.  When
78the register cache is full, the oldest cached register set is
79written to the stack.
80
81@ifinfo
82@node Calling Conventions Calling Mechanism, Calling Conventions Register Usage, Calling Conventions Processor Background, Calling Conventions
83@end ifinfo
84@section Calling Mechanism
85
86All RTEMS directives are invoked using either a call
87or callx instruction and return to the user via the ret
88instruction.
89
90@ifinfo
91@node Calling Conventions Register Usage, Calling Conventions Parameter Passing, Calling Conventions Calling Mechanism, Calling Conventions
92@end ifinfo
93@section Register Usage
94
95As discussed above, the call and callx instructions
96automatically save the current contents of the local register
97set (R0 through R15).  The contents of the local registers will
98be restored as part of returning to the application.  The
99contents of global registers G0 through G7 are not preserved by
100RTEMS directives.
101
102@ifinfo
103@node Calling Conventions Parameter Passing, Calling Conventions User-Provided Routines, Calling Conventions Register Usage, Calling Conventions
104@end ifinfo
105@section Parameter Passing
106
107RTEMS uses the standard i960 family C parameter
108passing mechanism in which G0 contains the first parameter, G1
109the second,  and so on  for the remaining parameters.  No RTEMS
110directive requires more than six parameters.
111
112@ifinfo
113@node Calling Conventions User-Provided Routines, Calling Conventions Leaf Procedures, Calling Conventions Parameter Passing, Calling Conventions
114@end ifinfo
115@section User-Provided Routines
116
117All user-provided routines invoked by RTEMS, such as
118user extensions, device drivers, and MPCI routines, must also
119adhere to these calling conventions.
120
121@ifinfo
122@node Calling Conventions Leaf Procedures, Memory Model, Calling Conventions User-Provided Routines, Calling Conventions
123@end ifinfo
124@section Leaf Procedures
125
126RTEMS utilizes leaf procedures internally to improve
127performance.  This improves execution speed as well as reducing
128stack usage and the number of register sets which must be cached.
129
130
Note: See TracBrowser for help on using the repository browser.