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