Skip to content

Commit 1bd6446

Browse files
authored
Merge pull request #19715 from jketema/neon-ir-test
C++: Add basic Aarch64 Neon IR test
2 parents 652d32d + a4be276 commit 1bd6446

File tree

4 files changed

+252
-0
lines changed

4 files changed

+252
-0
lines changed

cpp/ql/test/library-tests/ir/ir/PrintAST.expected

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,77 @@
5858
#-----| Type = [LongType] unsigned long
5959
#-----| getParameter(1): [Parameter] (unnamed parameter 1)
6060
#-----| Type = [ScopedEnum] align_val_t
61+
arm.cpp:
62+
# 6| [TopLevelFunction] uint8x8_t vadd_u8(uint8x8_t, uint8x8_t)
63+
# 6| <params>:
64+
# 6| getParameter(0): [Parameter] a
65+
# 6| Type = [CTypedefType] uint8x8_t
66+
# 6| getParameter(1): [Parameter] b
67+
# 6| Type = [CTypedefType] uint8x8_t
68+
# 6| getEntryPoint(): [BlockStmt] { ... }
69+
# 7| getStmt(0): [ReturnStmt] return ...
70+
# 7| getExpr(): [AddExpr] ... + ...
71+
# 7| Type = [GNUVectorType] __attribute((neon_vector_type(8))) unsigned char
72+
# 7| ValueCategory = prvalue
73+
# 7| getLeftOperand(): [VariableAccess] a
74+
# 7| Type = [CTypedefType] uint8x8_t
75+
# 7| ValueCategory = prvalue(load)
76+
# 7| getRightOperand(): [VariableAccess] b
77+
# 7| Type = [CTypedefType] uint8x8_t
78+
# 7| ValueCategory = prvalue(load)
79+
# 12| [TopLevelFunction] uint16x8_t __builtin_aarch64_uaddlv8qi_uuu(uint8x8_t, uint8x8_t)
80+
# 12| <params>:
81+
# 12| getParameter(0): [Parameter] (unnamed parameter 0)
82+
# 12| Type = [CTypedefType] uint8x8_t
83+
# 12| getParameter(1): [Parameter] (unnamed parameter 1)
84+
# 12| Type = [CTypedefType] uint8x8_t
85+
# 14| [TopLevelFunction] uint16x8_t vaddl_u8(uint8x8_t, uint8x8_t)
86+
# 14| <params>:
87+
# 14| getParameter(0): [Parameter] a
88+
# 14| Type = [CTypedefType] uint8x8_t
89+
# 14| getParameter(1): [Parameter] b
90+
# 14| Type = [CTypedefType] uint8x8_t
91+
# 14| getEntryPoint(): [BlockStmt] { ... }
92+
# 15| getStmt(0): [ReturnStmt] return ...
93+
# 15| getExpr(): [FunctionCall] call to __builtin_aarch64_uaddlv8qi_uuu
94+
# 15| Type = [CTypedefType] uint16x8_t
95+
# 15| ValueCategory = prvalue
96+
# 15| getArgument(0): [VariableAccess] a
97+
# 15| Type = [CTypedefType] uint8x8_t
98+
# 15| ValueCategory = prvalue(load)
99+
# 15| getArgument(1): [VariableAccess] b
100+
# 15| Type = [CTypedefType] uint8x8_t
101+
# 15| ValueCategory = prvalue(load)
102+
# 18| [TopLevelFunction] uint16x8_t arm_add(uint8x8_t, uint8x8_t)
103+
# 18| <params>:
104+
# 18| getParameter(0): [Parameter] a
105+
# 18| Type = [CTypedefType] uint8x8_t
106+
# 18| getParameter(1): [Parameter] b
107+
# 18| Type = [CTypedefType] uint8x8_t
108+
# 18| getEntryPoint(): [BlockStmt] { ... }
109+
# 19| getStmt(0): [DeclStmt] declaration
110+
# 19| getDeclarationEntry(0): [VariableDeclarationEntry] definition of c
111+
# 19| Type = [CTypedefType] uint8x8_t
112+
# 19| getVariable().getInitializer(): [Initializer] initializer for c
113+
# 19| getExpr(): [FunctionCall] call to vadd_u8
114+
# 19| Type = [CTypedefType] uint8x8_t
115+
# 19| ValueCategory = prvalue
116+
# 19| getArgument(0): [VariableAccess] a
117+
# 19| Type = [CTypedefType] uint8x8_t
118+
# 19| ValueCategory = prvalue(load)
119+
# 19| getArgument(1): [VariableAccess] b
120+
# 19| Type = [CTypedefType] uint8x8_t
121+
# 19| ValueCategory = prvalue(load)
122+
# 20| getStmt(1): [ReturnStmt] return ...
123+
# 20| getExpr(): [FunctionCall] call to vaddl_u8
124+
# 20| Type = [CTypedefType] uint16x8_t
125+
# 20| ValueCategory = prvalue
126+
# 20| getArgument(0): [VariableAccess] a
127+
# 20| Type = [CTypedefType] uint8x8_t
128+
# 20| ValueCategory = prvalue(load)
129+
# 20| getArgument(1): [VariableAccess] c
130+
# 20| Type = [CTypedefType] uint8x8_t
131+
# 20| ValueCategory = prvalue(load)
61132
bad_asts.cpp:
62133
# 5| [CopyAssignmentOperator] Bad::S& Bad::S::operator=(Bad::S const&)
63134
# 5| <params>:

cpp/ql/test/library-tests/ir/ir/aliased_ir.expected

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,86 @@
1+
arm.cpp:
2+
# 6| uint8x8_t vadd_u8(uint8x8_t, uint8x8_t)
3+
# 6| Block 0
4+
# 6| v6_1(void) = EnterFunction :
5+
# 6| m6_2(unknown) = AliasedDefinition :
6+
# 6| m6_3(unknown) = InitializeNonLocal :
7+
# 6| m6_4(unknown) = Chi : total:m6_2, partial:m6_3
8+
# 6| r6_5(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[a] :
9+
# 6| m6_6(__attribute((neon_vector_type(8))) unsigned char) = InitializeParameter[a] : &:r6_5
10+
# 6| r6_7(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[b] :
11+
# 6| m6_8(__attribute((neon_vector_type(8))) unsigned char) = InitializeParameter[b] : &:r6_7
12+
# 7| r7_1(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[#return] :
13+
# 7| r7_2(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[a] :
14+
# 7| r7_3(__attribute((neon_vector_type(8))) unsigned char) = Load[a] : &:r7_2, m6_6
15+
# 7| r7_4(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[b] :
16+
# 7| r7_5(__attribute((neon_vector_type(8))) unsigned char) = Load[b] : &:r7_4, m6_8
17+
# 7| r7_6(__attribute((neon_vector_type(8))) unsigned char) = Add : r7_3, r7_5
18+
# 7| m7_7(__attribute((neon_vector_type(8))) unsigned char) = Store[#return] : &:r7_1, r7_6
19+
# 6| r6_9(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[#return] :
20+
# 6| v6_10(void) = ReturnValue : &:r6_9, m7_7
21+
# 6| v6_11(void) = AliasedUse : m6_3
22+
# 6| v6_12(void) = ExitFunction :
23+
24+
# 14| uint16x8_t vaddl_u8(uint8x8_t, uint8x8_t)
25+
# 14| Block 0
26+
# 14| v14_1(void) = EnterFunction :
27+
# 14| m14_2(unknown) = AliasedDefinition :
28+
# 14| m14_3(unknown) = InitializeNonLocal :
29+
# 14| m14_4(unknown) = Chi : total:m14_2, partial:m14_3
30+
# 14| r14_5(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[a] :
31+
# 14| m14_6(__attribute((neon_vector_type(8))) unsigned char) = InitializeParameter[a] : &:r14_5
32+
# 14| r14_7(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[b] :
33+
# 14| m14_8(__attribute((neon_vector_type(8))) unsigned char) = InitializeParameter[b] : &:r14_7
34+
# 15| r15_1(glval<__attribute((neon_vector_type(8))) unsigned short>) = VariableAddress[#return] :
35+
# 15| r15_2(glval<unknown>) = FunctionAddress[__builtin_aarch64_uaddlv8qi_uuu] :
36+
# 15| r15_3(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[a] :
37+
# 15| r15_4(__attribute((neon_vector_type(8))) unsigned char) = Load[a] : &:r15_3, m14_6
38+
# 15| r15_5(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[b] :
39+
# 15| r15_6(__attribute((neon_vector_type(8))) unsigned char) = Load[b] : &:r15_5, m14_8
40+
# 15| r15_7(__attribute((neon_vector_type(8))) unsigned short) = Call[__builtin_aarch64_uaddlv8qi_uuu] : func:r15_2, 0:r15_4, 1:r15_6
41+
# 15| m15_8(unknown) = ^CallSideEffect : ~m14_4
42+
# 15| m15_9(unknown) = Chi : total:m14_4, partial:m15_8
43+
# 15| m15_10(__attribute((neon_vector_type(8))) unsigned short) = Store[#return] : &:r15_1, r15_7
44+
# 14| r14_9(glval<__attribute((neon_vector_type(8))) unsigned short>) = VariableAddress[#return] :
45+
# 14| v14_10(void) = ReturnValue : &:r14_9, m15_10
46+
# 14| v14_11(void) = AliasedUse : ~m15_9
47+
# 14| v14_12(void) = ExitFunction :
48+
49+
# 18| uint16x8_t arm_add(uint8x8_t, uint8x8_t)
50+
# 18| Block 0
51+
# 18| v18_1(void) = EnterFunction :
52+
# 18| m18_2(unknown) = AliasedDefinition :
53+
# 18| m18_3(unknown) = InitializeNonLocal :
54+
# 18| m18_4(unknown) = Chi : total:m18_2, partial:m18_3
55+
# 18| r18_5(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[a] :
56+
# 18| m18_6(__attribute((neon_vector_type(8))) unsigned char) = InitializeParameter[a] : &:r18_5
57+
# 18| r18_7(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[b] :
58+
# 18| m18_8(__attribute((neon_vector_type(8))) unsigned char) = InitializeParameter[b] : &:r18_7
59+
# 19| r19_1(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[c] :
60+
# 19| r19_2(glval<unknown>) = FunctionAddress[vadd_u8] :
61+
# 19| r19_3(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[a] :
62+
# 19| r19_4(__attribute((neon_vector_type(8))) unsigned char) = Load[a] : &:r19_3, m18_6
63+
# 19| r19_5(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[b] :
64+
# 19| r19_6(__attribute((neon_vector_type(8))) unsigned char) = Load[b] : &:r19_5, m18_8
65+
# 19| r19_7(__attribute((neon_vector_type(8))) unsigned char) = Call[vadd_u8] : func:r19_2, 0:r19_4, 1:r19_6
66+
# 19| m19_8(unknown) = ^CallSideEffect : ~m18_4
67+
# 19| m19_9(unknown) = Chi : total:m18_4, partial:m19_8
68+
# 19| m19_10(__attribute((neon_vector_type(8))) unsigned char) = Store[c] : &:r19_1, r19_7
69+
# 20| r20_1(glval<__attribute((neon_vector_type(8))) unsigned short>) = VariableAddress[#return] :
70+
# 20| r20_2(glval<unknown>) = FunctionAddress[vaddl_u8] :
71+
# 20| r20_3(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[a] :
72+
# 20| r20_4(__attribute((neon_vector_type(8))) unsigned char) = Load[a] : &:r20_3, m18_6
73+
# 20| r20_5(glval<__attribute((neon_vector_type(8))) unsigned char>) = VariableAddress[c] :
74+
# 20| r20_6(__attribute((neon_vector_type(8))) unsigned char) = Load[c] : &:r20_5, m19_10
75+
# 20| r20_7(__attribute((neon_vector_type(8))) unsigned short) = Call[vaddl_u8] : func:r20_2, 0:r20_4, 1:r20_6
76+
# 20| m20_8(unknown) = ^CallSideEffect : ~m19_9
77+
# 20| m20_9(unknown) = Chi : total:m19_9, partial:m20_8
78+
# 20| m20_10(__attribute((neon_vector_type(8))) unsigned short) = Store[#return] : &:r20_1, r20_7
79+
# 18| r18_9(glval<__attribute((neon_vector_type(8))) unsigned short>) = VariableAddress[#return] :
80+
# 18| v18_10(void) = ReturnValue : &:r18_9, m20_10
81+
# 18| v18_11(void) = AliasedUse : ~m20_9
82+
# 18| v18_12(void) = ExitFunction :
83+
184
bad_asts.cpp:
285
# 9| int Bad::S::MemberFunction<int 6>(int)
386
# 9| Block 0
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// semmle-extractor-options: --edg --target --edg linux_arm64
2+
3+
typedef __Uint8x8_t uint8x8_t;
4+
typedef __Uint16x8_t uint16x8_t;
5+
6+
uint8x8_t vadd_u8(uint8x8_t a, uint8x8_t b) {
7+
return a + b;
8+
}
9+
10+
// Workaround: the frontend only exposes this when the arm_neon.h
11+
// header is encountered.
12+
uint16x8_t __builtin_aarch64_uaddlv8qi_uuu(uint8x8_t, uint8x8_t);
13+
14+
uint16x8_t vaddl_u8(uint8x8_t a, uint8x8_t b) {
15+
return __builtin_aarch64_uaddlv8qi_uuu (a, b);
16+
}
17+
18+
uint16x8_t arm_add(uint8x8_t a, uint8x8_t b) {
19+
uint8x8_t c = vadd_u8(a, b);
20+
return vaddl_u8(a, c);
21+
}

0 commit comments

Comments
 (0)