C++: Add Arm scalable vector type QL classes

This commit is contained in:
Jeroen Ketema
2025-06-17 13:02:20 +02:00
parent b2f7b89c80
commit 7ac26e879b
3 changed files with 51 additions and 2 deletions

View File

@@ -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;
@@ -1643,6 +1659,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.
* ```

View File

@@ -134,6 +134,8 @@ private predicate isOpaqueType(Type type) {
)
or
type instanceof PointerToMemberType // PTMs are missing size info
or
type instanceof ScalableVectorCount
}
/**

View File

@@ -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