Skip to content

Commit f34a158

Browse files
authored
Merge pull request #1813 from goblint/float16
Add `_Float16` parsing support
2 parents e6640fa + a738203 commit f34a158

File tree

8 files changed

+26
-11
lines changed

8 files changed

+26
-11
lines changed

goblint.opam

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ dev-repo: "git+https://github.com/goblint/analyzer.git"
101101
# also remember to generate/adjust goblint.opam.locked!
102102
available: os-family != "bsd" & os-distribution != "alpine" & (arch != "arm64" | os = "macos")
103103
pin-depends: [
104-
# published goblint-cil 2.0.6 is currently up-to-date, but pinned for reproducibility
105-
[ "goblint-cil.2.0.6" "git+https://github.com/goblint/cil.git#4b8b06eb39801a87d195f81d830a686578bd8b8b" ]
104+
[ "goblint-cil.2.0.7" "git+https://github.com/goblint/cil.git#8e2212316ceda6911de2db716933bfb8c64a8585" ]
106105
# pinned for stability (https://github.com/goblint/analyzer/issues/1520), remove after new apron release
107106
[ "apron.v0.9.15" "git+https://github.com/antoinemine/apron.git#418a217c7a70dae3f422678f3aaba38ae374d91a" ]
108107
]

goblint.opam.locked

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ depends: [
6666
"fileutils" {= "0.6.4"}
6767
"fmt" {= "0.9.0"}
6868
"fpath" {= "0.7.3"}
69-
"goblint-cil" {= "2.0.6"}
69+
"goblint-cil" {= "2.0.7"}
7070
"hex" {= "1.5.0"}
7171
"integers" {= "0.7.0"}
7272
"json-data-encoding" {= "1.0.1"}
@@ -142,8 +142,8 @@ post-messages: [
142142
]
143143
pin-depends: [
144144
[
145-
"goblint-cil.2.0.6"
146-
"git+https://github.com/goblint/cil.git#4b8b06eb39801a87d195f81d830a686578bd8b8b"
145+
"goblint-cil.2.0.7"
146+
"git+https://github.com/goblint/cil.git#8e2212316ceda6911de2db716933bfb8c64a8585"
147147
]
148148
[
149149
"apron.v0.9.15"

goblint.opam.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# also remember to generate/adjust goblint.opam.locked!
33
available: os-family != "bsd" & os-distribution != "alpine" & (arch != "arm64" | os = "macos")
44
pin-depends: [
5-
[ "goblint-cil.2.0.6" "git+https://github.com/goblint/cil.git#4b8b06eb39801a87d195f81d830a686578bd8b8b" ]
5+
[ "goblint-cil.2.0.7" "git+https://github.com/goblint/cil.git#8e2212316ceda6911de2db716933bfb8c64a8585" ]
66
# pinned for stability (https://github.com/goblint/analyzer/issues/1520), remove after new apron release
77
[ "apron.v0.9.15" "git+https://github.com/antoinemine/apron.git#418a217c7a70dae3f422678f3aaba38ae374d91a" ]
88
]

gobview

src/cdomain/value/cdomains/floatDomain.ml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,10 +1002,15 @@ module FloatIntervalImplLifted = struct
10021002
| FDouble -> F64 (op64 ())
10031003
| FLongDouble -> FLong (op64 ())
10041004
| FFloat128 -> FFloat128 (op64 ())
1005-
| _ ->
1005+
| FFloat16 -> failwith "fkind FFloat16 not supported"
1006+
| FComplexFloat
1007+
| FComplexDouble
1008+
| FComplexLongDouble
1009+
| FComplexFloat128
1010+
| FComplexFloat16 ->
10061011
(* this should never be reached, as we have to check for invalid fkind elsewhere,
10071012
however we could instead of crashing also return top_of some fkind to avoid this and nonetheless have no actual information about anything*)
1008-
failwith "unsupported fkind"
1013+
failwith "complex fkind not supported"
10091014

10101015
let neg = lift (F1.neg, F2.neg)
10111016
let fabs = lift (F1.fabs, F2.fabs)

src/cdomain/value/cdomains/valueDomain.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,13 +357,18 @@ struct
357357
(*| TPtr _, t -> bitsSizeOf t <= bitsSizeOf !upointType
358358
| t, TPtr _ -> bitsSizeOf t >= bitsSizeOf !upointType*)
359359
| TFloat (fk1,_), TFloat (fk2,_) when fk1 = fk2 -> true
360+
| TFloat (FFloat,_), TFloat (FFloat16,_) -> true
360361
| TFloat (FDouble,_), TFloat (FFloat,_) -> true
362+
| TFloat (FDouble,_), TFloat (FFloat16,_) -> true
361363
| TFloat (FLongDouble,_), TFloat (FFloat,_) -> true
362364
| TFloat (FLongDouble,_), TFloat (FDouble,_) -> true
365+
| TFloat (FLongDouble,_), TFloat (FFloat16,_) -> true
363366
| TFloat (FFloat128, _), TFloat (FFloat,_) -> true
364367
| TFloat (FFloat128, _), TFloat (FDouble,_) -> true
365368
| TFloat (FFloat128, _), TFloat (FLongDouble,_) -> true
369+
| TFloat (FFloat128, _), TFloat (FFloat16,_) -> true
366370
| _, TFloat _ -> false (* casting float to an integral type always looses the decimals *)
371+
| TFloat (FFloat16, _), (TInt((IBool | IChar | IUChar | ISChar), _) | TEnum ({ekind = IBool | IChar | IUChar | ISChar; _}, _)) -> true (* reasonably small integers can be stored in _Float16 *)
367372
| TFloat (fk, _), (TInt((IBool | IChar | IUChar | ISChar | IShort | IUShort), _) | TEnum ({ekind = IBool | IChar | IUChar | ISChar | IShort | IUShort; _}, _)) when not (Cilfacade.isComplexFKind fk) -> true (* reasonably small integers can be stored in all fkinds *)
368373
| TFloat ((FDouble | FLongDouble | FFloat128), _), (TInt((IInt | IUInt | ILong | IULong), _) | TEnum ({ekind = IInt | IUInt | ILong | IULong; _}, _)) -> true (* values stored in between 16 and 32 bits can only be stored in at least doubles *)
369374
| TFloat _, _ -> false (* all wider integers can not be completely put into a float, partially because our internal representation of long double is the same as for doubles *)

src/common/util/cilType.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,12 @@ struct
144144
| FDouble
145145
| FLongDouble
146146
| FFloat128
147+
| FFloat16
147148
| FComplexFloat
148149
| FComplexDouble
149150
| FComplexLongDouble
150151
| FComplexFloat128
152+
| FComplexFloat16
151153
[@@deriving hash]
152154
(* Hashtbl.hash doesn't monomorphize, so derive instead. *)
153155

src/common/util/cilfacade.ml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,12 @@ let typeOfRealAndImagComponents t =
297297
| FDouble -> FDouble (* [double] *)
298298
| FLongDouble -> FLongDouble (* [long double] *)
299299
| FFloat128 -> FFloat128 (* [float128] *)
300+
| FFloat16 -> FFloat16 (* [_Float16] *)
300301
| FComplexFloat -> FFloat
301302
| FComplexDouble -> FDouble
302303
| FComplexLongDouble -> FLongDouble
303304
| FComplexFloat128 -> FComplexFloat128
305+
| FComplexFloat16 -> FComplexFloat16
304306
in
305307
TFloat (newfkind fkind, attrs)
306308
| _ -> raise (TypeOfError RealImag_NonNumerical)
@@ -309,11 +311,13 @@ let isComplexFKind = function
309311
| FFloat
310312
| FDouble
311313
| FLongDouble
312-
| FFloat128 -> false
314+
| FFloat128
315+
| FFloat16 -> false
313316
| FComplexFloat
314317
| FComplexDouble
315318
| FComplexLongDouble
316-
| FComplexFloat128 -> true
319+
| FComplexFloat128
320+
| FComplexFloat16 -> true
317321

318322
(** @raise TypeOfError *)
319323
let rec typeOf (e: exp) : typ =

0 commit comments

Comments
 (0)