-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMutrecBproof.v
1427 lines (1307 loc) · 57 KB
/
MutrecBproof.v
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
Require Import CoqlibC Maps Postorder.
Require Import AST Linking.
Require Import ValuesC Memory GlobalenvsC Events Smallstep.
Require Import Op Registers ClightC Renumber.
Require Import sflib.
Require Import MutrecHeader IntegersC.
Require Import MutrecB MutrecBspec.
Require Import Simulation.
Require Import Skeleton Mod ModSem SimMod SimModSemLift SimSymb SimMemLift AsmregsC MatchSimModSem.
Require SoundTop.
Require SimMemInjC SimMemInjInv SimMemInjInvC.
Require Mach.
Require Import AsmC AsmregsC Conventions1C MemoryC AsmExtra StoreArgumentsProps.
Set Implicit Arguments.
Definition memoized_inv: SimMemInjInv.memblk_invariant :=
SimMemInjInv.memblk_invarant_mk
(fun mem =>
exists i,
(<<VINDEX: mem Mint32 0 = Some (Vint i)>>) /\
(<<VSUM: mem Mint32 (size_chunk Mint32) = Some (Vint (sum i))>>))
(fun chunk ofs p =>
(chunk = Mint32 /\ ofs = 0 /\ p = Writable) \/
(chunk = Mint32 /\ ofs = (size_chunk Mint32) /\ p = Writable)).
Local Instance SimMemMemoizedB: SimMem.class := SimMemInjInvC.SimMemInjInv SimMemInjInv.top_inv memoized_inv.
Definition symbol_memoized: ident -> Prop := eq _memoized.
Lemma memoized_inv_store_le i v_ind v_sum blk ofs0 ofs1 m_tgt0 m_tgt1
(sm0 sm1: SimMemInjInv.t')
(MWF: SimMem.wf sm0)
(INVAR: sm0.(SimMemInjInv.mem_inv_tgt) blk)
(OFSI: ofs0 = 0)
(OFSV: ofs1 = size_chunk Mint32)
(INDEX: v_ind = Vint i)
(SUM: v_sum = Vint (sum i))
(STR0: Mem.store Mint32 sm0.(SimMemInjInv.minj).(SimMemInj.tgt) blk ofs0 v_ind = Some m_tgt0)
(STR1: Mem.store Mint32 m_tgt0 blk ofs1 v_sum = Some m_tgt1)
(MREL: sm1 = SimMemInjInv.mk
(SimMemInjC.update
(sm0.(SimMemInjInv.minj))
(sm0.(SimMemInjInv.minj).(SimMemInj.src))
m_tgt1
(sm0.(SimMemInjInv.minj).(SimMemInj.inj)))
sm0.(SimMemInjInv.mem_inv_src)
sm0.(SimMemInjInv.mem_inv_tgt))
:
(<<MLE: SimMem.le sm0 sm1>>) /\
(<<MWF: SimMem.wf sm1>>).
Proof.
unfold SimMemInjC.update in *. clarify. ss.
inv MWF. inv WF. split.
- econs; ss; eauto. econs; ss; eauto.
+ refl.
+ etrans.
* eapply Mem.store_unchanged_on; eauto.
ii. exploit INVRANGETGT; eauto. i. des.
exfalso. eauto.
* eapply Mem.store_unchanged_on; eauto.
ii. exploit INVRANGETGT; eauto. i. des.
exfalso. eauto.
+ eapply SimMemInj.frozen_refl. + eapply SimMemInj.frozen_refl.
+ ii. eapply Mem.perm_store_2; eauto. eapply Mem.perm_store_2; eauto.
- econs; ss; eauto.
+ econs; ss; eauto.
* eapply MemoryC.private_unchanged_inject; eauto; cycle 1.
{ instantiate (1:=~2
loc_out_of_reach (SimMemInj.inj (SimMemInjInv.minj sm0))
(SimMemInj.src (SimMemInjInv.minj sm0))). ss. }
etrans.
{ eapply Mem.store_unchanged_on; eauto.
ii. eapply H0.
eapply INVRANGETGT; eauto. }
{ eapply Mem.store_unchanged_on; eauto.
ii. eapply H0.
eapply INVRANGETGT; eauto. }
* etrans; eauto.
unfold SimMemInj.tgt_private, SimMemInj.valid_blocks in *. ss.
ii. des. split; auto. eapply Mem.store_valid_block_1; eauto.
eapply Mem.store_valid_block_1; eauto.
* rpapply TGTLE. etrans.
{ eapply Mem.nextblock_store; eauto. }
{ eapply Mem.nextblock_store; eauto. }
+ ii. exploit SATTGT; eauto. i. inv H. des. des_ifs.
* assert (Mem.valid_access m_tgt1 Mint32 blk0 0 Writable).
{ eapply Mem.store_valid_access_1; eauto.
eapply Mem.store_valid_access_1; eauto.
hexploit PERMISSIONS; ss; eauto. }
assert (Mem.valid_access m_tgt1 Mint32 blk0 (size_chunk Mint32) Writable).
{ eapply Mem.store_valid_access_1; eauto.
eapply Mem.store_valid_access_1; eauto.
hexploit PERMISSIONS; ss; eauto. }
econs.
{ ii. ss. des; clarify; eauto. }
{ destruct (peq blk blk0).
{ clarify. exists (i). des_ifs. split.
- erewrite Mem.load_store_other; try apply STR1; eauto.
+ erewrite Mem.load_store_same; eauto. ss.
+ ss. right. left. refl.
- erewrite Mem.load_store_same; eauto. ss. }
{ ss. des. exists i0. split.
- erewrite Mem.load_store_other; try apply STR1; eauto.
erewrite Mem.load_store_other; try apply STR0; eauto.
- erewrite Mem.load_store_other; try apply STR1; eauto.
erewrite Mem.load_store_other; try apply STR0; eauto. }
}
Qed.
Section SIMMODSEM.
Variable skenv_link: SkEnv.t.
Variable sm_link: SimMem.t.
Let md_src: Mod.t := (MutrecBspec.module).
Let md_tgt: Mod.t := (AsmC.module prog).
Hypothesis (INCL: SkEnv.includes skenv_link (Mod.sk md_src)).
Hypothesis (WF: SkEnv.wf skenv_link).
Let tge := (SkEnv.revive ((SkEnv.project skenv_link) (Sk.of_program fn_sig prog))) prog.
Definition msp: ModSemPair.t :=
ModSemPair.mk (md_src skenv_link) (md_tgt skenv_link) (SimMemInjInvC.mk symbol_memoized md_src md_tgt) sm_link.
Inductive well_saved (initstk stk: block)
: regset -> regset -> mem -> Prop :=
| well_saved_intro
(init_rs rs: regset) m
(INITSIG: (Genv.find_funct tge) (init_rs # PC) = Some (Internal func_g))
(INITRSPVAL: init_rs RSP = Vptr initstk Ptrofs.zero)
(RANOTFPTR: forall blk ofs (RAVAL: init_rs RA = Vptr blk ofs),
~ Plt blk (Genv.genv_next skenv_link))
(RSPVAL: rs RSP = Vptr stk Ptrofs.zero)
(STKPERM: Mem.range_perm m stk 0 24 Cur Freeable)
(RASAVED: Mem.loadv Mptr m (Val.offset_ptr (rs RSP) (Ptrofs.repr 16)) = Some (init_rs RA))
(RSPSAVED: Mem.loadv Mptr m (Val.offset_ptr (rs RSP) Ptrofs.zero) = Some (init_rs RSP))
(REGSAVED: forall mr (CALLEESAVE: Conventions1.is_callee_save mr)
(INREG: mr <> Machregs.BX), init_rs (to_preg mr) = rs (to_preg mr))
(REGSAVEDSTK: Mem.loadv Many64 m (Val.addl (rs RSP) (Vlong (Int64.repr 8))) = Some (init_rs RBX))
:
well_saved
initstk stk
init_rs rs m.
Lemma well_saved_keep init_rs initstk stk rs0 rs1 m0 m1
(SAVED: well_saved
initstk stk
init_rs rs0 m0)
(REGSAME: forall mr (CALLEESAVE: Conventions1.is_callee_save mr)
(INREG: mr <> Machregs.BX),
rs0 (to_preg mr) = rs1 (to_preg mr))
(RSPSAME: rs0 RSP = rs1 RSP)
(UNCHSTK: Mem.unchanged_on
(fun blk _ => blk = stk) m0 m1)
:
well_saved
initstk stk
init_rs rs1 m1.
Proof.
inv SAVED. rewrite RSPVAL in *. ss. econs; eauto.
- ii. eapply Mem.perm_unchanged_on; [apply UNCHSTK|..]; ss; eauto.
- rewrite <- RSPSAME. ss. erewrite Mem.load_unchanged_on; eauto. ss.
- rewrite <- RSPSAME. ss. erewrite Mem.load_unchanged_on; eauto. ss.
- ii. erewrite REGSAVED; eauto.
- ii. rewrite <- RSPSAME. ss. des_ifs. ss.
erewrite Mem.load_unchanged_on; eauto. ss.
Qed.
Inductive curr_pc (v: val) (ofs: ptrofs): Prop :=
| curr_pc_intro
blk
(RSPC: v = Vptr blk ofs)
(FINDF: Genv.find_funct_ptr tge blk = Some (Internal func_g))
.
Require Import mktac.
Inductive match_states
:
nat -> MutrecBspec.state -> AsmC.state -> SimMem.t -> Prop :=
| match_states_initial
idx m_src sm0
i stk initstk init_rs rs m_tgt
(MCOMPATSRC: m_src = sm0.(SimMem.src))
(MCOMPATTGT: m_tgt = sm0.(SimMem.tgt))
(MWF: SimMem.wf sm0)
(SAVED: well_saved initstk stk init_rs rs m_tgt)
(PRIV: forall
blk_src blk_tgt delta
(DETLA: sm0.(SimMemInjInv.minj).(SimMemInj.inj) blk_src = Some (blk_tgt, delta)),
blk_tgt <> stk)
(NOTEXT: forall
ofs,
~ sm0.(SimMemInjInv.minj).(SimMemInj.tgt_external) stk ofs)
(NINV: ~ sm0.(SimMemInjInv.mem_inv_tgt) stk)
(CURRPC: curr_pc (rs PC) (Ptrofs.repr 2))
(ARG: rs RDI = Vint i)
(RANGE: 0 <= i.(Int.intval) < MAX)
(IDX: (idx > 9)%nat)
:
match_states idx (Callstate i m_src)
(AsmC.mkstate init_rs (Asm.State rs m_tgt)) sm0
| match_states_at_external
idx m_src sm0
i stk initstk init_rs rs m_tgt
(MCOMPATSRC: m_src = sm0.(SimMem.src))
(MCOMPATTGT: m_tgt = sm0.(SimMem.tgt))
(MWF: SimMem.wf sm0)
(SAVED: well_saved initstk stk init_rs rs m_tgt)
(PRIV: forall
blk_src blk_tgt delta
(DETLA: sm0.(SimMemInjInv.minj).(SimMemInj.inj) blk_src = Some (blk_tgt, delta)),
blk_tgt <> stk)
(NOTEXT: forall
ofs,
~ sm0.(SimMemInjInv.minj).(SimMemInj.tgt_external) stk ofs)
(NINV: ~ sm0.(SimMemInjInv.mem_inv_tgt) stk)
(CURRPC: curr_pc (rs PC) (Ptrofs.repr 12))
(ARG: rs RBX = Vint i)
(FARG: rs RDI = Vint (Int.sub i (Int.repr 1)))
(RANGE: 0 < i.(Int.intval) < MAX)
(IDX: (idx > 6)%nat)
:
match_states idx (Interstate i m_src)
(AsmC.mkstate init_rs (Asm.State rs m_tgt)) sm0
| match_states_after_external
idx m_src sm0
i stk initstk init_rs rs m_tgt
(MCOMPATSRC: m_src = sm0.(SimMem.src))
(MCOMPATTGT: m_tgt = sm0.(SimMem.tgt))
(MWF: SimMem.wf sm0)
(SAVED: well_saved initstk stk init_rs rs m_tgt)
(PRIV: forall
blk_src blk_tgt delta
(DETLA: sm0.(SimMemInjInv.minj).(SimMemInj.inj) blk_src = Some (blk_tgt, delta)),
blk_tgt <> stk)
(NOTEXT: forall
ofs,
~ sm0.(SimMemInjInv.minj).(SimMemInj.tgt_external) stk ofs)
(NINV: ~ sm0.(SimMemInjInv.mem_inv_tgt) stk)
(CURRPC: curr_pc (rs PC) (Ptrofs.repr 13))
(ARG: rs RBX = Vint i)
(SUM: rs RAX = Vint (sum (Int.sub i Int.one)))
(RANGE: 0 < i.(Int.intval) < MAX)
(IDX: (idx > 3)%nat)
:
match_states idx (Returnstate (sum i) m_src)
(AsmC.mkstate init_rs (Asm.State rs m_tgt))sm0
| match_states_final
idx m_src sm0
i stk initstk init_rs rs m_tgt
(MCOMPATSRC: m_src = sm0.(SimMem.src))
(MCOMPATTGT: m_tgt = sm0.(SimMem.tgt))
(MWF: SimMem.wf sm0)
(SAVED: well_saved initstk stk init_rs rs m_tgt)
(PRIV: forall
blk_src blk_tgt delta
(DETLA: sm0.(SimMemInjInv.minj).(SimMemInj.inj) blk_src = Some (blk_tgt, delta)),
blk_tgt <> stk)
(NOTEXT: forall
ofs,
~ sm0.(SimMemInjInv.minj).(SimMemInj.tgt_external) stk ofs)
(NINV: ~ sm0.(SimMemInjInv.mem_inv_tgt) stk)
(CURRPC: curr_pc (rs PC) (Ptrofs.repr 20))
(ARG: rs RAX = Vint i)
(IDX: (idx >= 2)%nat)
:
match_states idx (Returnstate i m_src)
(AsmC.mkstate init_rs (Asm.State rs m_tgt)) sm0
.
Lemma f_blk_exists
:
exists f_blk,
(<<FINDF: Genv.find_symbol
(SkEnv.revive (SkEnv.project skenv_link (Sk.of_program fn_sig prog)) prog)
f_id = Some f_blk>>)
/\
(<<FINDF: Genv.find_funct_ptr
(SkEnv.revive (SkEnv.project skenv_link (Sk.of_program fn_sig prog)) prog)
f_blk = None>>)
/\
(<<FINDF: exists skd, Genv.find_funct_ptr skenv_link f_blk = Some skd /\
Some (mksignature (AST.Tint :: nil) (Some AST.Tint) cc_default true) = Sk.get_csig skd>>)
.
Proof.
exploit (prog_defmap_norepet prog f_id); eauto.
{ unfold prog_defs_names. ss. repeat (econs; eauto).
- ii; ss; des; ss.
- ii; ss; des; ss. }
{ ss. eauto. }
intro T; des.
destruct ((prog_defmap (Sk.of_program fn_sig prog)) ! f_id) eqn:DMAP; clarify.
exploit SkEnv.project_impl_spec; eauto. intro PROJ.
assert(PREC: SkEnv.genv_precise
(SkEnv.revive (SkEnv.project skenv_link (Sk.of_program fn_sig prog)) prog)
prog).
{ eapply SkEnv.project_revive_precise; ss; et. }
inv PREC.
exploit (P2GE f_id); eauto. i; des. des_ifs.
rename b into f_blk.
eexists. splits; et.
{ unfold Genv.find_funct_ptr. des_ifs. }
{ inv INCL.
exploit (Sk.of_program_prog_defmap prog fn_sig); et. rewrite DMAP. intro S. ss.
remember ((prog_defmap (Sk.of_program fn_sig prog)) ! f_id) as U in *.
destruct U eqn:V; try (by ss). inv S. inv H1.
exploit DEFS; eauto. i; des.
assert(blk = f_blk).
{ inv PROJ. exploit SYMBKEEP; et.
- instantiate (1:= f_id). unfold defs. des_sumbool. ss. et.
- i. rewrite SYMB0 in *. clear - SYMB H. unfold SkEnv.revive in *. rewrite Genv_map_defs_symb in *. ss.
rewrite SYMB in *. des. clarify.
}
clarify. inv MATCH.
esplits; eauto.
- unfold Genv.find_funct_ptr. rewrite DEF0. et.
- ss. des_ifs. clear - H. inv H; ss.
- ss.
}
Qed.
(* from DempProof *)
Lemma E0_double:
E0 = E0 ** E0.
Proof. auto. Qed.
Hint Resolve E0_double.
Lemma match_states_lxsim
idx st_src0 st_tgt0 sm0
(SIMSK: SimSymb.sim_skenv
sm0 (SimMemInjInvC.mk symbol_memoized md_src md_tgt)
(SkEnv.project skenv_link (Sk.of_program fn_sig prog))
(SkEnv.project skenv_link (Sk.of_program fn_sig prog)))
(MATCH: match_states idx st_src0 st_tgt0 sm0)
:
<<XSIM: lxsimL (md_src skenv_link) (md_tgt skenv_link)
(fun st => unit -> exists su m_init, SoundTop.sound_state su m_init st)
(top3) (fun _ _ => SimMem.le)
(Ord.lift_idx lt_wf idx) st_src0 st_tgt0 sm0>>
.
Proof.
destruct (Genv.find_symbol
((SkEnv.revive ((SkEnv.project skenv_link) (Sk.of_program fn_sig prog))) prog)
_memoized) as [b_memo|] eqn:BLK; cycle 1.
{ exfalso. clear - INCL BLK. inversion INCL; subst.
exploit DEFS; eauto.
- instantiate (2:=_memoized). ss.
- i. des.
exploit SkEnv.project_impl_spec. eapply INCL. i. inv H. ss.
exploit SYMBKEEP. instantiate (1:=_memoized). ss. i.
rr in H. rewrite <- H in *.
assert (Genv.find_symbol (SkEnv.revive (SkEnv.project skenv_link (Sk.of_program fn_sig prog)) prog) _memoized = Some blk).
{ ss. } clarify. }
revert_until tge.
pcofix CIH.
i. pfold.
generalize f_blk_exists; et. i; des.
inv MATCH.
(* initial *)
- intros _. inv CURRPC.
assert (CMP: compare_ints
(Val.and (rs RDI) (rs RDI)) Vzero
(rs # RBX <- (rs RDI)) # PC <- (Vptr blk (Ptrofs.add (Ptrofs.repr 2) Ptrofs.one))
(SimMemInj.tgt sm0.(SimMemInjInv.minj)) ZF = if (Int.eq_dec i Int.zero) then Vtrue else Vfalse).
{ unfold compare_ints, nextinstr, Val.cmpu.
repeat (rewrite Pregmap.gso; [| clarify; fail]).
repeat rewrite Pregmap.gss.
rewrite ARG. ss. rewrite Int.and_idem.
exploit Int.eq_spec; eauto. i. des_ifs. }
destruct (classic (i = Int.zero)).
(* i = Int.zero *)
+ clarify. econs 1. i. econs.
* split; ii.
{ inv H. inv H0. }
{ inv H. inv H0. }
* i. ss. inv STEPSRC; ss.
esplits.
{ left. econs; eauto.
{ instantiate (1:=AsmC.mkstate _ _). split.
- eapply modsem_determinate; eauto.
- ss. econs; ss. econs; eauto.
+ des_ifs.
+ ss. }
econs 2; eauto.
{ instantiate (1:=AsmC.mkstate _ _). split.
- eapply modsem_determinate; eauto.
- ss. econs; ss. econs; eauto.
+ unfold nextinstr.
rewrite Pregmap.gss.
rewrite Pregmap.gso; clarify.
rewrite RSPC. ss.
+ des_ifs.
+ ss. }
econs 2; eauto.
{ instantiate (1:=AsmC.mkstate _ _). split.
- eapply modsem_determinate; eauto.
- ss. econs; ss. econs; eauto.
+ unfold nextinstr.
repeat rewrite Pregmap.gss.
repeat (rewrite Pregmap.gso; [| clarify; fail]).
repeat rewrite Pregmap.gss.
repeat (rewrite Pregmap.gso; [| clarify; fail]).
rewrite RSPC. ss.
+ des_ifs.
+ ss.
unfold nextinstr.
repeat rewrite Pregmap.gss.
repeat (rewrite Pregmap.gso; [| clarify; fail]).
repeat rewrite Pregmap.gss.
repeat (rewrite Pregmap.gso; [| clarify; fail]).
rewrite RSPC. ss. rewrite CMP. ss. }
econs 2; eauto.
{ instantiate (1:=AsmC.mkstate _ _). split.
- eapply modsem_determinate; eauto.
- ss. econs; ss. econs; eauto.
+ unfold nextinstr.
rewrite Pregmap.gss. ss.
+ des_ifs.
+ ss. }
econs 2; eauto.
{ instantiate (1:=AsmC.mkstate _ _). split.
- eapply modsem_determinate; eauto.
- ss. econs; ss. econs; eauto.
+ unfold nextinstr_nf, undef_regs, nextinstr. ss.
+ des_ifs.
+ ss. }
econs 1.
}
{ refl. }
{ right. eapply CIH; eauto. econs 4; eauto.
- eapply well_saved_keep; eauto.
+ unfold is_callee_save, nextinstr_nf, nextinstr, undef_regs,
to_preg, preg_of, compare_ints, Pregmap.set.
ii. des_ifs.
+ refl.
- ss.
unfold nextinstr_nf, nextinstr, undef_regs.
repeat rewrite Pregmap.gss. econs; eauto.
- ss.
unfold nextinstr_nf, nextinstr, undef_regs.
repeat (rewrite Pregmap.gso; [| clarify; fail]).
repeat rewrite Pregmap.gss.
unfold Vzero. rewrite sum_recurse. des_ifs. }
* econs; ss.
{ ii. inv H; ss.
eexists. inv H0. econs. }
{ ii. inv H; ss; nia. }
(* i <> Int.zero *)
+ cinv MWF. ss.
assert (INVAR: SimMemInjInv.mem_inv_tgt sm0 b_memo).
{ inv SIMSK. ss. inv INJECT.
eapply INVCOMPAT; eauto. ss. }
exploit SATTGT; eauto. intros SAT0. inv SAT0. ss.
des. rename i0 into x.
assert (CMP0:
nextinstr
(compare_ints
(nextinstr_nf
(((compare_ints (Val.and (rs RDI) (rs RDI)) Vzero
(rs # RBX <- (rs RDI)) # PC <-
(Vptr blk (Ptrofs.add (Ptrofs.repr 2) Ptrofs.one))
(SimMemInj.tgt sm0.(SimMemInjInv.minj))) # PC <-
(Vptr blk (Ptrofs.add (Ptrofs.add (Ptrofs.repr 2) Ptrofs.one) Ptrofs.one)))
# PC <- (Vptr blk (Ptrofs.repr 8))) # RAX <- (Vint x) RBX)
(nextinstr_nf
(((compare_ints (Val.and (rs RDI) (rs RDI)) Vzero
(rs # RBX <- (rs RDI)) # PC <-
(Vptr blk (Ptrofs.add (Ptrofs.repr 2) Ptrofs.one))
(SimMemInj.tgt sm0.(SimMemInjInv.minj))) # PC <-
(Vptr blk (Ptrofs.add (Ptrofs.add (Ptrofs.repr 2) Ptrofs.one) Ptrofs.one)))
# PC <- (Vptr blk (Ptrofs.repr 8))) # RAX <- (Vint x) RAX)
(nextinstr_nf
(((compare_ints (Val.and (rs RDI) (rs RDI)) Vzero
(rs # RBX <- (rs RDI)) # PC <-
(Vptr blk (Ptrofs.add (Ptrofs.repr 2) Ptrofs.one))
(SimMemInj.tgt sm0.(SimMemInjInv.minj))) # PC <-
(Vptr blk (Ptrofs.add (Ptrofs.add (Ptrofs.repr 2) Ptrofs.one) Ptrofs.one)))
# PC <- (Vptr blk (Ptrofs.repr 8))) # RAX <- (Vint x))
(SimMemInj.tgt sm0.(SimMemInjInv.minj))) ZF =
if (Int.eq_dec x i) then Vtrue else Vfalse).
{ unfold compare_ints at 1.
unfold nextinstr_nf, undef_regs, nextinstr.
repeat (rewrite Pregmap.gso; [| clarify; fail]).
repeat rewrite Pregmap.gss. ss.
repeat (rewrite Pregmap.gso; [| clarify; fail]).
repeat rewrite Pregmap.gss. ss.
unfold Val.cmpu, Val.of_optbool, Val.cmpu_bool. ss.
unfold compare_ints.
repeat (rewrite Pregmap.gso; [| clarify; fail]).
repeat rewrite Pregmap.gss.
rewrite ARG.
exploit Int.eq_spec; eauto. i. des_ifs. }
destruct (Int.eq_dec x i).
(* already memoized *)
{ clarify. econs 2. i. splits.
- econs 2.
+ split.
* apply star_one. ss. econs 1.
* eapply Ord.lift_idx_spec. eauto.
+ refl.
+ left. pfold. intros _. econs 1. i. econs 2.
* esplits.
{
econs; eauto.
{ instantiate (1:=AsmC.mkstate _ _). split.
- eapply modsem_determinate; eauto.
- ss. econs; ss. econs; eauto.
+ des_ifs.
+ ss. }
econs 2; eauto.
{ instantiate (1:=AsmC.mkstate _ _). split.
- eapply modsem_determinate; eauto.
- ss. econs; ss. econs; eauto.
+ unfold nextinstr.
rewrite Pregmap.gss.
rewrite Pregmap.gso; clarify.
rewrite RSPC. ss.
+ des_ifs.
+ ss. }
econs 2; eauto.
{ instantiate (1:=AsmC.mkstate _ _). split.
- eapply modsem_determinate; eauto.
- ss. econs; ss. econs; eauto.
+ unfold nextinstr.
repeat rewrite Pregmap.gss.
repeat (rewrite Pregmap.gso; [| clarify; fail]).
repeat rewrite Pregmap.gss.
repeat (rewrite Pregmap.gso; [| clarify; fail]).
rewrite RSPC. ss.
+ des_ifs.
+ ss.
unfold nextinstr.
repeat rewrite Pregmap.gss.
repeat (rewrite Pregmap.gso; [| clarify; fail]).
repeat rewrite Pregmap.gss.
repeat (rewrite Pregmap.gso; [| clarify; fail]).
rewrite RSPC. ss. rewrite CMP. des_ifs.
exfalso. unfold Vfalse in *. clarify. }
econs 2; eauto.
{ instantiate (1:=AsmC.mkstate _ _). split.
- eapply modsem_determinate; eauto.
- ss. econs; ss. econs; eauto.
+ unfold nextinstr.
repeat rewrite Pregmap.gss. ss.
+ des_ifs.
+ ss. unfold exec_load, eval_addrmode. ss.
unfold Genv.symbol_address. ss. rewrite BLK. psimpl.
des_ifs_safe. ss. psimpl.
replace (Ptrofs.unsigned (Ptrofs.of_int64 Int64.zero)) with 0; cycle 1.
{ unfold Int64.zero.
exploit Ptrofs.of_int64_to_int64; eauto. }
rewrite VINDEX. ss. }
econs 2; eauto.
{ instantiate (1:=AsmC.mkstate _ _). split.
- eapply modsem_determinate; eauto.
- ss. econs; ss. econs; eauto.
+ unfold nextinstr_nf, undef_regs, nextinstr.
repeat rewrite Pregmap.gss. ss.
+ des_ifs.
+ ss. }
econs 2; eauto.
{ instantiate (1:=AsmC.mkstate _ _). split.
- eapply modsem_determinate; eauto.
- ss. econs; ss. econs; eauto.
+ unfold nextinstr_nf, undef_regs, nextinstr.
repeat rewrite Pregmap.gss. ss.
+ des_ifs.
+ ss. rewrite CMP0. ss. }
econs 2; eauto.
{ instantiate (1:=AsmC.mkstate _ _). split.
- eapply modsem_determinate; eauto.
- ss. econs; ss. econs; eauto.
+ unfold nextinstr.
repeat rewrite Pregmap.gss. ss.
+ des_ifs.
+ ss. unfold exec_load, eval_addrmode. ss.
unfold Genv.symbol_address. ss. rewrite BLK. psimpl.
des_ifs_safe. ss.
replace (Ptrofs.unsigned (Ptrofs.add (Ptrofs.repr 4) (Ptrofs.of_int64 Int64.zero))) with 4; cycle 1.
{ exploit Ptrofs.of_int64_to_int64; eauto. }
rewrite VSUM. ss. }
econs 2; eauto.
{ instantiate (1:=AsmC.mkstate _ _). split.
- eapply modsem_determinate; eauto.
- ss. econs; ss. econs; eauto.
+ unfold nextinstr.
repeat rewrite Pregmap.gss. ss.
+ des_ifs.
+ ss. }
econs 1.
}
{ eapply Ord.lift_idx_spec. eauto. }
* refl.
* right. eapply CIH; eauto.
econs 4; eauto.
{ eapply well_saved_keep; eauto.
- unfold is_callee_save, nextinstr_nf, nextinstr, undef_regs,
to_preg, preg_of, compare_ints, Pregmap.set.
destruct mr; ss.
- refl. }
{ unfold nextinstr_nf, nextinstr.
repeat rewrite Pregmap.gss. ss. econs; eauto. }
{ omega. }
}
(* not memoized *)
{ clarify. econs 2. i. splits.
- econs 2.
+ split.
* apply star_one. ss. econs 2.
exploit Int.eq_false. eapply H. ii.
unfold Int.eq in H0. des_ifs.
* eapply Ord.lift_idx_spec. eauto.
+ refl.
+ left. pfold. intros _. econs 1. i. econs 2.
* esplits.
{
econs; eauto.
{ instantiate (1:=AsmC.mkstate _ _). split.
- eapply modsem_determinate; eauto.
- ss. econs; ss. econs; eauto.
+ des_ifs.
+ ss. }
econs 2; eauto.
{ instantiate (1:=AsmC.mkstate _ _). split.
- eapply modsem_determinate; eauto.
- ss. econs; ss. econs; eauto.
+ unfold nextinstr.
rewrite Pregmap.gss.
rewrite Pregmap.gso; clarify.
rewrite RSPC. ss.
+ des_ifs.
+ ss. }
econs 2; eauto.
{ instantiate (1:=AsmC.mkstate _ _). split.
- eapply modsem_determinate; eauto.
- ss. econs; ss. econs; eauto.
+ unfold nextinstr.
repeat rewrite Pregmap.gss.
repeat (rewrite Pregmap.gso; [| clarify; fail]).
repeat rewrite Pregmap.gss.
repeat (rewrite Pregmap.gso; [| clarify; fail]).
rewrite RSPC. ss.
+ des_ifs.
+ ss.
unfold nextinstr.
repeat rewrite Pregmap.gss.
repeat (rewrite Pregmap.gso; [| clarify; fail]).
repeat rewrite Pregmap.gss.
repeat (rewrite Pregmap.gso; [| clarify; fail]).
rewrite RSPC. ss. rewrite CMP.
simpl. des_ifs.
unfold Vfalse in *. clarify. }
econs 2; eauto.
{ instantiate (1:=AsmC.mkstate _ _). split.
- eapply modsem_determinate; eauto.
- ss. econs; ss. econs; eauto.
+ unfold nextinstr.
repeat rewrite Pregmap.gss. ss.
+ des_ifs.
+ ss. unfold exec_load, eval_addrmode. ss.
unfold Genv.symbol_address. ss. rewrite BLK. psimpl.
des_ifs_safe. ss. psimpl.
replace (Ptrofs.unsigned (Ptrofs.of_int64 Int64.zero)) with 0; cycle 1.
{ unfold Int64.zero.
exploit Ptrofs.of_int64_to_int64; eauto. }
rewrite VINDEX. ss. }
econs 2; eauto.
{ instantiate (1:=AsmC.mkstate _ _). split.
- eapply modsem_determinate; eauto.
- ss. econs; ss. econs; eauto.
+ unfold nextinstr_nf, undef_regs, nextinstr.
repeat rewrite Pregmap.gss. ss.
+ des_ifs.
+ ss. }
econs 2; eauto.
{ instantiate (1:=AsmC.mkstate _ _). split.
- eapply modsem_determinate; eauto.
- ss. econs; ss. econs; eauto.
+ unfold nextinstr_nf, undef_regs, nextinstr.
repeat rewrite Pregmap.gss. ss.
+ des_ifs.
+ ss. rewrite CMP0. ss. }
econs 2; eauto.
{ instantiate (1:=AsmC.mkstate _ _). split.
- eapply modsem_determinate; eauto.
- ss. econs; ss. econs; eauto.
+ unfold nextinstr.
repeat rewrite Pregmap.gss. ss.
+ des_ifs.
+ ss. }
econs 1.
}
{ eapply Ord.lift_idx_spec. eauto. }
* refl.
* right. eapply CIH; eauto.
econs 2; eauto.
{ eapply well_saved_keep; eauto.
- unfold is_callee_save, nextinstr_nf, nextinstr, undef_regs,
to_preg, preg_of, compare_ints, Pregmap.set.
destruct mr; ss.
- refl. }
{ unfold nextinstr_nf, nextinstr.
repeat rewrite Pregmap.gss. ss. econs; eauto. }
{ unfold nextinstr_nf, nextinstr.
repeat rewrite Pregmap.gss.
repeat (rewrite Pregmap.gso; [| clarify; fail]). ss.
repeat rewrite Pregmap.gss.
repeat (rewrite Pregmap.gso; [| clarify; fail]). ss.
repeat rewrite Pregmap.gss.
unfold compare_ints.
repeat (rewrite Pregmap.gso; [| clarify; fail]). ss.
repeat rewrite Pregmap.gss.
rewrite ARG. ss. f_equal.
rewrite Int.add_zero_l.
rewrite Int.add_signed. rewrite Int.sub_signed. ss. }
{ exploit Int.eq_false. eapply H. i.
unfold Int.eq in H0.
rewrite Int.unsigned_zero in H0.
des_ifs. split; eauto. destruct i. ss. omega. }
}
- intros _. inv CURRPC.
econs 1. i. econs 2.
{ split.
- instantiate (1:=AsmC.mkstate _ _). apply plus_one. split.
+ eapply modsem_determinate; eauto.
+ ss. econs; ss. econs; eauto.
* des_ifs.
* ss.
- eapply Ord.lift_idx_spec. eauto. }
{ refl. }
left. pfold. intros _. econs 3; eauto.
+ econs; eauto. econs; eauto.
+ ii.
hexploit Mem.range_perm_free.
{ instantiate (1:=0).
instantiate (1:=0).
instantiate (1:=stk).
instantiate (1:=SimMem.tgt sm0).
ii. lia. } intros [m_tgt FREE].
cinv MWF.
hexploit (@SimMemInjInvC.unchanged_on_mle
SimMemInjInv.top_inv memoized_inv sm0
sm0.(SimMemInjInv.minj).(SimMemInj.src) m_tgt sm0.(SimMemInjInv.minj).(SimMemInj.inj)); ss; eauto.
{ eapply private_unchanged_inject; eauto.
- cinv WF0. eauto.
- instantiate (1:=~2
loc_out_of_reach (SimMemInj.inj (SimMemInjInv.minj sm0))
(SimMemInj.src (SimMemInjInv.minj sm0))).
eapply Mem.free_unchanged_on; eauto.
ii. omega.
- ss. }
{ ii. clarify. }
{ refl. }
{ eapply Mem.free_unchanged_on; eauto. ii. omega. }
{ ii. eapply Mem.perm_free_3; eauto. }
i. des.
cinv SAVED. inv ATSRC.
eexists (Args.mk _ [Vint (Int.sub i (Int.repr 1))] _).
esplits; eauto.
* econs; ss; eauto.
instantiate (1:=Vptr g_fptr Ptrofs.zero).
inv SIMSK. inv SIMSKENV. inv INJECT. ss.
econs. eapply DOMAIN; eauto.
exploit Genv.genv_symb_range. unfold Genv.find_symbol in *. eauto.
i. ss. ii.
exploit INVCOMPAT; eauto. i. rewrite <- H0 in H. ss.
rewrite Ptrofs.add_zero_l. ss.
* econs 1; eauto.
{ repeat rewrite Pregmap.gss. ss.
unfold Genv.symbol_address.
assert (Genv.find_symbol
(SkEnv.revive (SkEnv.project skenv_link (Sk.of_program fn_sig prog)) prog) f_id = Some g_fptr) by ss.
rewrite H. ss. }
{ unfold Genv.find_funct. des_ifs.
unfold Genv.find_funct_ptr. des_ifs.
unfold Genv.find_def in Heq. ss.
do 2 rewrite MapsC.PTree_filter_map_spec, o_bind_ignore in *.
des_ifs.
exploit Genv.find_invert_symbol. eauto. i. rewrite H in *.
unfold o_bind in Heq. ss. clarify.
destruct (Genv.invert_symbol skenv_link g_fptr) eqn:SYMB.
unfold o_bind in Heq0. ss. des_ifs.
exploit SkEnv.project_impl_spec. eapply INCL. i. inv H0. ss.
destruct ((prog_defmap (Sk.of_program fn_sig prog)) ! i0) eqn:DMAP; ss.
assert (defs (Sk.of_program fn_sig prog) i0).
{ rewrite <- defs_prog_defmap. eauto. }
exploit SYMBKEEP; eauto. i. rr in H1.
clarify. exploit Genv.invert_find_symbol. eapply SYMB. i.
rewrite <- H1 in H2. exploit Genv.find_invert_symbol; eauto. i.
rewrite H3 in *. clarify.
unfold o_bind in Heq0. ss. }
{ destruct ((prog_defmap (Sk.of_program fn_sig prog)) ! f_id) eqn:DMAP; clarify.
assert (DEFS0: defs (Sk.of_program fn_sig prog) f_id).
{ rewrite <- defs_prog_defmap. eauto. }
exploit SkEnv.project_impl_spec. eapply INCL. i. inv H.
inv INCL.
exploit DEFS; eauto. i. des.
exploit SYMBKEEP; eauto. i. rr in H.
rewrite H in *. rewrite FINDG in *. ss. clarify.
inv MATCH. ss. inv H1; des_ifs; esplits; try rewrite Genv.find_funct_ptr_iff; eauto; ss. }
{ split; ss.
- repeat (rewrite Pregmap.gso; [| clarify; fail]).
rewrite Pregmap.gss. rewrite RSPC. ss.
- repeat (rewrite Pregmap.gso; [| clarify; fail]).
rewrite Pregmap.gss. rewrite RSPC. ss. }
{ econs; eauto.
- econs; eauto. ss.
rpapply extcall_arg_reg. ss.
- econs. }
{ zsimpl. psimpl. inv WF.
rewrite Genv.find_funct_ptr_iff in FINDF1.
eapply WFPARAM in FINDF1. generalize (size_arguments_above (Sk.get_sig skd)); i. etrans; eauto. xomega. }
{ ii. apply Z.divide_0_r. }
{ ss. }
* i. inv AFTERSRC. ss. inv SIMRETV; ss.
exploit Mem_unfree_suceeds.
{ instantiate (1:=stk).
instantiate (1:=SimMemInj.tgt sm_ret.(SimMemInjInv.minj)).
inv MLE0. inv MLE1. ss.
unfold Mem.valid_block. eapply Plt_Ple_trans; eauto.
- eapply Mem.perm_valid_block; eauto.
eapply STKPERM; eauto. instantiate (1:=0). lia.
- erewrite <- Mem.nextblock_free; eauto.
eapply Mem.unchanged_on_nextblock; eauto. } i. des.
exploit Mem_unfree_right_inject; try apply UNFR; eauto.
{ inv MWF1. inv WF1. eauto. }
{ instantiate (1:=0). instantiate (1:=0). ii. lia. } intros INJ.
eapply SimMemInjInvC.unlift_wf in MWF1; try apply MLE0; eauto.
dup MLE0. eapply SimMemInjInvC.unlift_spec in MLE0; eauto.
exploit SimMemInjInvC.unchanged_on_mle; eauto.
{ ss. ii. clarify. }
{ refl. }
{ eapply Mem.unchanged_on_implies.
- eapply Mem_unfree_unchanged_on; eauto.
- unfold brange. ii. des. lia. }
{ ii. eapply Mem_unfree_unchanged_on; eauto.
unfold brange. ii. des. lia. } i. des.
eexists.
eexists (SimMemInjInv.mk
(SimMemInj.mk
(SimMemInj.src sm_ret.(SimMemInjInv.minj))
m1 _ _ _ _ _ _ _) _ _).
esplits; ss.
{ econs; ss; eauto.
- instantiate (1:=mksignature [AST.Tint] (Some AST.Tint) cc_default true).
assert (SYMBREV: Genv.find_symbol
(SkEnv.revive (SkEnv.project skenv_link (Sk.of_program fn_sig prog)) prog) f_id = Some g_fptr) by ss.
unfold Genv.symbol_address. rewrite SYMBREV. ss. des_ifs.
destruct ((prog_defmap (Sk.of_program fn_sig prog)) ! f_id) eqn:DMAP; clarify.
assert (DEFS0: defs (Sk.of_program fn_sig prog) f_id).
{ rewrite <- defs_prog_defmap. eauto. }
exploit SkEnv.project_impl_spec. eapply INCL. i. inv H.
inv INCL. exploit DEFS; eauto.
- unfold size_arguments. des_ifs. ss. psimpl. eauto. }
{ etrans; eauto. refl. }
{ right. eapply CIH; eauto.
{ exploit SimSymb.mle_preserves_sim_skenv; ss; cycle 1; eauto.
etrans; eauto. etrans; eauto. }
econs 3; ss; eauto.
- eapply well_saved_keep; eauto.
+ unfold is_callee_save, nextinstr_nf, nextinstr, undef_regs,
to_preg, preg_of, compare_ints, Pregmap.set.
destruct mr; ss.
+ etrans.
{ eapply Mem.free_unchanged_on; eauto. clear. ii. lia. }
etrans.
{ inv MLE1. ss. inv MLE3. ss.
eapply Mem.unchanged_on_implies; eauto.
ii. clarify. split; auto. split; ss; auto.
ii. eapply PRIV; eauto. }
{ eapply Mem.unchanged_on_implies; eauto.
- eapply Mem_unfree_unchanged_on; eauto.
- clear. ii. destruct H1. lia. }
- inv MLE0. ss. inv MLE3. ss. ii. clarify.
destruct (SimMemInj.inj (SimMemInjInv.minj sm0) blk_src) eqn:BLK0.
+ destruct p. dup BLK0. eapply INCR in BLK0.
clarify. hexploit PRIV; eauto.
+ inv MLE1. ss. inv MLE0. ss. inv FROZEN0.
exploit NEW_IMPLIES_OUTSIDE; eauto. i. des.
inv SAVED. eapply (Plt_strict stk).
eapply Plt_Ple_trans; eauto.
eapply Mem.nextblock_free in FREE. rewrite FREE.
eapply Mem.perm_valid_block; eauto.
eapply STKPERM; eauto. instantiate (1:=0). clear. lia.
- repeat rewrite Pregmap.gss. rewrite RSPC.
repeat (rewrite Pregmap.gso; [| clarify; fail]).
repeat rewrite Pregmap.gss. ss. econs; eauto.
- unfold set_pair, loc_external_result, loc_result. des_ifs_safe. ss.
clarify.
repeat (rewrite Pregmap.gso; [| clarify; fail]).
repeat rewrite Pregmap.gss. inv RETV; eauto. }
- intros _. econs 1. i. cinv CURRPC.
cinv MWF. ss.
assert (INVAR: SimMemInjInv.mem_inv_tgt sm0 b_memo).
{ inv SIMSK. ss. inv INJECT.
eapply INVCOMPAT; eauto. ss. }
hexploit SATTGT; eauto. intros SAT0.
specialize (SAT0 _ INVAR). destruct SAT0. des. des_ifs_safe.
hexploit Mem.valid_access_store.
{ eapply PERMISSIONS. ss. left. eauto. } intros [m_tgt0 STR0].
hexploit Mem.valid_access_store.
{ eapply Mem.store_valid_access_1; eauto.
eapply PERMISSIONS. ss. right. eauto. } intros [m_tgt1 STR1].
hexploit memoized_inv_store_le; try refl; eauto.
instantiate (1:=i) in STR0. i. des.
econs 2.
+ split.
* econs 1; eauto.
{ instantiate (1:=AsmC.mkstate _ _). split.
- eapply modsem_determinate; eauto.
- ss. econs; ss. econs; eauto.
+ des_ifs.
+ ss. }
econs 2; eauto.
{ instantiate (1:=AsmC.mkstate _ _). split.
- eapply modsem_determinate; eauto.
- ss. econs; ss. econs; eauto.
+ unfold nextinstr.
repeat rewrite Pregmap.gss.
repeat (rewrite Pregmap.gso; [| clarify; fail]).
rewrite RSPC. ss.
+ des_ifs.
+ ss.
unfold exec_store, Mem.storev, eval_addrmode. ss.
des_ifs_safe. unfold Genv.symbol_address. rewrite BLK.
psimpl. unfold nextinstr at 1.
repeat (rewrite Pregmap.gso; [| clarify; fail]).
rewrite ARG.
replace (Ptrofs.unsigned (Ptrofs.of_int64 Int64.zero)) with 0; cycle 1.
{ unfold Int64.zero.
exploit Ptrofs.of_int64_to_int64; eauto. }
rewrite STR0.
ss. }
econs 2; eauto.
{ instantiate (1:=AsmC.mkstate _ _). split.