[sledge] Remove 'packed' field from Llair types

Summary: It is unused.

Reviewed By: jvillard

Differential Revision: D24772952

fbshipit-source-id: e4e414f84
master
Josh Berdine 4 years ago committed by Facebook GitHub Bot
parent a40cd07c7d
commit 18c908423a

@ -256,18 +256,17 @@ let rec xlate_type : x -> Llvm.lltype -> Typ.t =
| Struct ->
let llelts = Llvm.struct_element_types llt in
let len = Array.length llelts in
let packed = Llvm.is_packed llt in
if Llvm.is_literal llt then
let elts =
IArray.map ~f:(xlate_type x) (IArray.of_array llelts)
in
Typ.tuple elts ~bits ~byts ~packed
Typ.tuple elts ~bits ~byts
else
let name = struct_name llt in
let elts =
IArray.init len ~f:(fun i -> lazy (xlate_type x llelts.(i)))
in
Typ.struct_ ~name elts ~bits ~byts ~packed
Typ.struct_ ~name elts ~bits ~byts
| Function -> fail "expected to be unsized: %a" pp_lltype llt ()
| Vector -> todo "vector types: %a" pp_lltype llt ()
| Void | Label | Metadata | Token -> assert false
@ -823,9 +822,7 @@ let landingpad_typs : x -> Llvm.llvalue -> Typ.t * Typ.t * Llvm.lltype =
let exception_typs =
let pi8 = Typ.pointer ~elt:Typ.byt in
let i32 = Typ.integer ~bits:32 ~byts:4 in
let exc =
Typ.tuple ~packed:false (IArray.of_array [|pi8; i32|]) ~bits:96 ~byts:12
in
let exc = Typ.tuple (IArray.of_array [|pi8; i32|]) ~bits:96 ~byts:12 in
(pi8, i32, exc)
(** Translate a control transfer from instruction [instr] to block [dst] to

@ -13,14 +13,13 @@ type t =
| Float of {bits: int; byts: int; enc: [`IEEE | `Extended | `Pair]}
| Pointer of {elt: t}
| Array of {elt: t; len: int; bits: int; byts: int}
| Tuple of {elts: t iarray; bits: int; byts: int; packed: bool}
| Tuple of {elts: t iarray; bits: int; byts: int}
| Struct of
{ name: string
; elts: t iarray (* possibly cyclic, name unique *)
[@compare.ignore] [@equal.ignore] [@sexp_drop_if fun _ -> true]
; bits: int
; byts: int
; packed: bool }
; byts: int }
| Opaque of {name: string}
[@@deriving compare, equal, hash, sexp]
@ -43,17 +42,14 @@ let rec pp fs typ =
pf "f%i%s" bits enc_str
| Pointer {elt} -> pf "%a*" pp elt
| Array {elt; len} -> pf "[%i x %a]" len pp elt
| Tuple {elts; packed} ->
let opn, cls = if packed then ("<{", "}>") else ("{", "}") in
pf "%s @[%a@] %s" opn pps elts cls
| Tuple {elts} -> pf "{ @[%a@] }" pps elts
| Struct {name} | Opaque {name} -> pf "%%%s" name
and pps fs typs = IArray.pp ",@ " pp fs typs
let pp_defn fs = function
| Struct {name; elts; packed} ->
let opn, cls = if packed then ("<{", "}>") else ("{", "}") in
Format.fprintf fs "@[<2>%%%s =@ @[%s %a@] %s@]" name opn pps elts cls
| Struct {name; elts} ->
Format.fprintf fs "@[<2>%%%s =@ @[{ %a@] }@]" name pps elts
| Opaque {name} -> Format.fprintf fs "@[<2>%%%s =@ opaque@]" name
| typ -> pp fs typ
@ -85,24 +81,20 @@ let pointer ~elt = Pointer {elt} |> check invariant
let array ~elt ~len ~bits ~byts =
Array {elt; len; bits; byts} |> check invariant
let tuple elts ~bits ~byts ~packed =
Tuple {elts; bits; byts; packed} |> check invariant
let tuple elts ~bits ~byts = Tuple {elts; bits; byts} |> check invariant
let opaque ~name = Opaque {name} |> check invariant
let struct_ =
let defns = String.Tbl.create () in
let dummy_typ = Opaque {name= "dummy"} in
fun ~name ~bits ~byts ~packed elt_thks ->
fun ~name ~bits ~byts elt_thks ->
match String.Tbl.find defns name with
| Some typ -> typ
| None ->
(* Add placeholder defn to prevent computing [elts] in calls to
[struct] from [elts] for recursive occurrences of [name]. *)
let elts = Array.make (IArray.length elt_thks) dummy_typ in
let typ =
Struct {name; elts= IArray.of_array elts; bits; byts; packed}
in
let typ = Struct {name; elts= IArray.of_array elts; bits; byts} in
String.Tbl.set defns ~key:name ~data:typ ;
IArray.iteri elt_thks ~f:(fun i (lazy elt) -> elts.(i) <- elt) ;
typ |> check invariant

@ -16,10 +16,9 @@ type t = private
| Pointer of {elt: t} (** Pointer to element type. *)
| Array of {elt: t; len: int; bits: int; byts: int}
(** Statically-sized array of [len] elements of type [elt]. *)
| Tuple of {elts: t iarray; bits: int; byts: int; packed: bool}
| Tuple of {elts: t iarray; bits: int; byts: int}
(** Anonymous aggregate of heterogeneous types. *)
| Struct of
{name: string; elts: t iarray; bits: int; byts: int; packed: bool}
| Struct of {name: string; elts: t iarray; bits: int; byts: int}
(** Uniquely named aggregate of heterogeneous types. Every cycle of
recursive types contains a [Struct]. NOTE: recursive [Struct]
types are represented by cyclic values. *)
@ -44,11 +43,8 @@ val integer : bits:int -> byts:int -> t
val float : bits:int -> byts:int -> enc:[`Extended | `IEEE | `Pair] -> t
val pointer : elt:t -> t
val array : elt:t -> len:int -> bits:int -> byts:int -> t
val tuple : t iarray -> bits:int -> byts:int -> packed:bool -> t
val struct_ :
name:string -> bits:int -> byts:int -> packed:bool -> t lazy_t iarray -> t
val tuple : t iarray -> bits:int -> byts:int -> t
val struct_ : name:string -> bits:int -> byts:int -> t lazy_t iarray -> t
val opaque : name:string -> t
(** Queries *)

Loading…
Cancel
Save