Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/trunk/src/MLRISC/c-calls/c-calls.sig
ViewVC logotype

Annotation of /sml/trunk/src/MLRISC/c-calls/c-calls.sig

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1530 - (view) (download) (as text)

1 : george 608 (* c-calls.sig
2 :     *
3 : jhr 1043 * COPYRIGHT (c) 2002 Bell Labs, Lucent Technologies
4 : george 608 *)
5 : george 556
6 : george 608 signature C_CALLS =
7 :     sig
8 : george 556
9 : george 608 structure T : MLTREE
10 : george 556
11 : george 608 datatype c_arg
12 :     = ARG of T.rexp
13 :     (* rexp specifies integer or pointer; if the
14 :     * corresponding parameter is a C struct, then
15 :     * this argument is the address of the struct.
16 :     *)
17 :     | FARG of T.fexp
18 :     (* fexp specifies floating-point argument *)
19 :     | ARGS of c_arg list
20 :     (* list of arguments corresponding to the contents of a C struct *)
21 : george 556
22 : jhr 1523 (* this constant is the offset from the caller's SP to the low-address of the
23 : jhr 1043 * parameter area (see the paramAlloc callback below).
24 :     *)
25 :     val paramAreaOffset : int
26 :    
27 : george 556 (* translate a C function call with the given argument list into
28 : jhr 1043 * a MLRISC statement list. The arguments are as follows:
29 : blume 838 *
30 : jhr 1043 * name -- an expression that speficies the function.
31 :     * proto -- the function's prototype
32 :     * paramAlloc -- this callback takes the size and alignment
33 :     * constraints on the parameter-passing area
34 : blume 1045 * in the stack. If it returns true, then the
35 : jhr 1043 * space for the parameters is allocated by
36 :     * client; otherwise genCall allocates the space.
37 : jhr 1444 * structRet -- this callback takes the size and alignment
38 : jhr 1043 * of space required for returning a struct
39 :     * value. It returns the address of the
40 :     * reserved space.
41 :     * saveRestoreDedicated -- this callback takes a list of registers
42 :     * that the call kills and should return an
43 :     * instruction sequence to save/restore any
44 :     * registers that the client run-time model
45 :     * expects to be preserved (e.g., allocation
46 :     * pointers).
47 :     * callComment -- if present, the comment string is attached
48 : jhr 1444 * the CALL instruction as a COMMENT annotation.
49 : jhr 1043 * args -- the arguments to the call.
50 :     *
51 :     * The result of genCall is a mlrisc list specifying where the result
52 :     * is and the MLRisc statements that implement the calling sequence.
53 :     * Functions with void return type have no result, most others have
54 :     * one result, but some conventions may flatten larger arguments into
55 :     * multiple registers (e.g., a register pair for long long results).
56 :     *
57 :     * WARNING: if the client's implementation of structRet uses the stack
58 :     * pointer to address the struct-return area, then paramAlloc should always
59 : jhr 1523 * handle allocating space for the parameter area (i.e., return true).
60 : george 556 *)
61 : george 608 val genCall : {
62 :     name : T.rexp,
63 :     proto : CTypes.c_proto,
64 : jhr 1043 paramAlloc : {szb : int, align : int} -> bool,
65 : george 608 structRet : {szb : int, align : int} -> T.rexp,
66 : blume 838 saveRestoreDedicated :
67 : jhr 1043 T.mlrisc list -> {save: T.stm list, restore: T.stm list},
68 : blume 838 callComment : string option,
69 : george 608 args : c_arg list
70 :     } -> {
71 :     callseq : T.stm list,
72 :     result: T.mlrisc list
73 :     }
74 :    
75 : jhr 1521 (* the location of arguments/parameters; offsets are given with respect to the
76 :     * low end of the parameter area (see paramAreaOffset above).
77 :     *)
78 :     datatype arg_location
79 : jhr 1523 = Reg of T.ty * T.reg * T.I.machine_int option
80 :     (* integer/pointer argument in register *)
81 :     | FReg of T.fty * T.reg * T.I.machine_int option
82 :     (* floating-point argument in register *)
83 : jhr 1521 | Stk of T.ty * T.I.machine_int (* integer/pointer argument in parameter area *)
84 :     | FStk of T.fty * T.I.machine_int (* floating-point argument in parameter area *)
85 :     | Args of arg_location list
86 :    
87 :     val layout : CTypes.c_proto -> {
88 : jhr 1523 argLocs : arg_location list, (* argument/parameter assignment *)
89 :     resLoc : arg_location option, (* result location; NONE for void functions *)
90 : jhr 1530 structRetLoc : {szb : int, align : int} option
91 : jhr 1521 }
92 :    
93 :     (* Callee-save registers as defined in the C calling convention. Note that
94 :     * these do not include special registers (e.g., stack and frame-pointers)
95 :     * that are preserved across calls.
96 :     *)
97 :     val calleeSaveRegs : T.reg list (* C callee-save registers *)
98 :     val calleeSaveFRegs : T.reg list (* C callee-save floating-point registers *)
99 :    
100 : george 608 end

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0