OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [doc/] [supplements/] [i960/] [callconv.t] - Blame information for rev 1765

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.