File tree Expand file tree Collapse file tree 2 files changed +22
-9
lines changed
Expand file tree Collapse file tree 2 files changed +22
-9
lines changed Original file line number Diff line number Diff line change @@ -169,14 +169,12 @@ let coerce ltyp rtyp exp = match ltyp,rtyp with
169169
170170
171171let create_arg size i intent name t (data ,exp ) sub =
172- let ltyp = match size#bits t with
173- | None -> Type. imm (Size. in_bits size#pointer)
174- | Some m -> Type. imm m in
175172 let layout = match data with
176173 | Data. Ptr _ ->
177174 if Bap_c_type. is_pointer t then layout size t
178175 else layout size (Bap_c_type. pointer t)
179176 | _ -> layout size t in
177+ let ltyp = Type. imm (size_of_layout size layout) in
180178 let rtyp = Type. infer_exn exp in
181179 let name = if String. is_empty name then sprintf " arg%d" (i+ 1 ) else name in
182180 let var = Var. create (Sub. name sub ^ " _" ^ name) ltyp in
@@ -633,6 +631,9 @@ module Arg = struct
633631 with_hidden @@ fun () ->
634632 register file (C.Type. pointer t)
635633
634+ let pointer file t =
635+ register file (C.Type. pointer t)
636+
636637 let update_stack f =
637638 let * s = Arg. get () in
638639 match s.stack with
Original file line number Diff line number Diff line change @@ -322,17 +322,29 @@ module Arg : sig
322322 @since 2.5.0 *)
323323 val discard : ?n : int -> arena -> unit t
324324
325- (* * [reference arena t] passes the argument of type [t] as a pointer
326- to [t] via the first available register in [arena].
325+ (* * [reference arena t] passes a hidden pointer to [t] via
326+ the first available register in [arena].
327327
328328 Rejects the computation if there are no available registers in
329- [arena] or if the target doesn't have a register with the stack
330- pointer role. The size of [t] is not required. *)
329+ [arena]. The size of [t] is not required.
330+
331+ Note, that [reference] and [hidden] are increasing the number of
332+ hidden arguments of a subroutine, but do not add the actual
333+ arguments. *)
331334 val reference : arena -> ctype -> unit t
332335
333336
334- (* * [hidden t] passes the argument of type [t] as a pointer
335- to [t] via the first available stack slot.
337+ (* * [pointer arena t] passes argument [t] as a pointer.
338+
339+ Rejects the computation if [arena] is empty. The size of [t] is
340+ not required.
341+
342+ @since 2.5.0 *)
343+ val pointer : arena -> ctype -> unit t
344+
345+
346+ (* * [hidden t] inserts a hidden pointer to [t] into the next
347+ available stack slot.
336348
337349 The computation is rejected if the target doesn't have a stack.
338350
You can’t perform that action at this time.
0 commit comments