blob: b3fdebd0d76e88b8070a107a58f540d83250fcfa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
(* *********************************************************************)
(* *)
(* The Compcert verified compiler *)
(* *)
(* Xavier Leroy, Collège de France and Inria Paris *)
(* *)
(* Copyright Institut National de Recherche en Informatique et en *)
(* Automatique. All rights reserved. This file is distributed *)
(* under the terms of the GNU Lesser General Public License as *)
(* published by the Free Software Foundation, either version 2.1 of *)
(* the License, or (at your option) any later version. *)
(* This file is also distributed under the terms of the *)
(* INRIA Non-Commercial License Agreement. *)
(* *)
(* *********************************************************************)
(** Platform-specific built-in functions *)
Require Import String Coqlib.
Require Import AST Integers Floats Values.
Require Import Builtins0.
Inductive platform_builtin : Type :=
| BI_isel
| BI_uisel
| BI_isel64
| BI_uisel64
| BI_bsel
| BI_mulhw
| BI_mulhwu
| BI_mulhd
| BI_mulhdu.
Local Open Scope string_scope.
Definition platform_builtin_table : list (string * platform_builtin) :=
("__builtin_isel", BI_isel)
:: ("__builtin_uisel", BI_uisel)
:: ("__builtin_isel64", BI_isel64)
:: ("__builtin_uisel64", BI_uisel64)
:: ("__builtin_bsel", BI_bsel)
:: ("__builtin_mulhw", BI_mulhw)
:: ("__builtin_mulhwu", BI_mulhwu)
:: ("__builtin_mulhd", BI_mulhd)
:: ("__builtin_mulhdu", BI_mulhdu)
:: nil.
Definition platform_builtin_sig (b: platform_builtin) : signature :=
match b with
| BI_isel | BI_uisel | BI_bsel =>
mksignature (Tint :: Tint :: Tint :: nil) Tint cc_default
| BI_isel64 | BI_uisel64 =>
mksignature (Tint :: Tlong :: Tlong :: nil) Tlong cc_default
| BI_mulhw | BI_mulhwu =>
mksignature (Tint :: Tint :: nil) Tint cc_default
| BI_mulhd | BI_mulhdu =>
mksignature (Tlong :: Tlong :: nil) Tlong cc_default
end.
Definition platform_builtin_sem (b: platform_builtin) : builtin_sem (sig_res (platform_builtin_sig b)) :=
match b with
| BI_isel | BI_uisel | BI_bsel =>
mkbuiltin_n3t Tint Tint Tint Tint (fun c n1 n2 => if Int.eq c Int.zero then n2 else n1)
| BI_isel64 | BI_uisel64 =>
mkbuiltin_n3t Tint Tlong Tlong Tlong (fun c n1 n2 => if Int.eq c Int.zero then n2 else n1)
| BI_mulhw =>
mkbuiltin_n2t Tint Tint Tint Int.mulhs
| BI_mulhwu =>
mkbuiltin_n2t Tint Tint Tint Int.mulhu
| BI_mulhd =>
mkbuiltin_n2t Tlong Tlong Tlong Int64.mulhs
| BI_mulhdu =>
mkbuiltin_n2t Tlong Tlong Tlong Int64.mulhu
end.
|