aboutsummaryrefslogtreecommitdiffstats
path: root/cfrontend/Csharpminor.v
diff options
context:
space:
mode:
authorxleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2014-08-17 07:52:12 +0000
committerxleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2014-08-17 07:52:12 +0000
commit17f519651feb4a09aa90c89c949469e8a5ab0e88 (patch)
treec7bda5e43a2d1f950180521a1b854ac9592eea73 /cfrontend/Csharpminor.v
parent88613c0f5415a0d3f2e0e0e9ff74bd32b6b4685e (diff)
downloadcompcert-kvx-17f519651feb4a09aa90c89c949469e8a5ab0e88.tar.gz
compcert-kvx-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/Csharpminor.v')
-rw-r--r--cfrontend/Csharpminor.v20
1 files changed, 11 insertions, 9 deletions
diff --git a/cfrontend/Csharpminor.v b/cfrontend/Csharpminor.v
index d37fa819..c34b10a4 100644
--- a/cfrontend/Csharpminor.v
+++ b/cfrontend/Csharpminor.v
@@ -21,6 +21,7 @@ Require Import Values.
Require Import Memory.
Require Import Events.
Require Import Globalenvs.
+Require Import Switch.
Require Cminor.
Require Import Smallstep.
@@ -67,14 +68,14 @@ Inductive stmt : Type :=
| Sloop: stmt -> stmt
| Sblock: stmt -> stmt
| Sexit: nat -> stmt
- | Sswitch: expr -> lbl_stmt -> stmt
+ | Sswitch: bool -> expr -> lbl_stmt -> stmt
| Sreturn: option expr -> stmt
| Slabel: label -> stmt -> stmt
| Sgoto: label -> stmt
with lbl_stmt : Type :=
| LSnil: lbl_stmt
- | LScons: option int -> stmt -> lbl_stmt -> lbl_stmt.
+ | LScons: option Z -> stmt -> lbl_stmt -> lbl_stmt.
(** Functions are composed of a return type, a list of parameter names,
a list of local variables with their sizes, a list of temporary variables,
@@ -191,14 +192,14 @@ Fixpoint select_switch_default (sl: lbl_stmt): lbl_stmt :=
| LScons (Some i) s sl' => select_switch_default sl'
end.
-Fixpoint select_switch_case (n: int) (sl: lbl_stmt): option lbl_stmt :=
+Fixpoint select_switch_case (n: Z) (sl: lbl_stmt): option lbl_stmt :=
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: lbl_stmt): lbl_stmt :=
+Definition select_switch (n: Z) (sl: lbl_stmt): lbl_stmt :=
match select_switch_case n sl with
| Some sl' => sl'
| None => select_switch_default sl
@@ -230,7 +231,7 @@ Fixpoint find_label (lbl: label) (s: stmt) (k: cont)
find_label lbl s1 (Kseq (Sloop s1) k)
| Sblock s1 =>
find_label lbl s1 (Kblock k)
- | Sswitch a sl =>
+ | Sswitch long a sl =>
find_label_ls lbl sl k
| Slabel lbl' s' =>
if ident_eq lbl lbl' then Some(s', k) else find_label lbl s' k
@@ -423,9 +424,10 @@ Inductive step: state -> trace -> state -> Prop :=
step (State f (Sexit (S n)) (Kblock k) e le m)
E0 (State f (Sexit n) k e le m)
- | step_switch: forall f a cases k e le m n,
- eval_expr e le m a (Vint n) ->
- step (State f (Sswitch a cases) k e le m)
+ | step_switch: forall f islong a cases k e le m v n,
+ eval_expr e le m a v ->
+ switch_argument islong v n ->
+ step (State f (Sswitch islong a cases) k e le m)
E0 (State f (seq_of_lbl_stmt (select_switch n cases)) k e le m)
| step_return_0: forall f k e le m m',