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