1 (***********************************************************************)
5 (* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
7 (* Copyright 1996 Institut National de Recherche en Informatique et *)
8 (* en Automatique. All rights reserved. This file is distributed *)
9 (* under the terms of the Q Public License version 1.0. *)
11 (***********************************************************************)
15 (* Representation of machine code by sequences of pseudoinstructions *)
17 type integer_comparison
=
18 Isigned
of Cmm.comparison
19 | Iunsigned
of Cmm.comparison
21 type integer_operation
=
22 Iadd
| Isub
| Imul
| Idiv
| Imod
23 | Iand
| Ior
| Ixor
| Ilsl
| Ilsr
| Iasr
24 | Icomp
of integer_comparison
30 | Iinttest
of integer_comparison
31 | Iinttest_imm
of integer_comparison
* int
32 | Ifloattest
of Cmm.comparison
* bool
40 | Iconst_int
of nativeint
41 | Iconst_float
of string
42 | Iconst_symbol
of string
46 | Itailcall_imm
of string
47 | Iextcall
of string * bool
49 | Iload
of Cmm.memory_chunk
* Arch.addressing_mode
50 | Istore
of Cmm.memory_chunk
* Arch.addressing_mode
52 | Iintop
of integer_operation
53 | Iintop_imm
of integer_operation
* int
54 | Inegf
| Iabsf
| Iaddf
| Isubf
| Imulf
| Idivf
55 | Ifloatofint
| Iintoffloat
56 | Ispecific
of Arch.specific_operation
59 { desc
: instruction_desc
;
64 mutable live
: Reg.Set.t
}
66 and instruction_desc
=
70 | Iifthenelse
of test
* instruction
* instruction
71 | Iswitch
of int array
* instruction array
72 | Iloop
of instruction
73 | Icatch
of int * instruction
* instruction
75 | Itrywith
of instruction
* instruction
80 fun_args
: Reg.t array
;
81 fun_body
: instruction
;
90 live
= Reg.Set.empty
}
98 live
= Reg.Set.empty
}
100 let instr_cons d a r n
=
101 { desc
= d
; next
= n
; arg
= a
; res
= r
;
102 dbg
= Debuginfo.none
; live
= Reg.Set.empty
}
104 let instr_cons_debug d a r dbg n
=
105 { desc
= d
; next
= n
; arg
= a
; res
= r
; dbg
= dbg
; live
= Reg.Set.empty
}
107 let rec instr_iter f i
=
114 | Ireturn
| Iop
(Itailcall_ind
) | Iop
(Itailcall_imm _
) -> ()
115 | Iifthenelse
(tst
, ifso
, ifnot
) ->
116 instr_iter f ifso
; instr_iter f ifnot
; instr_iter f i
.next
117 | Iswitch
(index
, cases
) ->
118 for i
= 0 to Array.length cases
- 1 do
119 instr_iter f cases
.(i
)
123 instr_iter f body
; instr_iter f i
.next
124 | Icatch
(_
, body
, handler
) ->
125 instr_iter f body
; instr_iter f handler
; instr_iter f i
.next
127 | Itrywith
(body
, handler
) ->
128 instr_iter f body
; instr_iter f handler
; instr_iter f i
.next