Fixpoint hardware_alignof (ha_env: PTree.t Z) t: Z :=
match t with
| Tarray t' _ _ => hardware_alignof ha_env t'
| Tstruct id _ =>
match ha_env ! id with
| Some ha => ha
| None => 1
end
| Tunion id _ =>
match ha_env ! id with
| Some ha => ha
| None => 1
end
| _ => match access_mode t with
| By_value ch => Memdata.align_chunk ch
| _ => 1
end
end.
Fixpoint hardware_alignof_composite (ha_env: PTree.t Z) (m: members): Z :=
match m with
| nil => 1
| (_, t) :: m' => Z.max (hardware_alignof ha_env t) (hardware_alignof_composite ha_env m')
end.
Definition hardware_alignof_env (cenv: composite_env): PTree.t Z :=
let l := composite_reorder.rebuild_composite_elements cenv in
fold_right (fun (ic: positive * composite) (T0: PTree.t Z) => let (i, co) := ic in let T := T0 in PTree.set i (hardware_alignof_composite T (co_members co)) T) (PTree.empty _) l.
Definition hardware_alignof_env_consistent (cenv: composite_env) (ha_env: PTree.t Z): Prop :=
forall i co ha,
cenv ! i = Some co ->
ha_env ! i = Some ha ->
ha = hardware_alignof_composite ha_env (co_members co).
Definition hardware_alignof_env_complete (cenv: composite_env) (ha_env: PTree.t Z): Prop :=
forall i,
(exists co, cenv ! i = Some co) <->
(exists ha, ha_env ! i = Some ha).
Module Type HARDWARE_ALIGNOF_FACTS.

(* Specifications: *)
Axiom hardware_alignof_consistency:
forall (cenv: composite_env) (ha_env: PTree.t Z),
composite_env_consistent cenv ->
ha_env = hardware_alignof_env cenv ->
hardware_alignof_env_consistent cenv ha_env.
Axiom hardware_alignof_completeness:
forall (cenv: composite_env) (ha_env: PTree.t Z),
ha_env = hardware_alignof_env cenv ->
hardware_alignof_env_complete cenv ha_env.