diff options
author | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2014-08-17 07:52:12 +0000 |
---|---|---|
committer | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2014-08-17 07:52:12 +0000 |
commit | 17f519651feb4a09aa90c89c949469e8a5ab0e88 (patch) | |
tree | c7bda5e43a2d1f950180521a1b854ac9592eea73 /cfrontend/Clight.v | |
parent | 88613c0f5415a0d3f2e0e0e9ff74bd32b6b4685e (diff) | |
download | compcert-17f519651feb4a09aa90c89c949469e8a5ab0e88.tar.gz compcert-17f519651feb4a09aa90c89c949469e8a5ab0e88.zip |
- Support "switch" statements over 64-bit integers
(in CompCert C to Cminor, included)
- Translation of "switch" to decision trees or jumptables made generic
over the sizes of integers and moved to the Cminor->CminorSel pass
instead of CminorSel->RTL as before.
- CminorSel: add "exitexpr" to support the above.
- ValueDomain: more precise analysis of comparisons against an integer
literal. E.g. "x >=u 0" is always true.
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@2565 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'cfrontend/Clight.v')
-rw-r--r-- | cfrontend/Clight.v | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/cfrontend/Clight.v b/cfrontend/Clight.v index d9fb6501..40206d38 100644 --- a/cfrontend/Clight.v +++ b/cfrontend/Clight.v @@ -111,7 +111,7 @@ Inductive statement : Type := with labeled_statements : Type := (**r cases of a [switch] *) | LSnil: labeled_statements - | LScons: option int -> statement -> labeled_statements -> labeled_statements. + | LScons: option Z -> statement -> labeled_statements -> labeled_statements. (**r [None] is [default], [Some x] is [case x] *) (** The C loops are derived forms. *) @@ -312,14 +312,14 @@ Fixpoint select_switch_default (sl: labeled_statements): labeled_statements := | LScons (Some i) s sl' => select_switch_default sl' end. -Fixpoint select_switch_case (n: int) (sl: labeled_statements): option labeled_statements := +Fixpoint select_switch_case (n: Z) (sl: labeled_statements): option labeled_statements := match sl with | LSnil => None | LScons None s sl' => select_switch_case n sl' - | LScons (Some c) s sl' => if Int.eq c n then Some sl else select_switch_case n sl' + | LScons (Some c) s sl' => if zeq c n then Some sl else select_switch_case n sl' end. -Definition select_switch (n: int) (sl: labeled_statements): labeled_statements := +Definition select_switch (n: Z) (sl: labeled_statements): labeled_statements := match select_switch_case n sl with | Some sl' => sl' | None => select_switch_default sl @@ -614,8 +614,9 @@ Inductive step: state -> trace -> state -> Prop := step (State f Sskip k e le m) E0 (Returnstate Vundef k m') - | step_switch: forall f a sl k e le m n, - eval_expr e le m a (Vint n) -> + | step_switch: forall f a sl k e le m v n, + eval_expr e le m a v -> + sem_switch_arg v (typeof a) = Some n -> step (State f (Sswitch a sl) k e le m) E0 (State f (seq_of_labeled_statement (select_switch n sl)) (Kswitch k) e le m) | step_skip_break_switch: forall f x k e le m, |