File: mdl-rtl-comp.sig

package info (click to toggle)
mlton 20210117%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 58,464 kB
  • sloc: ansic: 27,682; sh: 4,455; asm: 3,569; lisp: 2,879; makefile: 2,347; perl: 1,169; python: 191; pascal: 68; javascript: 7
file content (99 lines) | stat: -rw-r--r-- 3,653 bytes parent folder | download | duplicates (6)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
(*
 * Process rtl descriptions
 *)
signature MDL_RTL_COMP =
sig
   structure Ast  : MDL_AST
   structure Comp : MDL_COMPILE
   structure RTL  : MLTREE_RTL
   structure MLRiscTypes : MLRISC_TYPES
     sharing Comp.Ast = MLRiscTypes.Ast = Ast
     sharing MLRiscTypes.RTL = RTL

   type compiled_rtls (* rtl in digested form *)

   datatype rtl_def = RTLDEF of {id:Ast.id,args:Ast.id list,rtl:RTL.rtl}

   (* current set of rtls *)
   val current_rtls : rtl_def list ref

   (* process the rtl *)
   val compile : Comp.md -> compiled_rtls

   (* extract the md component *)
   val md      : compiled_rtls -> Comp.md

   (* extract the rtls *)
   val rtls    : compiled_rtls -> rtl_def list

   (* emit and execute code for building the rtls *)
   val gen     : compiled_rtls -> unit 

   (* dump out all the rtl definitions *)
   val dumpLog : compiled_rtls -> unit 

   (* A generic combinator for generate query functions.
    * Use this method if you want to create new query routines.
    *)
   val mkQuery : compiled_rtls ->
       { name     : Ast.id,           (* name of function *)
         namedArguments : bool,       (* use record arguments? *)
         args     : Ast.id list list, (* labeled arguments, may be curried *)
         decls    : Ast.decl list,    (* local definitions *)
         caseArgs : Ast.id list,      (* extra arguments to the case exp *)
                 (* Callback to generate the actual code. 
                  * An instruction constructor may represent a set of
                  * different instructions with different rtl templates.
                  * We enumerate all of them and let you decide 
                  * how to generate the code.
                  *)
         body  : {instr : Ast.consbind,      (* current instruction *)
                  rtl   : rtl_def,           (* rtl for this instruction *)
                  const : Ast.exp -> Ast.exp (* callback for making constants*)
                 } ->
                 { casePats : Ast.pat list, (* extra patterns *) 
                   exp      : Ast.exp       (* and clause *)
                 }
       } -> Ast.decl

  (*
   * A generic routine for generating def/use like queries
   *)
  val mkDefUseQuery : compiled_rtls ->
       { name  : Ast.id,           (* name of function *)
         args  : Ast.id list list,
         namedArguments : bool,
         decls : Ast.decl list,    (* local definitions *)
         def   : Ast.exp * RTL.exp * Ast.exp -> Ast.exp option,
         use   : Ast.exp * RTL.exp * Ast.exp -> Ast.exp option
       } -> Ast.decl



  (*
   * Analyze all the arguments in an expression according to its 
   * rtl definition.
   *)
  val forallArgs : {instr     : Ast.consbind, (* current instruction *)
                    rtl       : rtl_def,      (* current rtl *)
                    rtlArg    : Ast.id * Ast.ty * RTL.exp * RTL.pos * 'a -> 'a,
                    nonRtlArg : Ast.id * Ast.ty * 'a -> 'a
                   } -> 'a -> 'a
  (*
   * Analyze all the arguments in an expression according to its 
   * rtl definition, create an expression that recreate that instruction.
   *)
  val mapInstr : {instr     : Ast.consbind, (* current instruction *)
                  rtl       : rtl_def,      (* current rtl *)
                  rtlArg    : Ast.id * Ast.ty * RTL.exp * RTL.pos -> 
                                 Ast.exp option,
                  nonRtlArg : Ast.id * Ast.ty -> Ast.exp option
                 } -> Ast.exp
  (*
   * Make an error handler 
   *)
  val simpleErrorHandler : string -> Ast.decl
  val complexErrorHandler : string -> Ast.decl
  val complexErrorHandlerDef : unit -> Ast.decl

end