Changeset 2992 for src/Cminor
- Timestamp:
- Mar 28, 2013, 12:07:56 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Cminor/toRTLabs.ma
r2971 r2992 181 181 ; pf_entry : Σl:label. present ?? pf_graph l 182 182 ; pf_exit : Σl:label. present ?? pf_graph l 183 ; pf_only_exit : ∀l. lookup … pf_graph l = Some ? St_return → l = pf_exit 183 184 }. 184 185 … … 247 248 ] qed. 248 249 250 definition not_return : statement → Prop ≝ 251 λs. match s with [ St_return ⇒ False | _ ⇒ True ]. 252 249 253 (* Add a statement to the graph, *without* updating the entry label. *) 250 definition fill_in_statement : ∀fx. label → ∀s:statement. ∀f:partial_fn fx.254 definition fill_in_statement : ∀fx. label → ∀s:statement. not_return s → ∀f:partial_fn fx. 251 255 labels_present (pf_graph … f) s → 252 256 statement_typed_in … f s → 253 257 Σf':partial_fn fx. fn_contains … f f' ≝ 254 λfx,l,s, f,p,tp.258 λfx,l,s,NR,f,p,tp. 255 259 mk_partial_fn fx (pf_labgen … f) (pf_reggen … f) 256 260 (pf_params … f) (pf_locals … f) (pf_result … f) (pf_envok … f) 257 261 (pf_stacksize … f) (add ?? (pf_graph … f) l s) ? 258 262 (mk_goto_map … (pf_gotos … f) ??) «pf_labels … f, ?» ? 259 «pf_entry … f, ?» «pf_exit … f, ?» .263 «pf_entry … f, ?» «pf_exit … f, ?» ?. 260 264 [ @add_statement_inv @p 261 265 | @gm_img … … 264 268 | @forall_nodes_add // 265 269 | 6,7: @lookup_add_oblivious [ @(pi2 … (pf_entry … f)) | @(pi2 … (pf_exit … f)) ] 270 | #l' #L cases (lookup_add_cases ??????? L) 271 [ * #_ #R @⊥ <R in NR; * 272 | @(pf_only_exit … f) 273 ] 266 274 | % [ #l' @lookup_add_oblivious | // | cases (pf_labels fx f) /2/ ] 267 275 ] qed. 268 276 269 277 (* Add a statement to the graph, making it the entry label. *) 270 definition add_to_graph : ∀fx. label → ∀s:statement. ∀f:partial_fn fx.278 definition add_to_graph : ∀fx. label → ∀s:statement. not_return s → ∀f:partial_fn fx. 271 279 labels_present (pf_graph … f) s → 272 280 statement_typed_in … f s → 273 281 Σf':partial_fn fx. fn_contains … f f' ≝ 274 λfx,l,s, f,p,tl.282 λfx,l,s,NR,f,p,tl. 275 283 mk_partial_fn fx (pf_labgen … f) (pf_reggen … f) 276 284 (pf_params … f) (pf_locals … f) (pf_result … f) (pf_envok … f) 277 285 (pf_stacksize … f) (add ?? (pf_graph … f) l s) ???? 278 «l, ?» «pf_exit … f, ?» .286 «l, ?» «pf_exit … f, ?» ?. 279 287 [ @add_statement_inv @p 280 288 | cases (pf_gotos … f) #m #dom #img % … … 284 292 | whd >lookup_add_hit % #E destruct 285 293 | @lookup_add_oblivious @(pi2 … (pf_exit … f)) 294 | #l' #L cases (lookup_add_cases ??????? L) 295 [ * #_ #R @⊥ <R in NR; * 296 | @(pf_only_exit … f) 297 ] 286 298 | % [ #l' @lookup_add_oblivious | // | cases (pf_labels fx f) /2/ ] 287 299 ] qed. … … 297 309 (pf_stacksize … f) (pf_graph … f) (pf_closed … f) (pf_gotos … f) 298 310 (pf_labels … f) (pf_typed … f) 299 «l, PR» (pf_exit … f) .311 «l, PR» (pf_exit … f) (pf_only_exit … f). 300 312 % // 301 313 qed. … … 306 318 (∀l. present ?? (pf_graph … f) l → labels_present (pf_graph … f) (s l)) → 307 319 (∀l. statement_typed_in … f (s l)) → 320 (∀l. not_return (s l)) → 308 321 Σf':partial_fn fx. fn_contains … f f' ≝ 309 λfx,s,f,p,tp .322 λfx,s,f,p,tp,NR. 310 323 let 〈l,g〉 ≝ fresh … (pf_labgen … f) in 311 324 let s' ≝ s (pf_entry … f) in … … 313 326 (pf_params … f) (pf_locals … f) (pf_result … f) (pf_envok … f) 314 327 (pf_stacksize … f) (add ?? (pf_graph … f) l s') ???? 315 «l, ?» «pf_exit … f, ?» ).328 «l, ?» «pf_exit … f, ?» ?). 316 329 [ 4: cases (pf_labels … f) #m #PR %{m} #l1 #l2 #L @lookup_add_oblivious @(PR … L) 317 330 | % [ #l' @lookup_add_oblivious | // | cases (pf_labels fx f) /2/ ] … … 322 335 | whd >lookup_add_hit % #E destruct 323 336 | @lookup_add_oblivious @(pi2 … (pf_exit …)) 337 | #l' #L cases (lookup_add_cases ??????? L) 338 [ * #_ #R @⊥ lapply (NR (pf_entry fx f)) whd in R:(???%); <R * 339 | @(pf_only_exit … f) 340 ] 324 341 ] qed. 325 342 … … 352 369 «mk_partial_fn fx 353 370 (pf_labgen … f) g (pf_params … f) (〈r,ty〉::(pf_locals … f)) ? ? 354 (pf_stacksize … f) (pf_graph … f) (pf_closed … f) (pf_gotos … f) (pf_labels … f) ? (pf_entry … f) (pf_exit … f) , ?»371 (pf_stacksize … f) (pf_graph … f) (pf_closed … f) (pf_gotos … f) (pf_labels … f) ? (pf_entry … f) (pf_exit … f) (pf_only_exit … f), ?» 355 372 in 356 373 ❬f' , ?(*«r, ?»*)❭. … … 486 503 match register_eq r dst with 487 504 [ inl _ ⇒ «f, ?» 488 | inr _ ⇒ «pi1 … (add_fresh_to_graph … (St_op1 t t (Oid t) dst r) f ?? ), ?»505 | inr _ ⇒ «pi1 … (add_fresh_to_graph … (St_op1 t t (Oid t) dst r) f ???), ?» 489 506 ] 490 | Cst _ c ⇒ λ_.λdst. «add_fresh_to_graph … (St_const ? dst c) f ?? , ?»507 | Cst _ c ⇒ λ_.λdst. «add_fresh_to_graph … (St_const ? dst c) f ???, ?» 491 508 | Op1 t t' op e' ⇒ λEnv,dst. 492 509 let ❬f,r❭ ≝ choose_reg … e' f Env in 493 let f ≝ add_fresh_to_graph … (St_op1 t' t op dst r) f ?? in510 let f ≝ add_fresh_to_graph … (St_op1 t' t op dst r) f ??? in 494 511 let f ≝ add_expr … ? e' Env f «r, ?» in 495 512 «pi1 … f, ?» … … 497 514 let ❬f,r1❭ ≝ choose_reg … e1 f (proj1 … Env) in 498 515 let ❬f,r2❭ ≝ choose_reg … e2 f (proj2 … Env) in 499 let f ≝ add_fresh_to_graph … (St_op2 ??? op dst r1 r2) f ?? in516 let f ≝ add_fresh_to_graph … (St_op2 ??? op dst r1 r2) f ??? in 500 517 let f ≝ add_expr … ? e2 (proj2 … Env) f «r2, ?» in 501 518 let f ≝ add_expr … ? e1 (proj1 … Env) f «r1, ?» in … … 503 520 | Mem t e' ⇒ λEnv,dst. 504 521 let ❬f,r❭ ≝ choose_reg … e' f Env in 505 let f ≝ add_fresh_to_graph … (St_load t r dst) f ?? in522 let f ≝ add_fresh_to_graph … (St_load t r dst) f ??? in 506 523 let f ≝ add_expr … ? e' Env f «r,?» in 507 524 «pi1 … f, ?» … … 510 527 let f ≝ add_expr … ? e2 (proj2 … Env) f dst in 511 528 let lfalse ≝ pf_entry … f in 512 let f ≝ add_fresh_to_graph … (λ_.St_skip resume_at) f ?? in529 let f ≝ add_fresh_to_graph … (λ_.St_skip resume_at) f ??? in 513 530 let f ≝ add_expr … ? e1 (proj2 … (proj1 … Env)) f «dst, ?» in 514 531 let ❬f,r❭ ≝ choose_reg … e' f ? in 515 let f ≝ add_fresh_to_graph … (λltrue. St_cond r ltrue lfalse) f ?? in532 let f ≝ add_fresh_to_graph … (λltrue. St_cond r ltrue lfalse) f ??? in 516 533 let f ≝ add_expr … ? e' (proj1 … (proj1 … Env)) f «r, ?» in 517 534 «pi1 … f, ?» 518 535 | Ecost _ l e' ⇒ λEnv,dst. 519 536 let f ≝ add_expr … ? e' Env f dst in 520 let f ≝ add_fresh_to_graph … (St_cost l) f ?? in537 let f ≝ add_fresh_to_graph … (St_cost l) f ??? in 521 538 «f, ?» 522 539 ] Env dst. … … 678 695 (pf_result … f) (pf_envok … f) (pf_stacksize … f) (pf_graph … f) 679 696 (pf_closed … f) (pf_gotos … f) «add … (pf_labels … f) l (pf_entry … f), ?» 680 (pf_typed … f) (pf_entry … f) (pf_exit … f) .697 (pf_typed … f) (pf_entry … f) (pf_exit … f) (pf_only_exit … f). 681 698 #l1 #l2 cases (identifier_eq … l2 (pf_entry … f)) 682 699 [ #E destruct #L @(pi2 … (pf_entry … f)) … … 695 712 (mk_partial_fn fx g (pf_reggen … f) 696 713 (pf_params … f) (pf_locals … f) (pf_result … f) (pf_envok … f) 697 (pf_stacksize … f) (add ?? (pf_graph … f) l St_return) ?714 (pf_stacksize … f) (add ?? (pf_graph … f) l (St_skip l)) ? 698 715 (mk_goto_map … (add … (pf_gotos … f) l dest) ??) 699 716 «pf_labels … f, ?» ? 700 «l, ?» «pf_exit … f, ?» ).717 «l, ?» «pf_exit … f, ?» ?). 701 718 [ % [ #l' @lookup_add_oblivious | // | cases (pf_labels fx f) /2/ ] 702 | @add_statement_inv @I 719 | #l' #s #L cases (lookup_add_cases ??????? L) 720 [ * #E1 #E2 destruct // 721 | #L' @(labels_P_mp … (pf_closed … f … L')) /2/ 722 ] 703 723 | #l1 #l2 cases (identifier_eq … l1 l) 704 724 [ #E destruct >lookup_add_hit #E destruct @PR … … 713 733 | whd >lookup_add_hit % #E destruct 714 734 | @lookup_add_oblivious @(pi2 … (pf_exit …)) 735 | #l' #L cases (lookup_add_cases ??????? L) 736 [ * #_ #R lapply (eq_to_jmeq ??? R) -R #R destruct (* XXX discr hack *) 737 | @(pf_only_exit … f) 738 ] 715 739 ] qed. 716 740 … … 731 755 let ❬f, val_reg❭ ≝ choose_reg … e2 f (π2 (si_vars … (π1 Env))) in 732 756 let ❬f, addr_reg❭ ≝ choose_reg … e1 f (π1 (si_vars … (π1 Env))) in 733 let f ≝ add_fresh_to_graph … (St_store t addr_reg val_reg) f ?? in757 let f ≝ add_fresh_to_graph … (St_store t addr_reg val_reg) f ??? in 734 758 let f ≝ add_expr … e1 (π1 (si_vars … (π1 Env))) f «addr_reg, ?» in 735 759 «pi1 … (add_expr … ? e2 (π2 (si_vars … (π1 Env))) f «val_reg, ?»), ?» … … 743 767 let f ≝ 744 768 match expr_is_cst_ident ? e with 745 [ Some id ⇒ add_fresh_to_graph … (St_call_id id args_regs return_opt_reg) f ?? 769 [ Some id ⇒ add_fresh_to_graph … (St_call_id id args_regs return_opt_reg) f ??? 746 770 | None ⇒ 747 771 let ❬f, fnr❭ ≝ choose_reg … e f (π2 (π1 (si_vars … (π1 Env)))) in 748 let f ≝ add_fresh_to_graph … (St_call_ptr fnr args_regs return_opt_reg) f ?? in772 let f ≝ add_fresh_to_graph … (St_call_ptr fnr args_regs return_opt_reg) f ??? in 749 773 «pi1 … (add_expr … ? e (π2 (π1 (si_vars … (π1 Env)))) f «fnr, ?»), ?» 750 774 ] in … … 761 785 let f1 ≝ add_stmt … s1 (π1 (π2 Env)) f in 762 786 let ❬f,r❭ ≝ choose_reg … e f1 (si_vars … (π1 Env)) in 763 let f ≝ add_fresh_to_graph … (λl1. St_cond r l1 l2) f ?? in787 let f ≝ add_fresh_to_graph … (λl1. St_cond r l1 l2) f ??? in 764 788 «pi1 … (add_expr … ? e (si_vars … (π1 Env)) f «r, ?»), ?» 765 789 | St_return opt_e ⇒ λEnv. add_return fx opt_e f Env … … 771 795 | St_cost l s' ⇒ λEnv. 772 796 let f ≝ add_stmt … s' (π2 Env) f in 773 «pi1 … (add_fresh_to_graph … (St_cost l) f ?? ), ?»797 «pi1 … (add_fresh_to_graph … (St_cost l) f ???), ?» 774 798 ] Env. 775 799 try @(π2 Env) … … 834 858 λfx,f,PR. 835 859 fold_inf ? (Σf':partial_fn fx. ∀l. present ?? (pf_labels … f) l → present ?? (pf_labels … f') l) ? (pf_gotos … f) 836 (λl,l',H,f'. «fill_in_statement fx l (St_skip (lookup_present ?? (pf_labels … f') l' ?)) f' ??, ?»)860 (λl,l',H,f'. «fill_in_statement fx l (St_skip (lookup_present ?? (pf_labels … f') l' ?)) I f' ??, ?») 837 861 «f, λx,H.H». 838 862 [ #l #PR' @(pi2 … f') @PR' … … 874 898 ? 875 899 l 876 l in 900 l 901 ? in 877 902 let f ≝ add_stmt fixed (f_body f) ? emptyfn in 878 903 let f ≝ patch_gotos … f ? in … … 889 914 (pf_entry … f) 890 915 (pf_exit … f) 916 (pf_only_exit … f) 891 917 . 892 918 [ #l1 #l2 #L … … 934 960 ] 935 961 | 9,10: whd >lookup_add_hit % #E destruct 962 | #l' #L cases (lookup_add_cases ??????? L) 963 [ *#E >E #_ % 964 | #L' whd in L':(??%?); destruct 965 ] 936 966 | % @refl 937 967 ]
Note: See TracChangeset
for help on using the changeset viewer.