source: driver/backendPrinter.ml @ 2856

Last change on this file since 2856 was 2856, checked in by sacerdot, 7 years ago

Pretty printing of LTL almost finished.

File size: 5.4 KB
Line 
1let print_keyword =
2 function
3  | Extracted.Joint_printer.KwCOMMENT      -> "COMMENT"
4  | Extracted.Joint_printer.KwMOVE         -> "MOVE"
5  | Extracted.Joint_printer.KwPOP          -> "POP"
6  | Extracted.Joint_printer.KwPUSH         -> "PUSH"
7  | Extracted.Joint_printer.KwADDRESS      -> "ADDRESS"
8  | Extracted.Joint_printer.KwOPACCS       -> "OPACCS"
9  | Extracted.Joint_printer.KwOP1          -> "OP1"
10  | Extracted.Joint_printer.KwOP2          -> "OP2"
11  | Extracted.Joint_printer.KwCLEAR_CARRY  -> "CLEAR_CARRY"
12  | Extracted.Joint_printer.KwSET_CARRY    -> "SET_CARRY"
13  | Extracted.Joint_printer.KwLOAD         -> "LOAD"
14  | Extracted.Joint_printer.KwSTORE        -> "STORE"
15  | Extracted.Joint_printer.KwCOST_LABEL   -> "COST_LABEL"
16  | Extracted.Joint_printer.KwCOND         -> "COND"
17  | Extracted.Joint_printer.KwCALL         -> "CALL"
18  | Extracted.Joint_printer.KwGOTO         -> "GOTO"
19  | Extracted.Joint_printer.KwRETURN       -> "RETURN"
20  | Extracted.Joint_printer.KwTAILCALL     -> "TAILCALL"
21  | Extracted.Joint_printer.KwFCOND        -> "FCOND"
22
23let print_opAccs =
24 function
25  | Extracted.BackEndOps.Mul -> "Mul"
26  | Extracted.BackEndOps.DivuModu -> "DivModu"
27
28let print_op1 =
29 function
30  | Extracted.BackEndOps.Cmpl -> "Cmpl"
31  | Extracted.BackEndOps.Inc -> "Inc"
32  | Extracted.BackEndOps.Rl -> "Rl"
33
34let print_op2 =
35 function
36  | Extracted.BackEndOps.Add -> "Add"
37  | Extracted.BackEndOps.Addc -> "Addc"
38  | Extracted.BackEndOps.Sub -> "Sub"
39  | Extracted.BackEndOps.And -> "And"
40  | Extracted.BackEndOps.Or -> "Or"
41  | Extracted.BackEndOps.Xor -> "Xor"
42
43(* Duplicated, also in cerco.ml! *)
44let string_of_pos n = string_of_int (Extracted.Glue.int_of_matitapos n)
45
46let printing_pass_independent_params =
47 { Extracted.Joint_printer.print_String =
48    (fun Extracted.String.EmptyString -> "EmptyString")
49 ; print_keyword = print_keyword
50 ; print_concat = (fun s1 s2 -> s1 ^ " " ^ s2)
51 ; print_empty = ""
52 ; print_newline = "\n"
53 ; print_ident = (fun n -> "fun_" ^ string_of_pos n)
54 ; print_costlabel = (fun n -> "k_" ^ string_of_pos n)
55 ; print_label = (fun n -> "l_" ^ string_of_pos n)
56 ; print_OpAccs = print_opAccs
57 ; print_Op1 = print_op1
58 ; print_Op2 = print_op2
59 }
60
61let print_byte b = string_of_int (IntelHex.int_of_vect b)
62
63let print_argument print_arg =
64 function
65    Extracted.Joint.Imm b -> print_byte b
66  | Extracted.Joint.Reg x -> print_arg x
67
68let print_Register =
69 function
70  | Extracted.I8051.Register00     -> "Register00"
71  | Extracted.I8051.Register01     -> "Register01"
72  | Extracted.I8051.Register02     -> "Register02"
73  | Extracted.I8051.Register03     -> "Register03"
74  | Extracted.I8051.Register04     -> "Register04"
75  | Extracted.I8051.Register05     -> "Register05"
76  | Extracted.I8051.Register06     -> "Register06"
77  | Extracted.I8051.Register07     -> "Register07"
78  | Extracted.I8051.Register10     -> "Register10"
79  | Extracted.I8051.Register11     -> "Register11"
80  | Extracted.I8051.Register12     -> "Register12"
81  | Extracted.I8051.Register13     -> "Register13"
82  | Extracted.I8051.Register14     -> "Register14"
83  | Extracted.I8051.Register15     -> "Register15"
84  | Extracted.I8051.Register16     -> "Register16"
85  | Extracted.I8051.Register17     -> "Register17"
86  | Extracted.I8051.Register20     -> "Register20"
87  | Extracted.I8051.Register21     -> "Register21"
88  | Extracted.I8051.Register22     -> "Register22"
89  | Extracted.I8051.Register23     -> "Register23"
90  | Extracted.I8051.Register24     -> "Register24"
91  | Extracted.I8051.Register25     -> "Register25"
92  | Extracted.I8051.Register26     -> "Register26"
93  | Extracted.I8051.Register27     -> "Register27"
94  | Extracted.I8051.Register30     -> "Register30"
95  | Extracted.I8051.Register31     -> "Register31"
96  | Extracted.I8051.Register32     -> "Register32"
97  | Extracted.I8051.Register33     -> "Register33"
98  | Extracted.I8051.Register34     -> "Register34"
99  | Extracted.I8051.Register35     -> "Register35"
100  | Extracted.I8051.Register36     -> "Register36"
101  | Extracted.I8051.Register37     -> "Register37"
102  | Extracted.I8051.RegisterA      -> "RegisterA"
103  | Extracted.I8051.RegisterB      -> "RegisterB"
104  | Extracted.I8051.RegisterDPL    -> "RegisterDPL"
105  | Extracted.I8051.RegisterDPH    -> "RegisterDPH"
106  | Extracted.I8051.RegisterCarry  -> "RegisterCarry"
107
108let print_registers_move =
109 function
110  | Extracted.Joint_LTL_LIN.From_acc (reg,_unit) ->
111     print_Register reg ^ " " ^ "ACC_A"
112  | Extracted.Joint_LTL_LIN.To_acc (_unit,reg) ->
113     "ACC_A " ^ print_Register reg
114  | Extracted.Joint_LTL_LIN.Int_to_reg (reg,byte) ->
115     print_Register reg ^ " " ^ print_byte byte
116  | Extracted.Joint_LTL_LIN.Int_to_acc (_unit,byte) ->
117     "ACC_A " ^ print_byte byte
118
119let joint_LTL_LIN_printing_params =
120 { Extracted.Joint_printer.print_pass_ind = printing_pass_independent_params
121 ; print_acc_a_reg = (fun _ -> "ACC_A")
122 ; print_acc_b_reg = (fun _ -> "ACC_B")
123 ; print_acc_a_arg = (fun _ -> "ACC_A")
124 ; print_acc_b_arg = (fun _ -> "ACC_B")
125 ; print_dpl_reg = (fun _ -> "DPL")
126 ; print_dph_reg = (fun _ -> "DPH")
127 ; print_dpl_arg = (fun _ -> "DPL")
128 ; print_dph_arg = (fun _ -> "DPH")
129 ; print_snd_arg = (fun hdw_arg -> print_argument print_Register (Obj.magic hdw_arg))
130 ; print_pair_move = Obj.magic print_registers_move
131 ; print_call_args =
132    (fun n ->string_of_int (Extracted.Glue.int_of_matitanat (Obj.magic n)))
133 ; print_call_dest = (fun _ -> "")
134 ; print_ext_seq = (fun ltl_lin_seq -> assert false )
135 }
136
137let print_LTL_program =
138 Extracted.LTL_printer.print_LTL_program joint_LTL_LIN_printing_params
Note: See TracBrowser for help on using the repository browser.