Debian Codegraph @

lib/mlrisc-lib/MLRISC/c-call/varargs/call/vararg-constants.sml

raw
1 (* vararg-constants.sml
2 *
3 * Constants shared between calling coded and the interpreter generator.
4 *)
5
6 structure VarargConstants =
7 struct
8
9 structure W = Word32
10
11 (* encodings for the kinds of argument locations *)
12 local
13 val [ GPR, FPR, STK, FSTK ] = List.tabulate(4, W.fromInt)
14 in
15 fun kind CLocKind.GPR = GPR
16 | kind CLocKind.FPR = FPR
17 | kind CLocKind.STK = STK
18 | kind CLocKind.FSTK = FSTK
19 end
20
21 (*
22 * the located argument structure:
23
24 typedef void* Word_t;
25 enum loc_kind {GPR=0, FPR, STK, FSTK};
26 struct located_arg_s {
27 loc_kind k;
28 int width;
29 int narrowing;
30 int loc;
31 int offset;
32 union {
33 Word_t* p; long l; int i; char* s; double d;
34 } arg;
35 };
36
37 * The following offsets should mimic the way that C lays out the struct.
38 *)
39 val [ kindOffB, widthOffB, narrowingOffB, locOffB, offsetOffB, argOffB ] =
40 List.tabulate(6, fn i => W.fromInt i * 0w4)
41
42 (* max byte width of arguments *)
43 val maxArgSzB = 8
44
45 val argSzB : W.word = 0w8
46
47 (* number of bytes for a located argument *)
48 val locdArgSzB = argOffB + argSzB
49
50 val varargInterpreter = "VarargInterp"
51
52 val header = String.concatWith "\n" [
53 "/* ",
54 " * ",
55 " * This file is GENERATED by the varargs library. Modify the",
56 " * code at your peril :).",
57 " * ",
58 " * This interpreter parses the arguments for a vararg C function,",
59 " * putting them in the correct locations, and then calls the function.",
60 " * ",
61 " * Mike Rainey ([email protected])",
62 " */"
63 ]
64
65 end