-
Notifications
You must be signed in to change notification settings - Fork 258
Expand file tree
/
Copy pathAllocproof.v
More file actions
2545 lines (2391 loc) · 97 KB
/
Allocproof.v
File metadata and controls
2545 lines (2391 loc) · 97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(* *********************************************************************)
(* *)
(* The Compcert verified compiler *)
(* *)
(* Xavier Leroy, INRIA Paris-Rocquencourt *)
(* *)
(* Copyright Institut National de Recherche en Informatique et en *)
(* Automatique. All rights reserved. This file is distributed *)
(* under the terms of the INRIA Non-Commercial License Agreement. *)
(* *)
(* *********************************************************************)
(** Correctness proof for the [Allocation] pass (validated translation from
RTL to LTL). *)
Require Import FunInd.
Require Import FSets.
Require Import Coqlib Ordered Maps Errors Integers Floats.
Require Import AST Linking Lattice Kildall.
Require Import Values Memory Globalenvs Events Smallstep.
Require Archi.
Require Import Op Registers RTL Locations Conventions RTLtyping LTL.
Require Import Allocation.
Definition match_prog (p: RTL.program) (tp: LTL.program) :=
match_program (fun _ f tf => transf_fundef f = OK tf) eq p tp.
Lemma transf_program_match:
forall p tp, transf_program p = OK tp -> match_prog p tp.
Proof.
intros. eapply match_transform_partial_program; eauto.
Qed.
(** * Soundness of structural checks *)
Definition expand_move (m: move) : instruction :=
match m with
| MV (R src) (R dst) => Lop Omove (src::nil) dst
| MV (S sl ofs ty) (R dst) => Lgetstack sl ofs ty dst
| MV (R src) (S sl ofs ty) => Lsetstack src sl ofs ty
| MV (S _ _ _) (S _ _ _) => Lreturn (**r should never happen *)
| MVmakelong src1 src2 dst => Lop Omakelong (src1::src2::nil) dst
| MVlowlong src dst => Lop Olowlong (src::nil) dst
| MVhighlong src dst => Lop Ohighlong (src::nil) dst
end.
Definition expand_moves (mv: moves) (k: bblock) : bblock :=
List.map expand_move mv ++ k.
Definition wf_move (m: move) : Prop :=
match m with
| MV (S _ _ _) (S _ _ _) => False
| _ => True
end.
Definition wf_moves (mv: moves) : Prop :=
List.Forall wf_move mv.
Inductive expand_block_shape: block_shape -> RTL.instruction -> LTL.bblock -> Prop :=
| ebs_nop: forall mv s k,
wf_moves mv ->
expand_block_shape (BSnop mv s)
(Inop s)
(expand_moves mv (Lbranch s :: k))
| ebs_move: forall src dst mv s k,
wf_moves mv ->
expand_block_shape (BSmove src dst mv s)
(Iop Omove (src :: nil) dst s)
(expand_moves mv (Lbranch s :: k))
| ebs_makelong: forall src1 src2 dst mv s k,
wf_moves mv ->
Archi.splitlong = true ->
expand_block_shape (BSmakelong src1 src2 dst mv s)
(Iop Omakelong (src1 :: src2 :: nil) dst s)
(expand_moves mv (Lbranch s :: k))
| ebs_lowlong: forall src dst mv s k,
wf_moves mv ->
Archi.splitlong = true ->
expand_block_shape (BSlowlong src dst mv s)
(Iop Olowlong (src :: nil) dst s)
(expand_moves mv (Lbranch s :: k))
| ebs_highlong: forall src dst mv s k,
wf_moves mv ->
Archi.splitlong = true ->
expand_block_shape (BShighlong src dst mv s)
(Iop Ohighlong (src :: nil) dst s)
(expand_moves mv (Lbranch s :: k))
| ebs_op: forall op args res mv1 args' res' mv2 s k,
wf_moves mv1 -> wf_moves mv2 ->
expand_block_shape (BSop op args res mv1 args' res' mv2 s)
(Iop op args res s)
(expand_moves mv1
(Lop op args' res' :: expand_moves mv2 (Lbranch s :: k)))
| ebs_op_dead: forall op args res mv s k,
wf_moves mv ->
expand_block_shape (BSopdead op args res mv s)
(Iop op args res s)
(expand_moves mv (Lbranch s :: k))
| ebs_load: forall chunk addr args dst mv1 args' dst' mv2 s k,
wf_moves mv1 -> wf_moves mv2 ->
expand_block_shape (BSload chunk addr args dst mv1 args' dst' mv2 s)
(Iload chunk addr args dst s)
(expand_moves mv1
(Lload chunk addr args' dst' :: expand_moves mv2 (Lbranch s :: k)))
| ebs_load2: forall addr addr2 args dst mv1 args1' dst1' mv2 args2' dst2' mv3 s k,
wf_moves mv1 -> wf_moves mv2 -> wf_moves mv3 ->
Archi.splitlong = true ->
offset_addressing addr 4 = Some addr2 ->
expand_block_shape (BSload2 addr addr2 args dst mv1 args1' dst1' mv2 args2' dst2' mv3 s)
(Iload Mint64 addr args dst s)
(expand_moves mv1
(Lload Mint32 addr args1' dst1' ::
expand_moves mv2
(Lload Mint32 addr2 args2' dst2' ::
expand_moves mv3 (Lbranch s :: k))))
| ebs_load2_1: forall addr args dst mv1 args' dst' mv2 s k,
wf_moves mv1 -> wf_moves mv2 ->
Archi.splitlong = true ->
expand_block_shape (BSload2_1 addr args dst mv1 args' dst' mv2 s)
(Iload Mint64 addr args dst s)
(expand_moves mv1
(Lload Mint32 addr args' dst' ::
expand_moves mv2 (Lbranch s :: k)))
| ebs_load2_2: forall addr addr2 args dst mv1 args' dst' mv2 s k,
wf_moves mv1 -> wf_moves mv2 ->
Archi.splitlong = true ->
offset_addressing addr 4 = Some addr2 ->
expand_block_shape (BSload2_2 addr addr2 args dst mv1 args' dst' mv2 s)
(Iload Mint64 addr args dst s)
(expand_moves mv1
(Lload Mint32 addr2 args' dst' ::
expand_moves mv2 (Lbranch s :: k)))
| ebs_load_dead: forall chunk addr args dst mv s k,
wf_moves mv ->
expand_block_shape (BSloaddead chunk addr args dst mv s)
(Iload chunk addr args dst s)
(expand_moves mv (Lbranch s :: k))
| ebs_store: forall chunk addr args src mv1 args' src' s k,
wf_moves mv1 ->
expand_block_shape (BSstore chunk addr args src mv1 args' src' s)
(Istore chunk addr args src s)
(expand_moves mv1
(Lstore chunk addr args' src' :: Lbranch s :: k))
| ebs_store2: forall addr addr2 args src mv1 args1' src1' mv2 args2' src2' s k,
wf_moves mv1 -> wf_moves mv2 ->
Archi.splitlong = true ->
offset_addressing addr 4 = Some addr2 ->
expand_block_shape (BSstore2 addr addr2 args src mv1 args1' src1' mv2 args2' src2' s)
(Istore Mint64 addr args src s)
(expand_moves mv1
(Lstore Mint32 addr args1' src1' ::
expand_moves mv2
(Lstore Mint32 addr2 args2' src2' ::
Lbranch s :: k)))
| ebs_call: forall sg ros args res mv1 ros' mv2 s k,
wf_moves mv1 -> wf_moves mv2 ->
expand_block_shape (BScall sg ros args res mv1 ros' mv2 s)
(Icall sg ros args res s)
(expand_moves mv1
(Lcall sg ros' :: expand_moves mv2 (Lbranch s :: k)))
| ebs_tailcall: forall sg ros args mv ros' k,
wf_moves mv ->
expand_block_shape (BStailcall sg ros args mv ros')
(Itailcall sg ros args)
(expand_moves mv (Ltailcall sg ros' :: k))
| ebs_builtin: forall ef args res mv1 args' res' mv2 s k,
wf_moves mv1 -> wf_moves mv2 ->
expand_block_shape (BSbuiltin ef args res mv1 args' res' mv2 s)
(Ibuiltin ef args res s)
(expand_moves mv1
(Lbuiltin ef args' res' :: expand_moves mv2 (Lbranch s :: k)))
| ebs_cond: forall cond args mv args' s1 s2 k,
wf_moves mv ->
expand_block_shape (BScond cond args mv args' s1 s2)
(Icond cond args s1 s2)
(expand_moves mv (Lcond cond args' s1 s2 :: k))
| ebs_jumptable: forall arg mv arg' tbl k,
wf_moves mv ->
expand_block_shape (BSjumptable arg mv arg' tbl)
(Ijumptable arg tbl)
(expand_moves mv (Ljumptable arg' tbl :: k))
| ebs_return: forall optarg mv k,
wf_moves mv ->
expand_block_shape (BSreturn optarg mv)
(Ireturn optarg)
(expand_moves mv (Lreturn :: k)).
Ltac MonadInv :=
match goal with
| [ H: match ?x with Some _ => _ | None => None end = Some _ |- _ ] =>
destruct x as [] eqn:? ; [MonadInv|discriminate]
| [ H: match ?x with left _ => _ | right _ => None end = Some _ |- _ ] =>
destruct x; [MonadInv|discriminate]
| [ H: match negb (proj_sumbool ?x) with true => _ | false => None end = Some _ |- _ ] =>
destruct x; [discriminate|simpl in H; MonadInv]
| [ H: match negb ?x with true => _ | false => None end = Some _ |- _ ] =>
destruct x as [] eqn:? ; [discriminate|simpl in H; MonadInv]
| [ H: match ?x with true => _ | false => None end = Some _ |- _ ] =>
destruct x as [] eqn:? ; [MonadInv|discriminate]
| [ H: match ?x with (_, _) => _ end = Some _ |- _ ] =>
destruct x as [] eqn:? ; MonadInv
| [ H: Some _ = Some _ |- _ ] =>
inv H; MonadInv
| [ H: None = Some _ |- _ ] =>
discriminate
| _ =>
idtac
end.
Remark expand_moves_cons:
forall m accu b,
expand_moves (rev (m :: accu)) b = expand_moves (rev accu) (expand_move m :: b).
Proof.
unfold expand_moves; intros. simpl. rewrite map_app. rewrite app_ass. auto.
Qed.
Lemma extract_moves_sound:
forall b mv b',
extract_moves nil b = (mv, b') ->
wf_moves mv /\ b = expand_moves mv b'.
Proof.
assert (BASE:
forall accu b,
wf_moves accu ->
wf_moves (List.rev accu) /\ expand_moves (List.rev accu) b = expand_moves (List.rev accu) b).
{ intros; split; auto. unfold wf_moves in *; rewrite Forall_forall in *.
intros. apply H. rewrite <- in_rev in H0; auto. }
assert (IND: forall b accu mv b',
extract_moves accu b = (mv, b') ->
wf_moves accu ->
wf_moves mv /\ expand_moves (List.rev accu) b = expand_moves mv b').
{ induction b; simpl; intros.
- inv H. auto.
- destruct a; try (inv H; apply BASE; auto; fail).
+ destruct (is_move_operation op args) as [arg|] eqn:E.
exploit is_move_operation_correct; eauto. intros [A B]; subst.
(* reg-reg move *)
exploit IHb; eauto. constructor; auto. exact I. rewrite expand_moves_cons; auto.
inv H; apply BASE; auto.
+ (* stack-reg move *)
exploit IHb; eauto. constructor; auto. exact I. rewrite expand_moves_cons; auto.
+ (* reg-stack move *)
exploit IHb; eauto. constructor; auto. exact I. rewrite expand_moves_cons; auto.
}
intros. exploit IND; eauto. constructor.
Qed.
Lemma extract_moves_ext_sound:
forall b mv b',
extract_moves_ext nil b = (mv, b') ->
wf_moves mv /\ b = expand_moves mv b'.
Proof.
assert (BASE:
forall accu b,
wf_moves accu ->
wf_moves (List.rev accu) /\ expand_moves (List.rev accu) b = expand_moves (List.rev accu) b).
{ intros; split; auto. unfold wf_moves in *; rewrite Forall_forall in *.
intros. apply H. rewrite <- in_rev in H0; auto. }
assert (IND: forall b accu mv b',
extract_moves_ext accu b = (mv, b') ->
wf_moves accu ->
wf_moves mv /\ expand_moves (List.rev accu) b = expand_moves mv b').
{ induction b; simpl; intros.
- inv H. auto.
- destruct a; try (inv H; apply BASE; auto; fail).
+ destruct (classify_operation op args).
* (* reg-reg move *)
exploit IHb; eauto. constructor; auto. exact I. rewrite expand_moves_cons; auto.
* (* makelong *)
exploit IHb; eauto. constructor; auto. exact I. rewrite expand_moves_cons; auto.
* (* lowlong *)
exploit IHb; eauto. constructor; auto. exact I. rewrite expand_moves_cons; auto.
* (* highlong *)
exploit IHb; eauto. constructor; auto. exact I. rewrite expand_moves_cons; auto.
* (* default *)
inv H; apply BASE; auto.
+ (* stack-reg move *)
exploit IHb; eauto. constructor; auto. exact I. rewrite expand_moves_cons; auto.
+ (* reg-stack move *)
exploit IHb; eauto. constructor; auto. exact I. rewrite expand_moves_cons; auto.
}
intros. exploit IND; eauto. constructor.
Qed.
Lemma check_succ_sound:
forall s b, check_succ s b = true -> exists k, b = Lbranch s :: k.
Proof.
intros. destruct b; simpl in H; try discriminate.
destruct i; try discriminate.
destruct (peq s s0); simpl in H; inv H. exists b; auto.
Qed.
Ltac UseParsingLemmas :=
match goal with
| [ H: extract_moves nil _ = (_, _) |- _ ] =>
destruct (extract_moves_sound _ _ _ H); clear H; subst; UseParsingLemmas
| [ H: extract_moves_ext nil _ = (_, _) |- _ ] =>
destruct (extract_moves_ext_sound _ _ _ H); clear H; subst; UseParsingLemmas
| [ H: check_succ _ _ = true |- _ ] =>
try (discriminate H);
destruct (check_succ_sound _ _ H); clear H; subst; UseParsingLemmas
| _ => idtac
end.
Lemma pair_instr_block_sound:
forall i b bsh,
pair_instr_block i b = Some bsh -> expand_block_shape bsh i b.
Proof.
assert (OP: forall op args res s b bsh,
pair_Iop_block op args res s b = Some bsh -> expand_block_shape bsh (Iop op args res s) b).
{
unfold pair_Iop_block; intros. MonadInv. destruct b0.
MonadInv; UseParsingLemmas.
destruct i; MonadInv; UseParsingLemmas.
eapply ebs_op; eauto.
inv H0. eapply ebs_op_dead; eauto. }
intros; destruct i; simpl in H; MonadInv; UseParsingLemmas.
- (* nop *)
econstructor; eauto.
- (* op *)
destruct (classify_operation o l).
+ (* move *)
MonadInv; UseParsingLemmas. econstructor; eauto.
+ (* makelong *)
destruct Archi.splitlong eqn:SL; eauto.
MonadInv; UseParsingLemmas. econstructor; eauto.
+ (* lowlong *)
destruct Archi.splitlong eqn:SL; eauto.
MonadInv; UseParsingLemmas. econstructor; eauto.
+ (* highlong *)
destruct Archi.splitlong eqn:SL; eauto.
MonadInv; UseParsingLemmas. econstructor; eauto.
+ (* other ops *)
eauto.
- (* load *)
destruct b0 as [ | [] b0]; MonadInv; UseParsingLemmas.
destruct (chunk_eq m Mint64 && Archi.splitlong) eqn:A; MonadInv; UseParsingLemmas.
destruct b as [ | [] b]; MonadInv; UseParsingLemmas.
InvBooleans. subst m. eapply ebs_load2; eauto.
InvBooleans. subst m.
destruct (eq_addressing a addr).
inv H; inv H2. eapply ebs_load2_1; eauto.
destruct (option_eq eq_addressing (offset_addressing a 4) (Some addr)).
inv H; inv H2. eapply ebs_load2_2; eauto.
discriminate.
eapply ebs_load; eauto.
inv H. eapply ebs_load_dead; eauto.
- (* store *)
destruct b0; MonadInv. destruct i; MonadInv; UseParsingLemmas.
destruct (chunk_eq m Mint64 && Archi.splitlong) eqn:A; MonadInv; UseParsingLemmas.
destruct b as [ | [] b]; MonadInv; UseParsingLemmas.
InvBooleans. subst m. eapply ebs_store2; eauto.
eapply ebs_store; eauto.
- (* call *)
destruct b0 as [|[] ]; MonadInv; UseParsingLemmas. econstructor; eauto.
- (* tailcall *)
destruct b0 as [|[] ]; MonadInv; UseParsingLemmas. econstructor; eauto.
- (* builtin *)
destruct b1 as [|[] ]; MonadInv; UseParsingLemmas. econstructor; eauto.
- (* cond *)
destruct b0 as [|[]]; MonadInv; UseParsingLemmas. econstructor; eauto.
- (* jumptable *)
destruct b0 as [|[]]; MonadInv; UseParsingLemmas. econstructor; eauto.
- (* return *)
destruct b0 as [|[]]; MonadInv; UseParsingLemmas. econstructor; eauto.
Qed.
Lemma matching_instr_block:
forall f1 f2 pc bsh i,
(pair_codes f1 f2)!pc = Some bsh ->
(RTL.fn_code f1)!pc = Some i ->
exists b, (LTL.fn_code f2)!pc = Some b /\ expand_block_shape bsh i b.
Proof.
intros. unfold pair_codes in H. rewrite PTree.gcombine in H; auto. rewrite H0 in H.
destruct (LTL.fn_code f2)!pc as [b|].
exists b; split; auto. apply pair_instr_block_sound; auto.
discriminate.
Qed.
(** * Properties of equations *)
Module ESF := FSetFacts.Facts(EqSet).
Module ESP := FSetProperties.Properties(EqSet).
Module ESD := FSetDecide.Decide(EqSet).
Definition sel_val (k: equation_kind) (v: val) : val :=
match k with
| Full => v
| Low => Val.loword v
| High => Val.hiword v
end.
(** A set of equations [e] is satisfied in a RTL pseudoreg state [rs]
and an LTL location state [ls] if, for every equation [r = l [k]] in [e],
[sel_val k (rs#r)] (the [k] fragment of [r]'s value in the RTL code)
is less defined than [ls l] (the value of [l] in the LTL code). *)
Definition satisf (rs: regset) (ls: locset) (e: eqs) : Prop :=
forall q, EqSet.In q e -> Val.lessdef (sel_val (ekind q) rs#(ereg q)) (ls (eloc q)).
Lemma empty_eqs_satisf:
forall rs ls, satisf rs ls empty_eqs.
Proof.
unfold empty_eqs; intros; red; intros. ESD.fsetdec.
Qed.
Lemma satisf_incr:
forall rs ls (e1 e2: eqs),
satisf rs ls e2 -> EqSet.Subset e1 e2 -> satisf rs ls e1.
Proof.
unfold satisf; intros. apply H. ESD.fsetdec.
Qed.
Lemma satisf_undef_reg:
forall rs ls e r,
satisf rs ls e ->
satisf (rs#r <- Vundef) ls e.
Proof.
intros; red; intros. rewrite Regmap.gsspec. destruct (peq (ereg q) r); auto.
destruct (ekind q); simpl; auto.
Qed.
Lemma add_equation_lessdef:
forall rs ls q e,
satisf rs ls (add_equation q e) -> Val.lessdef (sel_val (ekind q) rs#(ereg q)) (ls (eloc q)).
Proof.
intros. apply H. unfold add_equation. simpl. apply EqSet.add_1. auto.
Qed.
Lemma add_equation_satisf:
forall rs ls q e,
satisf rs ls (add_equation q e) -> satisf rs ls e.
Proof.
intros. eapply satisf_incr; eauto. unfold add_equation. simpl. ESD.fsetdec.
Qed.
Lemma add_equations_satisf:
forall rs ls rl ml e e',
add_equations rl ml e = Some e' ->
satisf rs ls e' -> satisf rs ls e.
Proof.
induction rl; destruct ml; simpl; intros; MonadInv.
auto.
eapply add_equation_satisf; eauto.
Qed.
Lemma add_equations_lessdef:
forall rs ls rl ml e e',
add_equations rl ml e = Some e' ->
satisf rs ls e' ->
Val.lessdef_list (rs##rl) (reglist ls ml).
Proof.
induction rl; destruct ml; simpl; intros; MonadInv.
constructor.
constructor; eauto.
apply add_equation_lessdef with (e := e) (q := Eq Full a (R m)).
eapply add_equations_satisf; eauto.
Qed.
Lemma add_equations_args_satisf:
forall rs ls rl tyl ll e e',
add_equations_args rl tyl ll e = Some e' ->
satisf rs ls e' -> satisf rs ls e.
Proof.
intros until e'. functional induction (add_equations_args rl tyl ll e); intros.
- inv H; auto.
- eapply add_equation_satisf; eauto.
- discriminate.
- eapply add_equation_satisf. eapply add_equation_satisf. eauto.
- congruence.
Qed.
Lemma val_longofwords_eq_1:
forall v,
Val.has_type v Tlong -> Archi.ptr64 = false ->
Val.longofwords (Val.hiword v) (Val.loword v) = v.
Proof.
intros. red in H. destruct v; try contradiction.
- reflexivity.
- simpl. rewrite Int64.ofwords_recompose. auto.
- congruence.
Qed.
Lemma val_longofwords_eq_2:
forall v,
Val.has_type v Tlong -> Archi.splitlong = true ->
Val.longofwords (Val.hiword v) (Val.loword v) = v.
Proof.
intros. apply Archi.splitlong_ptr32 in H0. apply val_longofwords_eq_1; assumption.
Qed.
Lemma add_equations_args_lessdef:
forall rs ls rl tyl ll e e',
add_equations_args rl tyl ll e = Some e' ->
satisf rs ls e' ->
Val.has_type_list (rs##rl) tyl ->
Val.lessdef_list (rs##rl) (map (fun p => Locmap.getpair p ls) ll).
Proof.
intros until e'. functional induction (add_equations_args rl tyl ll e); simpl; intros.
- inv H; auto.
- destruct H1. constructor; auto.
eapply add_equation_lessdef with (q := Eq Full r1 l1). eapply add_equations_args_satisf; eauto.
- discriminate.
- destruct H1. constructor; auto.
rewrite <- (val_longofwords_eq_1 (rs#r1)) by auto. apply Val.longofwords_lessdef.
eapply add_equation_lessdef with (q := Eq High r1 l1).
eapply add_equation_satisf. eapply add_equations_args_satisf; eauto.
eapply add_equation_lessdef with (q := Eq Low r1 l2).
eapply add_equations_args_satisf; eauto.
- discriminate.
Qed.
Lemma add_equation_ros_satisf:
forall rs ls ros mos e e',
add_equation_ros ros mos e = Some e' ->
satisf rs ls e' -> satisf rs ls e.
Proof.
unfold add_equation_ros; intros. destruct ros; destruct mos; MonadInv.
eapply add_equation_satisf; eauto.
auto.
Qed.
Lemma remove_equation_satisf:
forall rs ls q e,
satisf rs ls e -> satisf rs ls (remove_equation q e).
Proof.
intros. eapply satisf_incr; eauto. unfold remove_equation; simpl. ESD.fsetdec.
Qed.
Lemma remove_equation_res_satisf:
forall rs ls r l e e',
remove_equations_res r l e = Some e' ->
satisf rs ls e -> satisf rs ls e'.
Proof.
intros. functional inversion H.
apply remove_equation_satisf; auto.
apply remove_equation_satisf. apply remove_equation_satisf; auto.
Qed.
Remark select_reg_l_monotone:
forall r q1 q2,
OrderedEquation.eq q1 q2 \/ OrderedEquation.lt q1 q2 ->
select_reg_l r q1 = true -> select_reg_l r q2 = true.
Proof.
unfold select_reg_l; intros. destruct H.
red in H. congruence.
rewrite Pos.leb_le in *. red in H. destruct H as [A | [A B]].
red in A. zify; omega.
rewrite <- A; auto.
Qed.
Remark select_reg_h_monotone:
forall r q1 q2,
OrderedEquation.eq q1 q2 \/ OrderedEquation.lt q2 q1 ->
select_reg_h r q1 = true -> select_reg_h r q2 = true.
Proof.
unfold select_reg_h; intros. destruct H.
red in H. congruence.
rewrite Pos.leb_le in *. red in H. destruct H as [A | [A B]].
red in A. zify; omega.
rewrite A; auto.
Qed.
Remark select_reg_charact:
forall r q, select_reg_l r q = true /\ select_reg_h r q = true <-> ereg q = r.
Proof.
unfold select_reg_l, select_reg_h; intros; split.
rewrite ! Pos.leb_le. unfold reg; zify; omega.
intros. rewrite H. rewrite ! Pos.leb_refl; auto.
Qed.
Lemma reg_unconstrained_sound:
forall r e q,
reg_unconstrained r e = true ->
EqSet.In q e ->
ereg q <> r.
Proof.
unfold reg_unconstrained; intros. red; intros.
apply select_reg_charact in H1.
assert (EqSet.mem_between (select_reg_l r) (select_reg_h r) e = true).
{
apply EqSet.mem_between_2 with q; auto.
exact (select_reg_l_monotone r).
exact (select_reg_h_monotone r).
tauto.
tauto.
}
rewrite H2 in H; discriminate.
Qed.
Lemma reg_unconstrained_satisf:
forall r e rs ls v,
reg_unconstrained r e = true ->
satisf rs ls e ->
satisf (rs#r <- v) ls e.
Proof.
red; intros. rewrite PMap.gso. auto. eapply reg_unconstrained_sound; eauto.
Qed.
Remark select_loc_l_monotone:
forall l q1 q2,
OrderedEquation'.eq q1 q2 \/ OrderedEquation'.lt q1 q2 ->
select_loc_l l q1 = true -> select_loc_l l q2 = true.
Proof.
unfold select_loc_l; intros. set (lb := OrderedLoc.diff_low_bound l) in *.
destruct H.
red in H. subst q2; auto.
assert (eloc q1 = eloc q2 \/ OrderedLoc.lt (eloc q1) (eloc q2)).
red in H. tauto.
destruct H1. rewrite <- H1; auto.
destruct (OrderedLoc.compare (eloc q2) lb); auto.
assert (OrderedLoc.lt (eloc q1) lb) by (eapply OrderedLoc.lt_trans; eauto).
destruct (OrderedLoc.compare (eloc q1) lb).
auto.
eelim OrderedLoc.lt_not_eq; eauto.
eelim OrderedLoc.lt_not_eq. eapply OrderedLoc.lt_trans. eexact l1. eexact H2. red; auto.
Qed.
Remark select_loc_h_monotone:
forall l q1 q2,
OrderedEquation'.eq q1 q2 \/ OrderedEquation'.lt q2 q1 ->
select_loc_h l q1 = true -> select_loc_h l q2 = true.
Proof.
unfold select_loc_h; intros. set (lb := OrderedLoc.diff_high_bound l) in *.
destruct H.
red in H. subst q2; auto.
assert (eloc q2 = eloc q1 \/ OrderedLoc.lt (eloc q2) (eloc q1)).
red in H. tauto.
destruct H1. rewrite H1; auto.
destruct (OrderedLoc.compare (eloc q2) lb); auto.
assert (OrderedLoc.lt lb (eloc q1)) by (eapply OrderedLoc.lt_trans; eauto).
destruct (OrderedLoc.compare (eloc q1) lb).
eelim OrderedLoc.lt_not_eq. eapply OrderedLoc.lt_trans. eexact l1. eexact H2. red; auto.
eelim OrderedLoc.lt_not_eq. eexact H2. apply OrderedLoc.eq_sym; auto.
auto.
Qed.
Remark select_loc_charact:
forall l q,
select_loc_l l q = false \/ select_loc_h l q = false <-> Loc.diff l (eloc q).
Proof.
unfold select_loc_l, select_loc_h; intros; split; intros.
apply OrderedLoc.outside_interval_diff.
destruct H.
left. destruct (OrderedLoc.compare (eloc q) (OrderedLoc.diff_low_bound l)); assumption || discriminate.
right. destruct (OrderedLoc.compare (eloc q) (OrderedLoc.diff_high_bound l)); assumption || discriminate.
exploit OrderedLoc.diff_outside_interval. eauto.
intros [A | A].
left. destruct (OrderedLoc.compare (eloc q) (OrderedLoc.diff_low_bound l)).
auto.
eelim OrderedLoc.lt_not_eq; eauto.
eelim OrderedLoc.lt_not_eq. eapply OrderedLoc.lt_trans; eauto. red; auto.
right. destruct (OrderedLoc.compare (eloc q) (OrderedLoc.diff_high_bound l)).
eelim OrderedLoc.lt_not_eq. eapply OrderedLoc.lt_trans; eauto. red; auto.
eelim OrderedLoc.lt_not_eq; eauto. apply OrderedLoc.eq_sym; auto.
auto.
Qed.
Lemma loc_unconstrained_sound:
forall l e q,
loc_unconstrained l e = true ->
EqSet.In q e ->
Loc.diff l (eloc q).
Proof.
unfold loc_unconstrained; intros.
destruct (select_loc_l l q) eqn:SL.
destruct (select_loc_h l q) eqn:SH.
assert (EqSet2.mem_between (select_loc_l l) (select_loc_h l) (eqs2 e) = true).
{
apply EqSet2.mem_between_2 with q; auto.
exact (select_loc_l_monotone l).
exact (select_loc_h_monotone l).
apply eqs_same. auto.
}
rewrite H1 in H; discriminate.
apply select_loc_charact; auto.
apply select_loc_charact; auto.
Qed.
Lemma loc_unconstrained_satisf:
forall rs ls k r mr e v,
let l := R mr in
satisf rs ls (remove_equation (Eq k r l) e) ->
loc_unconstrained (R mr) (remove_equation (Eq k r l) e) = true ->
Val.lessdef (sel_val k rs#r) v ->
satisf rs (Locmap.set l v ls) e.
Proof.
intros; red; intros.
destruct (OrderedEquation.eq_dec q (Eq k r l)).
subst q; simpl. unfold l; rewrite Locmap.gss. auto.
assert (EqSet.In q (remove_equation (Eq k r l) e)).
simpl. ESD.fsetdec.
rewrite Locmap.gso. apply H; auto. eapply loc_unconstrained_sound; eauto.
Qed.
Lemma reg_loc_unconstrained_sound:
forall r l e q,
reg_loc_unconstrained r l e = true ->
EqSet.In q e ->
ereg q <> r /\ Loc.diff l (eloc q).
Proof.
intros. destruct (andb_prop _ _ H).
split. eapply reg_unconstrained_sound; eauto. eapply loc_unconstrained_sound; eauto.
Qed.
Lemma parallel_assignment_satisf:
forall k r mr e rs ls v v',
let l := R mr in
Val.lessdef (sel_val k v) v' ->
reg_loc_unconstrained r (R mr) (remove_equation (Eq k r l) e) = true ->
satisf rs ls (remove_equation (Eq k r l) e) ->
satisf (rs#r <- v) (Locmap.set l v' ls) e.
Proof.
intros; red; intros.
destruct (OrderedEquation.eq_dec q (Eq k r l)).
subst q; simpl. unfold l; rewrite Regmap.gss; rewrite Locmap.gss; auto.
assert (EqSet.In q (remove_equation {| ekind := k; ereg := r; eloc := l |} e)).
simpl. ESD.fsetdec.
exploit reg_loc_unconstrained_sound; eauto. intros [A B].
rewrite Regmap.gso; auto. rewrite Locmap.gso; auto.
Qed.
Lemma parallel_assignment_satisf_2:
forall rs ls res res' e e' v v',
remove_equations_res res res' e = Some e' ->
satisf rs ls e' ->
reg_unconstrained res e' = true ->
forallb (fun l => loc_unconstrained l e') (map R (regs_of_rpair res')) = true ->
Val.lessdef v v' ->
satisf (rs#res <- v) (Locmap.setpair res' v' ls) e.
Proof.
intros. functional inversion H.
- (* One location *)
subst. simpl in H2. InvBooleans. simpl.
apply parallel_assignment_satisf with Full; auto.
unfold reg_loc_unconstrained. rewrite H1, H4. auto.
- (* Two 32-bit halves *)
subst.
set (e' := remove_equation {| ekind := Low; ereg := res; eloc := R mr2 |}
(remove_equation {| ekind := High; ereg := res; eloc := R mr1 |} e)) in *.
simpl in H2. InvBooleans. simpl.
red; intros.
destruct (OrderedEquation.eq_dec q (Eq Low res (R mr2))).
subst q; simpl. rewrite Regmap.gss. rewrite Locmap.gss.
apply Val.loword_lessdef; auto.
destruct (OrderedEquation.eq_dec q (Eq High res (R mr1))).
subst q; simpl. rewrite Regmap.gss. rewrite Locmap.gso by auto. rewrite Locmap.gss.
apply Val.hiword_lessdef; auto.
assert (EqSet.In q e'). unfold e', remove_equation; simpl; ESD.fsetdec.
rewrite Regmap.gso. rewrite ! Locmap.gso. auto.
eapply loc_unconstrained_sound; eauto.
eapply loc_unconstrained_sound; eauto.
eapply reg_unconstrained_sound; eauto.
Qed.
Remark in_elements_between_1:
forall r1 s q,
EqSet.In q (EqSet.elements_between (select_reg_l r1) (select_reg_h r1) s) <-> EqSet.In q s /\ ereg q = r1.
Proof.
intros. rewrite EqSet.elements_between_iff, select_reg_charact. tauto.
exact (select_reg_l_monotone r1). exact (select_reg_h_monotone r1).
Qed.
Lemma in_subst_reg:
forall r1 r2 q (e: eqs),
EqSet.In q e ->
ereg q = r1 /\ EqSet.In (Eq (ekind q) r2 (eloc q)) (subst_reg r1 r2 e)
\/ ereg q <> r1 /\ EqSet.In q (subst_reg r1 r2 e).
Proof.
intros r1 r2 q e0 IN0. unfold subst_reg.
set (f := fun (q: EqSet.elt) e => add_equation (Eq (ekind q) r2 (eloc q)) (remove_equation q e)).
generalize (in_elements_between_1 r1 e0).
set (elt := EqSet.elements_between (select_reg_l r1) (select_reg_h r1) e0).
intros IN_ELT.
set (P := fun e1 e2 =>
EqSet.In q e1 ->
EqSet.In (Eq (ekind q) r2 (eloc q)) e2).
assert (P elt (EqSet.fold f elt e0)).
{
apply ESP.fold_rec; unfold P; intros.
- ESD.fsetdec.
- simpl. red in H1. apply H1 in H3. destruct H3.
+ subst x. ESD.fsetdec.
+ rewrite ESF.add_iff. rewrite ESF.remove_iff.
destruct (OrderedEquation.eq_dec x {| ekind := ekind q; ereg := r2; eloc := eloc q |}); auto.
left. subst x; auto.
}
set (Q := fun e1 e2 =>
~EqSet.In q e1 ->
EqSet.In q e2).
assert (Q elt (EqSet.fold f elt e0)).
{
apply ESP.fold_rec; unfold Q; intros.
- auto.
- simpl. red in H2. rewrite H2 in H4. ESD.fsetdec.
}
destruct (ESP.In_dec q elt).
left. split. apply IN_ELT. auto. apply H. auto.
right. split. red; intros. elim n. rewrite IN_ELT. auto. apply H0. auto.
Qed.
Lemma subst_reg_satisf:
forall src dst rs ls e,
satisf rs ls (subst_reg dst src e) ->
satisf (rs#dst <- (rs#src)) ls e.
Proof.
intros; red; intros.
destruct (in_subst_reg dst src q e H0) as [[A B] | [A B]].
subst dst. rewrite Regmap.gss. exploit H; eauto.
rewrite Regmap.gso; auto.
Qed.
Lemma in_subst_reg_kind:
forall r1 k1 r2 k2 q (e: eqs),
EqSet.In q e ->
(ereg q, ekind q) = (r1, k1) /\ EqSet.In (Eq k2 r2 (eloc q)) (subst_reg_kind r1 k1 r2 k2 e)
\/ EqSet.In q (subst_reg_kind r1 k1 r2 k2 e).
Proof.
intros r1 k1 r2 k2 q e0 IN0. unfold subst_reg.
set (f := fun (q: EqSet.elt) e =>
if IndexedEqKind.eq (ekind q) k1
then add_equation (Eq k2 r2 (eloc q)) (remove_equation q e)
else e).
generalize (in_elements_between_1 r1 e0).
set (elt := EqSet.elements_between (select_reg_l r1) (select_reg_h r1) e0).
intros IN_ELT.
set (P := fun e1 e2 =>
EqSet.In q e1 -> ekind q = k1 ->
EqSet.In (Eq k2 r2 (eloc q)) e2).
assert (P elt (EqSet.fold f elt e0)).
{
intros; apply ESP.fold_rec; unfold P; intros.
- ESD.fsetdec.
- simpl. red in H1. apply H1 in H3. destruct H3.
+ subst x. unfold f. destruct (IndexedEqKind.eq (ekind q) k1).
simpl. ESD.fsetdec. contradiction.
+ unfold f. destruct (IndexedEqKind.eq (ekind x) k1).
simpl. rewrite ESF.add_iff. rewrite ESF.remove_iff.
destruct (OrderedEquation.eq_dec x {| ekind := k2; ereg := r2; eloc := eloc q |}); auto.
left. subst x; auto.
auto.
}
set (Q := fun e1 e2 =>
~EqSet.In q e1 \/ ekind q <> k1 ->
EqSet.In q e2).
assert (Q elt (EqSet.fold f elt e0)).
{
apply ESP.fold_rec; unfold Q; intros.
- auto.
- unfold f. red in H2. rewrite H2 in H4.
destruct (IndexedEqKind.eq (ekind x) k1).
simpl. rewrite ESF.add_iff. rewrite ESF.remove_iff.
right. split. apply H3. tauto. intuition congruence.
apply H3. intuition auto.
}
destruct (ESP.In_dec q elt).
destruct (IndexedEqKind.eq (ekind q) k1).
left. split. f_equal. apply IN_ELT. auto. auto. apply H. auto. auto.
right. apply H0. auto.
right. apply H0. auto.
Qed.
Lemma subst_reg_kind_satisf_makelong:
forall src1 src2 dst rs ls e,
let e1 := subst_reg_kind dst High src1 Full e in
let e2 := subst_reg_kind dst Low src2 Full e1 in
reg_unconstrained dst e2 = true ->
satisf rs ls e2 ->
satisf (rs#dst <- (Val.longofwords rs#src1 rs#src2)) ls e.
Proof.
intros; red; intros.
destruct (in_subst_reg_kind dst High src1 Full q e H1) as [[A B] | B]; fold e1 in B.
destruct (in_subst_reg_kind dst Low src2 Full _ e1 B) as [[C D] | D]; fold e2 in D.
simpl in C; simpl in D. inv C.
inversion A. rewrite H3; rewrite H4. rewrite Regmap.gss.
apply Val.lessdef_trans with (rs#src1).
simpl. destruct (rs#src1); simpl; auto. destruct (rs#src2); simpl; auto.
rewrite Int64.hi_ofwords. auto.
exploit H0. eexact D. simpl. auto.
destruct (in_subst_reg_kind dst Low src2 Full q e1 B) as [[C D] | D]; fold e2 in D.
inversion C. rewrite H3; rewrite H4. rewrite Regmap.gss.
apply Val.lessdef_trans with (rs#src2).
simpl. destruct (rs#src1); simpl; auto. destruct (rs#src2); simpl; auto.
rewrite Int64.lo_ofwords. auto.
exploit H0. eexact D. simpl. auto.
rewrite Regmap.gso. apply H0; auto. eapply reg_unconstrained_sound; eauto.
Qed.
Lemma subst_reg_kind_satisf_lowlong:
forall src dst rs ls e,
let e1 := subst_reg_kind dst Full src Low e in
reg_unconstrained dst e1 = true ->
satisf rs ls e1 ->
satisf (rs#dst <- (Val.loword rs#src)) ls e.
Proof.
intros; red; intros.
destruct (in_subst_reg_kind dst Full src Low q e H1) as [[A B] | B]; fold e1 in B.
inversion A. rewrite H3; rewrite H4. simpl. rewrite Regmap.gss.
exploit H0. eexact B. simpl. auto.
rewrite Regmap.gso. apply H0; auto. eapply reg_unconstrained_sound; eauto.
Qed.
Lemma subst_reg_kind_satisf_highlong:
forall src dst rs ls e,
let e1 := subst_reg_kind dst Full src High e in
reg_unconstrained dst e1 = true ->
satisf rs ls e1 ->
satisf (rs#dst <- (Val.hiword rs#src)) ls e.
Proof.
intros; red; intros.
destruct (in_subst_reg_kind dst Full src High q e H1) as [[A B] | B]; fold e1 in B.
inversion A. rewrite H3; rewrite H4. simpl. rewrite Regmap.gss.
exploit H0. eexact B. simpl. auto.
rewrite Regmap.gso. apply H0; auto. eapply reg_unconstrained_sound; eauto.
Qed.
Module ESF2 := FSetFacts.Facts(EqSet2).
Module ESP2 := FSetProperties.Properties(EqSet2).
Module ESD2 := FSetDecide.Decide(EqSet2).
Lemma partial_fold_ind:
forall (A: Type) (P: EqSet2.t -> A -> Prop) f init final s,
EqSet2.fold
(fun q opte =>
match opte with
| None => None
| Some e => f q e
end)
s (Some init) = Some final ->
(forall s', EqSet2.Empty s' -> P s' init) ->
(forall x a' a'' s' s'',
EqSet2.In x s -> ~EqSet2.In x s' -> ESP2.Add x s' s'' ->
f x a' = Some a'' -> P s' a' -> P s'' a'') ->
P s final.
Proof.
intros.
set (g := fun q opte => match opte with Some e => f q e | None => None end) in *.
set (Q := fun s1 opte => match opte with None => True | Some e => P s1 e end).
change (Q s (Some final)).
rewrite <- H. apply ESP2.fold_rec; unfold Q, g; intros.
- auto.
- destruct a as [e|]; auto. destruct (f x e) as [e'|] eqn:F; auto. eapply H1; eauto.
Qed.
Lemma in_subst_loc:
forall l1 l2 q (e e': eqs),
EqSet.In q e ->
subst_loc l1 l2 e = Some e' ->
(eloc q = l1 /\ EqSet.In (Eq (ekind q) (ereg q) l2) e') \/ (Loc.diff l1 (eloc q) /\ EqSet.In q e').
Proof.
unfold subst_loc; intros l1 l2 q e0 e0' IN SUBST.
set (elt := EqSet2.elements_between (select_loc_l l1) (select_loc_h l1) (eqs2 e0)) in *.
set (f := fun q0 e =>
if Loc.eq l1 (eloc q0) then
Some (add_equation
{| ekind := ekind q0; ereg := ereg q0; eloc := l2 |}
(remove_equation q0 e))
else None).
set (P := fun e1 e2 => EqSet2.In q e1 -> eloc q = l1 /\ EqSet.In (Eq (ekind q) (ereg q) l2) e2).
assert (A: P elt e0').
{ eapply partial_fold_ind with (f := f) (s := elt) (final := e0'). eexact SUBST.
- unfold P; intros. ESD2.fsetdec.
- unfold P, f; intros. destruct (Loc.eq l1 (eloc x)); inversion H2; subst a''; clear H2.
simpl. rewrite ESF.add_iff, ESF.remove_iff.
apply H1 in H4; destruct H4.
subst x; rewrite e; auto.
apply H3 in H2; destruct H2. split. congruence.
destruct (OrderedEquation.eq_dec x {| ekind := ekind q; ereg := ereg q; eloc := l2 |}); auto.
subst x; auto.
}
set (Q := fun e1 e2 => ~EqSet2.In q e1 -> EqSet.In q e2).
assert (B: Q elt e0').
{ eapply partial_fold_ind with (f := f) (s := elt) (final := e0'). eexact SUBST.
- unfold Q; intros. auto.
- unfold Q, f; intros. destruct (Loc.eq l1 (eloc x)); inversion H2; subst a''; clear H2.
simpl. rewrite ESF.add_iff, ESF.remove_iff.
red in H1. rewrite H1 in H4. intuition auto. }
destruct (ESP2.In_dec q elt).
left. apply A; auto.
right. split; auto.
rewrite <- select_loc_charact.
destruct (select_loc_l l1 q) eqn: LL; auto.
destruct (select_loc_h l1 q) eqn: LH; auto.
elim n. eapply EqSet2.elements_between_iff.
exact (select_loc_l_monotone l1).
exact (select_loc_h_monotone l1).
split. apply eqs_same; auto. auto.
Qed.
Lemma loc_type_compat_charact:
forall env l e q,
loc_type_compat env l e = true ->
EqSet.In q e ->
subtype (sel_type (ekind q) (env (ereg q))) (Loc.type l) = true \/ Loc.diff l (eloc q).
Proof.
unfold loc_type_compat; intros.
rewrite EqSet2.for_all_between_iff in H.