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/Cop.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/Cop.v')
-rw-r--r-- | cfrontend/Cop.v | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/cfrontend/Cop.v b/cfrontend/Cop.v index ff43cbd5..a5d4c662 100644 --- a/cfrontend/Cop.v +++ b/cfrontend/Cop.v @@ -936,7 +936,7 @@ Definition sem_cmp (c:comparison) (** ** Function applications *) -Inductive classify_fun_cases : Type:= +Inductive classify_fun_cases : Type := | fun_case_f (targs: typelist) (tres: type) (cc: calling_convention) (**r (pointer to) function *) | fun_default. @@ -947,6 +947,30 @@ Definition classify_fun (ty: type) := | _ => fun_default end. +(** ** Argument of a [switch] statement *) + +Inductive classify_switch_cases : Type := + | switch_case_i + | switch_case_l + | switch_default. + +Definition classify_switch (ty: type) := + match ty with + | Tint _ _ _ => switch_case_i + | Tlong _ _ => switch_case_l + | _ => switch_default + end. + +Definition sem_switch_arg (v: val) (ty: type): option Z := + match classify_switch ty with + | switch_case_i => + match v with Vint n => Some(Int.unsigned n) | _ => None end + | switch_case_l => + match v with Vlong n => Some(Int64.unsigned n) | _ => None end + | switch_default => + None + end. + (** * Combined semantics of unary and binary operators *) Definition sem_unary_operation |