• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021-2024 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14# (a0 << 21) & a1
15.function i32 andv_shlv_i32(i32 a0, i32 a1) <static> {
16  movi v0, 21
17  lda a0
18  shl2v v0, v0
19  lda v0
20  and2v v0, a1
21  lda v0
22  return
23}
24# (a0 >>> 21) & a1
25.function i32 andv_shrv_i32(i32 a0, i32 a1) <static> {
26  movi v0, 21
27  lda a0
28  shr2v v0, v0
29  lda v0
30  and2v v0, a1
31  lda v0
32  return
33}
34# (a0 >> 21) & a1
35.function i32 andv_ashrv_i32(i32 a0, i32 a1) <static> {
36  movi v0, 21
37  lda a0
38  ashr2v v0, v0
39  lda v0
40  and2v v0, a1
41  lda v0
42  return
43}
44# a1 & (a0 << 21)
45.function i32 andv_shlv_i32_2(i32 a0, i32 a1) <static> {
46  movi v0, 21
47  lda a0
48  shl2v v0, v0
49  lda a1
50  and2v v0, v0
51  lda v0
52  return
53}
54# a1 & (a0 >>> 21)
55.function i32 andv_shrv_i32_2(i32 a0, i32 a1) <static> {
56  movi v0, 21
57  lda a0
58  shr2v v0, v0
59  lda a1
60  and2v v0, v0
61  lda v0
62  return
63}
64# a1 & (a0 >> 21)
65.function i32 andv_ashrv_i32_2(i32 a0, i32 a1) <static> {
66  movi v0, 21
67  ashrv a0, v0
68  andv a1, a0
69  lda a1
70  return
71}
72
73# (a0 << 42) & a1
74.function i64 andv_shlv_i64(i64 a0, i64 a1) <static> {
75  movi.64 v0, 42
76  lda.64 a0
77  shl2v.64 v0, v0
78  lda.64 v0
79  and2v.64 v0, a1
80  lda.64 v0
81  return.64
82}
83# (a0 >>> 42) & a1
84.function i64 andv_shrv_i64(i64 a0, i64 a1) <static> {
85  movi.64 v0, 42
86  lda.64 a0
87  shr2v.64 v0, v0
88  lda.64 v0
89  and2v.64 v0, a1
90  lda.64 v0
91  return.64
92}
93# (a0 >> 42) & a1
94.function i64 andv_ashrv_i64(i64 a0, i64 a1) <static> {
95  movi.64 v0, 42
96  lda.64 a0
97  ashr2v.64 v0, v0
98  lda.64 v0
99  and2v.64 v0, a1
100  lda.64 v0
101  return.64
102}
103# a1 & (a0 << 42)
104.function i64 andv_shlv_i64_2(i64 a0, i64 a1) <static> {
105  movi.64 v0, 42
106  lda.64 a0
107  shl2v.64 v0, v0
108  lda.64 a1
109  and2v.64 v0, v0
110  lda.64 v0
111  return.64
112}
113# a1 & (a0 >>> 42)
114.function i64 andv_shrv_i64_2(i64 a0, i64 a1) <static> {
115  movi.64 v0, 42
116  lda.64 a0
117  shr2v.64 v0, v0
118  lda.64 a1
119  and2v.64 v0, v0
120  lda.64 v0
121  return.64
122}
123# a1 & (a0 >> 42)
124.function i64 andv_ashrv_i64_2(i64 a0, i64 a1) <static> {
125  movi.64 v0, 42
126  lda.64 a0
127  ashr2v.64 v0, v0
128  lda.64 a1
129  and2v.64 v0, v0
130  lda.64 v0
131  return.64
132}
133
134.function i32 main() <static> {
135  movi v0, 21
136  ldai 0x200000
137  shr2 v0
138  sta v0
139  movi v1, 0x300000
140  call.short andv_shlv_i32, v0, v1
141  movi v0, 0x200000
142  jne v0, exit_error_0
143  movi v0, 21
144  ldai 1
145  shl2 v0
146  sta v0
147  movi v1, 3
148  call.short andv_shrv_i32, v0, v1
149  movi v0, 1
150  jne v0, exit_error_1
151  movi v0, 1
152  ldai -1
153  shl2 v0
154  sta v0
155  movi v1, 0xb1b1
156  call.short andv_ashrv_i32, v0, v1
157  movi v0, 0xb1b1
158  jne v0, exit_error_2
159  movi v0, 21
160  ldai 0x200000
161  shr2 v0
162  sta v0
163  movi v1, 0x300000
164  call.short andv_shlv_i32_2, v0, v1
165  movi v0, 0x200000
166  jne v0, exit_error_3
167  movi v0, 21
168  ldai 1
169  shl2 v0
170  sta v0
171  movi v1, 3
172  call.short andv_shrv_i32_2, v0, v1
173  movi v0, 1
174  jne v0, exit_error_4
175  movi v0, 1
176  ldai -1
177  shl2 v0
178  sta v0
179  movi v1, 0xb1b1
180  call.short andv_ashrv_i32_2, v0, v1
181  movi v0, 0xb1b1
182  jne v0, exit_error_5
183  movi.64 v0, 42
184  ldai.64 0x40000000000
185  shr2.64 v0
186  sta.64 v0
187  movi.64 v1, 0x50000000000
188  call.short andv_shlv_i64, v0, v1
189  movi.64 v0, 0x40000000000
190  cmp.64 v0
191  jnez exit_error_6
192  movi.64 v0, 42
193  ldai.64 1
194  shl2.64 v0
195  sta.64 v0
196  movi.64 v1, 3
197  call.short andv_shrv_i64, v0, v1
198  movi.64 v0, 1
199  cmp.64 v0
200  jnez exit_error_7
201  movi.64 v0, 42
202  ldai.64 -1
203  shl2.64 v0
204  sta.64 v0
205  movi.64 v1, 0x1234
206  call.short andv_ashrv_i64, v0, v1
207  movi.64 v0, 0x1234
208  cmp.64 v0
209  jnez exit_error_8
210  movi.64 v0, 42
211  ldai.64 0x40000000000
212  shr2.64 v0
213  sta.64 v0
214  movi.64 v1, 0x50000000000
215  call.short andv_shlv_i64_2, v0, v1
216  movi.64 v0, 0x40000000000
217  cmp.64 v0
218  jnez exit_error_9
219  movi.64 v0, 42
220  ldai.64 1
221  shl2.64 v0
222  sta.64 v0
223  movi.64 v1, 3
224  call.short andv_shrv_i64_2, v0, v1
225  movi.64 v0, 1
226  cmp.64 v0
227  jnez exit_error_10
228  movi.64 v0, 42
229  ldai.64 -1
230  shl2.64 v0
231  sta.64 v0
232  movi.64 v1, 0x1234
233  call.short andv_ashrv_i64_2, v0, v1
234  movi.64 v0, 0x1234
235  cmp.64 v0
236  jnez exit_error_11
237  ldai 0
238  return
239exit_error_0:
240  ldai 1
241  return
242exit_error_1:
243  ldai 2
244  return
245exit_error_2:
246  ldai 3
247  return
248exit_error_3:
249  ldai 4
250  return
251exit_error_4:
252  ldai 5
253  return
254exit_error_5:
255  ldai 6
256  return
257exit_error_6:
258  ldai 7
259  return
260exit_error_7:
261  ldai 8
262  return
263exit_error_8:
264  ldai 9
265  return
266exit_error_9:
267  ldai 10
268  return
269exit_error_10:
270  ldai 11
271  return
272exit_error_11:
273  ldai 12
274  return
275}
276