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