@@ -41,6 +41,10 @@ pub enum Type {
4141 FlexibleArray { typ : Box < Type > } ,
4242 /// `float`
4343 Float ,
44+ /// `_Float16`
45+ Float16 ,
46+ /// `_Float128`
47+ Float128 ,
4448 /// `struct x {}`
4549 IncompleteStruct { tag : InternedString } ,
4650 /// `union x {}`
@@ -166,6 +170,8 @@ impl DatatypeComponent {
166170 | Double
167171 | FlexibleArray { .. }
168172 | Float
173+ | Float16
174+ | Float128
169175 | Integer
170176 | Pointer { .. }
171177 | Signedbv { .. }
@@ -363,6 +369,8 @@ impl Type {
363369 Double => st. machine_model ( ) . double_width ,
364370 Empty => 0 ,
365371 FlexibleArray { .. } => 0 ,
372+ Float16 => 16 ,
373+ Float128 => 128 ,
366374 Float => st. machine_model ( ) . float_width ,
367375 IncompleteStruct { .. } => unreachable ! ( "IncompleteStruct doesn't have a sizeof" ) ,
368376 IncompleteUnion { .. } => unreachable ! ( "IncompleteUnion doesn't have a sizeof" ) ,
@@ -532,6 +540,22 @@ impl Type {
532540 }
533541 }
534542
543+ pub fn is_float_16 ( & self ) -> bool {
544+ let concrete = self . unwrap_typedef ( ) ;
545+ match concrete {
546+ Float16 => true ,
547+ _ => false ,
548+ }
549+ }
550+
551+ pub fn is_float_128 ( & self ) -> bool {
552+ let concrete = self . unwrap_typedef ( ) ;
553+ match concrete {
554+ Float128 => true ,
555+ _ => false ,
556+ }
557+ }
558+
535559 pub fn is_float ( & self ) -> bool {
536560 let concrete = self . unwrap_typedef ( ) ;
537561 match concrete {
@@ -543,7 +567,7 @@ impl Type {
543567 pub fn is_floating_point ( & self ) -> bool {
544568 let concrete = self . unwrap_typedef ( ) ;
545569 match concrete {
546- Double | Float => true ,
570+ Double | Float | Float16 | Float128 => true ,
547571 _ => false ,
548572 }
549573 }
@@ -577,6 +601,8 @@ impl Type {
577601 | CInteger ( _)
578602 | Double
579603 | Float
604+ | Float16
605+ | Float128
580606 | Integer
581607 | Pointer { .. }
582608 | Signedbv { .. }
@@ -632,6 +658,8 @@ impl Type {
632658 | Double
633659 | Empty
634660 | Float
661+ | Float16
662+ | Float128
635663 | Integer
636664 | Pointer { .. }
637665 | Signedbv { .. }
@@ -918,6 +946,8 @@ impl Type {
918946 | CInteger ( _)
919947 | Double
920948 | Float
949+ | Float16
950+ | Float128
921951 | Integer
922952 | Pointer { .. }
923953 | Signedbv { .. }
@@ -1042,6 +1072,14 @@ impl Type {
10421072 FlexibleArray { typ : Box :: new ( self ) }
10431073 }
10441074
1075+ pub fn float16 ( ) -> Self {
1076+ Float16
1077+ }
1078+
1079+ pub fn float128 ( ) -> Self {
1080+ Float128
1081+ }
1082+
10451083 pub fn float ( ) -> Self {
10461084 Float
10471085 }
@@ -1275,6 +1313,10 @@ impl Type {
12751313 Expr :: c_true ( )
12761314 } else if self . is_float ( ) {
12771315 Expr :: float_constant ( 1.0 )
1316+ } else if self . is_float_16 ( ) {
1317+ Expr :: float16_constant ( 1.0 )
1318+ } else if self . is_float_128 ( ) {
1319+ Expr :: float128_constant ( 1.0 )
12781320 } else if self . is_double ( ) {
12791321 Expr :: double_constant ( 1.0 )
12801322 } else {
@@ -1291,6 +1333,10 @@ impl Type {
12911333 Expr :: c_false ( )
12921334 } else if self . is_float ( ) {
12931335 Expr :: float_constant ( 0.0 )
1336+ } else if self . is_float_16 ( ) {
1337+ Expr :: float16_constant ( 0.0 )
1338+ } else if self . is_float_128 ( ) {
1339+ Expr :: float128_constant ( 0.0 )
12941340 } else if self . is_double ( ) {
12951341 Expr :: double_constant ( 0.0 )
12961342 } else if self . is_pointer ( ) {
@@ -1309,6 +1355,8 @@ impl Type {
13091355 | CInteger ( _)
13101356 | Double
13111357 | Float
1358+ | Float16
1359+ | Float128
13121360 | Integer
13131361 | Pointer { .. }
13141362 | Signedbv { .. }
@@ -1413,6 +1461,8 @@ impl Type {
14131461 Type :: Empty => "empty" . to_string ( ) ,
14141462 Type :: FlexibleArray { typ } => format ! ( "flexarray_of_{}" , typ. to_identifier( ) ) ,
14151463 Type :: Float => "float" . to_string ( ) ,
1464+ Type :: Float16 => "float16" . to_string ( ) ,
1465+ Type :: Float128 => "float128" . to_string ( ) ,
14161466 Type :: IncompleteStruct { tag } => tag. to_string ( ) ,
14171467 Type :: IncompleteUnion { tag } => tag. to_string ( ) ,
14181468 Type :: InfiniteArray { typ } => {
@@ -1512,6 +1562,8 @@ mod type_tests {
15121562 assert_eq ! ( type_def. is_unsigned( & mm) , src_type. is_unsigned( & mm) ) ;
15131563 assert_eq ! ( type_def. is_scalar( ) , src_type. is_scalar( ) ) ;
15141564 assert_eq ! ( type_def. is_float( ) , src_type. is_float( ) ) ;
1565+ assert_eq ! ( type_def. is_float_16( ) , src_type. is_float_16( ) ) ;
1566+ assert_eq ! ( type_def. is_float_128( ) , src_type. is_float_128( ) ) ;
15151567 assert_eq ! ( type_def. is_floating_point( ) , src_type. is_floating_point( ) ) ;
15161568 assert_eq ! ( type_def. width( ) , src_type. width( ) ) ;
15171569 assert_eq ! ( type_def. can_be_lvalue( ) , src_type. can_be_lvalue( ) ) ;
0 commit comments