Skip to content

Allow signed and unsigned 16-bit integers in asm directives #3984

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion backend/amd64/emit.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2688,7 +2688,8 @@ let end_assembly () =
let l = label_to_asm_label ~section:Data l in
ND.label l);
efa_8 = (fun n -> ND.uint8 (Numbers.Uint8.of_nonnegative_int_exn n));
efa_16 = (fun n -> ND.int16 (Numbers.Int16.of_int_exn n));
efa_i16 = (fun n -> ND.int16 (Numbers.Int16.of_int_exn n));
efa_u16 = (fun n -> ND.uint16 (Numbers.Uint16.of_nonnegative_int_exn n));
efa_32 = (fun n -> ND.int32 n);
efa_word = (fun n -> ND.targetint (Targetint.of_int_exn n));
efa_align = (fun n -> ND.align ~fill_x86_bin_emitter:Zero ~bytes:n);
Expand Down
3 changes: 2 additions & 1 deletion backend/arm64/emit.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2220,7 +2220,8 @@ let end_assembly () =
D.type_label ~ty:Object lbl;
D.label lbl);
efa_8 = (fun n -> D.uint8 (Numbers.Uint8.of_nonnegative_int_exn n));
efa_16 = (fun n -> D.uint16 (Numbers.Uint16.of_nonnegative_int_exn n));
efa_i16 = (fun n -> D.int16 (Numbers.Int16.of_int_exn n));
efa_u16 = (fun n -> D.uint16 (Numbers.Uint16.of_nonnegative_int_exn n));
(* CR sspies: for some reason, we can get negative numbers here *)
efa_32 = (fun n -> D.int32 n);
efa_word = (fun n -> D.targetint (Targetint.of_int_exn n));
Expand Down
18 changes: 10 additions & 8 deletions backend/emitaux.ml
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ type emit_frame_actions =
{ efa_code_label : Label.t -> unit;
efa_data_label : Label.t -> unit;
efa_8 : int -> unit;
efa_16 : int -> unit;
efa_i16 : int -> unit;
efa_u16 : int -> unit;
efa_32 : int32 -> unit;
efa_word : int -> unit;
efa_align : int -> unit;
Expand Down Expand Up @@ -252,12 +253,13 @@ let emit_frames a =
below. *)
if fd.fd_long
then (
a.efa_16 Flambda_backend_flags.max_long_frames_threshold;
a.efa_u16 Flambda_backend_flags.max_long_frames_threshold;
a.efa_align 4);
let emit_16_or_32 = if fd.fd_long then emit_32 else a.efa_16 in
emit_16_or_32 (fd.fd_frame_size + flags);
emit_16_or_32 (List.length fd.fd_live_offset);
List.iter emit_16_or_32 fd.fd_live_offset;
let emit_signed_16_or_32 = if fd.fd_long then emit_32 else a.efa_i16 in
(* CR sspies: We should also split the case for 32-bit integers now. *)
emit_signed_16_or_32 (fd.fd_frame_size + flags);
emit_signed_16_or_32 (List.length fd.fd_live_offset);
List.iter emit_signed_16_or_32 fd.fd_live_offset;
(match fd.fd_debuginfo with
| _ when flags = 0 -> ()
| Dbg_other dbg ->
Expand Down Expand Up @@ -295,8 +297,8 @@ let emit_frames a =
in
let emit_defname (_filename, defname, loc) (file_lbl, lbl) =
let emit_loc (start_chr, end_chr, end_offset) =
a.efa_16 start_chr;
a.efa_16 end_chr;
a.efa_u16 start_chr;
a.efa_u16 end_chr;
a.efa_32 (Int32.of_int end_offset)
in
(* These must be 32-bit aligned, both because they contain a 32-bit value,
Expand Down
3 changes: 2 additions & 1 deletion backend/emitaux.mli
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ type emit_frame_actions =
{ efa_code_label : Label.t -> unit;
efa_data_label : Label.t -> unit;
efa_8 : int -> unit;
efa_16 : int -> unit;
efa_i16 : int -> unit; (** signed 16-bit integers *)
efa_u16 : int -> unit; (** unsigned 16-bit integers *)
efa_32 : int32 -> unit;
efa_word : int -> unit;
efa_align : int -> unit;
Expand Down
2 changes: 2 additions & 0 deletions runtime/caml/frame_descriptors.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ typedef struct {
uint16_t frame_data; /* frame size and various flags */
uint16_t num_live;
uint16_t live_ofs[1 /* num_live */];
/* CR sspies: This is no longer correct. Due to recent changes in the compiler, the
offsets can now also be negative. */
/*
If frame_has_allocs(), alloc lengths follow:
uint8_t num_allocs;
Expand Down
Loading