• 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 sub_shl_i32(i32 a0, i32 a1) <static> {
16  movi v0, 21
17  lda a0
18  shl2 v0
19  sub2 a1
20  return
21}
22# (a0 >>> 21) - a1
23.function i32 sub_shr_i32(i32 a0, i32 a1) <static> {
24  movi v0, 21
25  lda a0
26  shr2 v0
27  sub2 a1
28  return
29}
30# (a0 >> 21) - a1
31.function i32 sub_ashr_i32(i32 a0, i32 a1) <static> {
32  movi v0, 21
33  lda a0
34  ashr2 v0
35  sub2 a1
36  return
37}
38# a1 - (a0 << 21)
39.function i32 sub_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  sub2 v0
46  return
47}
48# a1 - (a0 >>> 21)
49.function i32 sub_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  sub2 v0
56  return
57}
58# a1 - (a0 >> 21)
59.function i32 sub_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  sub2 v0
66  return
67}
68# (a0 << 42) - a1
69.function i64 sub_shl_i64(i64 a0, i64 a1) <static> {
70  movi.64 v0, 42
71  lda.64 a0
72  shl2.64 v0
73  sub2.64 a1
74  return.64
75}
76# (a0 >>> 42) - a1
77.function i64 sub_shr_i64(i64 a0, i64 a1) <static> {
78  movi.64 v0, 42
79  lda.64 a0
80  shr2.64 v0
81  sub2.64 a1
82  return.64
83}
84# (a0 >> 42) - a1
85.function i64 sub_ashr_i64(i64 a0, i64 a1) <static> {
86  movi.64 v0, 42
87  lda.64 a0
88  ashr2.64 v0
89  sub2.64 a1
90  return.64
91}
92# a1 - (a0 << 42)
93.function i64 sub_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  sub2.64 v0
100  return.64
101}
102# a1 - (a0 >>> 42)
103.function i64 sub_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  sub2.64 v0
110  return.64
111}
112# a1 - (a0 >> 42)
113.function i64 sub_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  sub2.64 v0
120  return.64
121}
122
123.function i32 main() <static> {
124  movi v0, 21
125  ldai 257949696
126  shr2 v0
127  sta v0
128  movi v1, 321
129  call.short sub_shl_i32, v0, v1
130  movi v0, 257949375
131  jne v0, exit_error_0
132  movi v0, 21
133  ldai 123
134  shl2 v0
135  sta v0
136  movi v1, 321
137  call.short sub_shr_i32, v0, v1
138  movi v0, -198
139  jne v0, exit_error_1
140  movi v0, 21
141  ldai -1
142  shl2 v0
143  sta v0
144  movi v1, 321
145  call.short sub_ashr_i32, v0, v1
146  movi v0, -322
147  jne v0, exit_error_2
148  movi v0, 21
149  ldai 257949696
150  shr2 v0
151  sta v0
152  movi v1, 321
153  call.short sub_shl_i32_2, v0, v1
154  movi v0, -257949375
155  jne v0, exit_error_3
156  movi v0, 21
157  ldai 123
158  shl2 v0
159  sta v0
160  movi v1, 321
161  call.short sub_shr_i32_2, v0, v1
162  movi v0, 198
163  jne v0, exit_error_4
164  movi v0, 21
165  ldai -1
166  shl2 v0
167  sta v0
168  movi v1, 321
169  call.short sub_ashr_i32_2, v0, v1
170  movi v0, 322
171  jne v0, exit_error_5
172  movi.64 v0, 42
173  ldai.64 540959720865792
174  shr2.64 v0
175  sta.64 v0
176  movi.64 v1, 321
177  call.short sub_shl_i64, v0, v1
178  movi.64 v0, 540959720865471
179  cmp.64 v0
180  jnez exit_error_6
181  movi.64 v0, 42
182  ldai.64 123
183  shl2.64 v0
184  sta.64 v0
185  movi.64 v1, 321
186  call.short sub_shr_i64, v0, v1
187  movi.64 v0, -198
188  cmp.64 v0
189  jnez exit_error_7
190  movi.64 v0, 42
191  ldai.64 -1
192  shl2.64 v0
193  sta.64 v0
194  movi.64 v1, 321
195  call.short sub_ashr_i64, v0, v1
196  movi.64 v0, -322
197  cmp.64 v0
198  jnez exit_error_8
199  movi.64 v0, 42
200  ldai.64 540959720865792
201  shr2.64 v0
202  sta.64 v0
203  movi.64 v1, 321
204  call.short sub_shl_i64_2, v0, v1
205  movi.64 v0, -540959720865471
206  cmp.64 v0
207  jnez exit_error_9
208  movi.64 v0, 42
209  ldai.64 123
210  shl2.64 v0
211  sta.64 v0
212  movi.64 v1, 321
213  call.short sub_shr_i64_2, v0, v1
214  movi.64 v0, 198
215  cmp.64 v0
216  jnez exit_error_10
217  movi.64 v0, 42
218  ldai.64 -1
219  shl2.64 v0
220  sta.64 v0
221  movi.64 v1, 321
222  call.short sub_ashr_i64_2, v0, v1
223  movi.64 v0, 322
224  cmp.64 v0
225  jnez exit_error_11
226  ldai 0
227  return
228exit_error_0:
229  ldai 1
230  return
231exit_error_1:
232  ldai 2
233  return
234exit_error_2:
235  ldai 3
236  return
237exit_error_3:
238  ldai 4
239  return
240exit_error_4:
241  ldai 5
242  return
243exit_error_5:
244  ldai 6
245  return
246exit_error_6:
247  ldai 7
248  return
249exit_error_7:
250  ldai 8
251  return
252exit_error_8:
253  ldai 9
254  return
255exit_error_9:
256  ldai 10
257  return
258exit_error_10:
259  ldai 11
260  return
261exit_error_11:
262  ldai 12
263  return
264}
265