Skip to content

Commit 0aeff47

Browse files
bschommerxavierleroy
authored andcommitted
Added semantics for the PowerPC sel and mulh built-ins
The semantics of the various selection functions are defined analogously to the ones from the type generic sel function. The semantics for the various high word multiplication functions is defined using the Integer functions. Bug 30035
1 parent 4011a08 commit 0aeff47

File tree

1 file changed

+44
-4
lines changed

1 file changed

+44
-4
lines changed

powerpc/Builtins1.v

+44-4
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,55 @@ Require Import String Coqlib.
1919
Require Import AST Integers Floats Values.
2020
Require Import Builtins0.
2121

22-
Inductive platform_builtin : Type := .
22+
Inductive platform_builtin : Type :=
23+
| BI_isel
24+
| BI_uisel
25+
| BI_isel64
26+
| BI_uisel64
27+
| BI_bsel
28+
| BI_mulhw
29+
| BI_mulhwu
30+
| BI_mulhd
31+
| BI_mulhdu.
2332

2433
Local Open Scope string_scope.
2534

2635
Definition platform_builtin_table : list (string * platform_builtin) :=
27-
nil.
36+
("__builtin_isel", BI_isel)
37+
:: ("__builtin_uisel", BI_uisel)
38+
:: ("__builtin_isel64", BI_isel64)
39+
:: ("__builtin_uisel64", BI_uisel64)
40+
:: ("__builtin_bsel", BI_bsel)
41+
:: ("__builtin_mulhw", BI_mulhw)
42+
:: ("__builtin_mulhwu", BI_mulhwu)
43+
:: ("__builtin_mulhd", BI_mulhd)
44+
:: ("__builtin_mulhdu", BI_mulhdu)
45+
:: nil.
2846

2947
Definition platform_builtin_sig (b: platform_builtin) : signature :=
30-
match b with end.
48+
match b with
49+
| BI_isel | BI_uisel | BI_bsel =>
50+
mksignature (Tint :: Tint :: Tint :: nil) Tint cc_default
51+
| BI_isel64 | BI_uisel64 =>
52+
mksignature (Tint :: Tlong :: Tlong :: nil) Tlong cc_default
53+
| BI_mulhw | BI_mulhwu =>
54+
mksignature (Tint :: Tint :: nil) Tint cc_default
55+
| BI_mulhd | BI_mulhdu =>
56+
mksignature (Tlong :: Tlong :: nil) Tlong cc_default
57+
end.
3158

3259
Definition platform_builtin_sem (b: platform_builtin) : builtin_sem (sig_res (platform_builtin_sig b)) :=
33-
match b with end.
60+
match b with
61+
| BI_isel | BI_uisel | BI_bsel =>
62+
mkbuiltin_n3t Tint Tint Tint Tint (fun c n1 n2 => if Int.eq c Int.zero then n2 else n1)
63+
| BI_isel64 | BI_uisel64 =>
64+
mkbuiltin_n3t Tint Tlong Tlong Tlong (fun c n1 n2 => if Int.eq c Int.zero then n2 else n1)
65+
| BI_mulhw =>
66+
mkbuiltin_n2t Tint Tint Tint Int.mulhs
67+
| BI_mulhwu =>
68+
mkbuiltin_n2t Tint Tint Tint Int.mulhu
69+
| BI_mulhd =>
70+
mkbuiltin_n2t Tlong Tlong Tlong Int64.mulhs
71+
| BI_mulhdu =>
72+
mkbuiltin_n2t Tlong Tlong Tlong Int64.mulhu
73+
end.

0 commit comments

Comments
 (0)