diff options
author | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2019-04-05 14:21:09 +0200 |
---|---|---|
committer | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2019-04-05 14:21:09 +0200 |
commit | 515fbe8f873d9dd1b246b0dab7531103b1b59cf6 (patch) | |
tree | f72305e287bf0495c8f150633f905fa30458f7f3 /backend/Selection.v | |
parent | 799698875bd5b42b9ef5e57138f71128e68ed35e (diff) | |
download | compcert-kvx-515fbe8f873d9dd1b246b0dab7531103b1b59cf6.tar.gz compcert-kvx-515fbe8f873d9dd1b246b0dab7531103b1b59cf6.zip |
preparing for the builtin connector
Diffstat (limited to 'backend/Selection.v')
-rw-r--r-- | backend/Selection.v | 72 |
1 files changed, 69 insertions, 3 deletions
diff --git a/backend/Selection.v b/backend/Selection.v index 05a06abf..3b0948a8 100644 --- a/backend/Selection.v +++ b/backend/Selection.v @@ -267,6 +267,69 @@ Definition sel_switch_long := (fun arg ofs => subl arg (longconst (Int64.repr ofs))) lowlong. + +Definition sel_builtin_default optid ef args := + OK (Sbuiltin (sel_builtin_res optid) ef + (sel_builtin_args args + (Machregs.builtin_constraints ef))). + +Definition sel_builtin optid ef args := + match ef with + | EF_builtin name sign => + (if String.string_dec name "__builtin_ternary_uint" + || String.string_dec name "__builtin_ternary_int" + then + match optid with + | None => OK Sskip + | Some id => + match args with + | a1::a2::a3::nil => + OK (Sassign id (select (sel_expr a3) (sel_expr a2) (sel_expr a1))) + | _ => Error (msg "__builtin_ternary_(u)int: arguments") + end + end + else + if String.string_dec name "__builtin_ternary_ulong" + || String.string_dec name "__builtin_ternary_long" + then + match optid with + | None => OK Sskip + | Some id => + match args with + | a1::a2::a3::nil => + OK (Sassign id (selectl (sel_expr a3) (sel_expr a2) (sel_expr a1))) + | _ => Error (msg "__builtin_ternary_(u)long: arguments") + end + end + else + if String.string_dec name "__builtin_ternary_double" + then + match optid with + | None => OK Sskip + | Some id => + match args with + | a1::a2::a3::nil => + OK (Sassign id (selectf (sel_expr a3) (sel_expr a2) (sel_expr a1))) + | _ => Error (msg "__builtin_ternary_double: arguments") + end + end + else + if String.string_dec name "__builtin_ternary_float" + then + match optid with + | None => OK Sskip + | Some id => + match args with + | a1::a2::a3::nil => + OK (Sassign id (selectfs (sel_expr a3) (sel_expr a2) (sel_expr a1))) + | _ => Error (msg "__builtin_ternary_float: arguments") + end + end + else + sel_builtin_default optid ef args) + | _ => sel_builtin_default optid ef args + end. + (** Conversion from Cminor statements to Cminorsel statements. *) Fixpoint sel_stmt (s: Cminor.stmt) : res stmt := @@ -278,9 +341,12 @@ Fixpoint sel_stmt (s: Cminor.stmt) : res stmt := OK (match classify_call fn with | Call_default => Scall optid sg (inl _ (sel_expr fn)) (sel_exprlist args) | Call_imm id => Scall optid sg (inr _ id) (sel_exprlist args) - | Call_builtin ef => Sbuiltin (sel_builtin_res optid) ef - (sel_builtin_args args - (Machregs.builtin_constraints ef)) + | Call_builtin ef => (Sbuiltin (sel_builtin_res optid) ef + (sel_builtin_args args + (Machregs.builtin_constraints ef))) + (* sel_builtin_default optid ef args *) + (* THIS IS WHERE TO ACTIVATE OUR OWN BUILTINS + change sel_builtin_default to sel_builtin *) end) | Cminor.Sbuiltin optid ef args => OK (Sbuiltin (sel_builtin_res optid) ef |