• 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 orv_shlv_i32(i32 a0, i32 a1) <static> {
16  movi v0, 21
17  lda a0
18  shl2v v0, v0
19  lda v0
20  or2v v0, a1
21  lda v0
22  return
23}
24# (a0 >>> 21) | a1
25.function i32 orv_shrv_i32(i32 a0, i32 a1) <static> {
26  movi v0, 21
27  lda a0
28  shr2v v0, v0
29  lda v0
30  or2v v0, a1
31  lda v0
32  return
33}
34# (a0 >> 21) | a1
35.function i32 orv_ashrv_i32(i32 a0, i32 a1) <static> {
36  movi v0, 21
37  lda a0
38  ashr2v v0, v0
39  lda v0
40  or2v v0, a1
41  lda v0
42  return
43}
44# a1 & (a0 << 21)
45.function i32 orv_shlv_i32_2(i32 a0, i32 a1) <static> {
46  movi v0, 21
47  lda a0
48  shl2v v0, v0
49  lda a1
50  or2v v0, v0
51  lda v0
52  return
53}
54# a1 & (a0 >>> 21)
55.function i32 orv_shrv_i32_2(i32 a0, i32 a1) <static> {
56  movi v0, 21
57  lda a0
58  shr2v v0, v0
59  lda a1
60  or2v v0, v0
61  lda v0
62  return
63}
64# a1 & (a0 >> 21)
65.function i32 orv_ashrv_i32_2(i32 a0, i32 a1) <static> {
66  movi v0, 21
67  lda a0
68  ashr2v v0, v0
69  lda a1
70  or2v v0, v0
71  lda v0
72  return
73}
74# (a0 << 42) | a1
75.function i64 orv_shlv_i64(i64 a0, i64 a1) <static> {
76  movi.64 v0, 42
77  lda.64 a0
78  shl2v.64 v0, v0
79  lda.64 v0
80  or2v.64 v0, a1
81  lda.64 v0
82  return.64
83}
84# (a0 >>> 42) | a1
85.function i64 orv_shrv_i64(i64 a0, i64 a1) <static> {
86  movi.64 v0, 42
87  lda.64 a0
88  shr2v.64 v0, v0
89  lda.64 v0
90  or2v.64 v0, a1
91  lda.64 v0
92  return.64
93}
94# (a0 >> 42) | a1
95.function i64 orv_ashrv_i64(i64 a0, i64 a1) <static> {
96  movi.64 v0, 42
97  lda.64 a0
98  ashr2v.64 v0, v0
99  lda.64 v0
100  or2v.64 v0, a1
101  lda.64 v0
102  return.64
103}
104# a1 | (a0 << 42)
105.function i64 orv_shlv_i64_2(i64 a0, i64 a1) <static> {
106  movi.64 v0, 42
107  lda.64 a0
108  shl2v.64 v0, v0
109  lda.64 a1
110  or2v.64 v0, v0
111  lda.64 v0
112  return.64
113}
114# a1 | (a0 >>> 42)
115.function i64 orv_shrv_i64_2(i64 a0, i64 a1) <static> {
116  movi.64 v0, 42
117  lda.64 a0
118  shr2v.64 v0, v0
119  lda.64 a1
120  or2v.64 v0, v0
121  lda.64 v0
122  return.64
123}
124# a1 | (a0 >> 42)
125.function i64 orv_ashrv_i64_2(i64 a0, i64 a1) <static> {
126  movi.64 v0, 42
127  lda.64 a0
128  ashr2v.64 v0, v0
129  lda.64 a1
130  or2v.64 v0, v0
131  lda.64 v0
132  return.64
133}
134
135
136.function i32 main() <static> {
137  movi v0, 21
138  ldai 0x200000
139  shr2 v0
140  sta v0
141  movi v1, 0x100000
142  call.short orv_shlv_i32, v0, v1
143  movi v0, 0x300000
144  jne v0, exit_error_0
145  movi v0, 21
146  ldai 1
147  shl2 v0
148  sta v0
149  movi v1, 2
150  call.short orv_shrv_i32, v0, v1
151  movi v0, 3
152  jne v0, exit_error_1
153  movi v0, 1
154  ldai -1
155  shl2 v0
156  sta v0
157  movi v1, 0xb1b1
158  call.short orv_ashrv_i32, v0, v1
159  movi v0, -1
160  jne v0, exit_error_2
161  movi v0, 21
162  ldai 0x200000
163  shr2 v0
164  sta v0
165  movi v1, 0x100000
166  call.short orv_shlv_i32_2, v0, v1
167  movi v0, 0x300000
168  jne v0, exit_error_3
169  movi v0, 21
170  ldai 1
171  shl2 v0
172  sta v0
173  movi v1, 2
174  call.short orv_shrv_i32_2, v0, v1
175  movi v0, 3
176  jne v0, exit_error_4
177  movi v0, 1
178  ldai -1
179  shl2 v0
180  sta v0
181  movi v1, 0xb1b1
182  call.short orv_ashrv_i32_2, v0, v1
183  movi v0, -1
184  jne v0, exit_error_5
185  movi.64 v0, 42
186  ldai.64 0x40000000000
187  shr2.64 v0
188  sta.64 v0
189  movi.64 v1, 0x10000000000
190  call.short orv_shlv_i64, v0, v1
191  movi.64 v0, 0x50000000000
192  cmp.64 v0
193  jnez exit_error_6
194  movi.64 v0, 42
195  ldai.64 1
196  shl2.64 v0
197  sta.64 v0
198  movi.64 v1, 2
199  call.short orv_shrv_i64, v0, v1
200  movi.64 v0, 3
201  cmp.64 v0
202  jnez exit_error_7
203  movi.64 v0, 42
204  ldai.64 -1
205  shl2.64 v0
206  sta.64 v0
207  movi.64 v1, 0x1234
208  call.short orv_ashrv_i64, v0, v1
209  movi.64 v0, -1
210  cmp.64 v0
211  jnez exit_error_8
212  movi.64 v0, 42
213  ldai.64 0x40000000000
214  shr2.64 v0
215  sta.64 v0
216  movi.64 v1, 0x10000000000
217  call.short orv_shlv_i64_2, v0, v1
218  movi.64 v0, 0x50000000000
219  cmp.64 v0
220  jnez exit_error_9
221  movi.64 v0, 42
222  ldai.64 1
223  shl2.64 v0
224  sta.64 v0
225  movi.64 v1, 2
226  call.short orv_shrv_i64_2, v0, v1
227  movi.64 v0, 3
228  cmp.64 v0
229  jnez exit_error_10
230  movi.64 v0, 42
231  ldai.64 -1
232  shl2.64 v0
233  sta.64 v0
234  movi.64 v1, 0x1234
235  call.short orv_ashrv_i64_2, v0, v1
236  movi.64 v0, -1
237  cmp.64 v0
238  jnez exit_error_11
239  ldai 0
240  return
241exit_error_0:
242  ldai 1
243  return
244exit_error_1:
245  ldai 2
246  return
247exit_error_2:
248  ldai 3
249  return
250exit_error_3:
251  ldai 4
252  return
253exit_error_4:
254  ldai 5
255  return
256exit_error_5:
257  ldai 6
258  return
259exit_error_6:
260  ldai 7
261  return
262exit_error_7:
263  ldai 8
264  return
265exit_error_8:
266  ldai 9
267  return
268exit_error_9:
269  ldai 10
270  return
271exit_error_10:
272  ldai 11
273  return
274exit_error_11:
275  ldai 12
276  return
277}
278