mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Merge pull request #19792 from jketema/sve
C++: Add Arm scalable vector type QL classes
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
class BuiltinType extends @builtintype {
|
||||
string toString() { none() }
|
||||
}
|
||||
|
||||
from BuiltinType id, string name, int kind, int new_kind, int size, int sign, int alignment
|
||||
where
|
||||
builtintypes(id, name, kind, size, sign, alignment) and
|
||||
if kind = 63 then /* @errortype */ new_kind = 1 else new_kind = kind
|
||||
select id, name, new_kind, size, sign, alignment
|
||||
@@ -0,0 +1,9 @@
|
||||
class Type extends @type {
|
||||
string toString() { none() }
|
||||
}
|
||||
|
||||
from Type type, string name, int kind, int new_kind, Type type_id
|
||||
where
|
||||
derivedtypes(type, name, kind, type_id) and
|
||||
if kind = 11 then /* @gnu_vector */ new_kind = 5 else new_kind = kind
|
||||
select type, name, new_kind, type_id
|
||||
2506
cpp/downgrades/e38346051783182ea75822e4adf8d4c6a949bc37/old.dbscheme
Normal file
2506
cpp/downgrades/e38346051783182ea75822e4adf8d4c6a949bc37/old.dbscheme
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,5 @@
|
||||
description: Arm scalable vector type support
|
||||
compatibility: backwards
|
||||
builtintypes.rel: run builtintypes.qlo
|
||||
derivedtypes.rel: run derivedtypes.qlo
|
||||
tupleelements.rel: delete
|
||||
@@ -352,7 +352,23 @@ class UnknownType extends BuiltInType {
|
||||
private predicate isArithmeticType(@builtintype type, int kind) {
|
||||
builtintypes(type, _, kind, _, _, _) and
|
||||
kind >= 4 and
|
||||
kind != 34 // Exclude decltype(nullptr)
|
||||
kind != 34 and // Exclude decltype(nullptr)
|
||||
kind != 63 // Exclude __SVCount_t
|
||||
}
|
||||
|
||||
/**
|
||||
* The Arm scalable vector count type.
|
||||
*
|
||||
* In the following example, `a` is declared using the scalable vector
|
||||
* count type:
|
||||
* ```
|
||||
* svcount_t a;
|
||||
* ```
|
||||
*/
|
||||
class ScalableVectorCount extends BuiltInType {
|
||||
ScalableVectorCount() { builtintypes(underlyingElement(this), _, 63, _, _, _) }
|
||||
|
||||
override string getAPrimaryQlClass() { result = "ScalableVectorCount" }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1084,7 +1100,7 @@ class NullPointerType extends BuiltInType {
|
||||
/**
|
||||
* A C/C++ derived type.
|
||||
*
|
||||
* These are pointer and reference types, array and GNU vector types, and `const` and `volatile` types.
|
||||
* These are pointer and reference types, array and vector types, and `const` and `volatile` types.
|
||||
* In all cases, the type is formed from a single base type. For example:
|
||||
* ```
|
||||
* int *pi;
|
||||
@@ -1648,6 +1664,30 @@ class GNUVectorType extends DerivedType {
|
||||
override predicate isDeeplyConstBelow() { this.getBaseType().isDeeplyConst() }
|
||||
}
|
||||
|
||||
/**
|
||||
* An Arm Scalable vector type.
|
||||
*
|
||||
* In the following example, `a` has a scalable vector type consisting
|
||||
* of 8-bit signed integer elements:
|
||||
* ```
|
||||
* svint8_t a;
|
||||
* ```
|
||||
*/
|
||||
class ScalableVectorType extends DerivedType {
|
||||
ScalableVectorType() { derivedtypes(underlyingElement(this), _, 11, _) }
|
||||
|
||||
/**
|
||||
* Get the number of tuple elements of this scalable vector type.
|
||||
*/
|
||||
int getNumTupleElements() { tupleelements(underlyingElement(this), result) }
|
||||
|
||||
override string getAPrimaryQlClass() { result = "ScalableVectorType" }
|
||||
|
||||
override string explain() { result = "scalable vector of {" + this.getBaseType().explain() + "}" }
|
||||
|
||||
override predicate isDeeplyConstBelow() { this.getBaseType().isDeeplyConst() }
|
||||
}
|
||||
|
||||
/**
|
||||
* A C/C++ pointer to a function. See 7.7.
|
||||
* ```
|
||||
|
||||
@@ -134,6 +134,8 @@ private predicate isOpaqueType(Type type) {
|
||||
)
|
||||
or
|
||||
type instanceof PointerToMemberType // PTMs are missing size info
|
||||
or
|
||||
type instanceof ScalableVectorCount
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -692,6 +692,7 @@ case @builtintype.kind of
|
||||
| 60 = @complex_float64x // _Complex _Float64x
|
||||
| 61 = @complex_std_float128 // _Complex _Float128
|
||||
| 62 = @mfp8 // __mfp8
|
||||
| 63 = @scalable_vector_count // __SVCount_t
|
||||
;
|
||||
|
||||
builtintypes(
|
||||
@@ -718,6 +719,7 @@ case @derivedtype.kind of
|
||||
| 8 = @rvalue_reference // C++11
|
||||
// ... 9 type_conforming_to_protocols deprecated
|
||||
| 10 = @block
|
||||
| 11 = @scalable_vector // Arm SVE
|
||||
;
|
||||
|
||||
derivedtypes(
|
||||
@@ -738,6 +740,11 @@ arraysizes(
|
||||
int alignment: int ref
|
||||
);
|
||||
|
||||
tupleelements(
|
||||
unique int id: @derivedtype ref,
|
||||
int num_elements: int ref
|
||||
);
|
||||
|
||||
typedefbase(
|
||||
unique int id: @usertype ref,
|
||||
int type_id: @type ref
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,2 @@
|
||||
description: Arm scalable vector type support
|
||||
compatibility: full
|
||||
@@ -21,6 +21,7 @@
|
||||
| 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 | __SVCount_t |
|
||||
| file://:0:0:0:0 | __bf16 |
|
||||
| file://:0:0:0:0 | __float128 |
|
||||
| file://:0:0:0:0 | __fp16 |
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
| file://:0:0:0:0 | _Imaginary double | 8 |
|
||||
| file://:0:0:0:0 | _Imaginary float | 4 |
|
||||
| file://:0:0:0:0 | _Imaginary long double | 16 |
|
||||
| file://:0:0:0:0 | __SVCount_t | 0 |
|
||||
| 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 |
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
| 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 | __SVCount_t | __SVCount_t |
|
||||
| file://:0:0:0:0 | __bf16 | __bf16 |
|
||||
| file://:0:0:0:0 | __float128 | __float128 |
|
||||
| file://:0:0:0:0 | __fp16 | __fp16 |
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
| _Imaginary double | BinaryFloatingPointType, ImaginaryNumberType | | | | |
|
||||
| _Imaginary float | BinaryFloatingPointType, ImaginaryNumberType | | | | |
|
||||
| _Imaginary long double | BinaryFloatingPointType, ImaginaryNumberType | | | | |
|
||||
| __SVCount_t | ScalableVectorCount | | | | |
|
||||
| __bf16 | BinaryFloatingPointType, RealNumberType | | | | |
|
||||
| __float128 | Float128Type | | | | |
|
||||
| __fp16 | BinaryFloatingPointType, RealNumberType | | | | |
|
||||
|
||||
Reference in New Issue
Block a user