forked from ocaml/ocaml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathx86_dsl.mli
192 lines (178 loc) · 5.43 KB
/
x86_dsl.mli
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
(**************************************************************************)
(* *)
(* OCaml *)
(* *)
(* Fabrice Le Fessant, projet Gallium, INRIA Rocquencourt *)
(* *)
(* Copyright 2014 Institut National de Recherche en Informatique et *)
(* en Automatique. *)
(* *)
(* All rights reserved. This file is distributed under the terms of *)
(* the GNU Lesser General Public License version 2.1, with the *)
(* special exception on linking described in the file LICENSE. *)
(* *)
(**************************************************************************)
(** Helpers for Intel code generators *)
(* The DSL* modules expose functions to emit x86/x86_64 instructions
using a syntax close to the official Intel syntax, except that
source and destination operands are reversed as in the AT&T
syntax:
mov src dst
*)
open X86_ast
val sym: string -> arg
val nat: nativeint -> arg
val int: int -> arg
val const_32: int32 -> constant
val const_nat: nativeint -> constant
val const: int -> constant
val al: arg
val ah: arg
val cl: arg
val ax: arg
val rax: arg
val r10: arg
val r11: arg
val r13: arg
val r14: arg
val r15: arg
val rsp: arg
val rbp: arg
val xmm15: arg
val eax: arg
val ebx: arg
val ecx: arg
val edx: arg
val ebp: arg
val esp: arg
val st0: arg
val st1: arg
val mem32:
data_type -> ?scale:int -> ?base:reg64 -> ?sym:string ->
int -> reg64 -> arg
val mem64:
data_type -> ?scale:int -> ?base:reg64 -> ?sym:string ->
int -> reg64 -> arg
val mem64_rip: data_type -> ?ofs:int -> string -> arg
module D : sig
(** Directives *)
val align: int -> unit
val byte: constant -> unit
val bytes: string -> unit
val cfi_adjust_cfa_offset: int -> unit
val cfi_endproc: unit -> unit
val cfi_startproc: unit -> unit
val comment: string -> unit
val data: unit -> unit
val extrn: string -> data_type -> unit
val file: file_num:int -> file_name:string -> unit
val global: string -> unit
val indirect_symbol: string -> unit
val label: ?typ:data_type -> string -> unit
val loc: file_num:int -> line:int -> col:int -> unit
val long: constant -> unit
val mode386: unit -> unit
val model: string -> unit
val private_extern: string -> unit
val qword: constant -> unit
val section: string list -> string option -> string list -> unit
val setvar: string * constant -> unit
val size: string -> constant -> unit
val space: int -> unit
val text: unit -> unit
val type_: string -> string -> unit
val word: constant -> unit
end
module I : sig
(* Instructions *)
val add: arg -> arg -> unit
val addsd: arg -> arg -> unit
val and_: arg -> arg -> unit
val andpd: arg -> arg -> unit
val bswap: arg -> unit
val call: arg -> unit
val cdq: unit -> unit
val cmp: arg -> arg -> unit
val comisd: arg -> arg -> unit
val cqo: unit -> unit
val cvtsd2ss: arg -> arg -> unit
val cvtsi2sd: arg -> arg -> unit
val cvtss2sd: arg -> arg -> unit
val cvttsd2si: arg -> arg -> unit
val dec: arg -> unit
val divsd: arg -> arg -> unit
val fabs: unit -> unit
val fadd: arg -> unit
val faddp: arg -> arg -> unit
val fchs: unit -> unit
val fcomp: arg -> unit
val fcompp: unit -> unit
val fcos: unit -> unit
val fdiv: arg -> unit
val fdivp: arg -> arg -> unit
val fdivr: arg -> unit
val fdivrp: arg -> arg -> unit
val fild: arg -> unit
val fistp: arg -> unit
val fld1: unit -> unit
val fld: arg -> unit
val fldcw: arg -> unit
val fldlg2: unit -> unit
val fldln2: unit -> unit
val fldz: unit -> unit
val fmul: arg -> unit
val fmulp: arg -> arg -> unit
val fnstcw: arg -> unit
val fnstsw: arg -> unit
val fpatan: unit -> unit
val fptan: unit -> unit
val fsin: unit -> unit
val fsqrt: unit -> unit
val fstp: arg -> unit
val fsub: arg -> unit
val fsubp: arg -> arg -> unit
val fsubr: arg -> unit
val fsubrp: arg -> arg -> unit
val fxch: arg -> unit
val fyl2x: unit -> unit
val hlt: unit -> unit
val idiv: arg -> unit
val imul: arg -> arg option -> unit
val inc: arg -> unit
val j: condition -> arg -> unit
val ja: arg -> unit
val jae: arg -> unit
val jb: arg -> unit
val jbe: arg -> unit
val je: arg -> unit
val jg: arg -> unit
val jmp: arg -> unit
val jne: arg -> unit
val jp: arg -> unit
val lea: arg -> arg -> unit
val mov: arg -> arg -> unit
val movapd: arg -> arg -> unit
val movsd: arg -> arg -> unit
val movss: arg -> arg -> unit
val movsx: arg -> arg -> unit
val movsxd: arg -> arg -> unit
val movzx: arg -> arg -> unit
val mulsd: arg -> arg -> unit
val nop: unit -> unit
val or_: arg -> arg -> unit
val pop: arg -> unit
val push: arg -> unit
val ret: unit -> unit
val sal: arg -> arg -> unit
val sar: arg -> arg -> unit
val set: condition -> arg -> unit
val shr: arg -> arg -> unit
val sqrtsd: arg -> arg -> unit
val sub: arg -> arg -> unit
val subsd: arg -> arg -> unit
val test: arg -> arg -> unit
val ucomisd: arg -> arg -> unit
val xchg: arg -> arg -> unit
val xor: arg -> arg -> unit
val xorpd: arg -> arg -> unit
end