-
Notifications
You must be signed in to change notification settings - Fork 108
/
Target-generic32.ML
61 lines (49 loc) · 1.4 KB
/
Target-generic32.ML
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
(*
* Copyright 2020, Data61, CSIRO (ABN 41 687 119 230)
*
* SPDX-License-Identifier: BSD-2-Clause
*)
structure ImplementationNumbers :> IMPLEMENTATION_NUMBERS =
struct
open IntInf
fun exp (n, ex) = if ex = 0 then 1
else let
val q = ex div 2
val r = if ex mod 2 = 1 then n else 1
val qex = exp (n, q)
in
qex * qex * r
end
val boolWidth = 8
val charWidth = 8
val shortWidth = 16
val intWidth = 32
val longWidth = 32
val llongWidth = 64
val ptrWidth : int = 32
val CHAR_BIT : int = 8
fun umax width = exp(2, width) - 1
fun max width = exp(2, width - 1) - 1
fun min width = ~(exp(2, width - 1))
val UCHAR_MAX = umax charWidth
val USHORT_MAX = umax shortWidth
val UINT_MAX = umax intWidth
val ULONG_MAX = umax longWidth
val ULLONG_MAX = umax llongWidth
val SCHAR_MAX = max intWidth
val SHORT_MAX = max shortWidth
val INT_MAX = max intWidth
val LONG_MAX = max longWidth
val LLONG_MAX = max llongWidth
val SCHAR_MIN = min charWidth
val SHORT_MIN = min shortWidth
val INT_MIN = min intWidth
val LONG_MIN = min longWidth
val LLONG_MIN = min llongWidth
val char_signedp = true
val CHAR_MAX = SCHAR_MAX
val CHAR_MIN = SCHAR_MIN
open CharLitUtil
val charliteral_conversion = schar_conv {umax=UCHAR_MAX,smin=SCHAR_MIN,
smax=SCHAR_MAX}
end