aboutsummaryrefslogtreecommitdiffstats
path: root/backend/RTL.v
diff options
context:
space:
mode:
authorxleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2009-11-10 12:50:57 +0000
committerxleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2009-11-10 12:50:57 +0000
commit74487f079dd56663f97f9731cea328931857495c (patch)
tree9de10b895da39adffaf66bff983d6ed573898068 /backend/RTL.v
parent0486654fac91947fec93d18a0738dd7aa10bcf96 (diff)
downloadcompcert-kvx-74487f079dd56663f97f9731cea328931857495c.tar.gz
compcert-kvx-74487f079dd56663f97f9731cea328931857495c.zip
Added support for jump tables in back end.
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1171 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'backend/RTL.v')
-rw-r--r--backend/RTL.v30
1 files changed, 12 insertions, 18 deletions
diff --git a/backend/RTL.v b/backend/RTL.v
index 5de073ee..b2ee80fc 100644
--- a/backend/RTL.v
+++ b/backend/RTL.v
@@ -75,6 +75,10 @@ Inductive instruction: Type :=
[cond] over the values of registers [args]. If the condition
is true, it transitions to [ifso]. If the condition is false,
it transitions to [ifnot]. *)
+ | Ijumptable: reg -> list node -> instruction
+ (** [Ijumptable arg tbl] transitions to the node that is the [n]-th
+ element of the list [tbl], where [n] is the signed integer
+ value of register [arg]. *)
| Ireturn: option reg -> instruction.
(** [Ireturn] terminates the execution of the current function
(it has no successor). It returns the value of the given
@@ -252,6 +256,13 @@ Inductive step: state -> trace -> state -> Prop :=
eval_condition cond rs##args = Some false ->
step (State s c sp pc rs m)
E0 (State s c sp ifnot rs m)
+ | exec_Ijumptable:
+ forall s c sp pc rs m arg tbl n pc',
+ c!pc = Some(Ijumptable arg tbl) ->
+ rs#arg = Vint n ->
+ list_nth_z tbl (Int.signed n) = Some pc' ->
+ step (State s c sp pc rs m)
+ E0 (State s c sp pc' rs m)
| exec_Ireturn:
forall s c stk pc rs m or,
c!pc = Some(Ireturn or) ->
@@ -339,30 +350,13 @@ Definition successors_instr (i: instruction) : list node :=
| Icall sig ros args res s => s :: nil
| Itailcall sig ros args => nil
| Icond cond args ifso ifnot => ifso :: ifnot :: nil
+ | Ijumptable arg tbl => tbl
| Ireturn optarg => nil
end.
Definition successors (f: function) : PTree.t (list node) :=
PTree.map (fun pc i => successors_instr i) f.(fn_code).
-(*
-Definition successors (f: function) (pc: node) : list node :=
- match f.(fn_code)!pc with
- | None => nil
- | Some i =>
- match i with
- | Inop s => s :: nil
- | Iop op args res s => s :: nil
- | Iload chunk addr args dst s => s :: nil
- | Istore chunk addr args src s => s :: nil
- | Icall sig ros args res s => s :: nil
- | Itailcall sig ros args => nil
- | Icond cond args ifso ifnot => ifso :: ifnot :: nil
- | Ireturn optarg => nil
- end
- end.
-*)
-
(** Transformation of a RTL function instruction by instruction.
This applies a given transformation function to all instructions
of a function and constructs a transformed function from that. *)