@@ -68,15 +68,20 @@ let to_x86_constant_with_width (c : ND.Directive.Constant_with_width.t) :
68
68
69
69
let to_x86_directive (dir : ND.Directive.t ) : X86_ast.asm_line list =
70
70
let comment_lines comment =
71
- Option. to_list (Option. map (fun s -> X86_ast. Comment s) comment)
71
+ (* CR sspies: This check is usually done in the printing function of the new
72
+ directives. Since we are skipping those at the moment (by emitting via
73
+ the X86 DSL), we do the same check here in the conversion. *)
74
+ if ! Clflags. keep_asm_file && ! Flambda_backend_flags. dasm_comments
75
+ then Option. to_list (Option. map (fun s -> X86_ast. Comment s) comment)
76
+ else []
72
77
in
73
78
match dir with
74
79
| Align { bytes } ->
75
80
[X86_ast. Align (false , bytes)]
76
81
(* The data field is currently ignored by both assembler backends. The bytes
77
82
field is only converted to the final value when printing. *)
78
83
| Bytes { str; comment } -> comment_lines comment @ [X86_ast. Bytes str]
79
- | Comment s -> [ X86_ast. Comment s]
84
+ | Comment s -> comment_lines ( Some s)
80
85
| Const { constant; comment } ->
81
86
comment_lines comment @ [to_x86_constant_with_width constant]
82
87
| Direct_assignment (s , c ) ->
@@ -619,105 +624,6 @@ let emit_jump_tables () =
619
624
List. iter emit_jump_table ! jump_tables;
620
625
jump_tables := []
621
626
622
- let file_emitter ~file_num ~file_name =
623
- ND. file ~file_num: (Some file_num) ~file_name
624
-
625
- let build_asm_directives () : (module Asm_targets.Asm_directives_intf.S) =
626
- (module Asm_targets.Asm_directives. Make (struct
627
- let emit_line line = ND. comment line
628
-
629
- let get_file_num file_name = Emitaux. get_file_num ~file_emitter file_name
630
-
631
- let debugging_comments_in_asm_files = ! Flambda_backend_flags. dasm_comments
632
-
633
- module D = struct
634
- type constant = ND.Directive.Constant .t
635
-
636
- let const_int64 num = ND.Directive.Constant. Signed_int num
637
-
638
- let const_label str = ND.Directive.Constant. Named_thing str
639
-
640
- let const_add c1 c2 = ND.Directive.Constant. Add (c1, c2)
641
-
642
- let const_sub c1 c2 = ND.Directive.Constant. Sub (c1, c2)
643
-
644
- (* CR sspies: The functions depending on [emit_directive] below break
645
- abstractions. This is intensional at the moment, because this is only
646
- the first step of getting rid of the first-class module entirely. *)
647
- let emit_directive d = List. iter directive (to_x86_directive d)
648
-
649
- type data_type =
650
- | NONE
651
- | DWORD
652
- | QWORD
653
- | VEC128
654
-
655
- let file = file_emitter
656
-
657
- let loc ~file_num ~line ~col ?discriminator () =
658
- ignore discriminator;
659
- D. loc ~file_num ~line ~col ?discriminator ()
660
-
661
- let comment str = D. comment str
662
-
663
- let label ?data_type str =
664
- let _ = data_type in
665
- emit_directive (New_label (str, Code ))
666
-
667
- let section ?delayed :_ name flags args =
668
- match name, flags, args with
669
- | [" .data" ], _ , _ -> ND. data ()
670
- | [" .text" ], _ , _ -> ND. text ()
671
- | name , flags , args -> ND. switch_to_section_raw ~names: name ~flags ~args
672
-
673
- let text () = D. text ()
674
-
675
- let new_line () = D. new_line ()
676
-
677
- let emit_constant const size =
678
- emit_directive
679
- (Const
680
- { constant = ND.Directive.Constant_with_width. create const size;
681
- comment = None
682
- })
683
-
684
- let global sym = emit_directive (Global sym)
685
-
686
- let protected sym =
687
- if not (is_macosx system) then emit_directive (Protected sym)
688
-
689
- let type_ sym typ_ =
690
- let typ_ : ND.symbol_type =
691
- match typ_ with
692
- | "@function" -> Function
693
- | "@object" -> Object
694
- | "STT_OBJECT" -> Object
695
- | "STT_FUNC" -> Function
696
- | _ -> Misc. fatal_error " Unsupported type"
697
- in
698
- emit_directive (Type (sym, typ_))
699
-
700
- let byte const = emit_constant const Eight
701
-
702
- let word const = emit_constant const Sixteen
703
-
704
- let long const = emit_constant const Thirty_two
705
-
706
- let qword const = emit_constant const Sixty_four
707
-
708
- let bytes str = ND. string str
709
-
710
- let uleb128 const =
711
- emit_directive (Uleb128 { constant = const; comment = None })
712
-
713
- let sleb128 const =
714
- emit_directive (Sleb128 { constant = const; comment = None })
715
-
716
- let direct_assignment var const =
717
- emit_directive (Direct_assignment (var, const))
718
- end
719
- end ))
720
-
721
627
(* Names for instructions *)
722
628
723
629
let instr_for_intop = function
@@ -2260,15 +2166,14 @@ let begin_assembly unix =
2260
2166
(* We initialize the new assembly directives. *)
2261
2167
Asm_targets.Asm_label. initialize ~new_label: (fun () ->
2262
2168
Cmm. new_label () |> Label. to_int);
2263
- ND. initialize
2264
- ~big_endian: Arch. big_endian
2169
+ ND. initialize ~big_endian: Arch. big_endian
2170
+ ~emit_assembly_comments: ! Flambda_backend_flags. dasm_comments
2265
2171
(* As a first step, we emit by calling the corresponding x86 emit
2266
2172
directives. *) ~emit: (fun d ->
2267
2173
List. iter directive (to_x86_directive d));
2268
2174
let code_begin = Cmm_helpers. make_symbol " code_begin" in
2269
2175
let code_end = Cmm_helpers. make_symbol " code_end" in
2270
- Emitaux.Dwarf_helpers. begin_dwarf ~build_asm_directives ~code_begin ~code_end
2271
- ~file_emitter: D. file;
2176
+ Emitaux.Dwarf_helpers. begin_dwarf ~code_begin ~code_end ~file_emitter: D. file;
2272
2177
if is_win64 system
2273
2178
then (
2274
2179
D. extrn " caml_call_gc" NEAR ;
0 commit comments