14
14
15
15
[@@@ ocaml.warning " +A-4-9-69" ]
16
16
17
+ open ! Int_replace_polymorphic_compare
17
18
open X86_ast
18
19
open X86_proc
19
20
module String = Misc.Stdlib. String
@@ -275,11 +276,13 @@ let eval_const b current_pos cst =
275
276
(* (X86_gas.string_of_constant cst)*) (Printexc. to_string e);
276
277
raise e
277
278
278
- let is_imm32L n = n < 0x8000_0000L && n > = - 0x8000_0000L
279
+ let is_imm32L n = Int64. compare n 0x8000_0000L < 0 && Int64. compare n ( - 0x8000_0000L ) > = 0
279
280
280
- let is_imm8L x = x < 128L && x > = - 128L
281
+ let is_imm8L x = Int64. compare x 128L < 0 && Int64. compare x ( - 128L ) > = 0
281
282
282
- let is_imm16L n = n < 32768L && n > = - 32768L
283
+ let is_imm16L n = Int64. compare n 32768L < 0 && Int64. compare n (- 32768L ) > = 0
284
+
285
+ let is_x86 = function | X86 -> true | X64 -> false
283
286
284
287
let rd_of_regf regf =
285
288
match regf with
@@ -380,14 +383,14 @@ let record_reloc b offset_from_section_beginning kind =
380
383
381
384
let declare_label b s =
382
385
let sy = get_symbol b s in
383
- assert (sy.sy_pos = None );
386
+ assert (Option. is_none sy.sy_pos);
384
387
let pos = Buffer. length b.buf in
385
388
sy.sy_pos < - Some pos
386
389
387
390
let buf_opcodes b opcodes =
388
391
ListLabels. iter ~f: (fun opcode -> buf_int8 b opcode) opcodes
389
392
390
- let arch64 = Config. architecture = " amd64"
393
+ let arch64 = String. equal Config. architecture " amd64"
391
394
392
395
let emit_rex b rexcode =
393
396
if arch64 && rexcode <> 0 then buf_int8 b (rexcode lor rex)
@@ -478,7 +481,7 @@ let emit_prefix_modrm b opcodes rm reg ~prefix =
478
481
let idx_reg = idx in
479
482
let idx = rd_of_reg64 idx in
480
483
if scale = 0 then (
481
- assert (base = None && arch = X86 );
484
+ assert (Option. is_none base && (is_x86 arch) );
482
485
match offset with
483
486
| OImm8 _ -> assert false
484
487
| OImm32 (sym , offset ) ->
@@ -1455,7 +1458,7 @@ let emit_reloc_jump near_opcodes far_opcodes b loc symbol =
1455
1458
in
1456
1459
1457
1460
(* Printf.printf "%s/%i: backward togo_short=%Ld\n%!" symbol loc togo_short; *)
1458
- if togo_short > = - 128L && togo_short < 128L then (
1461
+ if Int64. compare togo_short ( - 128L ) > = 0 && Int64. compare togo_short 128L < 0 then (
1459
1462
buf_opcodes b near_opcodes;
1460
1463
buf_int8L b togo_short)
1461
1464
else (
@@ -1480,7 +1483,7 @@ let emit_reloc_jump near_opcodes far_opcodes b loc symbol =
1480
1483
Printf.printf "%s/%i: short\n%!" symbol loc;
1481
1484
*)
1482
1485
let force_far =
1483
- Int64. of_int ((target_loc - loc) * ! instr_size) > = 120L
1486
+ Int64. compare ( Int64. of_int ((target_loc - loc) * ! instr_size)) 120L > = 0
1484
1487
|| IntSet. mem loc ! forced_long_jumps
1485
1488
in
1486
1489
if force_far then (
@@ -2164,8 +2167,8 @@ let assemble_line b loc ins =
2164
2167
| External (_ , _ ) -> ()
2165
2168
| Set (_ , _ ) -> assert false
2166
2169
| Section _ -> assert false
2167
- | Mode386 -> assert (system = S_win32 )
2168
- | Model _ -> assert (system = S_win32 )
2170
+ | Mode386 -> assert (is_win32 system )
2171
+ | Model _ -> assert (is_win32 system )
2169
2172
| Cfi_startproc -> ()
2170
2173
| Cfi_endproc -> ()
2171
2174
| Cfi_adjust_cfa_offset _ -> ()
0 commit comments