diff options
author | Justus Fasse <justus.fasse@etu.univ-grenoble-alpes.fr> | 2020-07-20 11:47:06 +0200 |
---|---|---|
committer | Justus Fasse <justus.fasse@etu.univ-grenoble-alpes.fr> | 2020-07-21 17:41:40 +0200 |
commit | 61410a182bfeb82043c1cb519b81d3dc8f4e997e (patch) | |
tree | 3f4ed4a808ec647a37e2c3d9d4d124948bebae54 /aarch64/Asmgen.v | |
parent | 1674f32a0339a0801489336ec15a2e116ba4f95b (diff) | |
download | compcert-kvx-61410a182bfeb82043c1cb519b81d3dc8f4e997e.tar.gz compcert-kvx-61410a182bfeb82043c1cb519b81d3dc8f4e997e.zip |
Add dynamically checked assumption to simplify Asmgenproof
Previously Asmblock.label_pos and Asm.label_pos could point to different
memory location for the same label.
Diffstat (limited to 'aarch64/Asmgen.v')
-rw-r--r-- | aarch64/Asmgen.v | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/aarch64/Asmgen.v b/aarch64/Asmgen.v index a3b21a88..08ad176a 100644 --- a/aarch64/Asmgen.v +++ b/aarch64/Asmgen.v @@ -315,15 +315,29 @@ Definition unfold_exit (oc: option control) := Definition unfold_bblock (bb: bblock) := let lbl := unfold_label (header bb) in - do rest <- (match (body bb), (exit bb) with - | (((Asmblock.Pfreeframe _ _ - | Asmblock.Pallocframe _ _)::nil) as bo), None => - unfold_body bo - | bo, ex => - do bo_is <- unfold_body bo; - OK (bo_is ++ unfold_exit ex) - end) - ; OK (lbl ++ rest). + (* + * With this dynamically checked assumption on a previous optimization we + * can show that [Asmblock.label_pos] and [Asm.label_pos] retrieve the same + * exact address. Maintaining this property allows us to use the simple + * formulation of match_states defined as equality. + * Otherwise we would have to deal with the case of a basic block header + * that has multiple labels. Asmblock.label_pos will, for all labels, point + * to the same location at the beginning of the basic block. Asm.label_pos + * on the other hand could return a position pointing into the original + * basic block. + *) + if zle (list_length_z (header bb)) 1 then + do rest <- (match (body bb), (exit bb) with + | (((Asmblock.Pfreeframe _ _ + | Asmblock.Pallocframe _ _)::nil) as bo), None => + unfold_body bo + | bo, ex => + do bo_is <- unfold_body bo; + OK (bo_is ++ unfold_exit ex) + end) + ; OK (lbl ++ rest) + else + Error (msg "Asmgen.unfold_bblock: Multiple labels were generated."). Fixpoint unfold (bbs: Asmblock.bblocks) : res Asm.code := match bbs with |