Skip to content

Commit debc14e

Browse files
committed
cleanup
1 parent d8be9af commit debc14e

File tree

3 files changed

+28
-24
lines changed

3 files changed

+28
-24
lines changed

backend/arm64/emit.ml

+19-24
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,6 @@ end = struct
372372
let ins name ops = print_ins name ops |> Emitaux.emit_string
373373

374374
let labeled_ins lbl name ops =
375-
(* CR sspies: labelled instructions have to be in the text section, right?
376-
Perhaps we should add an assert here. *)
377375
D.define_label lbl;
378376
print_ins name ops |> Emitaux.emit_string
379377

@@ -510,8 +508,6 @@ let record_frame_label live dbg =
510508
live;
511509
record_frame_descr ~label:lbl ~frame_size:(frame_size ())
512510
~live_offset:!live_offset dbg;
513-
(* CR sspies: Are we defining this in the text or data section? My guess would
514-
be text. *)
515511
label_to_asm_label ~section:Text lbl
516512

517513
let record_frame live dbg =
@@ -1997,7 +1993,6 @@ let emit_instr i =
19971993
|];
19981994
DSL.ins I.BR [| DSL.emit_reg reg_tmp1 |])
19991995
| Lstackcheck { max_frame_size_bytes } ->
2000-
(* CR sspies: Are both of these in the text section? *)
20011996
let overflow = L.create Text and ret = L.create Text in
20021997
let threshold_offset =
20031998
(Domainstate.stack_ctx_words * 8) + Stack_check.stack_threshold_size
@@ -2064,7 +2059,7 @@ let fundecl fundecl =
20642059
D.align ~bytes:8;
20652060
D.global fun_sym;
20662061
D.type_symbol ~ty:Function fun_sym;
2067-
D.define_function_symbol fun_sym;
2062+
D.define_symbol_label ~section:Text fun_sym;
20682063
emit_debug_info fundecl.fun_dbg;
20692064
cfi_startproc ();
20702065
let num_call_gc = num_call_gc_points fundecl.fun_body in
@@ -2102,16 +2097,15 @@ let emit_item (d : Cmm.data_item) =
21022097
evaluate to random other GOT entries. For the moment force all symbols
21032098
to be global. *)
21042099
D.global sym;
2105-
(* CR sspies: Are these data or function symbols? From context, I guessed
2106-
data symbols. *)
2107-
D.define_data_symbol sym
2108-
(* [Cint8] mirrors x86 with new directives *)
2100+
D.define_symbol_label ~section:Data sym
2101+
(* [Cint8] mirrors mshinwell/ocaml#gdb-names-gpr x86 emitter *)
21092102
| Cint8 n -> D.int8 (Numbers.Int8.of_int_exn n)
2110-
(* [Cint16] mirrors x86 with new directives *)
2103+
(* [Cint16] mirrors mshinwell/ocaml#gdb-names-gpr x86 emitter *)
21112104
| Cint16 n -> D.int16 (Numbers.Int16.of_int_exn n)
2112-
(* [Cint32] mirrors x86 with new directives *)
2105+
(* [Cint32] mirrors mshinwell/ocaml#gdb-names-gpr x86 emitter *)
21132106
| Cint32 n -> D.int32 (Nativeint.to_int32 n)
2114-
(* [Cint] mirrors x86 with new directives *)
2107+
(* CR mshinwell: Add [Targetint.of_nativeint] *)
2108+
(* [Cint] mirrors mshinwell/ocaml#gdb-names-gpr x86 emitter *)
21152109
| Cint n -> D.targetint (Targetint.of_int64 (Int64.of_nativeint n))
21162110
| Csingle f -> D.float32 f
21172111
| Cdouble f -> D.float64 f
@@ -2155,12 +2149,12 @@ let begin_assembly _unix =
21552149
let data_begin_sym = S.create data_begin in
21562150
D.data ();
21572151
D.global data_begin_sym;
2158-
D.define_data_symbol data_begin_sym;
2152+
D.define_symbol_label ~section:Data data_begin_sym;
21592153
let code_begin = Cmm_helpers.make_symbol "code_begin" in
21602154
let code_begin_sym = S.create code_begin in
21612155
emit_named_text_section code_begin;
21622156
D.global code_begin_sym;
2163-
D.define_function_symbol code_begin_sym;
2157+
D.define_symbol_label ~section:Text code_begin_sym;
21642158
(* we need to pad here to avoid collision for the unwind test between the
21652159
code_begin symbol and the first function. (See also #4690) Alignment is
21662160
needed to avoid linker warnings for shared_startup__code_{begin,end} (e.g.
@@ -2177,22 +2171,21 @@ let end_assembly () =
21772171
let code_end_sym = S.create code_end in
21782172
emit_named_text_section code_end;
21792173
D.global code_end_sym;
2180-
D.define_function_symbol code_end_sym;
2174+
D.define_symbol_label ~section:Text code_end_sym;
21812175
let data_end = Cmm_helpers.make_symbol "data_end" in
21822176
let data_end_sym = S.create data_end in
21832177
D.data ();
21842178
D.int64 0L;
21852179
(* PR#6329 *)
21862180
D.global data_end_sym;
2187-
D.define_data_symbol data_end_sym;
2181+
D.define_symbol_label ~section:Data data_end_sym;
21882182
D.int64 0L;
21892183
D.align ~bytes:8;
21902184
(* #7887 *)
21912185
let frametable = Cmm_helpers.make_symbol "frametable" in
21922186
let frametable_sym = S.create frametable in
2193-
(* Unlike the name `lbl` suggests, we emit the label as a symbol here. *)
21942187
D.global frametable_sym;
2195-
D.define_data_symbol frametable_sym;
2188+
D.define_symbol_label ~section:Data frametable_sym;
21962189
emit_frames
21972190
{ efa_code_label =
21982191
(fun lbl ->
@@ -2204,15 +2197,17 @@ let end_assembly () =
22042197
let lbl = label_to_asm_label ~section:Data lbl in
22052198
D.type_label ~ty:Object lbl;
22062199
D.label lbl);
2207-
(* [efa_8] is not part of x86 with new directives *)
2200+
(* [efa_8] is not part of mshinwell/ocaml#gdb-names-gpr *)
22082201
efa_8 = (fun n -> D.uint8 (Numbers.Uint8.of_nonnegative_int_exn n));
2209-
(* [efa_16] mirrors x86 with new directives *)
2202+
(* [efa_16] is [D.uint16 (Numbers.Uint16.of_int_exn n)] in
2203+
mshinwell/ocaml#gdb-names-gpr x86 emitter *)
22102204
efa_16 = (fun n -> D.uint16 (Numbers.Uint16.of_nonnegative_int_exn n));
2205+
(* [efa_16] is [D.uint32 (Numbers.Uint32.of_int32 n)] in
2206+
mshinwell/ocaml#gdb-names-gpr x86 emitter *)
22112207
(* CR sspies: for some reason, we can get negative numbers here *)
22122208
efa_32 = (fun n -> D.int32 n);
2213-
(* CR sspies: Is a word supposed to mean 64-bit here, or an actual word
2214-
(i.e., processor size)? *)
2215-
(* [efa_word] mirrors x86 with new directives *)
2209+
(* [efa_word] is [D.targetint (Targetint.of_int_exn n)] in
2210+
mshinwell/ocaml#gdb-names-gpr x86 emitter *)
22162211
efa_word = (fun n -> D.targetint (Targetint.of_int_exn n));
22172212
efa_align = (fun n -> D.align ~bytes:n);
22182213
efa_label_rel =

backend/asm_targets/asm_directives_new.ml

+6
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,12 @@ let define_function_symbol symbol =
751751
| GAS_like, false -> type_ (Asm_symbol.encode symbol) ~type_:Function
752752
| GAS_like, true | MacOS, _ | MASM, _ -> ()
753753

754+
let define_symbol_label ~section symbol =
755+
let typ : Directive.thing_after_label =
756+
match section with Asm_section.Text -> Code | _ -> Machine_width_data
757+
in
758+
emit (New_label (Asm_symbol.encode symbol, typ))
759+
754760
let type_symbol symbol ~ty =
755761
match TS.assembler (), TS.windows () with
756762
| GAS_like, false -> type_ (Asm_symbol.encode symbol) ~type_:ty

backend/asm_targets/asm_directives_new.mli

+3
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ val define_data_symbol : Asm_symbol.t -> unit
172172
will be raised if the current section is not a text section. *)
173173
val define_function_symbol : Asm_symbol.t -> unit
174174

175+
(** Define a symbol as a label at the current position. No type information is emitted. *)
176+
val define_symbol_label : section:Asm_section.t -> Asm_symbol.t -> unit
177+
175178
(** Mark a symbol as global. *)
176179
val global : Asm_symbol.t -> unit
177180

0 commit comments

Comments
 (0)