End LEGAL_ALIGNAS_FACTS.
Module LegalAlignasStrict <: LEGAL_ALIGNAS.
Section legal_alignas.
Context (cenv: composite_env) (ha_env: PTree.t Z).
Definition legal_alignas_obs: Type := bool.
Fixpoint legal_alignas_type (la_env: PTree.t bool) t: bool :=
(hardware_alignof ha_env t <=? alignof cenv t) &&
match t with
| Tarray t' _ _ => (sizeof cenv t' mod alignof cenv t' =? 0) && legal_alignas_type la_env t'
| Tstruct id _ =>
match la_env ! id with
| Some la => la
| None => false
end
| Tunion id _ =>
match la_env ! id with
| Some la => la
| None => false
end
| _ => match access_mode t with
| By_value ch => true
| _ => false
end
end.
Fixpoint legal_alignas_members (la_env: PTree.t bool) (m: members): bool :=
match m with
| nil => true
| (_, t) :: m' => (legal_alignas_type la_env t) && (legal_alignas_members la_env m')
end.
Definition legal_alignas_composite (la_env: PTree.t bool) (co: composite): bool :=
legal_alignas_members la_env (co_members co).
Definition legal_alignas_env: PTree.t bool :=
let l := composite_reorder.rebuild_composite_elements cenv in
fold_right (fun (ic: positive * composite) (T0: PTree.t bool) => let (i, co) := ic in let T := T0 in PTree.set i (legal_alignas_composite T co) T) (PTree.empty _) l.
Definition is_aligned_aux (b: bool) (ha: Z) (ofs: Z) := b && ((ofs mod ha) =? 0).
End legal_alignas.
End LegalAlignasStrict.
Module LegalAlignasStrictFacts: LEGAL_ALIGNAS_FACTS with Module LegalAlignas := LegalAlignasStrict.
Module LegalAlignas := LegalAlignasStrict.
Module LegalAlignasDefs := LegalAlignasDefsGen (LegalAlignas).
Export LegalAlignas LegalAlignasDefs.
Section legal_alignas.
Context (cenv: composite_env) (ha_env: PTree.t Z).

(* Specifications: *)
Lemma aux1: forall T co,
(fix fm (l : list (ident * type * bool)) : bool :=
match l with
| nil => true
| (_, _, la) :: l' => la && fm l'
end)
(map
(fun it0 : positive * type =>
let (i0, t0) := it0 in
(i0, t0,
type_func.F
(fun t : type =>
(hardware_alignof ha_env t <=? alignof cenv t) &&
match access_mode t with
| By_value _ => true
| By_reference => false
| By_copy => false
| By_nothing => false
end)
(fun (la : bool) (t : type) (n : Z) (a0 : attr) =>
(hardware_alignof ha_env (Tarray t n a0) <=? alignof cenv (Tarray t n a0)) && ((sizeof cenv t mod alignof cenv t =? 0) && la))
(fun (la : bool) (id : ident) (a0 : attr) =>
(hardware_alignof ha_env (Tstruct id a0) <=? alignof cenv (Tstruct id a0)) && la)
(fun (la : bool) (id : ident) (a0 : attr) =>
(hardware_alignof ha_env (Tunion id a0) <=? alignof cenv (Tunion id a0)) && la) T t0)) (co_members co)) =
legal_alignas_composite cenv ha_env T co.
Lemma aux2:
(type_func.Env
(fun t : type =>
(hardware_alignof ha_env t <=? alignof cenv t) &&
match access_mode t with
| By_value _ => true
| By_reference => false
| By_copy => false
| By_nothing => false
end)
(fun (la : bool) (t : type) (n : Z) (a0 : attr) =>
(hardware_alignof ha_env (Tarray t n a0) <=? alignof cenv (Tarray t n a0)) && ((sizeof cenv t mod alignof cenv t =? 0) && la))
(fun (la : bool) (id : ident) (a0 : attr) =>
(hardware_alignof ha_env (Tstruct id a0) <=? alignof cenv (Tstruct id a0)) && la)
(fun (la : bool) (id : ident) (a0 : attr) =>
(hardware_alignof ha_env (Tunion id a0) <=? alignof cenv (Tunion id a0)) && la)
(fun _ : struct_or_union =>
fix fm (l : list (ident * type * bool)) : bool :=
match l with
| nil => true
| (_, _, la) :: l' => la && fm l'
end) (composite_reorder.rebuild_composite_elements cenv)) =
legal_alignas_env cenv ha_env.