C++: Add basic Aarch64 Neon test

This commit is contained in:
Jeroen Ketema
2025-06-10 15:34:06 +02:00
parent 8f0f2006a8
commit 7d1b5ce584
4 changed files with 254 additions and 0 deletions

View File

@@ -58,6 +58,77 @@
#-----| Type = [LongType] unsigned long
#-----| getParameter(1): [Parameter] (unnamed parameter 1)
#-----| Type = [ScopedEnum] align_val_t
arm.cpp:
# 6| [TopLevelFunction] uint8x8_t vadd_u8(uint8x8_t, uint8x8_t)
# 6| <params>:
# 6| getParameter(0): [Parameter] __a
# 6| Type = [CTypedefType] uint8x8_t
# 6| getParameter(1): [Parameter] __b
# 6| Type = [CTypedefType] uint8x8_t
# 7| getEntryPoint(): [BlockStmt] { ... }
# 8| getStmt(0): [ReturnStmt] return ...
# 8| getExpr(): [AddExpr] ... + ...
# 8| Type = [GNUVectorType] __attribute((neon_vector_type(8))) unsigned char
# 8| ValueCategory = prvalue
# 8| getLeftOperand(): [VariableAccess] __a
# 8| Type = [CTypedefType] uint8x8_t
# 8| ValueCategory = prvalue(load)
# 8| getRightOperand(): [VariableAccess] __b
# 8| Type = [CTypedefType] uint8x8_t
# 8| ValueCategory = prvalue(load)
# 13| [TopLevelFunction] uint16x8_t __builtin_aarch64_uaddlv8qi_uuu(uint8x8_t, uint8x8_t)
# 13| <params>:
# 13| getParameter(0): [Parameter] (unnamed parameter 0)
# 13| Type = [CTypedefType] uint8x8_t
# 13| getParameter(1): [Parameter] (unnamed parameter 1)
# 13| Type = [CTypedefType] uint8x8_t
# 15| [TopLevelFunction] uint16x8_t vaddl_u8(uint8x8_t, uint8x8_t)
# 15| <params>:
# 15| getParameter(0): [Parameter] __a
# 15| Type = [CTypedefType] uint8x8_t
# 15| getParameter(1): [Parameter] __b
# 15| Type = [CTypedefType] uint8x8_t
# 16| getEntryPoint(): [BlockStmt] { ... }
# 17| getStmt(0): [ReturnStmt] return ...
# 17| getExpr(): [FunctionCall] call to __builtin_aarch64_uaddlv8qi_uuu
# 17| Type = [CTypedefType] uint16x8_t
# 17| ValueCategory = prvalue
# 17| getArgument(0): [VariableAccess] __a
# 17| Type = [CTypedefType] uint8x8_t
# 17| ValueCategory = prvalue(load)
# 17| getArgument(1): [VariableAccess] __b
# 17| Type = [CTypedefType] uint8x8_t
# 17| ValueCategory = prvalue(load)
# 20| [TopLevelFunction] uint16x8_t arm_add(uint8x8_t, uint8x8_t)
# 20| <params>:
# 20| getParameter(0): [Parameter] a
# 20| Type = [CTypedefType] uint8x8_t
# 20| getParameter(1): [Parameter] b
# 20| Type = [CTypedefType] uint8x8_t
# 20| getEntryPoint(): [BlockStmt] { ... }
# 21| getStmt(0): [DeclStmt] declaration
# 21| getDeclarationEntry(0): [VariableDeclarationEntry] definition of c
# 21| Type = [CTypedefType] uint8x8_t
# 21| getVariable().getInitializer(): [Initializer] initializer for c
# 21| getExpr(): [FunctionCall] call to vadd_u8
# 21| Type = [CTypedefType] uint8x8_t
# 21| ValueCategory = prvalue
# 21| getArgument(0): [VariableAccess] a
# 21| Type = [CTypedefType] uint8x8_t
# 21| ValueCategory = prvalue(load)
# 21| getArgument(1): [VariableAccess] b
# 21| Type = [CTypedefType] uint8x8_t
# 21| ValueCategory = prvalue(load)
# 22| getStmt(1): [ReturnStmt] return ...
# 22| getExpr(): [FunctionCall] call to vaddl_u8
# 22| Type = [CTypedefType] uint16x8_t
# 22| ValueCategory = prvalue
# 22| getArgument(0): [VariableAccess] a
# 22| Type = [CTypedefType] uint8x8_t
# 22| ValueCategory = prvalue(load)
# 22| getArgument(1): [VariableAccess] c
# 22| Type = [CTypedefType] uint8x8_t
# 22| ValueCategory = prvalue(load)
bad_asts.cpp:
# 5| [CopyAssignmentOperator] Bad::S& Bad::S::operator=(Bad::S const&)
# 5| <params>:

View File

@@ -1,3 +1,86 @@
arm.cpp:
# 6| uint8x8_t vadd_u8(uint8x8_t, uint8x8_t)
# 6| Block 0
# 6| v6_1(void) = EnterFunction :
# 6| m6_2(unknown) = AliasedDefinition :
# 6| m6_3(unknown) = InitializeNonLocal :
# 6| m6_4(unknown) = Chi : total:m6_2, partial:m6_3
# 6| r6_5(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[__a] :
# 6| m6_6(__attribute((neon_vector_type(8))) unsigned char) = InitializeParameter[__a] : &:r6_5
# 6| r6_7(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[__b] :
# 6| m6_8(__attribute((neon_vector_type(8))) unsigned char) = InitializeParameter[__b] : &:r6_7
# 8| r8_1(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[#return] :
# 8| r8_2(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[__a] :
# 8| r8_3(__attribute((neon_vector_type(8))) unsigned char) = Load[__a] : &:r8_2, m6_6
# 8| r8_4(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[__b] :
# 8| r8_5(__attribute((neon_vector_type(8))) unsigned char) = Load[__b] : &:r8_4, m6_8
# 8| r8_6(__attribute((neon_vector_type(8))) unsigned char) = Add : r8_3, r8_5
# 8| m8_7(__attribute((neon_vector_type(8))) unsigned char) = Store[#return] : &:r8_1, r8_6
# 6| r6_9(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[#return] :
# 6| v6_10(void) = ReturnValue : &:r6_9, m8_7
# 6| v6_11(void) = AliasedUse : m6_3
# 6| v6_12(void) = ExitFunction :
# 15| uint16x8_t vaddl_u8(uint8x8_t, uint8x8_t)
# 15| Block 0
# 15| v15_1(void) = EnterFunction :
# 15| m15_2(unknown) = AliasedDefinition :
# 15| m15_3(unknown) = InitializeNonLocal :
# 15| m15_4(unknown) = Chi : total:m15_2, partial:m15_3
# 15| r15_5(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[__a] :
# 15| m15_6(__attribute((neon_vector_type(8))) unsigned char) = InitializeParameter[__a] : &:r15_5
# 15| r15_7(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[__b] :
# 15| m15_8(__attribute((neon_vector_type(8))) unsigned char) = InitializeParameter[__b] : &:r15_7
# 17| r17_1(glval<__attribute((neon_vector_type(8))) unsigned short>) = VariableAddress[#return] :
# 17| r17_2(glval<unknown>) = FunctionAddress[__builtin_aarch64_uaddlv8qi_uuu] :
# 17| r17_3(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[__a] :
# 17| r17_4(__attribute((neon_vector_type(8))) unsigned char) = Load[__a] : &:r17_3, m15_6
# 17| r17_5(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[__b] :
# 17| r17_6(__attribute((neon_vector_type(8))) unsigned char) = Load[__b] : &:r17_5, m15_8
# 17| r17_7(__attribute((neon_vector_type(8))) unsigned short) = Call[__builtin_aarch64_uaddlv8qi_uuu] : func:r17_2, 0:r17_4, 1:r17_6
# 17| m17_8(unknown) = ^CallSideEffect : ~m15_4
# 17| m17_9(unknown) = Chi : total:m15_4, partial:m17_8
# 17| m17_10(__attribute((neon_vector_type(8))) unsigned short) = Store[#return] : &:r17_1, r17_7
# 15| r15_9(glval<__attribute((neon_vector_type(8))) unsigned short>) = VariableAddress[#return] :
# 15| v15_10(void) = ReturnValue : &:r15_9, m17_10
# 15| v15_11(void) = AliasedUse : ~m17_9
# 15| v15_12(void) = ExitFunction :
# 20| uint16x8_t arm_add(uint8x8_t, uint8x8_t)
# 20| Block 0
# 20| v20_1(void) = EnterFunction :
# 20| m20_2(unknown) = AliasedDefinition :
# 20| m20_3(unknown) = InitializeNonLocal :
# 20| m20_4(unknown) = Chi : total:m20_2, partial:m20_3
# 20| r20_5(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[a] :
# 20| m20_6(__attribute((neon_vector_type(8))) unsigned char) = InitializeParameter[a] : &:r20_5
# 20| r20_7(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[b] :
# 20| m20_8(__attribute((neon_vector_type(8))) unsigned char) = InitializeParameter[b] : &:r20_7
# 21| r21_1(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[c] :
# 21| r21_2(glval<unknown>) = FunctionAddress[vadd_u8] :
# 21| r21_3(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[a] :
# 21| r21_4(__attribute((neon_vector_type(8))) unsigned char) = Load[a] : &:r21_3, m20_6
# 21| r21_5(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[b] :
# 21| r21_6(__attribute((neon_vector_type(8))) unsigned char) = Load[b] : &:r21_5, m20_8
# 21| r21_7(__attribute((neon_vector_type(8))) unsigned char) = Call[vadd_u8] : func:r21_2, 0:r21_4, 1:r21_6
# 21| m21_8(unknown) = ^CallSideEffect : ~m20_4
# 21| m21_9(unknown) = Chi : total:m20_4, partial:m21_8
# 21| m21_10(__attribute((neon_vector_type(8))) unsigned char) = Store[c] : &:r21_1, r21_7
# 22| r22_1(glval<__attribute((neon_vector_type(8))) unsigned short>) = VariableAddress[#return] :
# 22| r22_2(glval<unknown>) = FunctionAddress[vaddl_u8] :
# 22| r22_3(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[a] :
# 22| r22_4(__attribute((neon_vector_type(8))) unsigned char) = Load[a] : &:r22_3, m20_6
# 22| r22_5(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[c] :
# 22| r22_6(__attribute((neon_vector_type(8))) unsigned char) = Load[c] : &:r22_5, m21_10
# 22| r22_7(__attribute((neon_vector_type(8))) unsigned short) = Call[vaddl_u8] : func:r22_2, 0:r22_4, 1:r22_6
# 22| m22_8(unknown) = ^CallSideEffect : ~m21_9
# 22| m22_9(unknown) = Chi : total:m21_9, partial:m22_8
# 22| m22_10(__attribute((neon_vector_type(8))) unsigned short) = Store[#return] : &:r22_1, r22_7
# 20| r20_9(glval<__attribute((neon_vector_type(8))) unsigned short>) = VariableAddress[#return] :
# 20| v20_10(void) = ReturnValue : &:r20_9, m22_10
# 20| v20_11(void) = AliasedUse : ~m22_9
# 20| v20_12(void) = ExitFunction :
bad_asts.cpp:
# 9| int Bad::S::MemberFunction<int 6>(int)
# 9| Block 0

View File

@@ -0,0 +1,23 @@
// semmle-extractor-options: --edg --target --edg linux_arm64
typedef __Uint8x8_t uint8x8_t;
typedef __Uint16x8_t uint16x8_t;
uint8x8_t vadd_u8 (uint8x8_t __a, uint8x8_t __b)
{
return __a + __b;
}
// Workaround: the frontend only exposes this when the arm_neon.h
// header is encountered.
uint16x8_t __builtin_aarch64_uaddlv8qi_uuu(uint8x8_t, uint8x8_t);
uint16x8_t vaddl_u8 (uint8x8_t __a, uint8x8_t __b)
{
return __builtin_aarch64_uaddlv8qi_uuu (__a, __b);
}
uint16x8_t arm_add(uint8x8_t a, uint8x8_t b) {
uint8x8_t c = vadd_u8(a, b);
return vaddl_u8(a, c);
}

View File

@@ -1,3 +1,80 @@
arm.cpp:
# 6| uint8x8_t vadd_u8(uint8x8_t, uint8x8_t)
# 6| Block 0
# 6| v6_1(void) = EnterFunction :
# 6| mu6_2(unknown) = AliasedDefinition :
# 6| mu6_3(unknown) = InitializeNonLocal :
# 6| r6_4(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[__a] :
# 6| mu6_5(__attribute((neon_vector_type(8))) unsigned char) = InitializeParameter[__a] : &:r6_4
# 6| r6_6(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[__b] :
# 6| mu6_7(__attribute((neon_vector_type(8))) unsigned char) = InitializeParameter[__b] : &:r6_6
# 8| r8_1(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[#return] :
# 8| r8_2(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[__a] :
# 8| r8_3(__attribute((neon_vector_type(8))) unsigned char) = Load[__a] : &:r8_2, ~m?
# 8| r8_4(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[__b] :
# 8| r8_5(__attribute((neon_vector_type(8))) unsigned char) = Load[__b] : &:r8_4, ~m?
# 8| r8_6(__attribute((neon_vector_type(8))) unsigned char) = Add : r8_3, r8_5
# 8| mu8_7(__attribute((neon_vector_type(8))) unsigned char) = Store[#return] : &:r8_1, r8_6
# 6| r6_8(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[#return] :
# 6| v6_9(void) = ReturnValue : &:r6_8, ~m?
# 6| v6_10(void) = AliasedUse : ~m?
# 6| v6_11(void) = ExitFunction :
# 15| uint16x8_t vaddl_u8(uint8x8_t, uint8x8_t)
# 15| Block 0
# 15| v15_1(void) = EnterFunction :
# 15| mu15_2(unknown) = AliasedDefinition :
# 15| mu15_3(unknown) = InitializeNonLocal :
# 15| r15_4(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[__a] :
# 15| mu15_5(__attribute((neon_vector_type(8))) unsigned char) = InitializeParameter[__a] : &:r15_4
# 15| r15_6(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[__b] :
# 15| mu15_7(__attribute((neon_vector_type(8))) unsigned char) = InitializeParameter[__b] : &:r15_6
# 17| r17_1(glval<__attribute((neon_vector_type(8))) unsigned short>) = VariableAddress[#return] :
# 17| r17_2(glval<unknown>) = FunctionAddress[__builtin_aarch64_uaddlv8qi_uuu] :
# 17| r17_3(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[__a] :
# 17| r17_4(__attribute((neon_vector_type(8))) unsigned char) = Load[__a] : &:r17_3, ~m?
# 17| r17_5(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[__b] :
# 17| r17_6(__attribute((neon_vector_type(8))) unsigned char) = Load[__b] : &:r17_5, ~m?
# 17| r17_7(__attribute((neon_vector_type(8))) unsigned short) = Call[__builtin_aarch64_uaddlv8qi_uuu] : func:r17_2, 0:r17_4, 1:r17_6
# 17| mu17_8(unknown) = ^CallSideEffect : ~m?
# 17| mu17_9(__attribute((neon_vector_type(8))) unsigned short) = Store[#return] : &:r17_1, r17_7
# 15| r15_8(glval<__attribute((neon_vector_type(8))) unsigned short>) = VariableAddress[#return] :
# 15| v15_9(void) = ReturnValue : &:r15_8, ~m?
# 15| v15_10(void) = AliasedUse : ~m?
# 15| v15_11(void) = ExitFunction :
# 20| uint16x8_t arm_add(uint8x8_t, uint8x8_t)
# 20| Block 0
# 20| v20_1(void) = EnterFunction :
# 20| mu20_2(unknown) = AliasedDefinition :
# 20| mu20_3(unknown) = InitializeNonLocal :
# 20| r20_4(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[a] :
# 20| mu20_5(__attribute((neon_vector_type(8))) unsigned char) = InitializeParameter[a] : &:r20_4
# 20| r20_6(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[b] :
# 20| mu20_7(__attribute((neon_vector_type(8))) unsigned char) = InitializeParameter[b] : &:r20_6
# 21| r21_1(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[c] :
# 21| r21_2(glval<unknown>) = FunctionAddress[vadd_u8] :
# 21| r21_3(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[a] :
# 21| r21_4(__attribute((neon_vector_type(8))) unsigned char) = Load[a] : &:r21_3, ~m?
# 21| r21_5(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[b] :
# 21| r21_6(__attribute((neon_vector_type(8))) unsigned char) = Load[b] : &:r21_5, ~m?
# 21| r21_7(__attribute((neon_vector_type(8))) unsigned char) = Call[vadd_u8] : func:r21_2, 0:r21_4, 1:r21_6
# 21| mu21_8(unknown) = ^CallSideEffect : ~m?
# 21| mu21_9(__attribute((neon_vector_type(8))) unsigned char) = Store[c] : &:r21_1, r21_7
# 22| r22_1(glval<__attribute((neon_vector_type(8))) unsigned short>) = VariableAddress[#return] :
# 22| r22_2(glval<unknown>) = FunctionAddress[vaddl_u8] :
# 22| r22_3(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[a] :
# 22| r22_4(__attribute((neon_vector_type(8))) unsigned char) = Load[a] : &:r22_3, ~m?
# 22| r22_5(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[c] :
# 22| r22_6(__attribute((neon_vector_type(8))) unsigned char) = Load[c] : &:r22_5, ~m?
# 22| r22_7(__attribute((neon_vector_type(8))) unsigned short) = Call[vaddl_u8] : func:r22_2, 0:r22_4, 1:r22_6
# 22| mu22_8(unknown) = ^CallSideEffect : ~m?
# 22| mu22_9(__attribute((neon_vector_type(8))) unsigned short) = Store[#return] : &:r22_1, r22_7
# 20| r20_8(glval<__attribute((neon_vector_type(8))) unsigned short>) = VariableAddress[#return] :
# 20| v20_9(void) = ReturnValue : &:r20_8, ~m?
# 20| v20_10(void) = AliasedUse : ~m?
# 20| v20_11(void) = ExitFunction :
bad_asts.cpp:
# 9| int Bad::S::MemberFunction<int 6>(int)
# 9| Block 0