C++: Add support for C23/C++23 floating-point types

This commit is contained in:
Jeroen Ketema
2023-09-25 09:50:05 +02:00
parent 7e71d9e619
commit 2a64552979
15 changed files with 13461 additions and 4529 deletions

View File

@@ -0,0 +1,19 @@
class BuiltinType extends @builtintype {
string toString() { none() }
}
from BuiltinType type, string name, int kind, int kind_new, int size, int sign, int alignment
where
builtintypes(type, name, kind, size, sign, alignment) and
if
type instanceof @fp16 or
type instanceof @std_bfloat16 or
type instanceof @std_float16 or
type instanceof @complex_std_float32 or
type instanceof @complex_float32x or
type instanceof @complex_std_float64 or
type instanceof @complex_float64x or
type instanceof @complex_std_float128
then kind_new = 2
else kind_new = kind
select type, name, kind_new, size, sign, alignment

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,3 @@
description: Introduce new floating-point types from C23 and C++23
compatibility: backwards
builtintypes.rel: run builtintypes.qlo

View File

@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* Added support for new floating-point types in C23 and C++23.

View File

@@ -819,6 +819,30 @@ private predicate floatingPointTypeMapping(
or
// _Complex _Float16
kind = 53 and base = 2 and domain = TComplexDomain() and realKind = 52 and extended = false
or
// __fp16
kind = 54 and base = 2 and domain = TRealDomain() and realKind = 54 and extended = false
or
// __bf16
kind = 55 and base = 2 and domain = TRealDomain() and realKind = 55 and extended = false
or
// std::float16_t
kind = 56 and base = 2 and domain = TRealDomain() and realKind = 56 and extended = false
or
// _Complex _Float32
kind = 57 and base = 2 and domain = TComplexDomain() and realKind = 45 and extended = false
or
// _Complex _Float32x
kind = 58 and base = 2 and domain = TComplexDomain() and realKind = 46 and extended = true
or
// _Complex _Float64
kind = 59 and base = 2 and domain = TComplexDomain() and realKind = 47 and extended = false
or
// _Complex _Float64x
kind = 60 and base = 2 and domain = TComplexDomain() and realKind = 48 and extended = true
or
// _Complex _Float128
kind = 61 and base = 2 and domain = TComplexDomain() and realKind = 49 and extended = false
}
/**

View File

@@ -612,6 +612,14 @@ case @builtintype.kind of
| 51 = @char8_t
| 52 = @float16 // _Float16
| 53 = @complex_float16 // _Complex _Float16
| 54 = @fp16 // __fp16
| 55 = @std_bfloat16 // __bf16
| 56 = @std_float16 // std::float16_t
| 57 = @complex_std_float32 // _Complex _Float32
| 58 = @complex_float32x // _Complex _Float32x
| 59 = @complex_std_float64 // _Complex _Float64
| 60 = @complex_float64x // _Complex _Float64x
| 61 = @complex_std_float128 // _Complex _Float128
;
builtintypes(

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,2 @@
description: Introduce new floating-point types from C23 and C++23
compatibility: full

View File

@@ -1,5 +1,10 @@
| file://:0:0:0:0 | Cl<char, Sa, Sb> * |
| file://:0:0:0:0 | _Complex _Float16 |
| file://:0:0:0:0 | _Complex _Float32 |
| file://:0:0:0:0 | _Complex _Float32x |
| file://:0:0:0:0 | _Complex _Float64 |
| file://:0:0:0:0 | _Complex _Float64x |
| file://:0:0:0:0 | _Complex _Float128 |
| file://:0:0:0:0 | _Complex __float128 |
| file://:0:0:0:0 | _Complex double |
| file://:0:0:0:0 | _Complex float |
@@ -16,7 +21,9 @@
| file://:0:0:0:0 | _Imaginary double |
| file://:0:0:0:0 | _Imaginary float |
| file://:0:0:0:0 | _Imaginary long double |
| file://:0:0:0:0 | __bf16 |
| file://:0:0:0:0 | __float128 |
| file://:0:0:0:0 | __fp16 |
| file://:0:0:0:0 | __int128 |
| file://:0:0:0:0 | __va_list_tag |
| file://:0:0:0:0 | __va_list_tag & |
@@ -44,6 +51,7 @@
| file://:0:0:0:0 | signed long |
| file://:0:0:0:0 | signed long long |
| file://:0:0:0:0 | signed short |
| file://:0:0:0:0 | std::float16_t |
| file://:0:0:0:0 | unknown |
| file://:0:0:0:0 | unsigned __int128 |
| file://:0:0:0:0 | unsigned char |

View File

@@ -20,6 +20,11 @@
| file://:0:0:0:0 | UnionWithDef & | 8 |
| file://:0:0:0:0 | UnionWithDef && | 8 |
| file://:0:0:0:0 | _Complex _Float16 | 4 |
| file://:0:0:0:0 | _Complex _Float32 | 8 |
| file://:0:0:0:0 | _Complex _Float32x | 16 |
| file://:0:0:0:0 | _Complex _Float64 | 16 |
| file://:0:0:0:0 | _Complex _Float64x | 32 |
| file://:0:0:0:0 | _Complex _Float128 | 32 |
| file://:0:0:0:0 | _Complex __float128 | 32 |
| file://:0:0:0:0 | _Complex double | 16 |
| file://:0:0:0:0 | _Complex float | 8 |
@@ -37,7 +42,9 @@
| file://:0:0:0:0 | _Imaginary float | 4 |
| file://:0:0:0:0 | _Imaginary long double | 16 |
| file://:0:0:0:0 | __attribute((vector_size(16))) int | 16 |
| file://:0:0:0:0 | __bf16 | 2 |
| file://:0:0:0:0 | __float128 | 16 |
| file://:0:0:0:0 | __fp16 | 2 |
| file://:0:0:0:0 | __int128 | 16 |
| file://:0:0:0:0 | __va_list_tag | 24 |
| file://:0:0:0:0 | __va_list_tag & | 8 |
@@ -83,6 +90,7 @@
| file://:0:0:0:0 | signed long | 8 |
| file://:0:0:0:0 | signed long long | 8 |
| file://:0:0:0:0 | signed short | 2 |
| file://:0:0:0:0 | std::float16_t | 2 |
| file://:0:0:0:0 | unknown | 1 |
| file://:0:0:0:0 | unsigned __int128 | 16 |
| file://:0:0:0:0 | unsigned char | 1 |

View File

@@ -2,6 +2,11 @@
| file://:0:0:0:0 | ..(*)(..) | ..(*)(..) |
| file://:0:0:0:0 | Tmpl<T> | Tmpl<T> |
| file://:0:0:0:0 | _Complex _Float16 | _Complex _Float16 |
| file://:0:0:0:0 | _Complex _Float32 | _Complex _Float32 |
| file://:0:0:0:0 | _Complex _Float32x | _Complex _Float32x |
| file://:0:0:0:0 | _Complex _Float64 | _Complex _Float64 |
| file://:0:0:0:0 | _Complex _Float64x | _Complex _Float64x |
| file://:0:0:0:0 | _Complex _Float128 | _Complex _Float128 |
| file://:0:0:0:0 | _Complex __float128 | _Complex __float128 |
| file://:0:0:0:0 | _Complex double | _Complex double |
| file://:0:0:0:0 | _Complex float | _Complex float |
@@ -18,7 +23,9 @@
| file://:0:0:0:0 | _Imaginary double | _Imaginary double |
| file://:0:0:0:0 | _Imaginary float | _Imaginary float |
| file://:0:0:0:0 | _Imaginary long double | _Imaginary long double |
| file://:0:0:0:0 | __bf16 | __bf16 |
| file://:0:0:0:0 | __float128 | __float128 |
| file://:0:0:0:0 | __fp16 | __fp16 |
| file://:0:0:0:0 | __int128 | __int128 |
| file://:0:0:0:0 | __va_list_tag & | __va_list_tag & |
| file://:0:0:0:0 | __va_list_tag && | __va_list_tag && |
@@ -45,6 +52,7 @@
| file://:0:0:0:0 | signed long | signed long |
| file://:0:0:0:0 | signed long long | signed long long |
| file://:0:0:0:0 | signed short | signed short |
| file://:0:0:0:0 | std::float16_t | std::float16_t |
| file://:0:0:0:0 | unknown | unknown |
| file://:0:0:0:0 | unsigned __int128 | unsigned __int128 |
| file://:0:0:0:0 | unsigned char | unsigned char |

View File

@@ -1,6 +1,11 @@
| ..()(..) | RoutineType | | | | |
| ..(*)(..) | FunctionPointerType | | ..()(..) | | |
| _Complex _Float16 | BinaryFloatingPointType, ComplexNumberType | | | | |
| _Complex _Float32 | BinaryFloatingPointType, ComplexNumberType | | | | |
| _Complex _Float32x | BinaryFloatingPointType, ComplexNumberType | | | | |
| _Complex _Float64 | BinaryFloatingPointType, ComplexNumberType | | | | |
| _Complex _Float64x | BinaryFloatingPointType, ComplexNumberType | | | | |
| _Complex _Float128 | BinaryFloatingPointType, ComplexNumberType | | | | |
| _Complex __float128 | BinaryFloatingPointType, ComplexNumberType | | | | |
| _Complex double | BinaryFloatingPointType, ComplexNumberType | | | | |
| _Complex float | BinaryFloatingPointType, ComplexNumberType | | | | |
@@ -17,7 +22,9 @@
| _Imaginary double | BinaryFloatingPointType, ImaginaryNumberType | | | | |
| _Imaginary float | BinaryFloatingPointType, ImaginaryNumberType | | | | |
| _Imaginary long double | BinaryFloatingPointType, ImaginaryNumberType | | | | |
| __bf16 | BinaryFloatingPointType, RealNumberType | | | | |
| __float128 | Float128Type | | | | |
| __fp16 | BinaryFloatingPointType, RealNumberType | | | | |
| __int128 | Int128Type | | | | |
| __va_list_tag | DirectAccessHolder, MetricClass, Struct, StructLikeClass | | | | |
| __va_list_tag & | LValueReferenceType | | __va_list_tag | | |
@@ -83,6 +90,7 @@
| signed long | LongType | | | | |
| signed long long | LongLongType | | | | |
| signed short | ShortType | | | | |
| std::float16_t | BinaryFloatingPointType, RealNumberType | | | | |
| unknown | UnknownType | | | | |
| unsigned __int128 | Int128Type | | | | unsigned integral |
| unsigned char | UnsignedCharType | | | | unsigned integral |